/* static/style.css - COMPLETE: ENHANCED WITH PROFESSIONAL ANIMATIONS + MULTIPLAYER TIMER SYSTEM */

/* ===== BACKGROUND & BASE STYLES ===== */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;

    --spotlight-strength: 0.6;
    --cursor-opacity: 0.6;
    --cursor-size: 280px;
    --cursor-color: #92d6ff;
    --cursor-core-color: rgba(146, 214, 255, 0.42);
    --cursor-mid-color: rgba(92, 103, 163, 0.26);
    background: linear-gradient(180deg, #2e3b68 0%, #1f2937 72%);
    color: #f9fafb;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    padding: 20px;
    box-sizing: border-box;
    overflow-x: hidden;
    position: relative;
}

/* Animated background particles */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(2px 2px at 20% 30%, rgba(255, 255, 255, 0.3), transparent),
        radial-gradient(2px 2px at 60% 70%, rgba(255, 255, 255, 0.2), transparent),
        radial-gradient(1px 1px at 50% 50%, rgba(255, 255, 255, 0.3), transparent),
        radial-gradient(2px 2px at 80% 10%, rgba(255, 255, 255, 0.3), transparent);
    background-size: 200% 200%;
    animation: sparkle 20s ease-in-out infinite;
    pointer-events: none;
    z-index: 0;
}

body::after {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: var(--cursor-opacity, var(--spotlight-strength, 0.6));
    background:
        radial-gradient(circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
            var(--cursor-core-color, rgba(146, 214, 255, 0.42)) 0,
            var(--cursor-mid-color, rgba(92, 103, 163, 0.26)) calc(var(--cursor-size, 280px) * 0.48),
            rgba(31, 41, 55, 0) var(--cursor-size, 280px));
    transition: opacity 0.2s ease;
}

body.spotlight-disabled::after {
    opacity: 0;
}

@keyframes sparkle {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.05); }
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

#game-container {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    width: 100%;
    max-width: 1400px;
    justify-content: center;
    align-items: flex-start;
    position: relative;
    z-index: 1;
    animation: fadeInContainer 0.8s ease-out;
}

#game-container.system-reboot-recovering {
    animation: systemRebootFlicker 350ms linear forwards;
    filter: contrast(1.05) saturate(1.08);
}

#game-container.system-reboot-recovering::after {
    content: "";
    position: absolute;
    inset: -2px;
    pointer-events: none;
    z-index: 20;
    opacity: 0.78;
    background:
        linear-gradient(90deg, rgba(255, 0, 80, 0.16), rgba(0, 255, 255, 0.12)),
        repeating-linear-gradient(180deg, rgba(255,255,255,0.12) 0 2px, rgba(0,0,0,0) 2px 6px);
    mix-blend-mode: screen;
    animation: systemScanlineSwipe 350ms linear forwards;
}

#game-container.system-reboot-recovering * {
    text-shadow:
        -1px 0 rgba(255, 0, 80, 0.38),
        1px 0 rgba(0, 255, 255, 0.34),
        0 0 8px rgba(255, 255, 255, 0.08);
}

@keyframes fadeInContainer {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes systemRebootFlicker {
    0% { opacity: 0.25; transform: translate3d(0, 2px, 0); }
    16% { opacity: 0.82; transform: translate3d(-2px, -1px, 0); }
    34% { opacity: 0.42; transform: translate3d(2px, 1px, 0); }
    52% { opacity: 0.94; transform: translate3d(-1px, 0, 0); }
    72% { opacity: 0.68; transform: translate3d(1px, -1px, 0); }
    100% { opacity: 1; transform: translate3d(0, 0, 0); }
}

@keyframes systemScanlineSwipe {
    0% { transform: translateY(-105%); opacity: 0.82; }
    100% { transform: translateY(105%); opacity: 0; }
}

/* ===== PANEL STYLES ===== */
#left-panel, #right-panel {
    flex: 1 1 0%;
    display: flex;
    flex-direction: column;
    gap: 20px;
    animation: slideInSide 0.6s ease-out;
    opacity: 1;
}

#left-panel {
    animation-delay: 0.1s;
    animation-fill-mode: both;
}

#right-panel {
    animation-delay: 0.2s;
    animation-fill-mode: both;
}

@keyframes slideInSide {
    from { opacity: 0; transform: translateX(-30px); }
    to { opacity: 1; transform: translateX(0); }
}

#center-panel {
    flex: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 500px;
}

#game-board-area {
    display: flex;
    justify-content: center;
    width: 100%;
}

/* ===== IMPROVED STATS AREA ===== */
#stats-area {
    background-color: rgba(17, 24, 39, 0.8);
    border: 2px solid #374151;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

#stats-area:hover {
    border-color: #4b5563;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.4);
}

#stats-area h2 {
    font-size: 1.1em;
    margin: 8px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #9ca3af;
    font-weight: 500;
}

#stats-area h2 span {
    color: #f9fafb;
    font-size: 1.3em;
    font-weight: 700;
    margin-left: 10px;
}

/* Unified stat display styling */
#round-display, #score-display, #gem-display {
    display: inline-block;
    min-width: 60px;
    text-align: right;
}

.gem-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.2em;
    height: 1.2em;
    flex: 0 0 1.2em;
}

.mobile-gem-icon,
.ability-button__gem,
.gem-badge-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    flex: 0 0 auto;
}

.kunzite-gem-svg {
    display: block;
    width: 1em;
    height: 1em;
    flex: 0 0 auto;
    transform-origin: center;
    transform-style: preserve-3d;
    filter: drop-shadow(0 0 2px rgba(217, 70, 239, 0.72));
    animation: none;
}

.gem-icon > .kunzite-gem-svg,
.mobile-gem-icon > .kunzite-gem-svg,
.gem > .kunzite-gem-svg {
    width: 100%;
    height: 100%;
}

.gem > .kunzite-gem-svg {
    backface-visibility: visible;
    animation: kunziteHorizontalTurn 2.9s linear infinite;
}

.gem-badge-icon > .kunzite-gem-svg {
    width: 0.82em;
    height: 0.82em;
}

.ability-button__gem > .kunzite-gem-svg {
    width: 1em;
    height: 1em;
}

.kunzite-confetti-gem {
    width: 1em;
    height: 1em;
}

@keyframes kunziteHorizontalTurn {
    0% { transform: rotateY(0deg); }
    15.52% { transform: rotateY(180deg); }
    50% { transform: rotateY(180deg); }
    65.52% { transform: rotateY(360deg); }
    100% { transform: rotateY(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .gem > .kunzite-gem-svg {
        animation: none;
    }
}

/* ===== SELECTION AREA ===== */
#selection-area {
    height: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 15px;
    position: relative;
    z-index: 10;
}

#current-word-display {
    font-size: 2.2em;
    font-weight: bold;
    color: #fff;
    letter-spacing: 2px;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
    transition: all 0.3s ease;
}

#current-word-display:not(:empty) {
    animation: wordPulse 0.5s ease;
}

@keyframes wordPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

#score-preview-display { 
    font-size: 1.4em; 
    color: #a7f3d0;
    transition: all 0.3s ease;
    text-shadow: 0 0 8px rgba(167, 243, 208, 0.6);
    margin-top: 5px;
}

#game-board {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 20px; /* I kept the 20px gap you preferred earlier! */
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    aspect-ratio: 1 / 1;
    touch-action: none;
    position: relative;
}

#game-board.game-board--shuffling {
    z-index: 2;
    pointer-events: none;
}

#game-board.board-disabled {
    opacity: 1;
    isolation: isolate;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

#game-board.board-disabled .grid-tile {
    cursor: default;
    filter: brightness(0.6);
    opacity: 0.92;
    transition: filter 0.18s ease, opacity 0.18s ease;
}

#game-board.board-disabled > * {
    position: relative;
    z-index: 1;
}

#game-board.board-disabled::after {
    content: none;
}

/* ===== PATH SVG ANIMATIONS ===== */
#path-svg { 
    position: absolute; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    pointer-events: none; 
    z-index: 1; 
}

#path-svg line { 
    stroke: rgba(255, 215, 0, 0.9); 
    stroke-width: 8px; 
    stroke-linecap: round;
    filter: drop-shadow(0 0 6px rgba(255, 215, 0, 0.8));
    animation: pathGlow 1.5s ease-in-out infinite;
}

@keyframes pathGlow {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ===== TILE STYLES & ANIMATIONS ===== */
/* Shuffle rebuild: block tileEntrance + nth-child delays until next full board render */
.grid-tile.grid-tile--entrance-suppressed {
    animation: none !important;
    animation-delay: 0s !important;
}

.grid-tile {
    /* NEW: Prevent the browser from highlighting the text */
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none; /* For Safari/iOS */
    position: relative; 
    width: 100%; 
    height: auto;
    aspect-ratio: 1 / 1;
    border: 2px solid #4b5563; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    font-size: clamp(1.2em, 5vw, 1.8em);
    font-weight: bold; 
    color: #1f2937;
    background: linear-gradient(145deg, #F8F6F0, #EFEADD);
    border-radius: 8px; 
    cursor: pointer;
    z-index: 2;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center;
    z-index: 2;
}

#game-board .grid-tile {
    z-index: 2;
}

.grid-tile--spawn {
    animation: tileEntrance 0.5s ease-out backwards;
}

/* Staggered entrance animation for tiles */
.grid-tile--spawn:nth-child(1) { animation-delay: 0.05s; }
.grid-tile--spawn:nth-child(2) { animation-delay: 0.1s; }
.grid-tile--spawn:nth-child(3) { animation-delay: 0.15s; }
.grid-tile--spawn:nth-child(4) { animation-delay: 0.2s; }
.grid-tile--spawn:nth-child(5) { animation-delay: 0.25s; }
.grid-tile--spawn:nth-child(6) { animation-delay: 0.3s; }
.grid-tile--spawn:nth-child(7) { animation-delay: 0.35s; }
.grid-tile--spawn:nth-child(8) { animation-delay: 0.4s; }
.grid-tile--spawn:nth-child(9) { animation-delay: 0.45s; }
.grid-tile--spawn:nth-child(10) { animation-delay: 0.5s; }
.grid-tile--spawn:nth-child(11) { animation-delay: 0.55s; }
.grid-tile--spawn:nth-child(12) { animation-delay: 0.6s; }
.grid-tile--spawn:nth-child(13) { animation-delay: 0.65s; }
.grid-tile--spawn:nth-child(14) { animation-delay: 0.7s; }
.grid-tile--spawn:nth-child(15) { animation-delay: 0.75s; }
.grid-tile--spawn:nth-child(16) { animation-delay: 0.8s; }
.grid-tile--spawn:nth-child(17) { animation-delay: 0.85s; }
.grid-tile--spawn:nth-child(18) { animation-delay: 0.9s; }
.grid-tile--spawn:nth-child(19) { animation-delay: 0.95s; }
.grid-tile--spawn:nth-child(20) { animation-delay: 1s; }
.grid-tile--spawn:nth-child(21) { animation-delay: 1.05s; }
.grid-tile--spawn:nth-child(22) { animation-delay: 1.1s; }
.grid-tile--spawn:nth-child(23) { animation-delay: 1.15s; }
.grid-tile--spawn:nth-child(24) { animation-delay: 1.2s; }
.grid-tile--spawn:nth-child(25) { animation-delay: 1.25s; }

@keyframes tileEntrance {
    from {
        opacity: 0;
        transform: scale(0) rotate(180deg);
    }
    to {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

/* Scrabble table scramble (vars set in JS; .shuffling on tiles) */
.grid-tile.shuffling {
    z-index: 30;
    transform-origin: center center;
    will-change: transform, box-shadow;
    --swirl-ox: 0px;
    --swirl-oy: 0px;
    --swirl-r-extra: 0deg;
}

@keyframes shufflePullToCenter {
    0% {
        transform: translate3d(0, 0, 0) scale(1) rotate(0deg);
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    }
    12% {
        transform: translate3d(0, 0, 0) scale(1.1) rotate(0deg);
        box-shadow:
            0 14px 32px rgba(0, 0, 0, 0.48),
            0 6px 12px rgba(0, 0, 0, 0.35),
            0 0 0 1px rgba(255, 255, 255, 0.12),
            0 0 24px rgba(255, 215, 0, 0.15);
    }
    100% {
        transform: translate3d(var(--pull-x), var(--pull-y), 0) scale(1.1) rotate(var(--random-rot));
        box-shadow:
            0 14px 32px rgba(0, 0, 0, 0.48),
            0 6px 12px rgba(0, 0, 0, 0.35),
            0 0 0 1px rgba(255, 255, 255, 0.12),
            0 0 24px rgba(255, 215, 0, 0.15);
    }
}

@keyframes shuffleCenterJiggle {
    0%, 100% {
        transform: translate3d(var(--pull-x), var(--pull-y), 0) scale(1.1) rotate(var(--random-rot));
        box-shadow:
            0 14px 32px rgba(0, 0, 0, 0.48),
            0 6px 12px rgba(0, 0, 0, 0.35),
            0 0 0 1px rgba(255, 255, 255, 0.12),
            0 0 24px rgba(255, 215, 0, 0.15);
    }
    /* Spread into a loose “ring” */
    28% {
        transform: translate3d(
                calc(var(--pull-x) + var(--swirl-ox)),
                calc(var(--pull-y) + var(--swirl-oy)),
                0)
            scale(1.14) rotate(calc(var(--random-rot) + var(--swirl-r-extra)));
        box-shadow:
            0 14px 32px rgba(0, 0, 0, 0.48),
            0 6px 12px rgba(0, 0, 0, 0.35),
            0 0 0 1px rgba(255, 255, 255, 0.12),
            0 0 24px rgba(255, 215, 0, 0.15);
    }
    /* Draw back toward pile center */
    52% {
        transform: translate3d(
                calc(var(--pull-x) + var(--swirl-ox) * 0.22),
                calc(var(--pull-y) + var(--swirl-oy) * 0.22),
                0)
            scale(1.09) rotate(calc(var(--random-rot) + var(--swirl-r-extra) * 0.4));
        box-shadow:
            0 14px 32px rgba(0, 0, 0, 0.48),
            0 6px 12px rgba(0, 0, 0, 0.35),
            0 0 0 1px rgba(255, 255, 255, 0.12),
            0 0 24px rgba(255, 215, 0, 0.15);
    }
    /* Light overshoot, then settle at 100% */
    76% {
        transform: translate3d(
                calc(var(--pull-x) + var(--swirl-ox) * -0.08),
                calc(var(--pull-y) + var(--swirl-oy) * -0.08),
                0)
            scale(1.11) rotate(calc(var(--random-rot) - var(--swirl-r-extra) * 0.25));
        box-shadow:
            0 14px 32px rgba(0, 0, 0, 0.48),
            0 6px 12px rgba(0, 0, 0, 0.35),
            0 0 0 1px rgba(255, 255, 255, 0.12),
            0 0 24px rgba(255, 215, 0, 0.15);
    }
}

/* Hover effect */
.grid-tile:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3), 
                0 0 20px rgba(255, 215, 0, 0.3);
    border-color: #ffd700;
}

/* Selected tile animation */
.grid-tile.selected { 
    background: linear-gradient(145deg, #ffd700, #ffed4e);
    transform: scale(0.95);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.8),
                inset 0 0 10px rgba(255, 215, 0, 0.4);
    animation: selectedPulse 0.6s ease-in-out;
}

.grid-tile.invalid-selection {
    background: linear-gradient(145deg, #f87171, #ef4444) !important;
    border-color: #fecaca !important;
    color: #fff7f7 !important;
    box-shadow: 0 0 18px rgba(239, 68, 68, 0.8),
                inset 0 0 12px rgba(127, 29, 29, 0.45) !important;
    animation: invalidFlash 0.26s ease-in-out;
}

@keyframes selectedPulse {
    0% { transform: scale(1); }
    50% { transform: scale(0.9); }
    100% { transform: scale(0.95); }
}

@keyframes electricBolt {
    0% { opacity: 0; transform: translate(-50%, -50%) scaleY(0.15); }
    35% { opacity: 1; transform: translate(-50%, -50%) scaleY(1); }
    100% { opacity: 0; transform: translate(-50%, -50%) scaleY(0.4); }
}

@keyframes invalidFlash {
    0% { transform: scale(0.95); }
    50% { transform: scale(1); }
    100% { transform: scale(0.95); }
}

/* Double Points tile */
.tile-dp { 
    position: relative;
    border: 3px solid #ff69b4; 
    box-shadow: 0 0 20px rgba(255, 105, 180, 0.6);
}

.tile-dp::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    opacity: 0;
    box-shadow: 0 0 30px rgba(255, 105, 180, 0.9);
    animation: glowPulsePeak 2s ease-in-out infinite;
}

@keyframes dpGlow {
    0%, 100% { box-shadow: 0 0 20px rgba(255, 105, 180, 0.6); }
    50% { box-shadow: 0 0 30px rgba(255, 105, 180, 0.9); }
}

/* ===== INDICATORS ===== */
.indicator { 
    position: absolute; 
    top: 2px; 
    right: 2px; 
    padding: 2px 5px; 
    font-size: 0.3em; 
    font-weight: bold; 
    color: white; 
    border-radius: 4px; 
    z-index: 1;
    animation: indicatorBounce 0.5s ease-out;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

@keyframes indicatorBounce {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.indicator-dl { 
    background: linear-gradient(135deg, #3498db, #2980b9);
}

.indicator-tl { 
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
}

.indicator-dp { 
    background: linear-gradient(135deg, #ff69b4, #ff1493);
}

.tile-score { 
    position: absolute; 
    bottom: 2px; 
    left: 4px; 
    font-size: 0.4em; 
    font-weight: bold; 
    color: #555;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
}

/* ===== GEM ANIMATIONS ===== */
.gem { 
    position: absolute; 
    top: -8px; 
    left: -8px; 
    width: 14px;
    height: 14px;
    z-index: 2; 
    opacity: 1;
    -webkit-transform: translate3d(0, 0, 0);
    transform: translate3d(0, 0, 0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    will-change: transform;
    animation: none;
}

.gem svg {
    display: block;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

@media (max-width: 768px) {
    .gem {
        top: -4px;
        left: -4px;
        width: 12px;
        height: 12px;
        z-index: 3;
    }
}

/* ===== INPUT AREA ===== */
#input-area { 
    margin-top: 28px; 
    display: flex; 
    width: 100%;
    gap: 12px;
    align-items: center;
    justify-content: center;
}

#word-input {
    display: none;
}

/* ===== BUTTON STYLES ===== */
#submit-button, #new-game-button, .ability-button { 
    padding: 12px 20px; 
    font-size: 1em; 
    font-weight: 600;
    cursor: pointer; 
    border-radius: 8px; 
    border: 2px solid #4b5563; 
    background: linear-gradient(145deg, #4b5563, #374151);
    color: #f9fafb;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin: 6px 0;
}

#submit-button {
    width: auto;
    margin: 0;
    min-width: 160px;
    flex: 0 0 auto;
}

.ability-button__icon {
    font-size: 1.2em;
    line-height: 1;
}

.ability-button__label {
    font-weight: 700;
    line-height: 1.2;
}

.ability-button__label--cancel {
    width: 100%;
    text-align: center;
}

.ability-button__cost {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #ffd700;
    font-weight: 700;
    line-height: 1;
}

.ability-button__gem {
    font-size: 1em;
}

    /* Lock ability button widths so they don't shrink on Cancel */
.ability-button {
    min-width: 220px; /* Adjust this number if 'Cancel Swap' still gets cut off or shrinks */
}

/* Ability button icon styling */
.ability-button .icon {
    font-size: 1.2em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

/* Ability button cost styling */
.ability-button .cost {
    margin-left: auto;
    font-size: 0.9em;
    color: #ffd700;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* Button press effect */
#submit-button:active, .ability-button:active {
    transform: translateY(2px) scale(0.98);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Button hover effect */
#submit-button:hover, .ability-button:hover {
    background: linear-gradient(145deg, #6b7280, #4b5563);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
    transform: translateY(-2px);
}

/* Button shine effect */
.ability-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s ease;
}

.ability-button:hover::before {
    left: 100%;
}

.ability-button:disabled { 
    cursor: not-allowed; 
    background: linear-gradient(145deg, #374151, #1f2937);
    color: #9ca3af;
    opacity: 0.6;
    transform: none;
    box-shadow: none;
}

#new-game-button { 
    width: 100%; 
    margin-top: 20px; 
    background: linear-gradient(145deg, #10b981, #059669);
    border-color: #059669;
    font-size: 1.2em;
    padding: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 6px 12px rgba(16, 185, 129, 0.3);
}

#new-game-button:hover {
    background: linear-gradient(145deg, #34d399, #10b981);
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.5);
    transform: translateY(-3px);
}

#new-game-button:active {
    transform: translateY(0);
    box-shadow: 0 4px 8px rgba(16, 185, 129, 0.3);
}

/* ===== MESSAGE AREA ===== */
#message-area { 
    margin-top: 12px; 
    min-height: 24px; 
    font-weight: bold; 
    text-align: center; 
    width: 100%;
    transition: all 0.3s ease;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* ===== PANEL CONTAINERS ===== */
#abilities-area, #found-words-container, #stats-area {
    background-color: rgba(17, 24, 39, 0.8);
    border: 2px solid #374151;
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

#abilities-area:hover, #found-words-container:hover, #stats-area:hover {
    border-color: #4b5563;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.4);
}

#found-words-container { 
    height: 300px; 
    overflow-y: auto;
}

/* Scrollbar styling */
#found-words-container::-webkit-scrollbar {
    width: 8px;
}

#found-words-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

#found-words-container::-webkit-scrollbar-thumb {
    background: #4b5563;
    border-radius: 4px;
}

