:root {
    --grid-size: 25;
    --grid-bg: #ffffff;
    --tile-border: #eee;
    --text-color: #333;
    --bg-color: #f4f7f6;
    --primary-accent: #3498db;
}

body {
    margin: 0;
    font-family: 'Roboto', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
}

.main-container {
    width: 100%;
    height: 100vh;
    padding: 10px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

h1 {
    font-weight: 400;
    margin-bottom: 0.5em;
}

p {
    display: none;
}

.controls-container {
    margin-bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

#color-palette {
    display: flex;
    gap: 10px;
}

.color-swatch {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid rgba(0,0,0,0.05);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.2s ease-in-out;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.color-swatch:hover {
    transform: scale(1.1) translateY(-2px);
}

.color-swatch.selected {
    border-color: var(--primary-accent);
    transform: scale(1.15) translateY(-2px);
}

.tool-btn {
    padding: 12px 20px;
    border: none;
    background-color: #fff;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    font-family: 'Roboto', sans-serif;
    color: #444;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 8px;
}

.tool-btn:hover {
    background-color: #fdfdfd;
    transform: translateY(-2px);
    box-shadow: 0 6px 10px rgba(0,0,0,0.1);
}

.tool-btn.selected {
    background-color: var(--primary-accent);
    color: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
    transform: translateY(-1px);
}

.tool-btn.selected i {
    color: white;
}

.tool-btn i {
    font-size: 1.1em;
    color: #888;
    transition: color 0.2s ease-in-out;
}

.tool-btn.hidden {
    display: none;
}

#clear-btn i {
    color: #e74c3c;
}

#clear-btn:hover i {
    color: white;
}

#grid-container {
    display: grid;
    grid-template-columns: repeat(var(--grid-size), 1fr);
    grid-template-rows: repeat(var(--grid-size), 1fr);
    
    width: 95vmin;
    height: 95vmin;
    
    max-width: 800px;
    max-height: 800px;
    
    margin: 0 auto;
    
    background-color: var(--grid-bg);
    border: 1px solid #e0e0e0;
    touch-action: none; /* Disables browser handling of touch events like panning */
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border-radius: 8px;
    position: relative; /* Needed for multiplayer cursors if they were inside */
}

.tile {
    /* Using a box-shadow for the grid lines allows them to look consistent and not double up */
    box-shadow: 0 0 0 1px var(--tile-border);
    user-select: none; /* Prevents text selection while dragging */
    height: 100%;
    /* pointer-events are re-enabled to fix painting on mobile. Grid container handles events. */
}

/* Multiplayer UI */
#multiplayer-ui {
    position: fixed;
    top: 10px;
    right: 10px;
    width: 200px;
    max-height: 40vh;
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    padding: 15px;
    box-sizing: border-box;
    z-index: 1500;
}

#multiplayer-ui.hidden {
    display: none;
}

#multiplayer-ui h3 {
    margin: 0 0 10px 0;
    font-size: 1rem;
    font-weight: 500;
    color: #333;
    text-align: center;
}

#player-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    max-height: calc(40vh - 50px);
}

.player-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.player-item img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.player-item span {
    font-size: 0.9rem;
    color: #555;
}

.player-cursor {
    position: fixed;
    pointer-events: none;
    z-index: 2500;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: top 0.1s linear, left 0.1s linear;
}

.player-cursor img {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.player-cursor span {
    background-color: rgba(0,0,0,0.7);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
    white-space: nowrap;
}

/* Comment Section */
#comment-container {
    position: fixed;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 95%;
    max-width: 500px;
    background-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1600;
    display: flex;
    flex-direction: column;
    height: 35vh;
    max-height: 250px;
}

#comment-container.hidden {
    display: none;
}

#comment-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.comment-message {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.comment-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    flex-shrink: 0;
}

.comment-author {
    font-weight: 500;
    font-size: 0.9rem;
    margin-bottom: 2px;
    display: block;
}

.comment-content {
    background: #e9e9eb;
    padding: 6px 10px;
    border-radius: 12px;
    font-size: 0.95rem;
    word-break: break-word;
}
.comment-content p {
    margin: 0;
    display: inline; /* To prevent extra margins from markdown */
}
.comment-content p:not(:last-child) {
    margin-bottom: 5px;
    display: block;
}

#comment-form {
    display: flex;
    padding: 8px;
    border-top: 1px solid #e0e0e0;
}

#comment-input {
    flex-grow: 1;
    border: none;
    background: transparent;
    padding: 8px;
    font-size: 1rem;
    outline: none;
}