#found-words-container::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}

#found-words-list { 
    list-style-type: none; 
    padding: 0; 
    margin: 0; 
}

#found-words-list li {
    padding: 8px;
    margin: 4px 0;
    background-color: rgba(75, 85, 99, 0.3);
    border-radius: 6px;
    animation: wordSlideIn 0.3s ease-out;
    transition: all 0.2s ease;
}

#found-words-list li:hover {
    background-color: rgba(75, 85, 99, 0.5);
    transform: translateX(5px);
}

@keyframes wordSlideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ===== UTILITY ===== */
.hidden { display: none !important; }

#mobile-game-header,
#mobile-player-rail,
#mobile-turn-banner,
#mobile-gem-tracker,
#mobile-view-words-toggle {
    display: none;
}

#mobile-ability-row {
    display: contents;
}

#mobile-words-backdrop,
#mobile-words-close {
    display: none !important;
}

#settings-modal {
    position: fixed;
    inset: 0;
    z-index: 15000;
}

#settings-modal-backdrop {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at top, rgba(59, 130, 246, 0.18), transparent 40%),
        rgba(4, 10, 28, 0.78);
    backdrop-filter: blur(16px);
}

#settings-modal-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    width: min(420px, calc(100vw - 32px));
    max-height: min(86vh, 760px);
    overflow: auto;
    transform: translate(-50%, -50%);
    padding: 24px;
    border-radius: 22px;
    border: 1px solid rgba(125, 211, 252, 0.32);
    background:
        linear-gradient(160deg, rgba(10, 20, 45, 0.97), rgba(17, 24, 39, 0.96)),
        rgba(15, 23, 42, 0.96);
    box-shadow:
        0 24px 60px rgba(2, 8, 23, 0.58),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.settings-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

#settings-modal-title {
    margin: 0;
    font-size: 1.35rem;
    letter-spacing: 0.04em;
    color: #e0f2fe;
}

#settings-close-button,
.mobile-icon-button {
    border: 1px solid rgba(125, 211, 252, 0.32);
    background: linear-gradient(145deg, rgba(8, 47, 73, 0.95), rgba(30, 41, 59, 0.95));
    color: #f8fafc;
    box-shadow: 0 10px 24px rgba(8, 47, 73, 0.28);
}

#settings-close-button {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1rem;
}

.settings-field,
.settings-toggle-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 14px;
    align-items: center;
    padding: 14px 16px;
    margin-bottom: 12px;
    border-radius: 16px;
    background: rgba(30, 41, 59, 0.72);
    border: 1px solid rgba(148, 163, 184, 0.15);
}

.settings-field span,
.settings-toggle-row span {
    font-weight: 600;
    color: #e2e8f0;
}

#settings-volume-slider,
#volume-slider {
    accent-color: #38bdf8;
}

#instant-submit-toggle {
    width: 20px;
    height: 20px;
    accent-color: #38bdf8;
}

.settings-help {
    margin: 6px 4px 0;
    color: #94a3b8;
    line-height: 1.5;
    font-size: 0.92rem;
}

#settings-modal-layout {
    display: block;
}

#menu-room-code-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px solid rgba(125, 211, 252, 0.22);
    background: linear-gradient(145deg, rgba(8, 47, 73, 0.78), rgba(15, 23, 42, 0.92));
}

.menu-room-code-copy {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.menu-room-code-label {
    color: #7dd3fc;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

#menu-room-code-value {
    color: #f8fafc;
    font-size: 1.2rem;
    letter-spacing: 0.18em;
}

#menu-tab-bar {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.menu-tab-button {
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: rgba(30, 41, 59, 0.64);
    color: #cbd5e1;
    font-weight: 700;
    cursor: pointer;
    transition: transform 140ms ease, border-color 140ms ease, background 140ms ease, color 140ms ease;
}

.menu-tab-button.is-active {
    color: #f8fafc;
    background: linear-gradient(145deg, rgba(37, 99, 235, 0.82), rgba(15, 23, 42, 0.92));
    border-color: rgba(125, 211, 252, 0.34);
    transform: translateY(-1px);
}

.menu-tab-panel {
    display: none;
}

.menu-tab-panel.is-active {
    display: block;
}

#menu-tips-content,
#menu-exit-panel {
    padding: 4px 2px 2px;
}

#menu-tips-content p,
#menu-exit-panel p {
    margin: 0 0 14px;
    color: #dbeafe;
    line-height: 1.6;
}

#menu-exit-panel p:last-child,
#menu-tips-content p:last-child {
    margin-bottom: 0;
}

.menu-exit-actions {
    display: grid;
    gap: 12px;
}

#settings-controls-column {
    min-width: 0;
}

#cursor-preview-card {
    display: none;
}

#cursor-preview-stage {
    position: relative;
    height: 220px;
    border-radius: 20px;
    overflow: hidden;
    background:
        radial-gradient(circle at 50% 36%, rgba(56, 189, 248, 0.12), transparent 42%),
        linear-gradient(180deg, rgba(8, 47, 73, 0.96), rgba(15, 23, 42, 0.98));
    border: 1px solid rgba(125, 211, 252, 0.2);
}

#cursor-preview-glow,
#cursor-preview-dot {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

#cursor-preview-glow {
    width: var(--cursor-preview-size, 280px);
    height: var(--cursor-preview-size, 280px);
    border-radius: 999px;
    background:
        radial-gradient(circle,
            var(--cursor-core-color, rgba(146, 214, 255, 0.42)) 0,
            var(--cursor-mid-color, rgba(92, 103, 163, 0.26)) 42%,
            rgba(15, 23, 42, 0) 72%);
    opacity: var(--cursor-opacity, var(--spotlight-strength, 0.6));
    transition: width 120ms ease, height 120ms ease, opacity 120ms ease, background 120ms ease;
}

#cursor-preview-dot {
    width: 14px;
    height: 14px;
    border-radius: 999px;
    background: rgba(248, 250, 252, 0.96);
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.52);
}

#cursor-preview-readout {
    margin: 0;
    font-size: 0.82rem;
    line-height: 1.45;
    color: #cbd5e1;
}

.cursor-preview-card__header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
    color: #e0f2fe;
    font-weight: 700;
}

.cursor-preview-card__header small {
    color: #7dd3fc;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

body.desktop-pointer-layout #settings-modal-panel {
    width: min(760px, calc(100vw - 40px));
}

body.desktop-pointer-layout #settings-modal-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 232px;
    gap: 18px;
    align-items: start;
}

body.desktop-pointer-layout #menu-exit-panel,
body.desktop-pointer-layout #menu-tips-content {
    padding-right: 4px;
}

body.desktop-pointer-layout #cursor-preview-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    border-radius: 20px;
    border: 1px solid rgba(125, 211, 252, 0.22);
    background: rgba(15, 23, 42, 0.72);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

#cursor-preview-card.is-disabled {
    opacity: 0.42;
}

/* ===== DEVELOPER MOBILE LAYOUT EDITOR ===== */
body.layout-editor-preview {
    align-items: flex-start;
    padding: 12px;
}

body.layout-editor-preview #game-container {
    position: relative;
    display: block !important;
    width: min(390px, calc(100vw - 24px));
    max-width: min(390px, calc(100vw - 24px));
    height: min(844px, calc(100dvh - 24px));
    max-height: min(844px, calc(100dvh - 24px));
    margin: 0 auto;
    overflow: hidden;
    border-radius: 28px;
    padding: 8px;
    background:
        radial-gradient(circle at top, rgba(59, 130, 246, 0.18), transparent 38%),
        linear-gradient(180deg, rgba(15, 23, 42, 0.98), rgba(30, 41, 59, 0.98));
    box-shadow: 0 24px 60px rgba(2, 8, 23, 0.48);
}

body.layout-editor-preview #left-panel,
body.layout-editor-preview #center-panel,
body.layout-editor-preview #right-panel {
    display: contents;
    width: auto;
    max-width: none;
}

body.layout-editor-preview #right-panel h1,
body.layout-editor-preview #stats-area,
body.layout-editor-preview #controls-area,
body.layout-editor-preview #new-game-button,
body.layout-editor-preview #selection-area,
body.layout-editor-preview #message-area {
    display: none !important;
}

body.layout-editor-preview #mobile-game-header,
body.layout-editor-preview #mobile-player-rail,
body.layout-editor-preview #mobile-turn-banner,
body.layout-editor-preview #mobile-gem-tracker,
body.layout-editor-preview #mobile-view-words-toggle,
body.layout-editor-preview #timer-container {
    display: block;
    box-sizing: border-box;
}

body.layout-editor-preview #mobile-ability-row {
    display: contents;
}

body.layout-editor-preview #mobile-game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

body.layout-editor-preview #mobile-round-pill {
    display: inline-flex;
    align-items: baseline;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 18px;
    background: linear-gradient(140deg, rgba(6, 78, 59, 0.92), rgba(8, 47, 73, 0.92));
    border: 1px solid rgba(103, 232, 249, 0.24);
    box-shadow: 0 12px 24px rgba(8, 47, 73, 0.25);
}

body.layout-editor-preview #mobile-round-display {
    font-size: 1rem;
    font-weight: 700;
    color: #f8fafc;
}

body.layout-editor-preview #mobile-nav-actions {
    display: flex;
    gap: 8px;
}

body.layout-editor-preview .mobile-icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 14px;
    font-size: 1rem;
    cursor: pointer;
}

body.layout-editor-preview #mobile-player-rail {
    overflow: hidden;
}

body.layout-editor-preview #mobile-player-carousel {
    display: flex;
    gap: 10px;
    overflow: hidden;
}

body.layout-editor-preview .mobile-player-card {
    flex: 0 0 100%;
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr);
    gap: 10px;
    padding: 12px;
    border-radius: 18px;
    background: linear-gradient(145deg, rgba(49, 46, 129, 0.92), rgba(30, 41, 59, 0.92));
    border: 1px solid rgba(129, 140, 248, 0.24);
    box-shadow: 0 14px 26px rgba(15, 23, 42, 0.34);
}

body.layout-editor-preview .mobile-player-avatar {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 700;
    color: #e0f2fe;
    background: linear-gradient(145deg, rgba(8, 47, 73, 0.95), rgba(37, 99, 235, 0.92));
}

body.layout-editor-preview .mobile-player-name-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 4px;
}

body.layout-editor-preview .mobile-player-name {
    font-weight: 700;
    color: #f8fafc;
}

body.layout-editor-preview .mobile-player-score {
    font-weight: 700;
    color: #fbbf24;
}

body.layout-editor-preview .mobile-player-last-word {
    font-size: 0.78rem;
    color: #cbd5e1;
}

body.layout-editor-preview #mobile-turn-banner {
    padding: 12px 14px;
    border-radius: 18px;
    background: linear-gradient(145deg, rgba(6, 78, 59, 0.88), rgba(15, 23, 42, 0.92));
    border: 1px solid rgba(45, 212, 191, 0.25);
}

body.layout-editor-preview #mobile-turn-title {
    font-size: 1rem;
    font-weight: 700;
    color: #ecfeff;
    margin-bottom: 4px;
}

body.layout-editor-preview #mobile-turn-subtitle {
    font-size: 0.82rem;
    color: #bae6fd;
    line-height: 1.4;
}

body.layout-editor-preview #game-board-area {
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

body.layout-editor-preview #game-board {
    gap: var(--layout-editor-board-gap, 8px);
    width: var(--layout-editor-board-size, 290px);
    max-width: var(--layout-editor-board-size, 290px);
}

body.layout-editor-preview #mobile-gem-tracker {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 18px;
    background: linear-gradient(145deg, rgba(88, 28, 135, 0.92), rgba(30, 41, 59, 0.92));
    border: 1px solid rgba(216, 180, 254, 0.28);
    font-weight: 700;
    color: #f5d0fe;
}

body.layout-editor-preview #abilities-area {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    padding: 10px;
    margin: 0;
    box-sizing: border-box;
}

body.layout-editor-preview #abilities-area h3 {
    display: none;
}

body.layout-editor-preview .ability-button {
    min-width: 0;
    width: 100%;
    margin: 0;
    padding: 12px 8px;
    font-size: 0.74rem;
    line-height: 1.2;
}

body.layout-editor-preview #input-area {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin: 0;
    width: 100%;
    box-sizing: border-box;
}

body.layout-editor-preview #submit-button,
body.layout-editor-preview #mobile-view-words-toggle {
    width: 100%;
    min-width: 0;
    padding: 14px 16px;
    border-radius: 18px;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.05em;
}

body.layout-editor-preview #mobile-view-words-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
}

body.layout-editor-preview #found-words-container {
    display: none !important;
}

body.layout-editor-preview .grid-tile,
body.layout-editor-preview .grid-tile:hover,
body.layout-editor-preview .grid-tile.selected {
    transform: none !important;
}

body.layout-editor-preview .layout-editor-target {
    position: absolute !important;
    left: var(--layout-x, 0px);
    top: var(--layout-y, 0px);
    width: var(--layout-w, auto);
    height: var(--layout-h, auto);
    margin: 0 !important;
    z-index: 20;
    outline: 1px dashed rgba(56, 189, 248, 0.5);
    outline-offset: 3px;
    cursor: grab;
    user-select: none;
    touch-action: none;
}

body.layout-editor-preview .layout-editor-target.is-selected {
    outline: 2px solid rgba(250, 204, 21, 0.88);
    box-shadow: 0 0 0 2px rgba(250, 204, 21, 0.24);
}

body.layout-editor-preview .layout-editor-target:active {
    cursor: grabbing;
}

body.layout-editor-preview .layout-editor-resize {
    position: absolute;
    right: -8px;
    bottom: -8px;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    background: linear-gradient(145deg, #38bdf8, #0f172a);
    border: 2px solid rgba(224, 242, 254, 0.92);
    box-shadow: 0 8px 20px rgba(14, 165, 233, 0.35);
    cursor: nwse-resize;
}

#layout-editor-panel {
    position: fixed;
    top: 12px;
    right: 12px;
    width: min(272px, calc(100vw - 24px));
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
    z-index: 18000;
    padding: 16px;
    border-radius: 20px;
    border: 1px solid rgba(125, 211, 252, 0.26);
    background: linear-gradient(160deg, rgba(10, 20, 45, 0.96), rgba(15, 23, 42, 0.96));
    box-shadow: 0 24px 60px rgba(2, 8, 23, 0.54);
}

.layout-editor-panel__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 14px;
}

.layout-editor-panel__header p,
.layout-editor-panel__status {
    margin: 4px 0 0;
    font-size: 0.78rem;
    line-height: 1.45;
    color: #cbd5e1;
}

.layout-editor-panel__section {
    margin-bottom: 14px;
}

.layout-editor-panel__label {
    font-size: 0.74rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #7dd3fc;
    margin-bottom: 6px;
}

.layout-editor-panel__value {
    font-size: 0.96rem;
    font-weight: 700;
    color: #f8fafc;
}

.layout-editor-panel__meta {
    margin-top: 4px;
    font-size: 0.8rem;
    color: #94a3b8;
}

.layout-editor-block-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.layout-editor-chip,
.layout-editor-button {
    border: 1px solid rgba(125, 211, 252, 0.24);
    background: linear-gradient(145deg, rgba(8, 47, 73, 0.95), rgba(30, 41, 59, 0.95));
    color: #e0f2fe;
    border-radius: 999px;
    padding: 8px 12px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.layout-editor-button {
    border-radius: 12px;
}

.layout-editor-chip:hover,
.layout-editor-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(14, 165, 233, 0.22);
    border-color: rgba(125, 211, 252, 0.4);
}

.layout-editor-chip.is-selected,
.layout-editor-button.is-primary {
    border-color: rgba(250, 204, 21, 0.6);
    color: #fef08a;
}

.layout-editor-panel__actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 16px;
}

.layout-editor-slider-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    font-size: 0.82rem;
    color: #e2e8f0;
    margin-bottom: 6px;
}

#layout-editor-panel input[type="range"] {
    width: 100%;
    margin-bottom: 12px;
    accent-color: #38bdf8;
}

/* ===== SWAP MODE ANIMATION (ISSUE 6: FIXED SEQUENCE) ===== */
/* Phase 1: All tiles pulse when swap mode active */
@keyframes swapModePulse {
    0%, 100% { 
        transform: scale(1.05);
        box-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
    }
    50% { 
        transform: scale(0.95);
        box-shadow: 0 0 5px rgba(255, 215, 0, 0.2);
    }
}

.swap-mode-pulse {
    animation: swapModePulse 1s ease-in-out infinite;
}

/* Phase 2: Individual tile morphs when letter is changed */
@keyframes swapMorph {
    0% {
        transform: scale(1.05);
        opacity: 1;
    }
    50% {
        transform: scale(0.95);
        opacity: 0.5;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.tile.swapping {
    animation: swapMorph 0.5s ease-in-out forwards;
}

/* Legacy pulse animation (kept for backward compatibility) */
@keyframes pulse { 
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.7); } 
    50% { transform: scale(1.05); box-shadow: 0 0 0 10px rgba(255, 215, 0, 0); } 
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 215, 0, 0); } 
}

/* ===== MODAL OVERLAYS ===== */
#letter-picker-overlay {
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex; 
    justify-content: center; 
    align-items: center; 
    z-index: 100;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

#letter-picker { 
    background: linear-gradient(145deg, #ffffff, #f0f0f0);
    width: min(560px, calc(100vw - 32px));
    max-width: calc(100vw - 32px);
    max-height: min(82dvh, 540px);
    padding: 30px; 
    border-radius: 15px; 
    display: grid; 
    grid-template-columns: repeat(7, minmax(0, 1fr)); 
    gap: 10px; 
    overflow: auto;
    box-sizing: border-box;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: modalSlideIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes modalSlideIn {
    from {
        transform: scale(0.7) translateY(-50px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.letter-picker-button { 
    width: 100%; 
    height: 50px; 
    font-size: 1.5em; 
    font-weight: bold; 
    cursor: pointer; 
    border: 2px solid #ccc; 
    background: linear-gradient(145deg, #ffffff, #e8e8e8);
    color: #1f2937;
    border-radius: 8px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.letter-picker-button:hover { 
    background: linear-gradient(145deg, #ffd700, #ffed4e);
    transform: translateY(-3px) scale(1.1);
    box-shadow: 0 6px 12px rgba(255, 215, 0, 0.4);
    border-color: #ffd700;
}

.letter-picker-button:active {
    transform: translateY(0) scale(1.05);
}

/* ===== HINT LOADER ===== */
/* --- THE NEW NON-BLOCKING HINT LOADER --- */
#hint-loader-overlay {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: rgba(31, 41, 55, 0.95);
    border: 2px solid #a855f7;
    border-radius: 12px;
    padding: 15px 25px;
    z-index: 1000;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    /* THIS IS THE MAGIC LINE: Clicks pass right through it! */
    pointer-events: none; 
    transition: opacity 0.3s ease;
}

#hint-loader-overlay .loader-content {
    display: flex;
    flex-direction: row; /* Puts spinner and text side-by-side */
    align-items: center;
    gap: 15px;
    color: white;
    font-size: 1.1em;
}

/* A smaller, sleeker spinner for the corner */
#hint-loader-overlay .spinner { 
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top: 4px solid #a855f7;
    border-radius: 50%; 
    width: 25px; 
    height: 25px; 
    animation: spin 1s linear infinite;
}

@keyframes spin { 
    0% { transform: rotate(0deg); } 
    100% { transform: rotate(360deg); } 
}

#hint-percentage {
    font-size: 1.5em;
    color: #ffd700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.8);
    animation: numberPulse 1s ease-in-out infinite;
}

@keyframes numberPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* ===== PATH HIGHLIGHT OVERLAY ===== */
.path-highlight {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 8px;
    z-index: 3;
    cursor: pointer;
    animation: highlightPulse 1.5s ease-in-out infinite;
    transition: all 0.3s ease;
}

.path-highlight:hover {
    transform: scale(1.1);
    z-index: 4;
}

@keyframes highlightPulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 0.8; }
}

/* ===== STATS AREA NUMBERS ===== */
#stats-area h2 {
    transition: all 0.3s ease;
}

#stats-area h2 span {
    display: inline-block;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Score change animation (added via JS) */
.score-change {
    animation: scorePopup 0.6s ease-out;
}

@keyframes scorePopup {
    0% { transform: scale(1); }
    50% { transform: scale(1.5); color: #ffd700; text-shadow: 0 0 20px rgba(255, 215, 0, 0.8); }
    100% { transform: scale(1); }
}

/* ===== TITLE ANIMATION ===== */
#right-panel h1 {
    animation: titleFloat 3s ease-in-out infinite;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
}

@keyframes titleFloat {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-5px); }
}

/* ===== ROUND TRANSITION EFFECT ===== */
.round-transition {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    animation: fadeOut 1s ease-out forwards;
}

.round-transition h1 {
    font-size: 4em;
    color: white;
    text-shadow: 0 0 30px rgba(255, 255, 255, 0.8);
    animation: scaleIn 0.5s ease-out;
}

@keyframes fadeOut {
    0% { opacity: 1; }
    70% { opacity: 1; }
    100% { opacity: 0; pointer-events: none; }
}

@keyframes scaleIn {
    0% { transform: scale(0); }
    100% { transform: scale(1); }
}

/* ===== ENHANCED MESSAGE ANIMATIONS ===== */
#message-area {
    animation: messageFade 0.3s ease-in;
}

@keyframes messageFade {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ========================================================================== */
/* ===== MULTIPLAYER & TIMER SYSTEM STYLES (NEW FEATURES) ===== */
/* ========================================================================== */

/* ===== MODE SELECTOR ===== */
#mode-selector {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 50% 50%, #5c67a3, #1f2937 70%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    padding: 16px;
    box-sizing: border-box;
}

.mode-selector-content {
    text-align: center;
    animation: fadeIn 0.5s ease;
}

.mode-title {
    font-size: 3.5em;
    color: #ffd700;
    text-shadow: 0 0 30px rgba(255, 215, 0, 0.8);
    margin-bottom: 10px;
}

.mode-subtitle {
    font-size: 1.3em;
    color: #d1d5db;
    margin-bottom: 50px;
}

.mode-buttons {
    display: flex;
    gap: 30px;
    justify-content: center;
}

.mode-button {
    width: 250px;
    padding: 30px 20px;
    background: linear-gradient(145deg, rgba(75, 85, 99, 0.8), rgba(55, 65, 81, 0.8));
    border: 2px solid #4b5563;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.mode-button:hover {
    transform: translateY(-5px) scale(1.05);
    border-color: #ffd700;
    box-shadow: 0 10px 30px rgba(255, 215, 0, 0.3);
}

.mode-icon {
    font-size: 3em;
}

.mode-label {
    font-size: 1.5em;
    font-weight: bold;
    color: #f9fafb;
}

.mode-desc {
    font-size: 0.9em;
    color: #9ca3af;
}

/* ===== MULTIPLAYER MENU ===== */
#multiplayer-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 50% 50%, #5c67a3, #1f2937 70%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    padding: 16px;
    box-sizing: border-box;
    overflow: hidden;
}

.multiplayer-menu-content {
    background: rgba(17, 24, 39, 0.95);
    border: 2px solid #4b5563;
    border-radius: 20px;
    padding: 20px;
    width: min(560px, calc(100vw - 32px));
    max-height: min(460px, calc(100dvh - 32px));
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: modalSlideIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.multiplayer-menu-content h2 {
    text-align: center;
    color: #ffd700;
    font-size: 1.8em;
    margin-bottom: 18px;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
}

.menu-input-group {
    margin-bottom: 18px;
}

.menu-input-group label {
    display: block;
    color: #d1d5db;
    font-size: 1em;
    margin-bottom: 6px;
}

.menu-input-group input,
#room-code-input {
    width: 100%;
    padding: 10px;
    font-size: 1em;
    background: rgba(55, 65, 81, 0.8);
    border: 2px solid #4b5563;
    border-radius: 8px;
    color: #f9fafb;
    transition: all 0.3s ease;
}

.menu-input-group input:focus,
#room-code-input:focus {
    outline: none;
    border-color: #ffd700;
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.4);
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.menu-button {
    padding: 13px 18px;
    font-size: 1.05em;
    font-weight: 600;
    border: 2px solid #4b5563;
    border-radius: 10px;
    background: linear-gradient(145deg, #4b5563, #374151);
    color: #f9fafb;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.menu-button:hover:not(:disabled) {
    background: linear-gradient(145deg, #6b7280, #4b5563);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

.menu-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn-icon {
    font-size: 1.3em;
}

.join-room-section {
    display: flex;
    gap: 10px;
}

#room-code-input {
    width: 150px;
}

.back-button {
    width: 100%;
    margin-top: 16px;
    padding: 10px;
    background: rgba(55, 65, 81, 0.5);
    border: 1px solid #4b5563;
    border-radius: 8px;
    color: #9ca3af;
    cursor: pointer;
    transition: all 0.2s ease;
}

.back-button:hover {
    background: rgba(75, 85, 99, 0.5);
    color: #f9fafb;
}

/* FIX #4: Connection Status Indicator */
.connection-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    margin-bottom: 12px;
    background: rgba(30, 41, 59, 0.6);
    border-radius: 6px;
    font-size: 0.95em;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    animation: pulse 1.5s ease-in-out infinite;
}

.status-dot.connecting {
    background: #f59e0b;
    box-shadow: 0 0 6px rgba(245, 158, 11, 0.6);
}

.status-dot.connected {
    background: #10b981;
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
    animation: none;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

#connection-text {
    color: #d1d5db;
    font-size: 0.9em;
}

/* ===== LOBBY ===== */
#lobby {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 50% 50%, #5c67a3, #1f2937 70%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    padding: 12px;
    box-sizing: border-box;
    overflow: hidden;
}

.lobby-content {
    background: rgba(17, 24, 39, 0.95);
    border: 2px solid #4b5563;
    border-radius: 20px;
    padding: 16px;
    width: min(980px, calc(100vw - 24px));
    max-height: min(820px, calc(100dvh - 24px));
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: modalSlideIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.lobby-content h2 {
    text-align: center;
    color: #ffd700;
    font-size: 1.8em;
    margin-bottom: 12px;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
}

.room-code-display {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: rgba(75, 85, 99, 0.3);
    border-radius: 12px;
    border: 2px solid #ffd700;
}

.room-code-label {
    display: block;
    color: #9ca3af;
    font-size: 1em;
    margin-bottom: 10px;
}

.room-code-value {
    display: block;
    font-size: 2.5em;
    font-weight: bold;
    color: #ffd700;
    letter-spacing: 8px;
    text-shadow: 0 0 15px rgba(255, 215, 0, 0.6);
    animation: codePulse 3s ease-in-out infinite;
}

@keyframes codePulse {
    0%, 100% {
        text-shadow: 0 0 15px rgba(255, 215, 0, 0.6);
    }
    50% {
        text-shadow: 0 0 25px rgba(255, 215, 0, 0.9);
    }
}

.lobby-info {
    text-align: center;
    color: #d1d5db;
    font-size: 1.1em;
    margin-bottom: 20px;
}

.lobby-players {
    margin-bottom: 30px;
}

.lobby-players h3 {
    color: #f9fafb;
    font-size: 1.3em;
    margin-bottom: 15px;
    border-bottom: 2px solid #4b5563;
    padding-bottom: 10px;
}

#lobby-player-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.lobby-player-item {
    background: rgba(75, 85, 99, 0.3);
    padding: 10px 12px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s ease;
    animation: wordSlideIn 0.3s ease;
}

.lobby-player-item:hover {
    background: rgba(75, 85, 99, 0.5);
}

.player-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: #4b5563;
    border-radius: 50%;
    color: #f9fafb;
    font-weight: bold;
}

.player-name {
    flex: 1;
    color: #f9fafb;
    font-size: 1em;
}

.host-badge {
    background: linear-gradient(145deg, #ffd700, #ffed4e);
    color: #1f2937;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: bold;
}

.lobby-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.lobby-button {
    flex: 1;
    padding: 12px;
    font-size: 1.05em;
    font-weight: 600;
    border: 2px solid #4b5563;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.start-btn {
    background: linear-gradient(145deg, #10b981, #059669);
    color: #fff;
    border-color: #059669;
}

.start-btn:hover {
    background: linear-gradient(145deg, #34d399, #10b981);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(16, 185, 129, 0.4);
}

.ready-btn {
    background: linear-gradient(145deg, #3f3f46, #1f2937);
    color: #fee2e2;
    border-color: rgba(239, 68, 68, 0.38);
}

.ready-btn.is-active {
    background: linear-gradient(145deg, #22c55e, #15803d);
    border-color: #22c55e;
    color: #f0fdf4;
    box-shadow: 0 10px 18px rgba(34, 197, 94, 0.28);
}

.leave-btn {
    background: linear-gradient(145deg, #ef4444, #dc2626);
    color: #fff;
    border-color: #dc2626;
}

.leave-btn:hover {
    background: linear-gradient(145deg, #f87171, #ef4444);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(239, 68, 68, 0.4);
}

.lobby-note {
    text-align: center;
    color: #9ca3af;
    font-size: 0.9em;
    font-style: italic;
    margin-top: 10px;
}

/* ===== TIMER UI STYLES ===== */

/* Game Configuration Panel */
.config-panel {
    background: rgba(30, 41, 59, 0.8);
    border-radius: 12px;
    padding: 12px;
    margin: 10px 0;
    border: 2px solid rgba(139, 92, 246, 0.3);
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

/* FIX #1: 2-Column Grid Layout */
.config-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 0;
}

.config-left-column {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.config-right-column {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

@media (max-width: 768px) {
    .config-grid {
        grid-template-columns: 1fr;
    }
}

.config-section {
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.config-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.config-section h3 {
    color: #a78bfa;
    font-size: 1em;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Radio Options */
.radio-option {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 7px;
    margin: 3px 0;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.radio-option:hover:not(.disabled) {
    background: rgba(139, 92, 246, 0.15);
    transform: translateX(4px);
    border-color: rgba(139, 92, 246, 0.3);
}

/* ISSUE 2: Guest settings styling - unselected/disabled appearance */
.radio-option.disabled {
    cursor: not-allowed;
    opacity: 0.5;
    background: rgba(255, 255, 255, 0.02) !important;
}

.radio-option.disabled input[type="radio"] {
    cursor: not-allowed;
    opacity: 0.5;
}

.radio-option.disabled:hover {
    background: rgba(255, 255, 255, 0.02) !important;
    transform: translateX(0) !important;
    border-color: transparent !important;
}

.radio-option input[type="radio"] {
    margin-top: 2px;
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #8b5cf6;
}

.radio-option input[type="radio"]:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.radio-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.radio-label strong {
    color: #e0e7ff;
    font-size: 1em;
}

.radio-label small {
    color: #9ca3af;
    font-size: 0.82em;
}

/* Timer Duration Slider */
#fixed-timer-controls {
    padding: 8px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    border: 1px solid rgba(139, 92, 246, 0.2);
}

#timer-duration-slider {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(to right, #8b5cf6, #ec4899);
    outline: none;
    -webkit-appearance: none;
    appearance: none; /* <-- This makes the Linter happy! */
    margin-top: 10px;
    cursor: pointer;
}

#timer-duration-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ffffff;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
}

#timer-duration-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.8), 0 4px 12px rgba(0, 0, 0, 0.4);
}

#timer-duration-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ffffff;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);
    border: none;
    transition: all 0.2s ease;
}

#timer-duration-slider::-moz-range-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.8), 0 4px 12px rgba(0, 0, 0, 0.4);
}

#timer-duration-value {
    color: #fbbf24;
    font-weight: bold;
    font-size: 1.2em;
    text-shadow: 0 0 10px rgba(251, 191, 36, 0.5);
}

/* Info Grid */
.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    color: #d1d5db;
}

.info-grid div {
    padding: 7px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    font-size: 0.9em;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.info-grid div strong {
    color: #f9fafb;
    font-size: 1.05em;
}

.max-player-limit-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

#max-players-select {
    min-width: 64px;
    padding: 5px 24px 5px 8px;
    border: 1px solid rgba(139, 92, 246, 0.45);
    border-radius: 7px;
    background: #202942;
    color: #f9fafb;
    font: inherit;
    cursor: pointer;
}

#max-players-select:disabled {
    cursor: not-allowed;
    opacity: 0.72;
}

/* Timer Container (In-Game) */

/* Timer Container (In-Game) */
#timer-container {
    animation: slideDown 0.5s ease-out;
}

#timer-action-slot {
    display: flex;
    align-items: stretch;
    width: 100%;
    min-height: 28px;
}

#timer-progress-track,
#vote-timer-btn {
    width: 100%;
    min-height: 28px;
    border-radius: 10px;
}

#timer-progress-track {
    position: relative;
    overflow: hidden;
    background: rgba(75, 85, 99, 0.5);
}

.timer-vote-inline {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 12px;
    color: #e5e7eb;
    font-size: 0.82rem;
    font-weight: 600;
    background: rgba(55, 65, 81, 0.92);
}

#vote-info-label {
    flex: 1;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#vote-info-count {
    text-align: right;
    color: #fbbf24;
    font-variant-numeric: tabular-nums;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes glowPulsePeak {
    0%, 100% { opacity: 0; }
    50% { opacity: 1; }
}

#timer-bar {
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
}

#timer-bar::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    opacity: 0;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.8);
    animation: glowPulsePeak 2s ease-in-out infinite;
}

@keyframes timerPulse {
    0%, 100% {
        box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
    }
    50% {
        box-shadow: 0 0 20px rgba(239, 68, 68, 0.8);
    }
}

/* Vote Timer Button */
#vote-timer-btn {
    background: linear-gradient(145deg, #fbbf24, #f59e0b);
    border-color: #f59e0b;
    color: #1f2937;
    font-weight: 700;
    font-size: 0.82rem;
    padding: 0 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.3s ease;
}

#vote-timer-btn:hover:not(:disabled) {
    background: linear-gradient(145deg, #fcd34d, #fbbf24);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(251, 191, 36, 0.4);
}

#vote-timer-btn:disabled {
    background: linear-gradient(145deg, #6b7280, #4b5563);
    color: #9ca3af;
    cursor: not-allowed;
    opacity: 0.6;
}

#vote-timer-btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(251, 191, 36, 0.3);
}

/* Timer Options in Lobby */
.timer-options {
    animation: fadeInSlide 0.5s ease-out;
}

.timer-options h3 {
    font-size: 1.2em;
    margin-bottom: 15px;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.timer-options label {
    transition: all 0.2s ease;
    padding: 10px;
    border-radius: 8px;
}

.timer-options label:hover {
    background: rgba(75, 85, 99, 0.5);
}

.timer-options input[type="radio"] {
    accent-color: #ffd700;
}

.timer-options input[type="number"] {
    transition: all 0.3s ease;
}

.timer-options input[type="number"]:focus {
    outline: none;
    border-color: #ffd700;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.4);
}

/* Timer Info Display (Non-Host) */
#timer-info-display {
    animation: fadeInSlide 0.5s ease-out;
    font-size: 1.1em;
}

@keyframes fadeInSlide {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Vote Info */
#vote-info {
    animation: fadeIn 0.3s ease;
}

/* Timer Label Colors */
#timer-label {
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    transition: color 0.3s ease;
}

/* Timer Text */
#timer-text {
    font-family: 'Courier New', monospace;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.6);
    transition: all 0.3s ease;
}

/* Warning state (last 10 seconds) */
.timer-warning #timer-bar {
    background: #dc2626 !important;
    box-shadow: 0 0 15px rgba(220, 38, 38, 0.8);
}

.timer-warning #timer-bar::after {
    box-shadow: 0 0 30px rgba(220, 38, 38, 1);
    animation-duration: 0.5s;
}

@keyframes timerWarning {
    0%, 100% {
        box-shadow: 0 0 15px rgba(220, 38, 38, 0.8);
    }
    50% {
        box-shadow: 0 0 30px rgba(220, 38, 38, 1);
    }
}

.timer-warning #timer-text {
    color: #dc2626;
    animation: textBlink 0.5s ease-in-out infinite;
}

@keyframes textBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Timer Expired Animation */
@keyframes timerExpired {
    0% {
        transform: scale(1);
        background: rgba(220, 38, 38, 0.9);
    }
    50% {
        transform: scale(1.05);
        background: rgba(220, 38, 38, 1);
    }
    100% {
        transform: scale(1);
        background: rgba(220, 38, 38, 0.9);
    }
}

.timer-expired {
    animation: timerExpired 0.5s ease 3;
}

/* Grace Period Indicator */
.grace-period #timer-bar::after {
    animation-duration: 1.8s;
}

@keyframes gracePulse {
    0%, 100% {
        box-shadow: 0 0 10px rgba(96, 165, 250, 0.5);
    }
    50% {
        box-shadow: 0 0 20px rgba(96, 165, 250, 0.8);
    }
}

/* Voting Active Indicator */
.voting-active #timer-bar::after {
    animation: none;
    opacity: 0;
}

@keyframes votingPulse {
    0%, 100% {
        box-shadow: 0 0 10px rgba(251, 191, 36, 0.5);
    }
    50% {
        box-shadow: 0 0 20px rgba(251, 191, 36, 0.8);
    }
}

/* Countdown Active Indicator */
.countdown-active #timer-bar::after {
    animation-duration: 1.4s;
}

/* Timer Container States */
#timer-container.grace-period #timer-label {
    color: inherit;
}

#timer-container.voting-active #timer-label {
    color: inherit;
}

#timer-container.countdown-active #timer-label {
    color: inherit;
}

/* Smooth transitions for timer states */
#timer-container,
#timer-bar,
#timer-label,
#timer-text {
    transition: all 0.3s ease;
}

/* Vote button animation when voting is enabled */
@keyframes voteButtonAppear {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

#vote-timer-btn {
    animation: voteButtonAppear 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Timer display number animations */
@keyframes numberChange {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

.number-change #timer-text {
    animation: numberChange 0.3s ease;
}

/* ===== FEATURE 2: SCOREBOARD STYLES ===== */
.score-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
}

.score-container h3 {
    color: #ffd700;
    margin: 0 0 10px 0;
    font-size: 1.1em;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.score-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    margin: 4px 0;
    background: rgba(75, 85, 99, 0.2);
    border-radius: 6px;
    font-size: 16px;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.score-item.active {
    opacity: 1;
    color: #ffffff;
    font-weight: 600;
    background: rgba(139, 92, 246, 0.2);
    border-color: rgba(139, 92, 246, 0.4);
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.3);
}

.score-item.inactive {
    opacity: 0.4;
    color: #9ca3af;
    font-weight: 500;
}

.score-item.shared {
    opacity: 1;
    color: #f9fafb;
    font-weight: 500;
}

.score-item.self {
    font-weight: 700;
    border-color: rgba(251, 191, 36, 0.45);
    box-shadow: 0 0 12px rgba(251, 191, 36, 0.18);
}

/* ===== FEATURE #5: OPPONENT TILE SELECTION ===== */
.opponent-selected,
.is-mirrored-active {
    position: relative;
    background: rgba(255, 165, 0, 0.3) !important;
    border: 2px solid orange !important;
    box-shadow: 0 0 10px rgba(255, 165, 0, 0.5) !important;
}

.opponent-selected::after,
.is-mirrored-active::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    opacity: 0;
    box-shadow: 0 0 20px rgba(255, 165, 0, 0.8);
    animation: glowPulsePeak 1s ease-in-out infinite;
}

@keyframes opponentPulse {
    0%, 100% { box-shadow: 0 0 10px rgba(255, 165, 0, 0.5); }
    50% { box-shadow: 0 0 20px rgba(255, 165, 0, 0.8); }
}

.played-word-center-overlay--tier-9 {
    will-change: transform, opacity;
    transform: translate3d(-50%, -50%, 0) !important;
    backface-visibility: hidden;
}

/* ===== FEATURE #7: BOARD STATE (ACTIVE/INACTIVE) ===== */
.board-active {
    filter: none;
    opacity: 1;
    pointer-events: auto;
}

.board-inactive {
    filter: grayscale(100%);
    opacity: 0.6;
    pointer-events: none;
}

.tile-locked {
    background: rgba(76, 175, 80, 0.2) !important;
    border: 2px solid #4CAF50 !important;
    cursor: not-allowed !important;
}

/* ===== FEATURE #6: SCORE HIDING ===== */
.score-hidden {
    color: #888;
    font-style: italic;
}

.score-hidden::after {
    content: ' (hidden)';
    font-size: 0.8em;
}

.timer-summary {
    color: #d1d5db;
    line-height: 1.5;
    min-height: 2.5em;
}

.results-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.82);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px;
    z-index: 10000;
}

.results-panel {
    width: min(560px, 100%);
    background: linear-gradient(145deg, #1f2937, #111827);
    border: 2px solid #fbbf24;
    border-radius: 18px;
    padding: 24px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
    position: relative;
}

.results-panel h2 {
    margin-top: 0;
    text-align: center;
    color: #fbbf24;
}

.results-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 12px 14px;
    margin-top: 6px;
    background: rgba(75, 85, 99, 0.24);
    border-radius: 10px;
}

.results-row__meta {
    min-width: 0;
    flex: 1 1 auto;
}

.results-row__actions {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
}

.summary-camera-button,
.summary-report-button,
.summary-close-button {
    border: 1px solid rgba(148, 163, 184, 0.28);
    background: rgba(15, 23, 42, 0.84);
    color: #f8fafc;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.summary-camera-button:hover,
.summary-report-button:hover,
.summary-close-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 18px rgba(2, 8, 23, 0.3);
    border-color: rgba(250, 204, 21, 0.42);
}

.summary-camera-button,
.summary-close-button {
    position: absolute;
    top: 16px;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.summary-camera-button {
    left: 16px;
}

.summary-close-button {
    right: 16px;
}

.summary-report-button {
    min-width: 40px;
    height: 40px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    font-size: 0.95rem;
    font-weight: 800;
}

.summary-export-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 15px;
    width: 100%;
}

.summary-export-actions .lobby-button {
    flex: 1 1 0;
}

.summary-panel--report,
.summary-panel--single {
    padding-top: 64px;
    max-height: calc(100vh - 10px);
    max-height: calc(100dvh - 10px);
    margin: 5px 0;
    overflow-y: auto;
    scrollbar-width: thin;
}