#comment-form button {
    background: var(--primary-accent);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: background-color 0.2s;
}

#comment-form button:hover {
    background-color: #2980b9;
}

#glitter-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3000;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background-color: #fff;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: center;
    padding-top: 15px;
    margin-top: 10px;
    border-top: 1px solid #eee;
}

#close-intro-btn {
    padding: 12px 25px;
    border: none;
    background-color: var(--primary-accent);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 2px 5px rgba(52, 152, 219, 0.3);
}

#close-intro-btn:hover {
    background-color: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(41, 128, 185, 0.4);
}

.close-btn {
    background: #f0f0f0;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: #888;
    line-height: 1;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: #e0e0e0;
    color: #000;
    transform: rotate(90deg);
}

.modal-body {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#intro-modal .modal-header {
    justify-content: center;
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
}

#intro-modal .modal-body p {
    display: block;
    font-size: 1rem;
    line-height: 1.6;
    text-align: center;
    color: #555;
    margin: 10px 0;
}

.shop-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 10px;
    background-color: #f9f9f9;
    border-radius: 8px;
    border: 1px solid #eee;
}

.shop-item-preview {
    font-size: 2.5rem;
    font-weight: bold;
    width: 60px;
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 8px;
    background-color: #3498db; /* Default preview color */
    border: 1px solid #ddd;
}

.shop-item-details {
    flex-grow: 1;
}

.shop-item-details h3 {
    margin: 0 0 5px 0;
}

.shop-item-details p {
    margin: 0;
    color: #666;
    font-size: 0.9rem;
    display: block; /* override display:none */
}

.select-btn {
    padding: 10px 18px;
    border: none;
    background-color: var(--primary-accent);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 2px 5px rgba(52, 152, 219, 0.3);
}

.select-btn:hover {
    background-color: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(41, 128, 185, 0.4);
}

/* Asset Library Styles */
#asset-library-body {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 15px;
    padding: 5px;
}

.asset-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease;
    border: 1px solid #eee;
}

.asset-item:hover {
    background-color: #f0f0f0;
    transform: translateY(-2px);
}

.asset-item.selected {
    background-color: #e0e8ff;
    border-color: var(--primary-accent);
}

.asset-preview {
    display: grid;
    background-color: #fff;
    border: 1px solid #ddd;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.asset-preview-cell {
    width: 10px;
    height: 10px;
}

.asset-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: #555;
}

/* Kevin's Task Bar */
#kevin-task-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: #1c1c1e;
    color: #fff;
    padding: 12px 20px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    z-index: 1000;
    transform: translateY(100%);
    transition: transform 0.5s ease-in-out;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.3);
}

#kevin-task-bar.visible {
    transform: translateY(0);
}

.task-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
}

#kevin-task-text {
    margin: 0;
    font-size: 1rem;
    line-height: 1.4;
    flex-grow: 1;
    text-align: left;
    display: block !important; /* Override the generic p selector */
}

#kevin-done-btn {
    padding: 8px 18px;
    border: none;
    background-color: #0a84ff; /* iOS blue */
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: background-color 0.2s ease, opacity 0.2s ease;
    flex-shrink: 0;
}

#kevin-done-btn:hover {
    background-color: #007aff;
}

#kevin-done-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #555;
}

/* Phone Call Modal Styles */
#phone-call-modal .phone-call-content {
    background-color: #1c1c1e; /* Dark mode, like a phone screen */
    color: #fff;
    width: 90%;
    max-width: 350px;
    height: 80vh; /* Set height relative to viewport */
    max-height: 600px; /* But not too tall */
    min-height: 450px; /* And not too short */
    border-radius: 30px;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 8px 30px rgba(0,0,0,0.5);
    text-align: center;
    box-sizing: border-box;
}

.caller-info {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.caller-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    margin-bottom: 20px;
    border: 3px solid rgba(255, 255, 255, 0.2);
}

.caller-name {
    font-size: 2rem;
    font-weight: 500;
    margin-bottom: 8px;
}

.call-status {
    font-size: 1rem;
    color: #8e8e93;
}

.call-actions {
    display: flex;
    justify-content: space-around;
    width: 100%;
    margin-top: 30px;
}

.action-button-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.action-button-container span {
    font-size: 0.9rem;
}

.call-action-btn {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    color: white;
    transition: transform 0.2s ease, background-color 0.2s ease;
}

.call-action-btn:hover {
    transform: scale(1.05);
}

.call-action-btn.decline {
    background-color: #ff3b30; /* iOS red */
}

.call-action-btn.accept {
    background-color: #34c759; /* iOS green */
}