.summary-snapshot-overlay {
    position: fixed;
    inset: 0;
    z-index: 10120;
    background: rgba(2, 6, 23, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    height: 100vh;
    height: 100dvh;
    padding: 0;
    overflow: hidden;
}

.summary-snapshot-shell {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    align-items: center;
    gap: 0;
    padding: 20px;
    box-sizing: border-box;
    background: rgba(0, 0, 0, 0.9);
}

.summary-snapshot-stage {
    width: 100%;
    min-height: 100%;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.summary-snapshot-viewport {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    flex: 0 0 auto;
    margin: auto;
    overflow: hidden;
}

.summary-snapshot-capture {
    transform-origin: top left;
    margin: 0;
}

.summary-snapshot-actions {
    position: absolute;
    top: 50%;
    right: 18px;
    z-index: 9999;
    width: 160px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transform: translateY(-50%);
}

.summary-snapshot-actions .lobby-button {
    width: 100%;
}

@media (max-width: 640px) {
    .summary-snapshot-shell {
        max-height: 100dvh;
        min-height: 100dvh;
        padding: 8px;
    }

    .summary-snapshot-actions {
        right: 8px;
        left: 8px;
        top: 8px;
        width: auto;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        grid-auto-flow: unset;
    }
}

#game-container.score-inversion-active {
    filter: invert(100%) hue-rotate(180deg);
    transition: filter 140ms ease;
}

.results-score {
    color: #10b981;
    font-size: 1.25rem;
    font-weight: 700;
}

.results-winner {
    text-align: center;
    color: #f9fafb;
    font-size: 1.15rem;
}

/* ===== FEATURE #2: TILE SWAP ANIMATION ===== */
@keyframes tileSwap {
    0% { transform: scale(1) rotateY(0deg); opacity: 1; }
    50% { transform: scale(1.2) rotateY(90deg); opacity: 0.5; }
    100% { transform: scale(1) rotateY(0deg); opacity: 1; }
}

/* ===== FEATURE #1: TILE REFRESH ANIMATION ===== */
@keyframes tileRefresh {
    0% { transform: scale(1); background: rgba(255, 215, 0, 0.1); }
    50% { transform: scale(1.1); background: rgba(255, 215, 0, 0.3); }
    100% { transform: scale(1); background: rgba(255, 215, 0, 0); }
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    #game-container {
        flex-direction: column;
        gap: 18px;
        align-items: stretch;
    }

    #left-panel,
    #center-panel,
    #right-panel {
        max-width: none;
        width: 100%;
        animation: none;
        opacity: 1;
    }

    #right-panel {
        order: 1;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }

    #right-panel h1,
    #new-game-button {
        grid-column: 1 / -1;
        margin: 0;
        text-align: center;
    }

    #right-panel h1 {
        font-size: clamp(1.35rem, 6vw, 2rem);
    }

    #center-panel {
        order: 2;
    }

    #left-panel {
        order: 3;
        gap: 14px;
    }

    .summary-export-actions .btn-copy {
        display: none !important;
    }

    .summary-export-actions .btn-download {
        flex: 1 1 100%;
        width: 100%;
    }

    #game-board {
        gap: 12px;
        max-width: min(88vw, 360px);
    }

    #selection-area {
        height: auto;
        min-height: 56px;
        margin-bottom: 10px;
    }

    #current-word-display {
        font-size: clamp(1.4rem, 7vw, 2rem);
        letter-spacing: 1px;
        text-align: center;
        overflow-wrap: anywhere;
    }

    #score-preview-display {
        font-size: 1.05rem;
    }

    #stats-area h2 {
        font-size: 1rem;
    }

    #controls-area {
        margin-top: 0 !important;
    }

    #input-area {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 12px;
        margin-top: 22px;
    }

    #word-input {
        flex: 1 1 100%;
    }

    #submit-button {
        width: 100%;
        min-width: 0;
        flex: 1 1 100%;
    }

    .timer-options {
        font-size: 0.9em;
    }
    
    #timer-container {
        padding: 10px;
    }
    
    #timer-text {
        font-size: 1.2em;
    }

    #found-words-container {
        height: min(220px, 32vh);
    }

    .mode-buttons {
        flex-direction: column;
    }

    .mode-button {
        width: 100%;
    }

    .multiplayer-menu-content,
    .lobby-content {
        min-width: auto;
        width: min(100%, 700px);
        padding: 20px;
    }

    .results-panel {
        padding: 18px;
    }

    .results-row {
        align-items: flex-start;
    }

    #letter-picker {
        width: min(calc(100vw - 24px), 360px);
        max-width: calc(100vw - 24px);
        padding: 16px;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 8px;
    }

    .letter-picker-button {
        height: clamp(40px, 10vw, 48px);
        font-size: clamp(1rem, 4.8vw, 1.25rem);
    }
}

body.multiplayer-active #center-panel {
    max-width: 500px;
    flex: 2;
}

body.multiplayer-active #right-panel {
    max-width: none;
}

body.multiplayer-active #left-panel {
    display: flex;
    max-width: none;
}

body.multiplayer-active #message-area {
    text-align: center;
}

body.multiplayer-active #timer-container {
    margin-bottom: 12px !important;
    padding: 12px !important;
}

body.multiplayer-active #game-board {
    gap: 20px;
    max-width: 400px;
}

@media (max-width: 768px) {
    body.multiplayer-active #game-container {
        gap: 14px;
    }

    body.multiplayer-active #right-panel {
        max-width: none;
    }

    body.multiplayer-active #left-panel {
        max-width: none;
    }

    body.multiplayer-active #game-board {
        max-width: min(82vw, 320px);
        gap: 10px;
    }

    body.multiplayer-active #timer-container {
        padding: 10px !important;
    }
}

/* ===== DICTIONARY DEFINITION FIX ===== */
#definition-box, 
#word-definition, 
.definition, 
#message-area {
    white-space: pre-line;
    text-align: left; /* Optional: Makes it look even more like a real dictionary */
    line-height: 1.5; /* Optional: Gives the text some breathing room */
}

/* Stacked dictionary senses (HTML from fetchWordDefinition: one <p> per sense) */
.word-definition-body {
    display: block;
    text-align: left;
    line-height: 1.65;
    margin: 0;
    overflow-wrap: break-word;
}

.word-definition-body .word-definition-sense {
    margin: 0 0 0.75em 0;
    text-align: left;
}

.word-definition-body .word-definition-sense:last-child {
    margin-bottom: 0;
}

.word-definition-panel .word-definition-body {
    color: #d1d5db;
    font-size: 1em;
}

#word-details-popup .word-definition-body {
    color: #f9fafb;
    font-size: 1.05em;
}

body.screen-menu,
body.screen-lobby,
body.screen-game {
    overflow: hidden;
}

body.screen-game #message-area {
    min-height: 24px;
    height: auto;
    text-align: center;
}

#input-area.submit-button-hidden {
    display: none;
}

.grid-tile.tile-refresh {
    animation: tileRefresh 0.45s ease;
}

@media (max-width: 768px) {
    body {
        padding: 8px;
        align-items: stretch;
        overflow: hidden;
    }

    #multiplayer-menu,
    #lobby {
        padding: 8px;
        overflow-x: hidden;
    }

    .multiplayer-menu-content,
    .lobby-content {
        width: min(100%, calc(100vw - 16px));
        max-height: calc(100dvh - 16px);
        overflow-y: auto;
        overflow-x: hidden;
    }

    .join-room-section {
        display: grid;
        grid-template-columns: 1fr;
    }

    #room-code-input {
        width: 100%;
    }

    #game-container {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto auto auto auto minmax(0, 1fr) auto auto auto;
        gap: 8px;
        align-items: stretch;
        width: 100%;
        max-width: 420px;
        height: calc(100dvh - 16px);
        margin: 0 auto;
    }

    #left-panel,
    #center-panel,
    #right-panel {
        display: contents;
        width: auto;
        max-width: none;
    }

    #right-panel h1,
    #stats-area,
    #controls-area,
    #new-game-button,
    #selection-area {
        display: none !important;
    }

    #mobile-game-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        grid-row: 1;
    }

    #mobile-round-pill {
        display: inline-flex;
        align-items: baseline;
        gap: 8px;
        padding: 10px 14px;
        border-radius: 18px;
        background: linear-gradient(140deg, rgba(6, 78, 59, 0.92), rgba(8, 47, 73, 0.92));
        border: 1px solid rgba(103, 232, 249, 0.24);
        box-shadow: 0 12px 24px rgba(8, 47, 73, 0.25);
    }

    .mobile-pill-label {
        font-size: 0.72rem;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: #bae6fd;
    }

    #mobile-round-display {
        font-size: 1rem;
        font-weight: 700;
        color: #f8fafc;
    }

    #mobile-nav-actions {
        display: flex;
        gap: 8px;
    }

    .mobile-icon-button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        border-radius: 14px;
        cursor: pointer;
        font-size: 1rem;
    }

    #mobile-player-rail {
        display: block;
        grid-row: 2;
        overflow: hidden;
    }

    #mobile-player-carousel {
        display: flex;
        gap: 10px;
        overflow-x: auto;
        padding-bottom: 2px;
        scrollbar-width: none;
    }

    #mobile-player-carousel::-webkit-scrollbar {
        display: none;
    }

    .mobile-player-card {
        flex: 0 0 min(260px, 78vw);
        display: grid;
        grid-template-columns: 52px minmax(0, 1fr);
        gap: 10px;
        padding: 12px;
        border-radius: 18px;
        background: linear-gradient(145deg, rgba(49, 46, 129, 0.92), rgba(30, 41, 59, 0.92));
        border: 1px solid rgba(129, 140, 248, 0.24);
        box-shadow: 0 14px 26px rgba(15, 23, 42, 0.34);
    }

    .mobile-player-card.active {
        border-color: rgba(250, 204, 21, 0.55);
        box-shadow: 0 0 0 1px rgba(250, 204, 21, 0.2), 0 16px 28px rgba(15, 23, 42, 0.42);
    }

    .mobile-player-card.self {
        border-color: rgba(56, 189, 248, 0.5);
    }

    .mobile-player-avatar {
        width: 52px;
        height: 52px;
        border-radius: 16px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.2rem;
        font-weight: 700;
        color: #e0f2fe;
        background: linear-gradient(145deg, rgba(8, 47, 73, 0.95), rgba(37, 99, 235, 0.92));
    }

    .mobile-player-meta {
        min-width: 0;
    }

    .mobile-player-name-row {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        margin-bottom: 4px;
    }

    .mobile-player-name {
        font-weight: 700;
        color: #f8fafc;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .mobile-player-score {
        font-weight: 700;
        color: #fbbf24;
    }

    .mobile-player-last-word {
        font-size: 0.78rem;
        color: #cbd5e1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    #timer-container {
        grid-row: 3;
        margin: 0 !important;
        padding: 10px 12px !important;
        width: 100% !important;
        border-radius: 18px !important;
    }

    #vote-timer-btn,
    #submit-button,
    #mobile-view-words-toggle {
        width: 100%;
        min-width: 0;
        padding: 14px 16px;
        border-radius: 18px;
        font-size: 0.95rem;
        font-weight: 700;
        letter-spacing: 0.05em;
    }

    #mobile-turn-banner {
        display: block;
        grid-row: 4;
        padding: 12px 14px;
        border-radius: 18px;
        background: linear-gradient(145deg, rgba(6, 78, 59, 0.88), rgba(15, 23, 42, 0.92));
        border: 1px solid rgba(45, 212, 191, 0.25);
    }

    #mobile-turn-title {
        font-size: 1rem;
        font-weight: 700;
        color: #ecfeff;
        margin-bottom: 4px;
    }

    #mobile-turn-subtitle {
        font-size: 0.82rem;
        color: #bae6fd;
        line-height: 1.4;
    }

    #game-board-area {
        grid-row: 5;
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 0;
    }

    #game-board {
        gap: 8px;
        width: min(68vw, 290px);
        max-width: min(68vw, 290px);
    }

    #mobile-gem-tracker {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        grid-row: 6;
        justify-self: start;
        padding: 10px 14px;
        border-radius: 18px;
        background: linear-gradient(145deg, rgba(88, 28, 135, 0.92), rgba(30, 41, 59, 0.92));
        border: 1px solid rgba(216, 180, 254, 0.28);
        font-weight: 700;
        color: #f5d0fe;
    }

    #abilities-area {
        grid-row: 7;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
        padding: 10px;
        margin: 0;
    }

    #abilities-area h3 {
        display: none;
    }

    #hint-display {
        grid-column: 1 / -1;
        margin-top: 0 !important;
    }

    .ability-button {
        min-width: 0;
        width: 100%;
        margin: 0;
        padding: 12px 8px;
        font-size: 0.74rem;
        line-height: 1.2;
    }

    .grid-tile,
    .grid-tile:hover,
    .grid-tile.selected {
        transform: none !important;
    }

    #input-area {
        grid-row: 8;
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
        margin: 0;
        width: 100%;
    }

    #mobile-view-words-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    #message-area {
        margin: 0;
        min-height: 18px;
        font-size: 0.82rem;
        text-align: center;
    }

    #game-container {
        --mobile-block-width: min(100%, 374px);
        --mobile-board-size: min(340px, calc(100vw - 50px));
        grid-template-rows: auto auto auto minmax(0, 1fr) auto auto auto auto;
        justify-items: center;
        gap: 10px;
        max-width: 390px;
    }

    #mobile-game-header,
    #mobile-player-rail,
    #timer-container,
    #game-board-area,
    #input-area,
    #mobile-view-words-toggle,
    #message-area {
        width: var(--mobile-block-width);
        max-width: 100%;
        justify-self: center;
        box-sizing: border-box;
    }

    #mobile-player-rail {
        grid-row: 2;
    }

    #timer-container {
        grid-row: 3;
        min-height: 68px;
    }

    #game-board-area {
        grid-row: 4;
        display: grid;
        place-items: center;
    }

    #game-board {
        width: var(--mobile-board-size);
        max-width: 100%;
        margin: 0 auto;
        gap: 20px;
    }

    #mobile-ability-row {
        display: grid;
        grid-row: 5;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 8px;
        width: var(--mobile-block-width);
        max-width: 100%;
        padding: 10px;
        border-radius: 22px;
        background: linear-gradient(145deg, rgba(12, 22, 43, 0.94), rgba(30, 41, 59, 0.96));
        border: 1px solid rgba(125, 211, 252, 0.22);
        box-shadow: 0 18px 34px rgba(2, 8, 23, 0.42);
        box-sizing: border-box;
    }

    #mobile-gem-tracker {
        display: inline-flex;
        grid-row: auto;
        grid-column: 1;
        align-items: center;
        justify-content: center;
        gap: 4px;
        width: 100%;
        min-height: 84px;
        padding: 0;
        border-radius: 18px;
        background: rgba(88, 28, 135, 0.92);
        border: 1px solid rgba(216, 180, 254, 0.28);
        font-size: 1.1rem;
        font-weight: 800;
        color: #f5d0fe;
        justify-self: stretch;
    }

    #mobile-gem-text {
        letter-spacing: 0.02em;
    }

    #abilities-area {
        grid-row: auto;
        grid-column: 2 / -1;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
        padding: 0;
        margin: 0;
        border: none;
        box-shadow: none;
        background: transparent;
        align-self: stretch;
    }

    .ability-button {
        min-width: 0;
        width: 100%;
        min-height: 84px;
        padding: 10px 6px;
        margin: 0;
        gap: 4px;
        border-radius: 18px;
    }

    .ability-button__label,
    .ability-button__cost {
        margin-left: 0;
        width: 100%;
        justify-content: center;
        text-align: center;
    }

    .ability-button__icon,
    .ability-button__label,
    .ability-button__cost {
        display: block;
    }

    .ability-button__icon {
        font-size: 1.15rem;
        margin-bottom: 2px;
    }

    .ability-button__label {
        font-size: 0.72rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }

    .ability-button__cost {
        font-size: 0.72rem;
        gap: 2px;
    }

    #input-area {
        grid-row: 6;
        width: var(--mobile-block-width);
        grid-template-columns: 1fr;
    }

    #submit-button,
    #mobile-view-words-toggle,
    #vote-timer-btn {
        width: 100%;
        min-height: 52px;
        height: 52px;
        padding: 0 16px;
    }

    #mobile-view-words-toggle {
        grid-row: 7;
    }

    #message-area {
        grid-row: 8;
        width: var(--mobile-block-width);
    }

    #found-words-container {
        position: fixed;
        left: 8px;
        right: 8px;
        bottom: 8px;
        height: min(38dvh, 280px);
        z-index: 14500;
        transform: translateY(calc(100% + 20px));
        transition: transform 0.28s ease;
        border-radius: 22px;
        box-shadow: 0 24px 48px rgba(2, 8, 23, 0.45);
    }

    body.mobile-words-open #found-words-container {
        transform: translateY(0);
    }

    #settings-modal-panel {
        width: min(360px, calc(100vw - 24px));
        padding: 20px;
    }
}

#settings-modal {
    pointer-events: auto;
}

#settings-modal-backdrop,
#settings-close-button,
#settings-modal-panel {
    pointer-events: auto;
    touch-action: manipulation;
}

@media (min-width: 769px) {
    body.screen-game #game-container {
        display: grid;
        grid-template-columns: minmax(260px, 1fr) minmax(430px, 520px) minmax(260px, 1fr);
        align-items: start;
        justify-items: stretch;
        gap: 30px;
        width: min(100%, 1480px);
        max-width: 1480px;
        margin: 0 auto;
    }

    body.screen-game #left-panel {
        grid-column: 1;
    }

    body.screen-game #center-panel {
        grid-column: 2;
        width: 100%;
        max-width: 520px;
        justify-self: center;
        align-items: center;
    }

    body.screen-game #right-panel {
        grid-column: 3;
    }

    body.screen-game #game-board-area {
        width: 100%;
        display: flex;
        justify-content: center;
    }

    body.multiplayer-active #controls-area {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
        align-items: stretch;
    }

    body.multiplayer-active #controls-area #home-button,
    body.multiplayer-active #controls-area #desktop-settings-button {
        width: 100% !important;
        margin: 0 !important;
    }
}

@media (max-width: 768px) {
    body.screen-game:not(.layout-editor-preview) {
        padding: 0;
        align-items: stretch;
        overflow: hidden;
    }

    body.screen-game:not(.layout-editor-preview) #game-container {
        display: flex;
        flex-direction: column;
        gap: 8px;
        width: 100vw;
        max-width: 100vw;
        height: 100dvh;
        max-height: 100dvh;
        margin: 0;
        padding: calc(env(safe-area-inset-top, 0px) + 8px) 10px calc(env(safe-area-inset-bottom, 0px) + 10px);
        box-sizing: border-box;
        overflow: hidden;
    }

    body.screen-game:not(.layout-editor-preview) #left-panel,
    body.screen-game:not(.layout-editor-preview) #right-panel {
        display: contents;
    }

    body.screen-game:not(.layout-editor-preview) #center-panel {
        display: contents;
    }

    body.screen-game:not(.layout-editor-preview) #right-panel h1,
    body.screen-game:not(.layout-editor-preview) #stats-area,
    body.screen-game:not(.layout-editor-preview) #controls-area,
    body.screen-game:not(.layout-editor-preview) #new-game-button,
    body.screen-game:not(.layout-editor-preview) #multiplayer-scoreboard,
    body.screen-game:not(.layout-editor-preview) #game-container #message-area {
        display: none !important;
    }

    body.screen-game:not(.layout-editor-preview) #mobile-game-header,
    body.screen-game:not(.layout-editor-preview) #mobile-player-rail,
    body.screen-game:not(.layout-editor-preview) #timer-container,
    body.screen-game:not(.layout-editor-preview) #selection-area,
    body.screen-game:not(.layout-editor-preview) #game-board-area,
    body.screen-game:not(.layout-editor-preview) #mobile-ability-row,
    body.screen-game:not(.layout-editor-preview) #input-area,
    body.screen-game:not(.layout-editor-preview) #mobile-view-words-toggle {
        width: min(100%, 390px);
        max-width: 390px;
        align-self: center;
        box-sizing: border-box;
    }

    body.screen-game:not(.layout-editor-preview) #mobile-game-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        flex: 0 0 auto;
        position: relative;
        z-index: 30;
        order: 10;
    }

    body.screen-game:not(.layout-editor-preview) #mobile-round-pill {
        display: inline-flex;
        align-items: baseline;
        gap: 8px;
        padding: 10px 14px;
        border-radius: 18px;
        background: linear-gradient(145deg, rgba(6, 78, 59, 0.94), rgba(8, 47, 73, 0.92));
        border: 1px solid rgba(103, 232, 249, 0.28);
        box-shadow: 0 14px 24px rgba(8, 47, 73, 0.26);
    }

    body.screen-game:not(.layout-editor-preview) #mobile-nav-actions {
        display: flex;
        gap: 8px;
        flex: 0 0 auto;
        position: relative;
        z-index: 31;
    }

    body.screen-game:not(.layout-editor-preview) .mobile-icon-button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 42px;
        height: 42px;
        border-radius: 14px;
        padding: 0;
        font-size: 0.95rem;
        position: relative;
        z-index: 32;
        pointer-events: auto;
    }

    body.screen-game:not(.layout-editor-preview) #mobile-player-rail {
        display: block;
        flex: 0 0 auto;
        overflow: hidden;
        position: relative;
        z-index: 20;
        order: 20;
    }

    body.screen-game:not(.layout-editor-preview) #mobile-player-carousel {
        width: 100%;
        display: block;
        overflow: visible;
        padding-bottom: 0;
    }

    body.screen-game:not(.layout-editor-preview) .mobile-carousel-shell {
        display: grid;
        grid-template-columns: 28px minmax(52px, 0.72fr) minmax(0, 1.7fr) minmax(52px, 0.72fr) 28px;
        align-items: center;
        gap: 8px;
        width: 100%;
        padding: 8px 0;
    }

    body.screen-game:not(.layout-editor-preview) .mobile-carousel-shell.solo {
        grid-template-columns: 12px 0 minmax(0, 1fr) 0 12px;
    }

    body.screen-game:not(.layout-editor-preview) .mobile-carousel-arrow,
    body.screen-game:not(.layout-editor-preview) .mobile-carousel-spacer {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 28px;
        height: 70px;
    }

    body.screen-game:not(.layout-editor-preview) .mobile-carousel-arrow {
        border: 1px solid rgba(125, 211, 252, 0.25);
        border-radius: 16px;
        background: linear-gradient(145deg, rgba(15, 23, 42, 0.9), rgba(30, 41, 59, 0.96));
        color: #fde68a;
        font-size: 1.15rem;
        box-shadow: 0 10px 20px rgba(2, 8, 23, 0.35);
    }

    body.screen-game:not(.layout-editor-preview) .mobile-carousel-preview {
        min-width: 0;
    }

    body.screen-game:not(.layout-editor-preview) .mobile-carousel-preview--main {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        align-items: center;
        gap: 10px;
        padding: 10px 12px;
        border-radius: 20px;
        background: linear-gradient(145deg, rgba(35, 50, 120, 0.96), rgba(18, 24, 50, 0.96));
        border: 1px solid rgba(147, 197, 253, 0.28);
        box-shadow: 0 16px 28px rgba(15, 23, 42, 0.34);
    }

    body.screen-game:not(.layout-editor-preview) .mobile-carousel-preview--main.self {
        border-color: rgba(56, 189, 248, 0.5);
    }

    body.screen-game:not(.layout-editor-preview) .mobile-carousel-preview--side {
        display: flex;
        justify-content: center;
    }

    body.screen-game:not(.layout-editor-preview) .mobile-main-hero,
    body.screen-game:not(.layout-editor-preview) .mobile-side-avatar-wrap {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    body.screen-game:not(.layout-editor-preview) .mobile-main-avatar-wrap {
        position: relative;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    body.screen-game:not(.layout-editor-preview) .mobile-player-avatar {
        width: 50px;
        height: 50px;
        border-radius: 16px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: linear-gradient(145deg, rgba(8, 47, 73, 0.98), rgba(37, 99, 235, 0.92));
        color: #e0f2fe;
        font-size: 1.1rem;
        font-weight: 800;
        box-shadow: 0 10px 20px rgba(8, 47, 73, 0.28);
    }

    body.screen-game:not(.layout-editor-preview) .mobile-main-gems,
    body.screen-game:not(.layout-editor-preview) .mobile-side-gems {
        position: absolute;
        right: -6px;
        bottom: -4px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 28px;
        height: 24px;
        padding: 0 6px;
        border-radius: 999px;
        background: linear-gradient(145deg, rgba(168, 85, 247, 0.98), rgba(126, 34, 206, 0.94));
        color: #fdf4ff;
        font-size: 0.72rem;
        font-weight: 800;
        box-shadow: 0 8px 14px rgba(88, 28, 135, 0.4);
    }

    body.screen-game:not(.layout-editor-preview) .mobile-main-score,
    body.screen-game:not(.layout-editor-preview) .mobile-side-score {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 48px;
        padding: 0 10px;
        height: 36px;
        border-radius: 14px;
        background: rgba(2, 6, 23, 0.75);
        color: #f8fafc;
        font-weight: 800;
        letter-spacing: 0.02em;
    }

    body.screen-game:not(.layout-editor-preview) .mobile-main-meta {
        min-width: 0;
    }

    body.screen-game:not(.layout-editor-preview) .mobile-player-name {
        font-weight: 800;
        color: #f8fafc;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    body.screen-game:not(.layout-editor-preview) .mobile-player-last-word {
        margin-top: 4px;
        font-size: 0.74rem;
        line-height: 1.3;
        color: #cbd5e1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    body.screen-game:not(.layout-editor-preview) .mobile-side-avatar-wrap {
        position: relative;
        flex-direction: column;
        gap: 6px;
    }

    body.screen-game:not(.layout-editor-preview) .mobile-side-avatar-wrap .mobile-player-avatar {
        width: 42px;
        height: 42px;
        border-radius: 14px;
        font-size: 0.95rem;
    }

    body.screen-game:not(.layout-editor-preview) .mobile-side-gems {
        position: static;
        min-width: 0;
        height: auto;
        padding: 2px 6px;
        font-size: 0.66rem;
    }

    body.screen-game:not(.layout-editor-preview) .mobile-side-score {
        min-width: 0;
        height: auto;
        padding: 4px 8px;
        font-size: 0.74rem;
    }

    body.screen-game:not(.layout-editor-preview) #timer-container {
        position: relative;
        flex: 0 0 auto;
        margin: 0 !important;
        padding: 0 !important;
        min-height: 34px;
        border-radius: 18px !important;
        overflow: hidden;
        order: 30;
    }

    body.screen-game:not(.layout-editor-preview) #timer-header-row {
        position: absolute;
        inset: 0;
        z-index: 3;
        display: flex !important;
        align-items: center;
        justify-content: center !important;
        margin: 0 !important;
        pointer-events: none;
    }

    body.screen-game:not(.layout-editor-preview) #timer-label {
        display: none !important;
    }

    body.screen-game:not(.layout-editor-preview) #timer-text {
        color: #f8fafc !important;
        font-size: 0.95rem !important;
        font-weight: 800 !important;
        text-shadow: 0 1px 4px rgba(2, 6, 23, 0.75);
    }

    body.screen-game:not(.layout-editor-preview) #timer-action-slot {
        display: flex;
        align-items: stretch;
        min-height: 34px;
    }

    body.screen-game:not(.layout-editor-preview) #timer-progress-track,
    body.screen-game:not(.layout-editor-preview) #vote-timer-btn {
        min-height: 34px;
        height: 34px;
        border-radius: 16px;
    }

    body.screen-game:not(.layout-editor-preview) #timer-progress-track {
        position: relative;
        width: 100%;
        overflow: hidden;
    }

    body.screen-game:not(.layout-editor-preview) #timer-bar {
        height: 100% !important;
    }

    body.screen-game:not(.layout-editor-preview) #vote-info {
        position: absolute;
        inset: 0;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 12px;
        font-size: 0.74rem;
        font-weight: 700;
        color: #f8fafc;
        background: rgba(15, 23, 42, 0.24);
    }

    body.screen-game:not(.layout-editor-preview) #selection-area {
        display: flex !important;
        flex: 0 0 auto;
        min-height: 48px;
        height: 48px;
        margin: 0;
        gap: 2px;
        justify-content: center;
        order: 32;
    }

    body.screen-game:not(.layout-editor-preview) #current-word-display,
    body.screen-game:not(.layout-editor-preview) #score-preview-display {
        display: block;
        min-height: 20px;
        line-height: 1.1;
    }

    body.screen-game:not(.layout-editor-preview) #current-word-display {
        font-size: 1.2rem;
        letter-spacing: 0.12em;
    }

    body.screen-game:not(.layout-editor-preview) #score-preview-display {
        font-size: 0.9rem;
    }

    body.screen-game:not(.layout-editor-preview) #current-word-display:empty::before {
        content: "PREVIEW";
        visibility: hidden;
    }

    body.screen-game:not(.layout-editor-preview) #score-preview-display:empty::before {
        content: "(+000)";
        visibility: hidden;
    }

    body.screen-game:not(.layout-editor-preview) #game-board-area {
        display: flex;
        align-items: center;
        justify-content: center;
        flex: 1 1 auto;
        min-height: 0;
        order: 40;
    }

    body.screen-game:not(.layout-editor-preview) #game-board {
        width: min(340px, calc(100vw - 36px));
        max-width: 100%;
        gap: 20px;
        flex-shrink: 1;
        margin: 0 auto;
    }

    body.screen-game:not(.layout-editor-preview) #mobile-ability-row {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 8px;
        flex: 0 0 auto;
        padding: 8px;
        border-radius: 20px;
        background: linear-gradient(145deg, rgba(12, 22, 43, 0.96), rgba(30, 41, 59, 0.97));
        border: 1px solid rgba(125, 211, 252, 0.22);
        box-shadow: 0 16px 30px rgba(2, 8, 23, 0.38);
        order: 50;
    }

    body.screen-game:not(.layout-editor-preview) #mobile-gem-tracker,
    body.screen-game:not(.layout-editor-preview) .ability-button {
        min-height: 78px;
        border-radius: 18px;
    }

    body.screen-game:not(.layout-editor-preview) #mobile-gem-tracker {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 4px;
        width: 100%;
        padding: 0;
        background: linear-gradient(145deg, rgba(88, 28, 135, 0.96), rgba(55, 48, 163, 0.92));
        border: 1px solid rgba(216, 180, 254, 0.34);
        color: #f5d0fe;
        font-size: 1.1rem;
        font-weight: 800;
    }

    body.screen-game:not(.layout-editor-preview) #abilities-area {
        grid-column: 2 / -1;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
        padding: 0;
        margin: 0;
        background: transparent;
        border: none;
        box-shadow: none;
    }

    body.screen-game:not(.layout-editor-preview) #abilities-area h3 {
        display: none;
    }

    body.screen-game:not(.layout-editor-preview) .ability-button {
        width: 100%;
        margin: 0;
        padding: 8px 6px;
        gap: 4px;
    }

    body.screen-game:not(.layout-editor-preview) .ability-button__icon,
    body.screen-game:not(.layout-editor-preview) .ability-button__label,
    body.screen-game:not(.layout-editor-preview) .ability-button__cost {
        display: block;
        width: 100%;
        text-align: center;
    }

    body.screen-game:not(.layout-editor-preview) .ability-button__icon {
        font-size: 1.08rem;
        margin-bottom: 2px;
    }

    body.screen-game:not(.layout-editor-preview) .ability-button__label {
        font-size: 0.7rem;
        text-transform: uppercase;
        letter-spacing: 0.04em;
    }

    body.screen-game:not(.layout-editor-preview) .ability-button__cost {
        font-size: 0.72rem;
        justify-content: center;
    }

    body.screen-game:not(.layout-editor-preview) #input-area,
    body.screen-game:not(.layout-editor-preview) #mobile-view-words-toggle {
        flex: 0 0 auto;
    }

    body.screen-game:not(.layout-editor-preview) #input-area {
        order: 60;
    }

    body.screen-game:not(.layout-editor-preview) #mobile-view-words-toggle {
        order: 70;
    }

    body.screen-game:not(.layout-editor-preview) #submit-button,
    body.screen-game:not(.layout-editor-preview) #mobile-view-words-toggle,
    body.screen-game:not(.layout-editor-preview) #vote-timer-btn {
        width: 100%;
        min-width: 0;
        min-height: 48px;
        height: 48px;
        padding: 0 16px;
        border-radius: 18px;
        font-size: 0.92rem;
        font-weight: 800;
        letter-spacing: 0.05em;
    }

    body.screen-game:not(.layout-editor-preview) #found-words-container {
        display: none !important;
        position: fixed;
        top: 50%;
        left: 50%;
        width: min(390px, calc(100vw - 24px));
        max-width: calc(100vw - 24px);
        max-height: min(58dvh, 430px);
        padding: 18px 16px 16px;
        transform: translate(-50%, -50%) scale(0.97);
        transform-origin: center;
        z-index: 16000;
        overflow: auto;
        border-radius: 22px;
        background: linear-gradient(160deg, rgba(10, 20, 45, 0.98), rgba(17, 24, 39, 0.98));
        border: 1px solid rgba(125, 211, 252, 0.3);
        box-shadow: 0 26px 50px rgba(2, 8, 23, 0.56);
    }

    body.screen-game.mobile-words-open:not(.layout-editor-preview) #found-words-container {
        display: block !important;
        transform: translate(-50%, -50%) scale(1);
    }

    body.screen-game:not(.layout-editor-preview) #mobile-words-backdrop {
        position: fixed;
        inset: 0;
        z-index: 15950;
        background: rgba(3, 7, 18, 0.62);
        backdrop-filter: blur(10px);
    }

    body.screen-game:not(.layout-editor-preview) #mobile-words-backdrop.hidden {
        display: none !important;
    }

    body.screen-game.mobile-words-open:not(.layout-editor-preview) #mobile-words-backdrop:not(.hidden) {
        display: block !important;
    }

    body.screen-game:not(.layout-editor-preview) #mobile-words-close {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        position: sticky;
        top: 0;
        float: right;
        width: 36px;
        height: 36px;
        margin: -4px -4px 8px 0;
        border-radius: 12px;
        border: 1px solid rgba(125, 211, 252, 0.28);
        background: linear-gradient(145deg, rgba(8, 47, 73, 0.95), rgba(30, 41, 59, 0.95));
        color: #f8fafc;
        font-size: 0.95rem;
        font-weight: 700;
        cursor: pointer;
        z-index: 2;
    }

body.screen-game:not(.layout-editor-preview) .grid-tile,
body.screen-game:not(.layout-editor-preview) .grid-tile:hover,
body.screen-game:not(.layout-editor-preview) .grid-tile.selected {
    transform: none !important;
}
}

/* ===== FINAL POLISH OVERRIDES ===== */

#settings-modal.hidden {
    display: none !important;
}

.settings-field--conditional.is-disabled {
    display: none !important;
}

.field-warning {
    min-height: 1.1rem;
    margin: 6px 2px 0;
    color: #fca5a5;
    font-size: 0.88rem;
}

.input-error {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.32) !important;
}

.room-code-entry {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.room-code-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.copy-room-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid rgba(125, 211, 252, 0.28);
    background: linear-gradient(145deg, rgba(8, 47, 73, 0.95), rgba(30, 41, 59, 0.95));
    color: #f8fafc;
    cursor: pointer;
}

.copy-room-feedback {
    min-width: 52px;
    font-size: 0.84rem;
    color: #cbd5e1;
}

.copy-room-feedback[data-state="green"] {
    color: #86efac;
}

.copy-room-feedback[data-state="red"] {
    color: #fca5a5;
}

#timer-container {
    display: none;
    flex-direction: column;
    width: 100%;
    min-height: 96px;
    padding: 12px 14px;
    margin-bottom: 14px;
    border-radius: 16px;
    background: rgba(17, 24, 39, 0.92);
    border: 2px solid #4b5563;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    box-sizing: border-box;
}

#timer-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    min-height: 28px;
    margin-bottom: 10px;
}

#timer-header-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
}

#timer-label {
    justify-self: start;
}

#timer-text {
    justify-self: end;
}

#timer-label {
    font-size: 1rem;
    font-weight: 700;
}

#timer-text {
    font-size: 1.25rem;
    font-weight: 800;
    color: #fde68a;
}

#timer-action-slot {
    display: flex;
    align-items: stretch;
    width: 100%;
    min-height: 34px;
    flex: 1 1 auto;
}

#timer-progress-track,
#vote-timer-btn {
    width: 100%;
    min-height: 34px;
    border-radius: 12px;
}

#timer-progress-track {
    position: relative;
    display: block;
    overflow: hidden;
    background: rgba(71, 85, 105, 0.7);
}

#timer-bar {
    position: absolute;
    left: 12px;
    right: auto;
    top: 50%;
    height: 10px;
    margin-top: -5px;
    border-radius: 999px;
    background: #ef4444;
    transition: width 0.3s ease, background-color 0.3s ease;
}

#vote-info {
    display: none;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 100%;
    padding: 0 12px;
    box-sizing: border-box;
}

#vote-info-label {
    flex: 1 1 auto;
    min-width: 0;
}

#vote-info-count {
    flex: 0 0 auto;
    padding-left: 10px;
}

body.multiplayer-active #controls-area {
    display: flex !important;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px !important;
    padding: 14px !important;
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.72) !important;
    border: 1px solid rgba(148, 163, 184, 0.16);
}

body.multiplayer-active #controls-area #home-button,
body.multiplayer-active #controls-area #desktop-settings-button {
    flex: 1 1 0;
    width: auto !important;
    margin: 0 !important;
    min-width: 0;
}

body.multiplayer-active #controls-area #home-button {
    background: linear-gradient(145deg, #4b5563, #374151) !important;
}

body.multiplayer-active #controls-area #desktop-settings-button {
    background: linear-gradient(145deg, #334155, #243447) !important;
}

#chat-fab {
    position: fixed;
    right: 22px;
    bottom: 22px;
    width: 58px;
    height: 58px;
    border: none;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, #22c55e, #0f766e);
    color: #f8fafc;
    font-size: 1.4rem;
    box-shadow: 0 16px 28px rgba(15, 118, 110, 0.38);
    cursor: pointer;
    z-index: 12000;
}

#dev-tools-fab {
    position: fixed;
    left: 18px;
    bottom: 18px;
    width: 52px;
    height: 52px;
    border-radius: 999px;
    border: 1px solid rgba(125, 211, 252, 0.28);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, rgba(15, 23, 42, 0.96), rgba(30, 41, 59, 0.98));
    color: #fef08a;
    font-size: 1.15rem;
    box-shadow: 0 12px 24px rgba(2, 8, 23, 0.4);
    z-index: 100210;
}

#dev-tools-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: flex-end;
    justify-content: flex-start;
    padding: 18px;
    background: rgba(2, 6, 23, 0.22);
    z-index: 100205;
}

#dev-tools-panel-shell {
    width: min(320px, calc(100vw - 36px));
    max-height: min(78dvh, 560px);
    overflow: auto;
    padding: 14px;
    border-radius: 18px;
    border: 1px solid rgba(125, 211, 252, 0.24);
    background: linear-gradient(145deg, rgba(15, 23, 42, 0.98), rgba(30, 41, 59, 0.98));
    box-shadow: 0 18px 36px rgba(2, 8, 23, 0.48);
}

.dev-tools-duration-field {
    margin-top: 10px;
}

.dev-audio-tester {
    margin-top: 12px;
    padding: 12px;
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: rgba(15, 23, 42, 0.72);
}

.dev-audio-tester h4 {
    margin: 0 0 10px;
    color: #f8fafc;
    font-size: 0.95rem;
}

.dev-audio-tester__actions {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

#dev-local-audio-status {
    margin: 10px 0 0;
    color: #cbd5e1;
    font-size: 0.82rem;
    line-height: 1.5;
}

.dev-tools-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.dev-tools-header h3 {
    margin: 0;
    color: #e0f2fe;
    font-size: 1rem;
}

#dev-tools-close {
    width: 34px;
    height: 34px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.24);
    background: rgba(30, 41, 59, 0.82);
    color: #f8fafc;
}

.dev-animation-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 10px;
}

body:not(.screen-game) #chat-fab,
body.screen-game:not(.multiplayer-active) #chat-fab {
    display: none;
}

.score-item--rich {
    gap: 12px;
    align-items: center;
}

.score-item__avatar-wrap {
    position: relative;
    flex: 0 0 auto;
}

.score-item__avatar {
    width: 42px;
    height: 42px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, rgba(37, 99, 235, 0.95), rgba(30, 41, 59, 0.95));
    color: #eff6ff;
    font-weight: 800;
}

.score-item__gems {
    position: absolute;
    right: -6px;
    bottom: -6px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, #d946ef, #9333ea);
    color: #fff7ff;
    font-size: 0.68rem;
    font-weight: 800;
    box-shadow: 0 6px 12px rgba(88, 28, 135, 0.38);
}

.score-item__gems,
.mobile-main-gems,
.mobile-side-gems {
    gap: 2px;
}

.score-item__meta {
    flex: 1 1 auto;
    min-width: 0;
}

.score-item__name {
    font-weight: 700;
    color: #f8fafc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.score-item__last-word {
    margin-top: 2px;
    color: #cbd5e1;
    font-size: 0.78rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.score-item__points {
    flex: 0 0 auto;
    font-size: 1.05rem;
    font-weight: 800;
    color: #f8fafc;
}

@keyframes activeTurnAvatarPulse {
    0%, 100% {
        border-color: rgba(34, 197, 94, 0.92);
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.26), 0 0 16px rgba(34, 197, 94, 0.34);
    }
    50% {
        border-color: rgba(134, 239, 172, 1);
        box-shadow: 0 0 0 7px rgba(34, 197, 94, 0.08), 0 0 24px rgba(34, 197, 94, 0.56);
    }
}

.score-item.active .score-item__avatar,
.mobile-carousel-preview.turn-active .mobile-player-avatar {
    position: relative;
    border: 3px solid #22c55e;
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.26), 0 0 16px rgba(34, 197, 94, 0.34);
    animation: activeTurnAvatarBorder 1.15s ease-in-out infinite;
}

.score-item.active .score-item__avatar::after,
.mobile-carousel-preview.turn-active .mobile-player-avatar::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    opacity: 0;
    box-shadow: 0 0 0 7px rgba(34, 197, 94, 0.08), 0 0 24px rgba(34, 197, 94, 0.56);
    animation: glowPulsePeak 1.15s ease-in-out infinite;
}

@keyframes activeTurnAvatarBorder {
    0%, 100% { border-color: rgba(34, 197, 94, 0.92); }
    50% { border-color: rgba(134, 239, 172, 1); }
}

@media (max-width: 768px) {
    body.desktop-pointer-layout #mobile-game-header,
    body.desktop-pointer-layout #mobile-player-rail,
    body.desktop-pointer-layout #mobile-gem-tracker,
    body.desktop-pointer-layout #mobile-view-words-toggle,
    body.desktop-pointer-layout #mobile-words-backdrop,
    body.desktop-pointer-layout #mobile-words-close {
        display: none !important;
    }

    body.desktop-pointer-layout #left-panel,
    body.desktop-pointer-layout #center-panel,
    body.desktop-pointer-layout #right-panel {
        display: flex !important;
    }

    body.desktop-pointer-layout #game-container {
        display: flex !important;
        flex-wrap: wrap;
        gap: 24px;
        align-items: flex-start;
        max-width: 1400px;
        height: auto;
    }

    body.desktop-pointer-layout #found-words-container,
    body.desktop-pointer-layout #multiplayer-scoreboard,
    body.desktop-pointer-layout #controls-area,
    body.desktop-pointer-layout #message-area,
    body.desktop-pointer-layout #selection-area,
    body.desktop-pointer-layout #input-area,
    body.desktop-pointer-layout #timer-container {
        display: block !important;
    }

    body.desktop-pointer-layout #center-panel {
        max-width: 500px;
        flex: 2;
    }

    body.desktop-pointer-layout #game-board {
        width: 100%;
        max-width: 400px;
        gap: 20px;
    }
}

@media (max-width: 768px) and (hover: none), (max-width: 768px) and (pointer: coarse) {
    #chat-fab {
        display: none !important;
    }

    body.screen-game:not(.layout-editor-preview) #game-container {
        height: calc(100dvh - 16px);
        display: flex;
        flex-direction: column;
        gap: 5px;
        overflow: hidden;
        padding: 0;
    }

    body.screen-game:not(.layout-editor-preview) #left-panel,
    body.screen-game:not(.layout-editor-preview) #center-panel,
    body.screen-game:not(.layout-editor-preview) #right-panel {
        display: contents;
    }

    body.screen-game:not(.layout-editor-preview) #multiplayer-scoreboard,
    body.screen-game:not(.layout-editor-preview) #controls-area,
    body.screen-game:not(.layout-editor-preview) #stats-area,
    body.screen-game:not(.layout-editor-preview) #right-panel h1,
    body.screen-game:not(.layout-editor-preview) #message-area,
    body.screen-game:not(.layout-editor-preview) #mobile-turn-banner {
        display: none !important;
    }

    body.screen-game:not(.layout-editor-preview) #mobile-game-header,
    body.screen-game:not(.layout-editor-preview) #mobile-player-rail,
    body.screen-game:not(.layout-editor-preview) #timer-container,
    body.screen-game:not(.layout-editor-preview) #selection-area,
    body.screen-game:not(.layout-editor-preview) #game-board-area,
    body.screen-game:not(.layout-editor-preview) #mobile-ability-row,
    body.screen-game:not(.layout-editor-preview) #input-area,
    body.screen-game:not(.layout-editor-preview) #mobile-view-words-toggle {
        width: min(100%, 360px);
        max-width: 360px;
        align-self: center;
    }

    body.screen-game:not(.layout-editor-preview) #mobile-player-rail {
        overflow: hidden;
    }

    body.screen-game:not(.layout-editor-preview) #mobile-game-header {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    body.screen-game:not(.layout-editor-preview) #mobile-round-pill {
        align-self: flex-start;
    }

    body.screen-game:not(.layout-editor-preview) #mobile-nav-actions {
        width: 100%;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    body.screen-game:not(.layout-editor-preview) .mobile-carousel-shell {
        grid-template-columns: 24px minmax(46px, 0.62fr) minmax(0, 1.9fr) minmax(46px, 0.62fr) 24px;
        gap: 4px;
        padding: 2px 0;
    }

    body.screen-game:not(.layout-editor-preview) .mobile-carousel-arrow,
    body.screen-game:not(.layout-editor-preview) .mobile-carousel-spacer {
        width: 24px;
        height: 62px;
    }

    body.screen-game:not(.layout-editor-preview) .mobile-carousel-preview--main {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 8px 8px 0;
        border-radius: 18px;
        background: linear-gradient(145deg, rgba(35, 50, 120, 0.96), rgba(18, 24, 50, 0.96));
    }

    body.screen-game:not(.layout-editor-preview) .mobile-main-avatar-wrap {
        flex: 0 0 auto;
        margin-left: 6px;
    }

    body.screen-game:not(.layout-editor-preview) .mobile-main-meta {
        flex: 1 1 auto;
        min-width: 0;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    body.screen-game:not(.layout-editor-preview) .mobile-player-name {
        font-size: 13px;
    }

    body.screen-game:not(.layout-editor-preview) .mobile-player-last-word {
        margin-top: 1px;
        font-size: 11px;
        opacity: 0.82;
    }

    body.screen-game:not(.layout-editor-preview) .mobile-main-score {
        flex: 0 0 auto;
        min-width: 0;
        padding: 0 8px;
        height: 30px;
        font-size: 13px;
    }

    body.screen-game:not(.layout-editor-preview) .mobile-side-avatar-wrap {
        gap: 3px;
    }

    body.screen-game:not(.layout-editor-preview) #timer-container {
        min-height: 34px;
        height: 34px;
        padding: 0 !important;
        margin-bottom: 0 !important;
        border-radius: 16px !important;
    }

    body.screen-game:not(.layout-editor-preview) #timer-header-row {
        inset: 0;
        margin: 0 !important;
        align-items: center;
        justify-content: center !important;
    }

    body.screen-game:not(.layout-editor-preview) #timer-progress-track,
    body.screen-game:not(.layout-editor-preview) #vote-timer-btn {
        min-height: 34px;
        height: 34px;
        border-radius: 16px;
    }

    body.screen-game:not(.layout-editor-preview) #timer-bar {
        left: 10px;
        height: 10px !important;
        margin-top: -5px;
    }

    body.screen-game:not(.layout-editor-preview) #timer-text {
        font-size: 0.88rem !important;
    }

    body.screen-game:not(.layout-editor-preview) #vote-info {
        padding: 0 10px;
        font-size: 0.68rem;
    }

    body.screen-game:not(.layout-editor-preview) #selection-area {
        display: flex !important;
        min-height: 40px;
        height: 40px;
        gap: 2px;
        margin: 0;
    }

    body.screen-game:not(.layout-editor-preview) #current-word-display,
    body.screen-game:not(.layout-editor-preview) #score-preview-display {
        display: block;
        min-height: 16px;
    }

    body.screen-game:not(.layout-editor-preview) #game-board-area {
        flex: 1 1 auto;
        min-height: 0;
    }

    body.screen-game:not(.layout-editor-preview) #game-board {
        width: min(320px, calc(100vw - 30px));
        max-width: 100%;
        gap: 12px;
        margin: 0 auto;
        flex-shrink: 1;
    }

    body.screen-game:not(.layout-editor-preview) #mobile-ability-row {
        gap: 6px;
        padding: 6px;
    }

    body.screen-game:not(.layout-editor-preview) #mobile-gem-tracker,
    body.screen-game:not(.layout-editor-preview) .ability-button {
        min-height: 72px;
    }

    body.screen-game:not(.layout-editor-preview) #input-area,
    body.screen-game:not(.layout-editor-preview) #mobile-view-words-toggle {
        min-height: 44px;
    }

    body.screen-game:not(.layout-editor-preview) #submit-button,
    body.screen-game:not(.layout-editor-preview) #mobile-view-words-toggle {
        min-height: 44px;
        height: 44px;
        border-radius: 16px;
        font-size: 0.88rem;
    }
}

/* ===== CURRENT PASS OVERRIDES ===== */

#mobile-action-row {
    display: contents;
}

#settings-modal-backdrop {
    z-index: 0;
}

#settings-modal-panel {
    z-index: 1;
    isolation: isolate;
}

#settings-close-button {
    position: relative;
    z-index: 2;
}

#timer-action-slot {
    align-items: center;
    height: 34px;
    min-height: 34px;
}

#timer-progress-track,
#vote-timer-btn,
#vote-info {
    height: 100%;
    min-height: 34px;
}

#timer-progress-track,
#vote-timer-btn {
    display: flex;
    align-items: center;
    justify-content: center;
}

#vote-info {
    align-items: center;
}

#vote-info-label,
#vote-info-count {
    display: inline-flex;
    align-items: center;
    height: 100%;
}

body.pseudo-fullscreen-active {
    overflow: hidden;
    padding: 0;
}

#game-container.pseudo-fullscreen-active {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    max-width: none;
    z-index: 99999;
    margin: 0;
    padding: 12px;
    box-sizing: border-box;
    background: linear-gradient(180deg, #2e3b68 0%, #1f2937 72%);
    overflow: hidden;
    border-radius: 0;
}

body.screen-game.mobile-words-open:not(.layout-editor-preview) #found-words-container {
    backdrop-filter: none !important;
    filter: none !important;
    isolation: isolate;
    z-index: 16020 !important;
}

body.screen-game:not(.layout-editor-preview) #mobile-words-backdrop {
    z-index: 15980 !important;
    backdrop-filter: none !important;
    background: rgba(0, 0, 0, 0.85) !important;
}

@media (max-width: 768px) and (hover: none), (max-width: 768px) and (pointer: coarse) {
    body.screen-game:not(.layout-editor-preview) #selection-area {
        min-height: 28px;
        height: auto;
        gap: 0;
        margin: 0;
        padding: 0;
    }

    body.screen-game:not(.layout-editor-preview) #score-preview-display {
        margin: 0 !important;
        line-height: 1.1;
    }

    body.screen-game:not(.layout-editor-preview) #mobile-action-row {
        width: min(100%, 360px);
        max-width: 360px;
        align-self: center;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        order: 60;
    }

    body.screen-game:not(.layout-editor-preview) #input-area,
    body.screen-game:not(.layout-editor-preview) #mobile-view-words-toggle {
        width: 100%;
        max-width: none;
        min-width: 0;
        margin: 0;
        grid-row: auto;
        grid-column: auto;
    }

    body.screen-game:not(.layout-editor-preview) #input-area {
        order: 0;
        margin-top: 0;
    }

    body.screen-game:not(.layout-editor-preview) #mobile-view-words-toggle {
        order: 0;
    }

    body.screen-game:not(.layout-editor-preview) #submit-button,
    body.screen-game:not(.layout-editor-preview) #mobile-view-words-toggle {
        width: 100%;
        height: 48px;
        min-height: 48px;
    }

    body.screen-game:not(.layout-editor-preview) .mobile-carousel-shell {
        gap: 2px;
        grid-template-columns: 22px minmax(40px, 0.52fr) minmax(0, 1.9fr) minmax(40px, 0.52fr) 22px;
    }

    body.screen-game:not(.layout-editor-preview) .mobile-carousel-preview--main {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 0;
        border: none;
        background: transparent;
        box-shadow: none;
    }

    body.screen-game:not(.layout-editor-preview) .mobile-main-avatar-wrap,
    body.screen-game:not(.layout-editor-preview) .mobile-side-avatar-badge-wrap {
        position: relative;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    body.screen-game:not(.layout-editor-preview) .mobile-side-avatar-wrap {
        gap: 4px;
        align-items: center;
    }

    body.screen-game:not(.layout-editor-preview) .mobile-main-gems,
    body.screen-game:not(.layout-editor-preview) .mobile-side-gems {
        right: -8px;
        bottom: -3px;
        min-width: 22px;
        height: 18px;
        padding: 0 5px;
        font-size: 0.58rem;
    }

    body.screen-game:not(.layout-editor-preview) .mobile-side-score {
        min-width: 0;
        padding: 2px 6px;
        font-size: 0.7rem;
    }

    body.screen-game:not(.layout-editor-preview) #mobile-ability-row {
        width: min(100%, 180px);
        max-width: 180px;
        gap: 4px;
        padding: 4px;
    }

    body.screen-game:not(.layout-editor-preview) #mobile-gem-tracker,
    body.screen-game:not(.layout-editor-preview) .ability-button {
        min-height: 60px;
        border-radius: 14px;
    }

    body.screen-game:not(.layout-editor-preview) #mobile-gem-tracker {
        font-size: 0.85rem;
        gap: 2px;
    }

    body.screen-game:not(.layout-editor-preview) #abilities-area {
        gap: 4px;
    }

    body.screen-game:not(.layout-editor-preview) .ability-button {
        padding: 6px 4px;
        gap: 2px;
    }

    body.screen-game:not(.layout-editor-preview) .ability-button__icon {
        display: none !important;
    }

    body.screen-game:not(.layout-editor-preview) .ability-button__label,
    body.screen-game:not(.layout-editor-preview) .ability-button__cost {
        display: block;
        width: 100%;
        text-align: center;
        line-height: 1.15;
    }

    body.screen-game:not(.layout-editor-preview) .ability-button__label {
        font-size: 0.54rem;
    }

    body.screen-game:not(.layout-editor-preview) .ability-button__cost {
        font-size: 0.56rem;
    }
}

@media (max-width: 768px) and (hover: none), (max-width: 768px) and (pointer: coarse) {
    body.screen-game:not(.layout-editor-preview) #selection-area {
        display: inline-flex !important;
        align-self: center;
        align-items: center;
        justify-content: center;
        width: fit-content;
        max-width: calc(100vw - 24px);
        min-height: 24px;
        height: auto;
        padding: 0 8px;
        gap: 6px;
        margin: 0;
        white-space: nowrap;
    }

    body.screen-game:not(.layout-editor-preview) #current-word-display,
    body.screen-game:not(.layout-editor-preview) #score-preview-display {
        display: inline-flex;
        align-items: center;
        width: auto;
        min-height: 0;
        line-height: 1;
    }

    body.screen-game:not(.layout-editor-preview) #current-word-display {
        font-size: 1rem;
        letter-spacing: 0.08em;
    }

    body.screen-game:not(.layout-editor-preview) #score-preview-display {
        font-size: 0.92rem;
        color: #34d399;
    }

    body.screen-game:not(.layout-editor-preview) #score-preview-display:empty::before {
        content: '+00';
        visibility: hidden;
    }

    body.screen-game:not(.layout-editor-preview) #game-board-area {
        flex: 0 0 auto;
        min-height: auto;
        margin: 0;
        padding: 0;
        line-height: 0;
        align-items: flex-start;
        justify-content: center;
    }

    body.screen-game:not(.layout-editor-preview) #game-board {
        margin: 0 auto !important;
        padding: 0 !important;
        gap: 12px;
    }

    body.screen-game:not(.layout-editor-preview) #mobile-ability-row {
        width: min(100%, 360px);
        max-width: 360px;
        min-height: 54px;
        gap: 5px;
        padding: 4px 6px;
    }

    body.screen-game:not(.layout-editor-preview) #mobile-gem-tracker,
    body.screen-game:not(.layout-editor-preview) .ability-button {
        min-height: 54px;
        max-height: 54px;
        border-radius: 14px;
    }

    body.screen-game:not(.layout-editor-preview) #mobile-gem-tracker {
        font-size: 0.92rem;
    }

    body.screen-game:not(.layout-editor-preview) #abilities-area {
        gap: 5px;
    }

    body.screen-game:not(.layout-editor-preview) .ability-button {
        padding: 4px 2px;
        overflow: hidden;
        justify-content: center;
    }

    body.screen-game:not(.layout-editor-preview) .ability-button__label,
    body.screen-game:not(.layout-editor-preview) .ability-button__cost {
        line-height: 1.05;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    body.screen-game:not(.layout-editor-preview) .ability-button__label {
        font-size: 0.58rem;
    }

    body.screen-game:not(.layout-editor-preview) .ability-button__cost {
        font-size: 0.58rem;
    }

    body.screen-game:not(.layout-editor-preview) .mobile-side-avatar-wrap {
        flex-direction: column;
        justify-content: flex-start;
        gap: 3px;
    }

    body.screen-game:not(.layout-editor-preview) .mobile-side-avatar-badge-wrap {
        position: relative;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    body.screen-game:not(.layout-editor-preview) .mobile-side-gems {
        position: absolute !important;
        right: -7px;
        bottom: -4px;
    }

    body.screen-game:not(.layout-editor-preview) .mobile-side-score {
        margin-top: 0;
        padding: 1px 5px;
        font-size: 0.68rem;
    }

    body.screen-game:not(.layout-editor-preview) .mobile-main-score {
        padding: 0 7px;
        height: 28px;
        font-size: 13px;
    }

    body.screen-game:not(.layout-editor-preview) .mobile-player-name,
    body.screen-game:not(.layout-editor-preview) .mobile-player-last-word {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

body.screen-game.mobile-words-open:not(.layout-editor-preview) #found-words-container,
body.screen-game:not(.layout-editor-preview) #mobile-words-backdrop {
    backdrop-filter: none !important;
    filter: none !important;
}
}

/* ===== FOLLOW-UP TIMER + MOBILE STACK FIXES ===== */

#timer-action-slot {
    align-items: stretch;
    height: 34px;
    min-height: 34px;
}

#timer-progress-track,
#vote-timer-btn,
#vote-info {
    height: 100%;
    min-height: 100%;
    box-sizing: border-box;
}

#timer-progress-track {
    display: flex;
    align-items: stretch;
}

#vote-timer-btn,
#vote-info {
    align-self: stretch;
}

#vote-timer-btn {
    justify-content: center;
}

#vote-info {
    align-items: center;
}

#vote-info-label,
#vote-info-count {
    display: inline-flex;
    align-items: center;
    height: 100%;
}

@media (max-width: 768px) and (hover: none), (max-width: 768px) and (pointer: coarse) {
    body.screen-game:not(.layout-editor-preview) #game-container {
        gap: 5px !important;
    }

    body.screen-game:not(.layout-editor-preview) #selection-area,
    body.screen-game:not(.layout-editor-preview) #game-board-area,
    body.screen-game:not(.layout-editor-preview) #mobile-ability-row,
    body.screen-game:not(.layout-editor-preview) #mobile-action-row {
        margin: 0 !important;
    }

    body.screen-game:not(.layout-editor-preview) #selection-area {
        display: inline-flex !important;
        align-self: center;
        align-items: center;
        justify-content: center;
        width: fit-content;
        max-width: calc(100vw - 24px);
        min-height: 22px;
        height: auto;
        padding: 0 !important;
        gap: 0 !important;
        line-height: 1;
        white-space: nowrap;
    }

    body.screen-game:not(.layout-editor-preview) #current-word-display {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        width: auto;
        min-height: 0;
        margin: 0;
        padding: 0;
        font-size: 1rem;
        letter-spacing: 0.06em;
        line-height: 1;
    }

    body.screen-game:not(.layout-editor-preview) #score-preview-display {
        display: none !important;
    }

    body.screen-game:not(.layout-editor-preview) #score-preview-display:empty::before {
        content: none !important;
    }

    body.screen-game:not(.layout-editor-preview) #game-board-area {
        flex: 0 0 auto;
        min-height: auto;
        padding: 0 !important;
        line-height: 0;
        align-items: flex-start;
        justify-content: center;
        overflow: visible;
    }

    body.screen-game:not(.layout-editor-preview) #game-board {
        width: min(320px, calc(100vw - 30px));
        max-width: 100%;
        margin: 0 auto !important;
        padding: 0 !important;
        gap: 12px;
        align-content: start;
        overflow: visible;
    }

    body.screen-game:not(.layout-editor-preview) #mobile-ability-row {
        width: 100%;
        max-width: 360px;
        min-height: 48px;
        max-height: 48px;
        gap: 5px;
        padding: 0 !important;
        align-items: stretch;
    }

    body.screen-game:not(.layout-editor-preview) #mobile-gem-tracker,
    body.screen-game:not(.layout-editor-preview) .ability-button {
        min-height: 48px;
        max-height: 48px;
        height: 48px;
        border-radius: 14px;
    }

    body.screen-game:not(.layout-editor-preview) #mobile-gem-tracker {
        font-size: 0.9rem;
    }

    body.screen-game:not(.layout-editor-preview) #abilities-area {
        gap: 5px;
    }

    body.screen-game:not(.layout-editor-preview) .ability-button {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 1px;
        padding: 3px 2px;
        overflow: hidden;
    }

    body.screen-game:not(.layout-editor-preview) .ability-button__icon {
        display: none !important;
    }

    body.screen-game:not(.layout-editor-preview) .ability-button__label,
    body.screen-game:not(.layout-editor-preview) .ability-button__cost {
        display: block;
        width: 100%;
        margin: 0;
        text-align: center;
        line-height: 1.02;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    body.screen-game:not(.layout-editor-preview) .ability-button__label {
        font-size: 0.56rem;
    }

    body.screen-game:not(.layout-editor-preview) .ability-button__cost {
        font-size: 0.56rem;
    }

    body.screen-game:not(.layout-editor-preview) .mobile-carousel-preview--side {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    body.screen-game:not(.layout-editor-preview) .mobile-side-avatar-wrap {
        display: flex;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: flex-start !important;
        gap: 3px !important;
    }

    body.screen-game:not(.layout-editor-preview) .mobile-side-avatar-badge-wrap {
        position: relative !important;
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        width: fit-content;
    }

    body.screen-game:not(.layout-editor-preview) .mobile-side-gems {
        position: absolute !important;
        right: -8px !important;
        bottom: -5px !important;
    }

    body.screen-game:not(.layout-editor-preview) .mobile-main-score {
        padding: 0 6px;
        min-height: 26px;
        height: 26px;
        font-size: 13px;
    }

    body.screen-game.mobile-words-open:not(.layout-editor-preview) #found-words-container {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        filter: none !important;
        background: rgba(7, 12, 25, 0.94) !important;
    }

    body.screen-game:not(.layout-editor-preview) #mobile-words-backdrop {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        filter: none !important;
        background: rgba(0, 0, 0, 0.85) !important;
    }
}

/* ===== FINAL LAYOUT + STABILITY PASS ===== */

#hint-path-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

#hint-path-svg line,
#hint-path-svg .hint-path-line {
    stroke: rgba(59, 130, 246, 0.95);
    stroke-width: 7px;
    stroke-linecap: round;
    filter: drop-shadow(0 0 6px rgba(59, 130, 246, 0.55));
    animation: hintLineTravel 1.4s ease-in-out infinite;
    animation-delay: var(--hint-delay, 0ms);
}

.grid-tile {
    position: relative;
}

.grid-tile.hint-target {
    border-color: rgba(96, 165, 250, 0.95) !important;
    box-shadow:
        0 0 0 2px rgba(96, 165, 250, 0.72),
        inset 0 0 14px rgba(37, 99, 235, 0.18) !important;
    animation: hintTileRipple 1.4s ease-in-out infinite;
    animation-delay: var(--hint-delay, 0ms);
}

.indicator {
    top: 2px;
    right: 2px;
    min-width: 0;
    width: auto;
    padding: 0 3px;
    font-size: 0.34em;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.indicator-shift-bottom-right {
    top: auto;
    bottom: 2px;
    right: 2px;
}

.tile-score {
    bottom: 4px;
    left: 2px;
    font-size: 0.42em;
    z-index: 3;
}

.gem {
    top: -4px;
    left: -4px;
    font-size: 0.48em;
    z-index: 3;
    opacity: 1;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    will-change: transform, filter;
    isolation: isolate;
}

@keyframes hintTileRipple {
    0%, 100% {
        box-shadow:
            0 0 0 2px rgba(96, 165, 250, 0.42),
            inset 0 0 10px rgba(37, 99, 235, 0.12);
    }
    35% {
        box-shadow:
            0 0 0 3px rgba(147, 197, 253, 0.88),
            0 0 18px rgba(59, 130, 246, 0.42),
            inset 0 0 18px rgba(59, 130, 246, 0.22);
    }
}

@keyframes hintLineTravel {
    0%, 100% {
        stroke: rgba(59, 130, 246, 0.72);
        stroke-width: 6px;
    }
    40% {
        stroke: rgba(147, 197, 253, 1);
        stroke-width: 9px;
    }
}

.selection-word {
    color: #f8fafc;
}

.selection-score {
    color: #86efac;
    text-shadow: 0 0 8px rgba(134, 239, 172, 0.6);
}

body.dragging-word .grid-tile,
body.dragging-word .grid-tile:hover,
body.dragging-word .grid-tile.selected {
    transition: none !important;
}

body.dragging-word .grid-tile.selected,
body.dragging-word .opponent-selected {
    box-shadow: none !important;
}

body.dragging-word #path-svg line {
    filter: none !important;
    animation: none !important;
}

body.desktop-pointer-layout #timer-text {
    font-size: 1.4rem;
    font-weight: 900;
    line-height: 1;
}

body.desktop-pointer-layout #vote-info,
body.desktop-pointer-layout #vote-timer-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 100%;
    font-size: 1.4rem;
    font-weight: 900;
    line-height: 1;
}

body.desktop-pointer-layout #timer-action-slot {
    align-items: stretch;
}

body.desktop-pointer-layout #vote-info {
    padding: 0 14px;
}

body.desktop-pointer-layout #vote-info-label,
body.desktop-pointer-layout #vote-info-count {
    display: inline-flex;
    align-items: center;
    align-self: stretch;
    height: 100%;
}

body.pseudo-fullscreen-active #settings-modal,
body.pseudo-fullscreen-active #letter-picker-overlay,
body.pseudo-fullscreen-active #hint-loader-overlay,
body.pseudo-fullscreen-active #word-spotlight,
body.pseudo-fullscreen-active .round-transition,
body.pseudo-fullscreen-active .results-overlay,
body.pseudo-fullscreen-active .played-word-center-overlay,
body.pseudo-fullscreen-active .word-animation-overlay,
body.pseudo-fullscreen-active .word-definition-panel,
body.pseudo-fullscreen-active #word-details-popup,
body.pseudo-fullscreen-active .word-details-popup {
    z-index: 100200 !important;
}

#game-container.pseudo-fullscreen-active {
    isolation: isolate;
}

.player-invalid-flash {
    animation: playerInvalidFlash 0.82s ease;
}

@keyframes playerInvalidFlash {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
    40% {
        box-shadow:
            0 0 0 2px rgba(248, 113, 113, 0.68),
            0 0 24px rgba(239, 68, 68, 0.42);
    }
}

.room-code-input-wrap {
    display: flex;
    align-items: center;
    gap: 0;
    flex: 0 0 168px;
    width: 168px;
    min-height: 61px;
    height: 61px;
    box-sizing: border-box;
    border: 2px solid #4b5563;
    border-right: none;
    border-radius: 10px 0 0 10px;
    background: rgba(55, 65, 81, 0.8);
    overflow: hidden;
}

.room-code-input-wrap #room-code-input {
    flex: 1 1 auto;
    width: 100%;
    height: 100%;
    min-height: 61px;
    min-width: 0;
    border: none;
    border-radius: 0;
    background: transparent;
    padding-top: 0;
    padding-bottom: 0;
    text-align: center;
    letter-spacing: 0.2em;
    font-weight: 800;
}

.room-code-input-wrap .copy-room-button {
    width: 42px;
    min-width: 42px;
    height: 100%;
    border: none;
    border-left: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 0;
    background: rgba(15, 23, 42, 0.55);
    box-shadow: none;
}

.room-code-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.room-visibility-button {
    margin-left: auto;
    padding: 6px 10px 6px 12px;
    min-height: 40px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.28);
    background: rgba(30, 41, 59, 0.9);
    color: #f8fafc;
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.room-visibility-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.28);
}

.room-visibility-button__label {
    white-space: nowrap;
}

.room-visibility-button__track {
    position: relative;
    width: 44px;
    height: 24px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.58);
    border: 1px solid rgba(148, 163, 184, 0.28);
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.18);
    flex: 0 0 auto;
}

.room-visibility-button__thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    background: #f8fafc;
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.22);
    transition: transform 0.18s ease;
}

.room-visibility-button[data-room-visibility="public"] {
    border-color: rgba(34, 197, 94, 0.5);
    background: linear-gradient(145deg, rgba(21, 128, 61, 0.96), rgba(15, 118, 110, 0.96));
}

.room-visibility-button[data-room-visibility="private"] {
    border-color: rgba(168, 85, 247, 0.42);
    background: linear-gradient(145deg, rgba(88, 28, 135, 0.96), rgba(49, 46, 129, 0.96));
}

.room-visibility-button[data-room-visibility="public"] .room-visibility-button__thumb {
    transform: translateX(20px);
}

.lobby-player-bell-button {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    border: 1px solid rgba(250, 204, 21, 0.28);
    background: linear-gradient(145deg, rgba(56, 189, 248, 0.88), rgba(37, 99, 235, 0.92));
    color: #f8fafc;
    font-size: 1rem;
    font-weight: 800;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.lobby-player-bell-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 18px rgba(37, 99, 235, 0.28);
}

.summary-panel {
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
    overflow-x: hidden;
    border-color: rgba(34, 211, 238, 0.5);
}

.match-summary-banner {
    background: linear-gradient(145deg, #1f2937, #111827);
}

.summary-layout-shell {
    position: relative;
    width: fit-content;
    margin: 0 auto;
}

.summary-layout-lines {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

.summary-layout-lines line {
    stroke: rgba(34, 211, 238, 0.78);
    stroke-width: 7px;
    stroke-linecap: round;
    filter: drop-shadow(0 0 6px rgba(34, 211, 238, 0.35));
}

.summary-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.summary-metrics--stacked {
    grid-template-columns: 1fr;
    justify-items: center;
}

.summary-metrics--stacked .summary-metric {
    width: min(100%, 420px);
}

.summary-metric {
    padding: 14px 12px;
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.58);
    border: 1px solid rgba(125, 211, 252, 0.18);
}

.summary-metric--score,
.summary-metric--longest,
.summary-metric--best {
    width: 100%;
    text-align: center;
}

.summary-metric--score .summary-metric__value {
    font-size: 1.45rem;
}

.summary-metric__label {
    display: block;
    color: #cbd5e1;
    font-size: 0.8rem;
    margin-bottom: 6px;
}

.summary-metric__value {
    color: #f8fafc;
    font-size: 1.05rem;
    overflow-wrap: break-word;
    word-break: break-word;
}

.summary-layout-section,
.summary-words-section {
    margin-top: 18px;
}

.summary-layout-section h3,
.summary-words-section h3 {
    margin: 0 0 10px;
    color: #e0f2fe;
    font-size: 1rem;
}

.summary-layout-grid {
    display: grid;
    grid-template-columns: repeat(5, 44px);
    gap: 8px;
    justify-content: center;
    position: relative;
    z-index: 1;
}

.summary-layout-cell {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, rgba(229, 231, 235, 0.96), rgba(203, 213, 225, 0.96));
    color: #0f172a;
    font-weight: 900;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
    position: relative;
    z-index: 1;
}

.summary-layout-cell__letter {
    position: relative;
    z-index: 2;
}

.summary-layout-cell--active {
    background: linear-gradient(145deg, rgba(34, 211, 238, 0.95), rgba(37, 99, 235, 0.95));
    color: #eff6ff;
}

.summary-empty,
.summary-words-empty {
    color: #cbd5e1;
    text-align: center;
}

.summary-words-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.summary-words-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(30, 41, 59, 0.6);
}

.summary-new-game {
    width: 100%;
    margin-top: 18px;
}

.settings-dev-section {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid rgba(148, 163, 184, 0.24);
}

#developer-tools-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

body.mirrored-invalid-flash-active .is-mirrored-active,
body.mirrored-invalid-flash-active .opponent-selected {
    background: linear-gradient(145deg, #f87171, #ef4444) !important;
    border-color: #fecaca !important;
    color: #fff7f7 !important;
    filter: none !important;
    opacity: 1 !important;
    box-shadow: 0 0 18px rgba(239, 68, 68, 0.8),
                inset 0 0 12px rgba(127, 29, 29, 0.45) !important;
    animation: invalidFlash 0.26s ease-in-out 1;
}

@keyframes opponentInvalidPulse {
    0%, 100% {
        box-shadow:
            0 0 18px rgba(239, 68, 68, 0.28),
            inset 0 0 8px rgba(127, 29, 29, 0.18);
    }
    50% {
        box-shadow:
            0 0 20px rgba(239, 68, 68, 0.88),
            inset 0 0 14px rgba(127, 29, 29, 0.5);
    }
}

.summary-fireworks {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.summary-fireworks span {
    position: absolute;
    top: -8%;
    left: var(--firework-x, 50%);
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: hsl(var(--firework-hue, 190), 95%, 68%);
    box-shadow:
        0 0 18px hsl(var(--firework-hue, 190), 95%, 68%),
        0 0 30px hsla(var(--firework-hue, 190), 95%, 68%, 0.45);
    opacity: 0;
    animation: summaryFirework 2.3s ease-out infinite;
    animation-delay: var(--firework-delay, 0s);
}

@keyframes summaryFirework {
    0% {
        transform: translate3d(0, 0, 0) scale(0.2);
        opacity: 0;
    }
    18% {
        opacity: 0.85;
    }
    55% {
        transform: translate3d(-8px, 180px, 0) scale(1.2);
        opacity: 0.95;
    }
    100% {
        transform: translate3d(14px, 320px, 0) scale(0.2);
        opacity: 0;
    }
}

@media (max-width: 768px) {
    body:not(.desktop-pointer-layout) .singleplayer-summary-overlay .summary-metrics {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    body:not(.desktop-pointer-layout) .singleplayer-summary-overlay .summary-metric {
        width: 100%;
        text-align: left !important;
    }

    body:not(.desktop-pointer-layout).screen-game:not(.layout-editor-preview) #selection-area {
        flex-direction: row !important;
        align-items: center !important;
        gap: 6px !important;
        margin: 0 !important;
    }

    body:not(.desktop-pointer-layout).screen-game:not(.layout-editor-preview) #current-word-display {
        gap: 6px;
    }

    body:not(.desktop-pointer-layout).screen-game:not(.layout-editor-preview) #game-board-area {
        margin: 0 0 5px !important;
        padding: 0 !important;
    }

    body:not(.desktop-pointer-layout).screen-game:not(.layout-editor-preview) #mobile-ability-row {
        width: min(calc(100vw - 32px), 390px) !important;
        max-width: calc(100vw - 32px) !important;
        min-height: 43px;
        height: 43px;
        gap: 4px;
        align-self: center !important;
        margin-inline: auto !important;
    }

    body:not(.desktop-pointer-layout).screen-game:not(.layout-editor-preview) #mobile-gem-tracker,
    body:not(.desktop-pointer-layout).screen-game:not(.layout-editor-preview) .ability-button {
        min-height: 43px;
        height: 43px;
        max-height: 43px;
    }

    body:not(.desktop-pointer-layout).screen-game:not(.layout-editor-preview) #mobile-gem-tracker {
        flex: 0 0 24%;
        font-size: 0.82rem;
    }

    body:not(.desktop-pointer-layout).screen-game:not(.layout-editor-preview) #abilities-area {
        flex: 1 1 auto;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        width: auto;
        gap: 4px;
    }

    body:not(.desktop-pointer-layout).screen-game:not(.layout-editor-preview) .ability-button {
        padding: 2px 3px;
        gap: 1px;
    }

    body:not(.desktop-pointer-layout).screen-game:not(.layout-editor-preview) .ability-button__label,
    body:not(.desktop-pointer-layout).screen-game:not(.layout-editor-preview) .ability-button__cost {
        white-space: normal;
        text-align: center;
        line-height: 1.02;
        font-size: 0.52rem;
    }

    body:not(.desktop-pointer-layout).screen-game:not(.layout-editor-preview) .mobile-carousel-preview--main {
        background: transparent !important;
        padding: 0 !important;
        box-shadow: none !important;
    }

    body:not(.desktop-pointer-layout).screen-game:not(.layout-editor-preview) .mobile-main-score {
        padding: 0 5px !important;
        min-height: 24px;
        height: 24px;
    }

    body:not(.desktop-pointer-layout).screen-game:not(.layout-editor-preview) .mobile-side-avatar-wrap {
        gap: 2px !important;
    }

    body:not(.desktop-pointer-layout).screen-game:not(.layout-editor-preview) .mobile-side-avatar-badge-wrap {
        position: relative !important;
        display: inline-flex !important;
        width: fit-content;
    }

    body:not(.desktop-pointer-layout).screen-game:not(.layout-editor-preview) .mobile-side-gems {
        position: absolute !important;
        right: -8px !important;
        bottom: -4px !important;
        min-width: 0;
        height: 18px;
        padding: 0 5px;
        white-space: nowrap;
    }

    body:not(.desktop-pointer-layout).screen-game:not(.layout-editor-preview) #mobile-words-backdrop {
        display: none !important;
        background: transparent !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }

    body:not(.desktop-pointer-layout).screen-game.mobile-words-open:not(.layout-editor-preview) #found-words-container {
        background: rgba(7, 12, 25, 0.96) !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        filter: none !important;
    }

    body:not(.desktop-pointer-layout).screen-game:not(.layout-editor-preview) #mobile-words-close {
        position: absolute !important;
        top: 10px;
        right: 10px;
        margin: 0 !important;
        float: none !important;
    }

    body:not(.desktop-pointer-layout) .singleplayer-summary-overlay .summary-panel {
        max-height: calc(100dvh - 32px);
        overflow-y: auto;
        width: min(92vw, 540px);
    }

    body:not(.desktop-pointer-layout).screen-game:not(.layout-editor-preview) #mobile-ability-row {
        width: min(calc(100vw - 32px), 390px) !important;
        max-width: calc(100vw - 32px) !important;
        margin-inline: auto !important;
        padding-inline: 8px;
    }
}

@keyframes matrixRain {
    0% {
        transform: translate3d(0, -18vh, 0);
        opacity: 0;
    }
    12% {
        opacity: 0.9;
    }
    100% {
        transform: translate3d(0, 136vh, 0);
        opacity: 0;
    }
}

@keyframes matrixChromaticPulse {
    0%,
    100% {
        transform: translate3d(0, 0, 0);
        text-shadow:
            4px 0 0 rgba(239, 68, 68, 0.92),
            -4px 0 0 rgba(34, 211, 238, 0.92),
            0 0 36px rgba(255, 215, 0, 0.76);
        filter: saturate(1.1) contrast(1.05);
    }
    50% {
        transform: translate3d(2px, -1px, 0);
        text-shadow:
            7px 0 0 rgba(239, 68, 68, 0.98),
            -7px 0 0 rgba(34, 211, 238, 0.98),
            0 0 44px rgba(255, 215, 0, 0.86);
        filter: saturate(1.32) contrast(1.18);
    }
}

@keyframes matrixScreenShake {
    0% { transform: translate3d(0, 0, 0); }
    20% { transform: translate3d(-3px, 1px, 0); }
    40% { transform: translate3d(3px, -2px, 0); }
    60% { transform: translate3d(-2px, 3px, 0); }
    80% { transform: translate3d(2px, 1px, 0); }
    100% { transform: translate3d(0, 0, 0); }
}

@keyframes rainbowMirrorScroll {
    0% {
        transform: translateX(calc(-100% - 10vw));
    }
    100% {
        transform: translateX(calc(100vw + 10vw));
    }
}

@keyframes rainbowMirrorScrollReverse {
    0% {
        transform: translateX(calc(100vw + 10vw));
    }
    100% {
        transform: translateX(calc(-100% - 10vw));
    }
}

@keyframes goldShockwave {
    0% {
        transform: translate(-50%, -50%) scale(0.2);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(26);
        opacity: 0;
    }
}

@keyframes goldShimmerSweep {
    0% {
        transform: translateX(-130%);
    }
    100% {
        transform: translateX(130%);
    }
}

#selection-area.spectating-preview {
    justify-content: center;
}

#selection-area.spectating-preview #current-word-display {
    width: 100%;
    justify-content: center;
}

#selection-area.spectating-preview #score-preview-display {
    display: none;
}

.summary-panel,
.summary-metrics,
.summary-metric {
    box-sizing: border-box;
    min-width: 0;
}

body.desktop-pointer-layout #timer-action-slot {
    align-items: stretch;
}

body.desktop-pointer-layout #vote-timer-btn,
body.desktop-pointer-layout #vote-info {
    flex: 1 1 auto;
    align-self: stretch;
    height: 100%;
}

body.desktop-pointer-layout #vote-info {
    justify-content: space-between;
}

body.desktop-pointer-layout #vote-info-label,
body.desktop-pointer-layout #vote-info-count,
body.desktop-pointer-layout #vote-timer-btn {
    min-height: 100%;
}

.score-item--spectatable,
.score-item--spectating-target {
    position: relative;
    overflow: hidden;
}

.score-item--spectatable {
    cursor: pointer;
}

.score-item--spectatable::after,
.score-item--spectating-target::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(56, 189, 248, 0.12);
    opacity: 0;
    transition: opacity 0.18s ease;
    pointer-events: none;
}

.score-item--spectatable:hover::after {
    opacity: 1;
}

.score-item__spectator-eye {
    position: absolute;
    inset: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.88);
    font-size: 1.25rem;
    text-shadow: 0 0 14px rgba(15, 23, 42, 0.82);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, color 0.18s ease, transform 0.18s ease;
    z-index: 2;
}

.score-item--spectatable:hover .score-item__spectator-eye,
.score-item--spectating-target .score-item__spectator-eye {
    opacity: 1;
    transform: scale(1.03);
}

.score-item--spectating-target {
    border-color: rgba(34, 197, 94, 0.76);
    box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.52), 0 0 18px rgba(34, 197, 94, 0.24);
}

.score-item--spectating-target::after {
    opacity: 0;
}

.score-item--spectating-target .score-item__spectator-eye {
    color: #22c55e;
}

.mobile-carousel-preview.spectator-target {
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.7), 0 0 18px rgba(34, 197, 94, 0.2);
}

/* ========================================= */
/* BUG FIX: MULTIPLAYER GRID PHANTOM TILE SHIELD */
/* ========================================= */
#game-board > svg,
#game-board > .mirrored-cursor-container {
    position: absolute !important;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

#game-board > #board-inactive-overlay {
    display: none !important;
}

/* ===== CHAT + CURSOR OVERRIDES ===== */

body {
    --spotlight-size: 280px;
    --spotlight-core-color: rgba(146, 214, 255, 0.42);
    --spotlight-mid-color: rgba(92, 103, 163, 0.26);
    --cursor-opacity: 0.6;
    --cursor-size: 280px;
    --cursor-core-color: rgba(146, 214, 255, 0.42);
    --cursor-mid-color: rgba(92, 103, 163, 0.26);
}

body::after {
    background:
        radial-gradient(circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
            var(--cursor-core-color, var(--spotlight-core-color)) 0,
            var(--cursor-mid-color, var(--spotlight-mid-color)) calc(var(--cursor-size, var(--spotlight-size, 280px)) * 0.48),
            rgba(31, 41, 55, 0) var(--cursor-size, var(--spotlight-size, 280px)));
}

#spotlight-color-picker {
    width: 52px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 10px;
    background: transparent;
    cursor: pointer;
}

#spotlight-color-picker::-webkit-color-swatch-wrapper {
    padding: 0;
}

#spotlight-color-picker::-webkit-color-swatch,
#spotlight-color-picker::-moz-color-swatch {
    border: 1px solid rgba(148, 163, 184, 0.24);
    border-radius: 10px;
}

#chat-panel {
    position: fixed;
    right: 22px;
    bottom: 92px;
    width: min(360px, calc(100vw - 36px));
    z-index: 12020;
}

#chat-panel-shell {
    display: flex;
    flex-direction: column;
    min-height: 360px;
    max-height: min(58vh, 520px);
    border-radius: 22px;
    border: 1px solid rgba(125, 211, 252, 0.24);
    background:
        linear-gradient(160deg, rgba(10, 20, 45, 0.97), rgba(17, 24, 39, 0.96)),
        rgba(15, 23, 42, 0.96);
    box-shadow: 0 24px 60px rgba(2, 8, 23, 0.55);
    overflow: hidden;
}

.chat-panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px 12px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.14);
}

#chat-panel-title {
    margin: 0;
    color: #f8fafc;
    font-size: 1rem;
}

#chat-panel-subtitle {
    display: none;
}

#chat-close-button {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    background: rgba(15, 23, 42, 0.8);
    color: #f8fafc;
    cursor: pointer;
}

#chat-message-list {
    flex: 1 1 auto;
    min-height: 140px;
    overflow-y: auto;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-message {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(30, 41, 59, 0.72);
    border: 1px solid rgba(148, 163, 184, 0.12);
}

.chat-message.chat-message--self {
    background: rgba(12, 74, 110, 0.8);
    border-color: rgba(56, 189, 248, 0.26);
}

.chat-message.chat-message--system {
    background: rgba(76, 29, 149, 0.36);
    border-color: rgba(216, 180, 254, 0.26);
}

.chat-message__meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 0.72rem;
    color: #93c5fd;
}

.chat-message__name {
    font-weight: 800;
    color: #e0f2fe;
}

.chat-message__text {
    color: #f8fafc;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}

.chat-message--system .chat-message__meta {
    color: #e9d5ff;
}

.chat-message--system .chat-message__name {
    color: #f5d0fe;
}

.chat-message--system .chat-message__text {
    color: #fae8ff;
    font-style: italic;
}

.chat-empty-state {
    margin: auto;
    text-align: center;
    color: #94a3b8;
    font-size: 0.92rem;
}

#chat-input-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    padding: 12px 16px 16px;
    border-top: 1px solid rgba(148, 163, 184, 0.12);
    background: rgba(2, 6, 23, 0.18);
}

#chat-input {
    min-width: 0;
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    background: rgba(15, 23, 42, 0.9);
    color: #f8fafc;
    padding: 12px 14px;
    font-size: 0.95rem;
}

#chat-send-button {
    border: none;
    border-radius: 14px;
    padding: 0 18px;
    background: linear-gradient(145deg, #22c55e, #0f766e);
    color: #f8fafc;
    font-weight: 800;
    cursor: pointer;
}

#chat-toast-container {
    position: fixed;
    right: 22px;
    bottom: 22px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    z-index: 12030;
    pointer-events: none;
}

.chat-toast {
    min-width: min(320px, calc(100vw - 44px));
    max-width: min(360px, calc(100vw - 44px));
    padding: 12px 14px;
    border-radius: 16px;
    background: rgba(15, 23, 42, 0.94);
    border: 1px solid rgba(56, 189, 248, 0.24);
    box-shadow: 0 18px 32px rgba(2, 8, 23, 0.36);
    color: #f8fafc;
    transform: translateY(12px);
    opacity: 0;
    animation: chatToastIn 260ms ease forwards;
}

.chat-toast__name {
    display: block;
    margin-bottom: 4px;
    color: #93c5fd;
    font-size: 0.78rem;
    font-weight: 800;
}

.chat-toast__text {
    display: block;
    color: #f8fafc;
    line-height: 1.35;
    white-space: pre-wrap;
    word-break: break-word;
}

@keyframes chatToastIn {
    from {
        transform: translateY(12px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

body.screen-lobby #chat-fab,
body.screen-game.multiplayer-active #chat-fab {
    display: inline-flex;
}

body.screen-mode #chat-fab,
body.screen-menu #chat-fab {
    display: none !important;
}

body:not(.multiplayer-active) #mobile-chat-button {
    display: none !important;
}

body.pseudo-fullscreen-active .played-word-center-overlay,
body.pseudo-fullscreen-active .glass-shatter-container,
body.pseudo-fullscreen-active .lightning-storm-overlay,
body.pseudo-fullscreen-active .simulation-glitch-terminal-stage {
    z-index: 100320 !important;
}

body.pseudo-fullscreen-active #chat-panel,
body.pseudo-fullscreen-active #chat-fab,
body.pseudo-fullscreen-active #chat-toast-container {
    z-index: 100250 !important;
}

.lobby-player-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    position: relative;
}

.lobby-player-main,
.lobby-player-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.lobby-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    box-shadow: 0 0 10px currentColor;
}

.lobby-status-dot.is-connected {
    color: #22c55e;
    background: #22c55e;
}

.lobby-status-dot.is-ready {
    color: #22c55e;
    background: #22c55e;
}

.lobby-status-dot.is-pending {
    color: #ef4444;
    background: #ef4444;
}

.lobby-status-dot.is-disconnected {
    color: #ef4444;
    background: #ef4444;
}

.lobby-kick-button {
    border: 1px solid rgba(248, 113, 113, 0.3);
    border-radius: 999px;
    background: rgba(127, 29, 29, 0.72);
    color: #fee2e2;
    padding: 6px 12px;
    font-weight: 700;
    cursor: pointer;
}

.lobby-player-actions {
    margin-left: auto;
    position: relative;
}

.lobby-player-menu-button {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    background: rgba(30, 41, 59, 0.86);
    color: #f8fafc;
    font-size: 1.1rem;
    font-weight: 800;
    cursor: pointer;
}

.lobby-player-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 170px;
    padding: 8px;
    border-radius: 16px;
    border: 1px solid rgba(125, 211, 252, 0.22);
    background: linear-gradient(145deg, rgba(15, 23, 42, 0.98), rgba(30, 41, 59, 0.98));
    box-shadow: 0 18px 36px rgba(2, 8, 23, 0.48);
    z-index: 25;
}

.lobby-player-menu__item {
    width: 100%;
    border: none;
    background: rgba(51, 65, 85, 0.34);
    color: #f8fafc;
    border-radius: 12px;
    padding: 10px 12px;
    text-align: left;
    font-weight: 700;
    cursor: pointer;
}

.lobby-player-menu__item + .lobby-player-menu__item {
    margin-top: 6px;
}

.lobby-player-menu__item[data-kick-player-id] {
    color: #fecaca;
    background: rgba(127, 29, 29, 0.7);
}

@media (max-width: 768px) and (hover: none), (max-width: 768px) and (pointer: coarse) {
    #chat-panel {
        left: 12px;
        right: 12px;
        bottom: 78px;
        width: auto;
    }

    #chat-panel-shell {
        min-height: 280px;
        max-height: min(52dvh, 420px);
        border-radius: 18px;
    }

    body.screen-lobby #chat-fab {
        display: inline-flex !important;
    }

    #chat-toast-container {
        top: max(16px, env(safe-area-inset-top, 0px) + 8px);
        left: 50%;
        right: auto;
        bottom: auto;
        transform: translateX(-50%);
        align-items: center;
    }

    .chat-toast {
        min-width: min(320px, calc(100vw - 24px));
        max-width: min(360px, calc(100vw - 24px));
    }
}

#menu-tab-bar {
    grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
}

.multiplayer-menu-content.hallway-shell > h2:first-of-type {
    display: none;
}

.multiplayer-menu-content.hallway-shell {
    width: min(920px, calc(100vw - 32px));
    max-height: min(760px, calc(100dvh - 32px));
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow-y: auto;
}

.hallway-shell > .hallway-header { order: 0; }
.hallway-shell > #connection-status { order: 1; }
.hallway-shell > .menu-input-group { order: 2; }
.hallway-shell > .menu-buttons { order: 3; }
.hallway-shell > #hallway-create-room-panel { order: 4; }
.hallway-shell > .hallway-grid { order: 5; }
.hallway-shell > .back-button { order: 6; }
.hallway-shell > #multiplayer-menu-message-area { order: 7; }

.hallway-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.hallway-header h2 {
    margin: 0;
    color: #ffd700;
    font-size: 1.85rem;
}

.hallway-subtitle {
    margin: 6px 0 0;
    color: #cbd5e1;
    line-height: 1.45;
}

.hallway-online-badge {
    flex: 0 0 auto;
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(15, 118, 110, 0.26);
    border: 1px solid rgba(45, 212, 191, 0.34);
    color: #ecfeff;
    font-weight: 800;
    white-space: nowrap;
}

.hallway-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
}

.hallway-panel {
    padding: 16px;
    border-radius: 18px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    background: rgba(15, 23, 42, 0.72);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.hallway-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.hallway-panel-header h3 {
    margin: 0;
    color: #f8fafc;
    font-size: 1rem;
}

.hallway-panel-meta {
    color: #94a3b8;
    font-size: 0.82rem;
}

.menu-buttons.hallway-action-bar {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 12px;
    flex-wrap: nowrap;
}

.hallway-name-cluster,
.hallway-room-code-cluster {
    display: flex;
    min-width: 0;
}

.hallway-name-cluster {
    flex: 0 1 auto;
    gap: 12px;
    align-items: stretch;
}

.hallway-name-cluster #player-name-input {
    flex: 0 1 clamp(180px, 20vw, 240px);
    min-width: 0;
    max-width: clamp(180px, 20vw, 240px);
    min-height: 61px;
    height: 61px;
    border-radius: 10px;
    box-sizing: border-box;
}

.hallway-action-bar__spacer {
    display: none;
}

.hallway-room-code-cluster {
    flex: 0 0 auto;
    justify-content: flex-start;
}

.room-code-entry {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

.join-room-section.room-join-inline {
    display: flex;
    align-items: stretch;
    gap: 0;
    justify-content: flex-end;
}

.join-room-section.room-join-inline #join-room-btn {
    border-radius: 0 10px 10px 0;
    min-width: 148px;
    min-height: 61px;
    height: 61px;
    white-space: nowrap;
}

.hallway-action-bar #create-room-btn,
.hallway-create-bar #room-name-input {
    min-height: 61px;
    height: 61px;
    box-sizing: border-box;
}

#hallway-create-room-panel {
    padding: 16px;
    border-radius: 18px;
    border: 1px solid rgba(125, 211, 252, 0.24);
    background: rgba(8, 47, 73, 0.42);
}

.hallway-create-bar {
    display: flex;
    align-items: stretch;
    gap: 12px;
}

.hallway-create-bar #room-name-input {
    flex: 1 1 auto;
    min-width: 0;
    border-radius: 10px;
}

.hallway-visibility-toggle {
    margin: 0;
    padding: 0;
    border: none;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.hallway-visibility-option {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(30, 41, 59, 0.78);
    border: 1px solid rgba(148, 163, 184, 0.18);
    color: #f8fafc;
}

.hallway-room-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    max-height: 420px;
    overflow-y: auto;
    align-items: stretch;
}

.hallway-empty-state {
    padding: 18px 14px;
    border-radius: 16px;
    background: rgba(30, 41, 59, 0.56);
    color: #94a3b8;
    text-align: center;
}

.hallway-room-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px 14px 12px;
    border-radius: 16px;
    background: rgba(30, 41, 59, 0.78);
    border: 1px solid rgba(148, 163, 184, 0.16);
    min-height: auto;
}

.hallway-room-card__line {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
}

.hallway-room-title {
    margin: 0;
    min-width: 0;
    color: #f8fafc;
    font-size: 1rem;
}

.hallway-room-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.hallway-room-badge--public {
    background: rgba(14, 116, 144, 0.26);
    color: #cffafe;
}

.hallway-room-badge--private {
    background: rgba(88, 28, 135, 0.28);
    color: #f5d0fe;
}

.hallway-room-detail {
    color: #e2e8f0;
    font-size: 0.84rem;
    font-weight: 700;
}

.hallway-room-detail--uptime {
    color: #cbd5e1;
}

.hallway-room-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 12px;
    padding: 10px 14px;
    background: linear-gradient(145deg, #22c55e, #0f766e);
    color: #f8fafc;
    font-weight: 800;
    cursor: pointer;
    min-width: 110px;
}

.hallway-room-action--muted {
    display: inline-flex;
    align-items: center;
    padding: 10px 0;
    background: transparent;
    color: #94a3b8;
    cursor: default;
}

.hallway-room-card__action {
    display: flex;
    justify-content: flex-end;
}

.hallway-room-card__action .hallway-room-action:not(.hallway-room-action--private) {
    width: auto;
}

.hallway-room-action--private {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    width: 100%;
    padding: 0;
    background: transparent;
}

.hallway-room-pin-input {
    width: 100%;
    min-width: 0;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    background: rgba(15, 23, 42, 0.92);
    color: #f8fafc;
    text-align: center;
    letter-spacing: 0.2em;
    font-weight: 800;
}

.hallway-room-pin-submit {
    border: none;
    border-radius: 12px;
    padding: 10px 14px;
    background: linear-gradient(145deg, #3b82f6, #1d4ed8);
    color: #f8fafc;
    font-weight: 800;
    cursor: pointer;
}

.hallway-room-host {
    color: #cbd5e1;
    font-size: 0.84rem;
    font-weight: 700;
}

.hallway-room-lock {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    font-size: 1rem;
    opacity: 0.9;
}

.dev-audio-tester__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.dev-sfx-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dev-sfx-row {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) auto;
    gap: 10px;
    padding: 12px;
    border-radius: 14px;
    background: rgba(30, 41, 59, 0.72);
    border: 1px solid rgba(148, 163, 184, 0.16);
}

.dev-sfx-row__name {
    min-width: 0;
    display: flex;
    align-items: center;
}

.dev-sfx-row__name-label {
    color: #e2e8f0;
    font-weight: 700;
}

.dev-sfx-row__name-input {
    width: 100%;
    min-width: 0;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    background: rgba(15, 23, 42, 0.94);
    color: #f8fafc;
    padding: 10px 12px;
}

.dev-sfx-row__file {
    width: 100%;
    min-width: 0;
    color: #cbd5e1;
}

.dev-sfx-row__status {
    grid-column: 1 / -1;
    margin: 0;
    color: #94a3b8;
    font-size: 0.78rem;
}

.summary-snapshot-shell {
    display: flex;
    flex-direction: column;
    gap: 0;
    align-items: center;
    justify-content: flex-start;
    position: fixed;
    inset: 0;
    overflow-y: auto;
    padding: 20px;
    box-sizing: border-box;
    background: rgba(0, 0, 0, 0.9);
}

.summary-snapshot-stage {
    width: 100%;
    min-width: 0;
    min-height: 100%;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.summary-snapshot-viewport {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    flex: 0 0 auto;
    margin: auto;
    overflow: hidden;
}

.summary-snapshot-actions {
    position: absolute;
    top: 50%;
    right: 18px;
    left: auto;
    width: 160px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 9999;
    transform: translateY(-50%);
}

.summary-panel--snapshot-capture .summary-metrics {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    justify-items: stretch !important;
    align-items: stretch !important;
    gap: 10px !important;
    width: 100% !important;
}

.summary-panel--snapshot-capture .summary-metrics.summary-metrics--stacked {
    grid-template-columns: 1fr !important;
}

.summary-panel--snapshot-capture .summary-metric {
    flex: 0 0 auto;
    min-width: 0;
    width: 100%;
}

.summary-snapshot-feedback-toast {
    position: fixed;
    top: 18px;
    left: 50%;
    transform: translate(-50%, -10px);
    padding: 12px 16px;
    border-radius: 999px;
    background: rgba(22, 163, 74, 0.96);
    color: #f0fdf4;
    font-weight: 800;
    letter-spacing: 0.04em;
    opacity: 0;
    pointer-events: none;
    z-index: 10210;
    transition: opacity 160ms ease, transform 160ms ease;
}

.summary-snapshot-feedback-toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

#chat-scope-tabs {
    display: flex;
    gap: 8px;
    padding: 0 16px 12px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.chat-scope-tab {
    flex: 1 1 0;
    min-width: 0;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 12px;
    padding: 10px 12px;
    background: rgba(15, 23, 42, 0.78);
    color: #cbd5e1;
    font-weight: 800;
    cursor: pointer;
}

.chat-scope-tab.is-active {
    background: linear-gradient(145deg, rgba(37, 99, 235, 0.88), rgba(15, 23, 42, 0.92));
    color: #f8fafc;
    border-color: rgba(125, 211, 252, 0.3);
}

.chat-scope-tab:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

body.screen-menu #chat-fab {
    display: inline-flex !important;
}

body.screen-mode #chat-fab {
    display: none !important;
}

#controls-area {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    align-items: stretch;
}

#controls-area #home-button,
#controls-area #desktop-settings-button {
    width: 100% !important;
    margin: 0 !important;
    min-width: 0;
}

#mobile-nav-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

#mobile-settings-button.mobile-nav-button,
#mobile-chat-button,
#mobile-fullscreen-button {
    width: 100%;
    min-width: 0;
}

#mobile-settings-button.mobile-nav-button {
    min-height: 40px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    background: linear-gradient(145deg, rgba(51, 65, 85, 0.96), rgba(30, 41, 59, 0.98));
    color: #f8fafc;
    font-weight: 800;
    font-size: 0.92rem;
}

#mobile-menu-return-button {
    display: none;
}

@media (max-width: 768px) {
    body.screen-game:not(.layout-editor-preview) #mobile-nav-actions {
        display: flex !important;
        width: auto;
        gap: 7px;
    }

    body.screen-game:not(.layout-editor-preview) #mobile-nav-actions > button {
        flex: 0 0 42px;
        width: 42px;
        min-width: 42px;
        height: 42px;
    }

    #mobile-menu-return-button {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        min-height: 46px;
        margin-top: 16px;
        padding: 10px 16px;
        border: 1px solid rgba(248, 113, 113, 0.42);
        border-radius: 12px;
        background: linear-gradient(145deg, rgba(127, 29, 29, 0.78), rgba(69, 10, 10, 0.9));
        color: #fee2e2;
        font: inherit;
        font-weight: 750;
        cursor: pointer;
        touch-action: manipulation;
    }
}

@media (max-width: 768px) {
    .multiplayer-menu-content.hallway-shell {
        width: min(100%, calc(100vw - 20px));
        max-height: min(100dvh - 20px, 820px);
        padding: 16px;
    }

    .hallway-header {
        display: flex;
        flex-direction: column;
        align-items: stretch;
    }

    .menu-buttons.hallway-action-bar,
    .hallway-create-bar {
        flex-direction: column;
        gap: 12px;
    }

    .hallway-name-cluster,
    .hallway-room-code-cluster,
    .join-room-section.room-join-inline {
        width: 100%;
    }

    .hallway-name-cluster,
    .join-room-section.room-join-inline {
        flex-direction: column;
    }

    .hallway-action-bar__spacer {
        display: none;
    }

    .hallway-name-cluster #player-name-input {
        width: auto;
        flex: 0 0 61px;
        max-width: none;
        min-height: 61px;
        height: 61px;
        box-sizing: border-box;
    }

    .room-code-input-wrap,
    .join-room-section.room-join-inline #join-room-btn {
        width: 100%;
        flex: 1 1 auto;
    }

    .room-code-input-wrap {
        border-right: 2px solid #4b5563;
        border-radius: 10px;
    }

    .join-room-section.room-join-inline #join-room-btn {
        border-radius: 10px;
        margin-top: 10px;
    }

    .hallway-online-badge {
        align-self: flex-start;
    }

    .hallway-room-card {
        min-height: auto;
    }

    .hallway-room-list {
        grid-template-columns: 1fr;
    }

    .summary-snapshot-shell {
        display: flex;
        flex-direction: column;
        width: 100%;
        gap: 0;
        margin: 0;
        padding-bottom: 10px;
        box-sizing: border-box;
    }

    .summary-snapshot-actions {
        top: auto;
        bottom: 15px;
        right: 8px;
        left: 8px;
        width: auto;
        display: grid;
        transform: none;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-auto-flow: unset;
        justify-items: stretch;
    }

    .summary-snapshot-actions .lobby-button {
        flex: 1 1 0;
        min-width: 0;
    }

    .summary-snapshot-actions .summary-snapshot-copy {
        display: none;
    }

    .summary-panel--snapshot-capture .summary-metrics {
        display: grid !important;
        grid-template-columns: 1fr !important;
        justify-items: center !important;
        align-items: stretch !important;
        gap: 8px !important;
    }

    .summary-panel--snapshot-capture .summary-metric {
        padding: 10px 8px;
    }

    .dev-sfx-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    #mobile-gem-tracker .mobile-gem-icon {
        width: 22px;
        height: 22px;
        flex: 0 0 22px;
        overflow: hidden;
    }

    #mobile-gem-tracker .mobile-gem-icon > .kunzite-gem-svg {
        width: 100%;
        height: 100%;
        max-width: 22px;
        max-height: 22px;
    }

    body.screen-game:not(.layout-editor-preview) #mobile-game-header {
        flex-direction: row !important;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
    }

    body.screen-game:not(.layout-editor-preview) #mobile-round-pill {
        align-self: auto;
        flex: 0 0 auto;
    }

    body.screen-game:not(.layout-editor-preview) #mobile-nav-actions {
        display: flex !important;
        width: auto !important;
        margin-left: auto;
        flex-wrap: nowrap;
    }

    body.screen-game:not(.layout-editor-preview) #mobile-chat-button {
        display: inline-flex !important;
    }
}

body.screen-game:not(.multiplayer-active) #chat-fab {
    display: inline-flex;
}

#timer-purchase-button {
    position: relative;
    inset: auto;
    z-index: 4;
    display: flex;
    align-items: center;
    justify-content: center;
    justify-self: center;
    width: auto;
    min-height: 0;
    padding: 2px 8px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #fff;
    font-family: inherit;
    font-size: 1.2em;
    font-weight: 800;
    line-height: 1;
    text-shadow: 0 1px 3px rgba(15, 23, 42, 0.9);
    cursor: pointer;
    touch-action: manipulation;
}

#timer-purchase-button:hover:not(:disabled) {
    background: rgba(15, 23, 42, 0.38);
}

#timer-purchase-button .timer-purchase-gem {
    display: inline-block;
    width: 0.95em;
    height: 0.95em;
    margin-left: 0.08em;
    vertical-align: -0.12em;
    filter: none;
}

#timer-purchase-button:disabled {
    cursor: wait;
}

@media (max-width: 768px) {
    body.screen-game:not(.layout-editor-preview) #timer-header-row {
        display: flex !important;
        justify-content: center !important;
    }

    body.screen-game:not(.layout-editor-preview) #timer-purchase-button {
        position: absolute;
        right: 8px;
        left: auto;
        justify-self: auto;
        padding: 2px 0;
        font-size: 0.65rem;
        white-space: nowrap;
        text-align: right;
        pointer-events: auto;
    }
}
