/* Play Page CSS */

.play-header {
    background: var(--bg-panel);
    padding: 12px 20px;
    border-radius: 12px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    min-height: 48px;
    flex-shrink: 0;
    width: 100%;
    box-sizing: border-box;
    z-index: 10;
    color: var(--text-primary);
    position: relative;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.play-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 800;
}

.game-params {
    font-size: 1rem;
    opacity: 0.9;
    font-weight: 500;
    flex: 1;
    text-align: center;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.2s ease, text-shadow 0.2s ease;
    user-select: none;
}

.game-params:hover {
    opacity: 1;
    text-shadow: 0 0 8px rgba(var(--text-primary-rgb), 0.15);
    transform: scale(1.015);
}

.game-params:active {
    transform: scale(0.98);
}

#param-bonus {
    color: #32cd32 !important; /* Lime green */
    font-weight: 700;
}

#param-diff {
    font-weight: 700;
    transition: color 0.3s ease;
}

.game-params.reveal-new {
    animation: fadeGoldToNormal 4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}


@keyframes fadeGoldToNormal {
    0% {
        color: #ffd700; /* Instant snap to gold */
        text-shadow: 0 0 15px rgba(255, 215, 0, 0.7);
        transform: scale(1.02); /* Slight pop when turning gold */
    }
    15% {
        color: #ffd700; /* Hold gold briefly */
        transform: scale(1);
    }
    100% {
        color: var(--text-primary); /* Fade back to normal readable color faster as requested */
        text-shadow: none;
    }
}





.return-btn {
    padding: 6px 12px;
    background: rgba(var(--text-primary-rgb), 0.2);
    border: 2px solid rgba(var(--text-primary-rgb), 0.3);
    border-radius: 8px;
    color: var(--text-primary);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.return-btn:hover {
    background: rgba(var(--text-primary-rgb), 0.3);
    transform: translateY(-2px);
}

#page-play {
    display: none;
}

#page-play.active {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    /* Better mobile support */
    padding: 10px; /* Reduced from 20px to use more screen width */
    box-sizing: border-box;
    overflow: hidden;
}

.play-grid {
    display: grid;
    /* User Request: Make side panels larger horizontally while preserving board space */
    grid-template-columns: var(--left-panel-w, 400px) 1fr var(--right-panel-w, 450px);
    gap: 12px; /* Slightly tighter gap to gain a few pixels */
    flex: 1;
    min-height: 0;
    /* Important for scrolling children */
}

/* Prevent grid items from expanding the grid row height */
.play-grid > div {
    min-height: 0;
}






.words-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-height: 0;
    height: 100%;
    box-sizing: border-box;
    min-width: 0; /* Allow the grid item to shrink below min-content width */
    container-type: inline-size;
    container-name: wordspanel;
}

.words-table-box {
    background: var(--bg-panel);
    border-radius: 12px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow-y: auto; /* Allow scrolling inside the box */
}


.words-header-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    /* Tighter spacing for header */
}

#submitted-words-list {
    flex: 1;
    overflow-y: auto;
}

/* Players Panel and Definitions Container */
.left-panel-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    height: 100%;
    min-width: 0; /* Allow the grid item to shrink below min-content width */
    container-type: inline-size;
    container-name: leftpanel;
}

.players-panel {
    display: flex;
    flex-direction: column;
    background: var(--bg-panel);
    border-radius: 12px;
    padding: 15px;
    overflow: hidden;
    flex: 1;
    /* Restore to take up remaining vertical space */
    min-height: 0;
    min-width: 0;
}

.chat-panel {
    background: var(--bg-panel);
    border-radius: 12px;
    padding: 10px;
    height: 200px; /* Force height to 200px as requested */
    flex-shrink: 0;
    overflow: hidden; /* Prevent content from overflowing or stretching the box */


    /* Protect chat */
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#chat-history {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 5px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
}

.chat-message {
    font-size: var(--chat-font-size);
    line-height: 1.2;
    word-break: break-word;
}

.chat-user {
    font-weight: 700;
    margin-right: 5px;
    /* User contrast outline: replaces blur with sharp definition */
    -webkit-text-stroke: 0.5px rgba(0,0,0,0.4);
    text-shadow: 0.5px 0.5px 0 rgba(0,0,0,0.1); 
}

.chat-text {
    color: var(--text-primary);
    text-shadow: 0 0 1px rgba(0,0,0,0.1);
}

.chat-sys {
    font-style: italic;
    opacity: 1;
    font-size: var(--chat-font-size);
    padding: 3px 0;
}

/* Premium Gold Styling for Winner Announcements */
.chat-sys .chat-text.gold-status,
.chat-sys .chat-text[data-is-winner="true"] {
    color: #ffd700 !important;
    font-weight: 950 !important;
    font-style: normal !important; /* Stand out from standard system italics */
    text-shadow: 
        0 0 8px rgba(255, 215, 0, 0.6), 
        0 0 2px rgba(0,0,0,0.8),
        0 0 15px rgba(255, 215, 0, 0.3);
    letter-spacing: 0.5px;
    opacity: 1 !important;
    display: inline-block;
    animation: goldShimmer 2.5s infinite alternate ease-in-out;
    padding: 2px 0;
}

@keyframes goldShimmer {
    from { filter: brightness(1); }
    to { filter: brightness(1.3) contrast(1.1); }
}

.chat-sys .chat-text.gold-status,
.chat-sys .chat-text[data-is-winner="true"] {
    will-change: filter;
}

.chat-input-section {
    display: flex;
    gap: 4px;
    flex-shrink: 0; /* Ensure it never shrinks to 0 height */
}


#chat-input {
    flex: 1;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 8px;
    padding: 8px 12px;
    color: var(--text-primary);
    font-size: var(--chat-font-size);
    outline: none;
    transition: all 0.3s ease;
    height: 28px;
}

#chat-input:focus {
    outline: none;
    border-color: #a8d5ff;
    background: var(--input-bg);
    filter: brightness(1.1);
}

#chat-send-btn {
    padding: 0 10px;
    background: rgba(var(--text-primary-rgb), 0.2);
    border: none;
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.2s;
    height: 28px;
    line-height: 28px;
}

#chat-send-btn:hover {
    background: rgba(var(--text-primary-rgb), 0.3);
}

.players-panel h3 {
    margin: 0 0 10px 0;
    text-align: center;
}

.find-me-btn {
    width: 100%;
    background: rgba(var(--text-primary-rgb), 0.15);
    border: 2px solid rgba(var(--text-primary-rgb), 0.25);
    border-radius: 8px;
    color: var(--text-primary);
    padding: 8px 0;
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    margin-bottom: 15px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
    white-space: nowrap;
}

.find-me-btn:hover {
    background: rgba(var(--text-primary-rgb), 0.25);
    border-color: rgba(var(--text-primary-rgb), 0.35);
    transform: translateY(-1px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.25);
}

.find-me-btn.active {
    background: #a0a0a0 !important;
    border-color: #c0c0c0 !important;
    color: #111111 !important;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.player-actions-row {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    width: 100%;
}

.player-actions-row .find-me-btn {
    margin-bottom: 0;
    flex: 1;
}

/* Remove table header styles */
.player-header-row {
    display: none;
}

#players-list {
    display: flex;
    flex-direction: column;
    gap: 6px; /* Tighter gap */
    overflow-y: auto;
    max-height: none !important; /* Remove restriction to fill space */
    flex: 1 !important; /* Expand to fill available space */
    min-height: 0;
    padding-right: 5px;
}


.player-item {
    background: rgba(var(--text-primary-rgb), 0.1);
    padding: 6px 15px;
    height: 60px; /* Reduced from 65px for compactness */
    flex-shrink: 0;
    border-radius: 12px;
    font-size: 0.95rem;
    display: flex;
    flex-direction: column;
    /* Two lines */
    justify-content: center;
    gap: 4px;
    border: 1px solid transparent;
    transition: all 0.2s;
    cursor: pointer;
    box-sizing: border-box;
    color: var(--text-primary);
}

.player-row-top,
.player-row-bottom {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 8px;
}

.player-row-bottom {
    justify-content: flex-start;
    gap: 8px;
    opacity: 0.8;
}

.player-item:hover {
    background: rgba(var(--text-primary-rgb), 0.15);
}

.player-rank {
    font-weight: 700;
    opacity: 0.6;
    width: 25px;
}

.rating-square {
    display: inline-block;
    width: 15px;
    height: 15px;
    border-radius: 3px;
    border: 1px solid rgba(var(--text-primary-rgb), 0.3);
}

.player-username {
    font-weight: 600;
    flex: 1;
    min-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.player-rating-val {
    font-size: 0.8rem;
    opacity: 0.9;
    white-space: nowrap;
    margin-left: auto;
    /* Align to right of top row */
}



.player-flag {
    font-size: 1.1rem;
    margin-right: 2px;
}

.player-input-icon {
    font-size: 1rem;
    width: 24px;
    text-align: center;
}

.trophy-icon {
    display: inline-block;
    font-size: 1rem;
    width: 24px;
    min-width: 24px;
    text-align: center;
    cursor: help;
    filter: drop-shadow(0 0 4px #ffd700);
}

.player-words-count {
    flex: 1;
    font-size: 0.8rem;
    opacity: 0.8;
    white-space: nowrap;
    text-align: center;
}

.player-score-val {
    font-weight: 700;
    color: #ffd700;
    text-align: right;
    white-space: nowrap;
    font-size: 1rem;
}

/* Theme-aware score color for light themes */
[class*="theme-white"] .player-score-val,
[class*="theme-light-"] .player-score-val,
body.theme-yellow .player-score-val,
body.theme-pink .player-score-val,
body.theme-orange .player-score-val,
body.theme-gray .player-score-val,
body.theme-light-brown .player-score-val {
    color: #444 !important;
    /* Dark gray for better visibility */
}

.player-item.bonus-finder {
    background: rgba(50, 205, 50, 0.3) !important;
    /* Lime green with transparency */
    border: 2px solid #32cd32;
    /* Lime green border */
    box-shadow: 0 0 15px rgba(50, 205, 50, 0.6);
    /* Glowing effect */
    animation: bonusPulse 2s ease-in-out infinite;
    /* Subtle pulsing */
}

@keyframes bonusPulse {

    0%,
    100% {
        box-shadow: 0 0 15px rgba(50, 205, 50, 0.6);
    }

    50% {
        box-shadow: 0 0 25px rgba(50, 205, 50, 0.8);
    }

    50% {
        box-shadow: 0 0 25px rgba(50, 205, 50, 0.8);
    }
}

.player-item.bonus-finder {
    will-change: box-shadow;
}

.player-item.current-user {
    background: rgba(64, 156, 255, 0.25);
    border: 1px solid #409cff;
    color: var(--text-primary);
}

.players-divider {
    text-align: center;
    color: rgba(var(--text-primary-rgb), 0.5);
    font-size: 1.2rem;
    line-height: 0.5;
    margin: 15px 0;
    font-weight: bold;
    letter-spacing: 2px;
}

.players-divider::after {
    content: "• • •";
}

.definitions-panel {
    background: var(--bg-panel);
    border-radius: 12px;
    padding: 12px 15px;
    flex: 0 0 150px !important; /* Force visibility and fixed size */
    border-top: none;
    /* Removed redundant border since it's now a separate box */
    margin-top: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    justify-content: flex-start;
    border-top: 1px solid rgba(var(--text-primary-rgb), 0.05);
    font-size: var(--def-font-size);
}

.definition-header {
    flex-shrink: 0;
    padding-bottom: 8px;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(var(--text-primary-rgb), 0.05);
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

#definition-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    font-size: 1em;
    line-height: 1.5;
    color: var(--text-primary);
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

.definition-word {
    font-weight: 800;
    color: var(--accent-color);
    font-size: 1.2em;
    display: block;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

.definition-text {
    display: block;
    opacity: 0.9;
    font-style: italic;
    font-size: 1em;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Board Panel */
.board-panel {
    background: var(--bg-panel);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    /* Reduced from 20px to tighten up space */
    align-items: center;
    transition: background-color 0.5s ease;
    min-width: 0; /* Allow grid column to control width; checkBoardOverflow handles cell sizing */
    min-height: 0;
    /* Allow shrinking */
    /* max-width removed to allow Board-First internal expansion */
    width: 100%;
    /* Fill the 1fr grid column */
    box-sizing: border-box;
    justify-self: center;
    /* Center in grid column */
    overflow-y: auto;
    /* Allow vertical scrolling for huge boards */
    overflow-x: hidden; /* Disallow horizontal scrolling on desktop */
    max-height: 100%;
    /* Constrain to grid area height */
}

/* ... existing styles ... */

.validation-status {
    min-height: 20px;
    /* Reduced from 24px */
    font-size: 0.9rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 2px;
    /* Reduced from 5px */
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
    text-transform: uppercase;
}

@keyframes low-time-pulse {
    0% { background-color: rgba(255, 107, 107, 0.15); box-shadow: inset 0 0 15px rgba(255, 50, 50, 0.1); }
    50% { background-color: rgba(255, 107, 107, 0.35); box-shadow: inset 0 0 30px rgba(255, 50, 50, 0.3); }
    100% { background-color: rgba(255, 107, 107, 0.15); box-shadow: inset 0 0 15px rgba(255, 50, 50, 0.1); }
}

.board-panel.low-time-warning {
    animation: low-time-pulse 3s infinite ease-in-out;
    border: 1px solid rgba(255, 100, 100, 0.3);
    will-change: background-color, box-shadow;
}

.timer-display {
    background: rgba(var(--text-primary-rgb), 0.15);
    padding: 15px 30px;
    border-radius: 10px;
    display: grid !important;
    grid-template-columns: 1fr auto 1fr !important; /* True centering for middle item */
    align-items: center;
    min-width: 200px !important; /* Give it some width to allow centering */
}
.timer-display .timer-label {
    justify-self: start !important;
}
.timer-display .timer-value {
    justify-self: center !important;
}

.spinner-set-label {
    display: none !important;
}

.timer-label {
    font-size: 1.1rem;
    font-weight: 600;
}

.timer-value {
    font-family: 'Courier New', Courier, monospace;
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
    min-width: 220px;
    text-align: center;
    display: inline-block;
}

@keyframes wait-bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-8px);
    }
}

.wait-dot {
    display: inline-block;
    animation: wait-bounce 1.4s infinite ease-in-out;
}

.wait-dot:nth-of-type(1) {
    animation-delay: 0s;
}

.wait-dot:nth-of-type(2) {
    animation-delay: 0.2s;
}

.wait-dot:nth-of-type(3) {
    animation-delay: 0.4s;
}
.header-title-group {
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.2s ease;
    user-select: none;
}

.header-title-group:hover {
    opacity: 0.95;
    transform: scale(1.02);
}

.header-title-group:active {
    transform: scale(0.98);
}

.game-board {
    display: inline-grid;
    gap: 4px;
    background: rgba(0, 0, 0, 0.2);
    padding: 12px;
    border-radius: 12px;
    max-width: 95vw;
    box-sizing: border-box;
    touch-action: none !important;
}

:root {
    --cell-size: 60px;
    --chat-font-size: 13px;
    /* Approx 0.8rem */
    --def-font-size: 15px;
    /* Approx 0.95rem */
}

.board-cell {
    width: var(--cell-size);
    height: var(--cell-size);
    background: #ffffff;
    color: #111111;
    -webkit-text-stroke: 0.1px rgba(0, 0, 0, 0.1);
    /* Very subtle stroke */
    /* Sharp multi-directional thin border */
    text-shadow:
        -0.5px -0.5px 0 #000,
        0.5px -0.5px 0 #000,
        -0.5px 0.5px 0 #000,
        0.5px 0.5px 0 #000,
        0px 0px 1px #000;
    
    /* DYNAMIC FEEDBACK: Transitions removed for instantaneous highlight */
    transition: none !important;
    

    
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    user-select: none;
    cursor: pointer;
}

/* Synesthesia: Custom Letter Colors */
.board-cell[data-letter*="A"] {
    color: var(--letter-A-color, #111111) !important;
}

.board-cell[data-letter*="B"] {
    color: var(--letter-B-color, #111111) !important;
}

.board-cell[data-letter*="C"] {
    color: var(--letter-C-color, #111111) !important;
}

.board-cell[data-letter*="D"] {
    color: var(--letter-D-color, #111111) !important;
}

.board-cell[data-letter*="E"] {
    color: var(--letter-E-color, #111111) !important;
}

.board-cell[data-letter*="F"] { color: var(--letter-F-color, #111111) !important; }
.board-cell[data-letter*="G"] { color: var(--letter-G-color, #111111) !important; }
.board-cell[data-letter*="H"] { color: var(--letter-H-color, #111111) !important; }

@keyframes cell-lighten-pulse {
    0% { transform: scale(1); filter: brightness(1); }
    50% { transform: scale(1.1); filter: brightness(1.4); }
    100% { transform: scale(1); filter: brightness(1); }
}
.cell-lightened { animation: cell-lighten-pulse 0.4s ease-out; }

.board-cell[data-letter*="I"] {
    color: var(--letter-I-color, #111111) !important;
}

.board-cell[data-letter*="J"] {
    color: var(--letter-J-color, #111111) !important;
}

.board-cell[data-letter*="K"] {
    color: var(--letter-K-color, #111111) !important;
}

.board-cell[data-letter*="L"] {
    color: var(--letter-L-color, #111111) !important;
}

.board-cell[data-letter*="M"] {
    color: var(--letter-M-color, #111111) !important;
}

.board-cell[data-letter*="N"] {
    color: var(--letter-N-color, #111111) !important;
}

.board-cell[data-letter*="O"] {
    color: var(--letter-O-color, #111111) !important;
}

.board-cell[data-letter*="P"] {
    color: var(--letter-P-color, #111111) !important;
}

.board-cell[data-letter*="Q"] {
    color: var(--letter-Q-color, #111111) !important;
}

.board-cell[data-letter*="R"] {
    color: var(--letter-R-color, #111111) !important;
}

.board-cell[data-letter*="S"] {
    color: var(--letter-S-color, #111111) !important;
}

.board-cell[data-letter*="T"] {
    color: var(--letter-T-color, #111111) !important;
}

.board-cell[data-letter*="U"] {
    color: var(--letter-U-color, #111111) !important;
}

.board-cell[data-letter*="V"] {
    color: var(--letter-V-color, #111111) !important;
}

.board-cell[data-letter*="W"] {
    color: var(--letter-W-color, #111111) !important;
}

.board-cell[data-letter*="X"] {
    color: var(--letter-X-color, #111111) !important;
}

.board-cell[data-letter*="Y"] {
    color: var(--letter-Y-color, #111111) !important;
}

.board-cell[data-letter*="Z"] {
    color: var(--letter-Z-color, #111111) !important;
}

.board-cell {
    /* Sharp charcoal for readability */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(var(--cell-size) * 0.6);
    font-weight: 800;
    border-radius: calc(var(--cell-size) * 0.15);
    cursor: pointer;
    position: relative;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
    user-select: none;
    -webkit-user-select: none;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25), inset 0 2px 0 rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(0, 0, 0, 0.05);
    pointer-events: none;
    /* Let diagonal corners fall through completely */
}

/* Dual Letter (Either/Or) Styles */
.dual-letter-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    width: 100%;
    gap: 1.5px;
    pointer-events: none;
}

.dual-letter-container span {
    font-size: 0.52em; /* Robustly scaled for standard cells */
    line-height: 1;
    font-weight: 900;
    text-shadow: none; /* Cleaner for small text */
    color: inherit;
}

.dual-divider {
    width: 65%;
    height: 1.5px;
    background: rgba(17, 17, 17, 0.4);
    flex-shrink: 0;
}

.board-cell.dual-letter {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Deactivate events on visual typography elements to prevent hit-testing confusion */
.board-cell>*:not(.cell-hitbox) {
    pointer-events: none;
}

/* The actual interactive surface: A precise octagon overlay */
.cell-hitbox {
    position: absolute;
    inset: 0;
    z-index: 20;
    pointer-events: auto !important;
    touch-action: none !important;
    /* Only this layer talks to the JS */
    clip-path: polygon(
        var(--corner-cutoff, 39%) 0%, 
        calc(100% - var(--corner-cutoff, 39%)) 0%, 
        100% var(--corner-cutoff, 39%), 
        100% calc(100% - var(--corner-cutoff, 39%)), 
        calc(100% - var(--corner-cutoff, 39%)) 100%, 
        var(--corner-cutoff, 39%) 100%, 
        0% calc(100% - var(--corner-cutoff, 39%)), 
        0% var(--corner-cutoff, 39%)
    );
    cursor: pointer;
}

.board-cell.grayed {
    background: #8c8c8c; /* Medium grey for intermission */
    color: #ffffff; /* White text for contrast */
    cursor: default;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
    border-color: rgba(0, 0, 0, 0.2);
}

/* Mouse selection visual feedback — all tiles in path look identical */
.board-cell.selected,
.board-cell.current {
    background: var(--highlight-mouse-color, rgba(64, 156, 255, 0.5)) !important;
    border: 3px solid #fff !important;
    box-shadow: 0 0 15px var(--highlight-mouse-color, rgba(64, 156, 255, 0.6)) !important;
    transform: scale(1.05);
    z-index: 10;
    color: #000 !important;
    transition: none !important;
}

/* Intermission tile click filter indicator style */
.board-cell.intermission-highlight {
    background: rgba(46, 204, 113, 0.45) !important;
    border: 3px solid #2ecc71 !important;
    box-shadow: 0 0 15px rgba(46, 204, 113, 0.6) !important;
    transform: scale(1.05);
    z-index: 10;
    color: #fff !important;
}

.board-cell.bonus-highlight {
    background: #32cd32 !important;
    /* Lime green */
    color: #fff !important;
    box-shadow: 0 0 15px rgba(50, 205, 50, 0.6), inset 0 2px 0 rgba(255, 255, 255, 0.8) !important;
    border: 2px solid #fff !important;
    animation: bonusPulse 2s ease-in-out infinite;
    z-index: 5; /* Ensure it stays above other decorations */
}

.bonus-star {
    position: absolute;
    top: 1px;
    left: 2px;
    font-size: 14px !important;
    color: #ffd700 !important;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8), 0 0 5px rgba(255, 215, 0, 0.4);
    z-index: 25;
    pointer-events: none;
    font-family: serif;
    font-weight: 900;
}

/* Make highlighted/selected/current bonus cells look identical to standard highlights, hiding green */
.board-cell.selected.bonus-highlight,
.board-cell.current.bonus-highlight {
    background: var(--highlight-mouse-color, rgba(64, 156, 255, 0.5)) !important;
    box-shadow: 0 0 15px var(--highlight-mouse-color, rgba(64, 156, 255, 0.6)) !important;
    animation: none !important;
}

.board-cell.typing-highlight.bonus-highlight {
    background: var(--highlight-typing-color, #ffcc00) !important;
    box-shadow: 0 0 20px var(--highlight-typing-color, #ffcc00) !important;
    animation: none !important;
}

.board-cell.review-highlight.bonus-highlight {
    background: #ffd700 !important;
    box-shadow: 0 0 25px rgba(255, 215, 0, 0.8), 0 0 10px #fff !important;
    animation: none !important;
}

/* Removed redundant dual-letter block previously at this location */

.board-cell .tile-value {
    position: absolute;
    bottom: 3px;
    right: 4px;
    font-size: 11px;
    opacity: 0.7;
    font-weight: 700;
    line-height: 1;
}

.board-cell.current {
    background: var(--highlight-mouse-color, rgba(64, 156, 255, 0.7)) !important;
    filter: brightness(1.2);
    box-shadow: 0 0 20px var(--highlight-mouse-color, rgba(64, 156, 255, 0.8));
}

.word-input-section {
    display: flex;
    gap: 8px;
    /* Reduced gap slightly */
    width: 100%;
    max-width: 640px;
    /* Increased to match board panel */
    margin: 0 auto;
    flex-wrap: nowrap;
    /* Prevent wrapping */
}

@media (min-width: 993px) {
    .word-input-section {
        display: flex !important;
    }
}


.validation-status {
    min-height: 24px;
    font-size: 0.9rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 5px;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
    text-transform: uppercase;
}

.status-valid {
    color: #48bb78;
    /* Green */
}

.status-invalid {
    color: #f56565;
    /* Red */
}

.status-already-found {
    color: #a855f7;
    /* Purple */
}

#word-input {
    flex: 1;
    min-width: 60px;
    /* Allow shrinking but keep usable */
    padding: 12px;
    background: var(--input-bg);
    border: 2px solid var(--input-border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
}

#word-input::placeholder {
    color: var(--muted-text);
}

#word-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#submit-word-btn {
    padding: 12px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 8px;
    color: #ffffff;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

#submit-word-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

#submit-word-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.rotate-btn {
    padding: 12px 16px;
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    border: none;
    border-radius: 8px;
    color: #ffffff;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.rotate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    filter: brightness(1.1);
}

/* Words Panel */
.words-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.words-tabs {
    display: flex;
    background: var(--tab-container-bg);
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 15px;
    border: 1px solid var(--input-border);
}

.word-tab {
    flex: 1;
    padding: 8px 4px;
    border: none;
    background: transparent;
    color: var(--muted-text);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.word-tab.active {
    background: var(--tab-active-bg);
    color: var(--text-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.tab-content {
    display: none;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    /* Prevent container from scrolling */
}

.tab-content.active {
    display: flex;
}

.words-header-group {
    margin-bottom: 10px;
}

.words-panel h3 {
    margin: 0 0 5px 0;
    text-align: center;
    font-size: 1.1rem;
}

.words-stats {
    font-size: 0.85rem;
    font-weight: normal;
    text-align: center;
    color: var(--text-primary);
    margin: 0;
}

.stats-text-primary {
    color: var(--text-primary);
}

.stats-text-secondary {
    color: var(--text-primary);
    opacity: 0.7;
}

#remaining-words-list {
    flex: 1;
    overflow-y: auto;
    padding-right: 5px;
    min-height: 0;
    /* Important for flex child scrolling */
}

#remaining-words-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

#remaining-words-table tr {
    border-bottom: 1px solid rgba(var(--text-primary-rgb), 0.05);
    transition: background-color 0.2s ease;
}

#remaining-words-table tr:nth-child(even) {
    background: rgba(var(--text-primary-rgb), 0.03);
}

#remaining-words-table tr:hover {
    background: rgba(var(--text-primary-rgb), 0.07);
}

#remaining-words-table td {
    padding: 10px;
    font-size: 0.95rem;
}

.len-cell {
    font-weight: 700;
    color: #4facfe;
    width: 60%;
}

.count-cell {
    text-align: right;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    opacity: 0.9;
}

#submitted-words-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    /* Grow to fill space */
    overflow-y: auto;
    /* Scrollably list */
    padding-right: 5px;
    /* Space for scrollbar */
    margin-bottom: 10px;
}

#previous-words-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    /* Grow to fill space */
    overflow-y: auto;
    /* Scrollably list */
    padding-right: 5px;
    /* Space for scrollbar */
    margin-bottom: 10px;
}

#history-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

#winners-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    overflow-y: auto;
    padding-right: 5px;
}

.history-item {
    transition: background-color 0.2s;
    border-radius: 8px;
    background: rgba(var(--text-primary-rgb), 0.03);
}

.history-item:hover {
    background: rgba(var(--text-primary-rgb), 0.07);
}

.word-item {
    background: rgba(72, 187, 120, 0.3);
    padding: 8px 12px;
    border-radius: 6px;
    font-weight: 600;
    white-space: nowrap;
}

.word-item.player-word {
    background: rgba(64, 156, 255, 0.4);
    /* Attractive blue with transparency */
    border: 2px solid #409cff;
    /* Blue border */
    box-shadow: 0 0 10px rgba(64, 156, 255, 0.4);
    /* Blue glow */
    font-weight: 700;
    /* Make it stand out */
}

.word-item.opponent-word {
    background: rgba(255, 99, 71, 0.25);
    /* Tomato Red, transparent */
    border: 1px solid rgba(255, 99, 71, 0.5);
    color: var(--text-primary);
}

.word-item.bonus-word,
.notepad-item.bonus-word {
    background: rgba(50, 255, 50, 0.4) !important;
    /* Vibrant Lime Green */
    border: 3px solid #32ff32 !important;
    box-shadow: 0 0 20px rgba(50, 255, 50, 0.7) !important;
    color: var(--text-primary);
    text-shadow: 0 0 8px rgba(0, 0, 0, 0.8), 0 0 4px #000;
    animation: bonusPulse 1.5s infinite;
    z-index: 5;
}

/* Remove blurriness for bonus word in light themes */
[class*="theme-white"] .word-item.bonus-word,
[class*="theme-white"] .notepad-item.bonus-word,
[class*="theme-light-"] .word-item.bonus-word,
[class*="theme-light-"] .notepad-item.bonus-word,
body.theme-yellow .word-item.bonus-word,
body.theme-yellow .notepad-item.bonus-word,
body.theme-pink .word-item.bonus-word,
body.theme-pink .notepad-item.bonus-word,
body.theme-orange .word-item.bonus-word,
body.theme-orange .notepad-item.bonus-word,
body.theme-gray .word-item.bonus-word,
body.theme-gray .notepad-item.bonus-word,
body.theme-light-brown .word-item.bonus-word,
body.theme-light-brown .notepad-item.bonus-word {
    text-shadow: none !important;
    box-shadow: 0 2px 8px rgba(0, 128, 0, 0.3) !important;
    color: #000 !important;
}

.word-item.unfound {
    display: flex !important;
    /* Ensure visibility */
    background: rgba(128, 128, 128, 0.1);
    /* Grayish with transparency */
    border: 1px solid rgba(128, 128, 128, 0.2);
    /* Gray border */
    color: var(--muted-text);
    /* Dimmed text but readable */
    opacity: 1;
    /* Remove opacity to ensure readable */
}

/* Added Word (Royal Purple) — Higher Priority than CSW-Only */
.added-word {
    background: rgba(147, 51, 234, 0.4) !important;
    border: 2px solid #9333ea !important;
    box-shadow: 0 0 10px rgba(147, 51, 234, 0.5) !important;
    color: var(--text-primary);
    font-weight: 700;
}

/* CSW-Only Word (Third Priority: Solid Gold) */
.word-item.csw-only {
    background: rgba(255, 215, 0, 0.7) !important;
    border: 2px solid #ffd700 !important;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.6) !important;
    color: #000 !important; /* Black text for better contrast on gold */
    font-weight: 800;
}

/* Active Highlight for Finding Finders */
.word-item.finder-active {
    outline: 3px solid #ffd700;
    outline-offset: 2px;
    z-index: 10;
    transform: scale(1.02);
}

.found-indicator {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    text-align: center;
    line-height: 16px;
    font-size: 10px;
    margin-right: 8px;
    font-weight: 900;
    flex-shrink: 0;
    vertical-align: middle;
}

.found-indicator.present {
    background: #2ecc71;
    color: #fff;
    border: 1.5px solid #000;
    box-shadow: 0 0 5px rgba(46, 204, 113, 0.4);
}

.found-indicator.empty {
    border: 1.5px solid rgba(var(--text-primary-rgb), 0.15);
    background: transparent;
}

/* Golden Highlight for Players who found a word */
.player-item.finder-highlight {
    border-color: #ffd700 !important;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.6) !important;
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.2) 0%, rgba(255, 215, 0, 0.05) 100%) !important;
    transform: scale(1.02);
    z-index: 5;
}

/* Missed by User (Red) */
.word-item.missed {
    background: rgba(244, 63, 94, 0.1) !important;
    border: 1px solid rgba(244, 63, 94, 0.2) !important;
    color: #fb7185 !important; /* Vibrant rose for dark themes */
    opacity: 0.95;
}

[class*="theme-white"] .word-item.missed,
[class*="theme-light-"] .word-item.missed,
body.theme-yellow .word-item.missed,
body.theme-pink .word-item.missed,
body.theme-orange .word-item.missed,
body.theme-gray .word-item.missed,
body.theme-light-brown .word-item.missed {
    color: #9f1239 !important; /* Deep crimson for light themes */
    background: rgba(159, 18, 57, 0.05) !important;
    border-color: rgba(159, 18, 57, 0.1) !important;
}

/* Equal Height for MP and LIC Charts */
.result-section:nth-child(1),
.result-section:nth-child(2) {
    flex: 0 0 250px;
    min-height: 200px;
}

/* --- LISTS TOOL STYLING --- */
.lists-container {
    display: flex;
    gap: 15px;
    height: calc(100vh - 240px);
    width: 100%;
    padding: 0 15px 10px 0;
    /* Flush left as requested */
    box-sizing: border-box;
}

.list-column {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(var(--text-primary-rgb), 0.1);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
    /* Allow grid to shrink them */
}

.list-column h3 {
    padding: 10px 15px;
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-primary);
    background: rgba(var(--text-primary-rgb), 0.05);
    border-bottom: 1px solid rgba(var(--text-primary-rgb), 0.1);
    text-align: center;
}

.list-count {
    font-size: 0.75rem;
    font-weight: 500;
    color: rgba(79, 172, 254, 0.8);
    opacity: 0.85;
}

.list-scroll-area {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.list-item {
    padding: 3px 6px;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 0.85rem;
    color: rgba(var(--text-primary-rgb), 0.8);
    border-bottom: 1px solid rgba(var(--text-primary-rgb), 0.03);
}

.list-item:hover {
    background: rgba(var(--text-primary-rgb), 0.1);
    color: var(--text-primary);
}

.likelihood-score {
    font-size: 0.75rem;
    font-weight: 600;
    color: rgba(79, 172, 254, 0.75);
    min-width: 28px;
    display: inline-block;
    margin-right: 4px;
    text-align: right;
}

/* --- SEQUENCE TOOL STYLING --- */
.seq-results-container {
    flex: 1;
    margin-top: 20px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(var(--text-primary-rgb), 0.1);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 75vh;
    /* Increased for more room */
    max-height: 1200px;
    /* Increased from 400px to allow full vertical utilization */
}

/* --- MANUAL TOOL STYLING --- */
.manual-workspace {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    align-items: center;
    margin-top: 20px;
    flex: 1;
}

#manual-results-container {
    width: 100%;
    flex: 1;
    min-height: 400px;
    height: auto !important;
    max-height: none !important;
    margin-top: 10px !important;
}

.manual-grid-scroll {
    width: auto;
    max-height: 600px !important;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 24px;
    border: 1px solid rgba(var(--text-primary-rgb), 0.1);
}

/* --- SUBANAGRAMS TOOL STYLING --- */
#tool-subanagrams .group-table td {
    text-align: center;
}

.manual-grid {
    display: grid;
    gap: 8px;
    margin: 0 auto;
    justify-content: center;
}

.manual-cell {
    width: 55px;
    height: 55px;
    background: #fff;
    border: 2px solid rgba(0,0,0,0.1);
    border-radius: 8px;
    text-align: center;
    font-size: 1.8rem;
    font-weight: 800;
    color: #111;
    text-transform: uppercase;
    outline: none;
    transition: all 0.2s;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

.manual-cell:focus {
    box-shadow: 0 0 10px rgba(64, 156, 255, 0.8);
    transform: scale(1.05);
}

.manual-action-btn {
    padding: 0 25px;
    height: 100%;
    background: linear-gradient(135deg, #4ade80, #22c55e);
    border: none;
    border-radius: 8px;
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(74, 222, 128, 0.3);
    transition: all 0.2s;
    min-width: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.manual-action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(74, 222, 128, 0.4);
    filter: brightness(1.1);
}

.manual-action-btn:active {
    transform: translateY(0);
}

.manual-action-btn:disabled {
    opacity: 0.5;
    cursor: default;
    transform: none;
}

.manual-clear-btn {
    background: linear-gradient(135deg, #f43f5e, #e11d48) !important;
    box-shadow: 0 4px 10px rgba(244, 63, 94, 0.3) !important;
}

.manual-clear-btn:hover {
    box-shadow: 0 6px 15px rgba(244, 63, 94, 0.4) !important;
}

.manual-results-hidden {
    display: none;
}

/* --- RANDOM WORD TOOL STYLING --- */
.random-word-container {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    min-height: 180px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(var(--text-primary-rgb), 0.1);
    border-radius: 12px;
    margin-top: 20px;
    padding: 20px;
}

.validation-scroll-container {
    max-height: 280px;
    overflow-y: auto;
    overflow-x: hidden;
    justify-content: flex-start !important;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.validation-scroll-container::-webkit-scrollbar {
    width: 6px;
}

.validation-scroll-container::-webkit-scrollbar-track {
    background: transparent;
}

.validation-scroll-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

.validation-scroll-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.random-word-large {
    font-size: 5.5rem;
    font-weight: 900;
    color: #f8fafc;
    text-transform: uppercase;
    text-align: center;
    letter-spacing: 2px;
    text-shadow: 0 0 25px rgba(var(--text-primary-rgb), 0.4),
        0 0 50px rgba(56, 189, 248, 0.3);
    animation: fadeInWord 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes fadeInWord {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* --- WORD OF THE DAY STYLING --- */
.wotd-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    min-height: 250px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(251, 191, 36, 0.2);
    /* Subtle Gold border */
    border-radius: 12px;
    margin-top: 20px;
    padding: 40px;
}

.wotd-intro {
    font-size: 1.2rem;
    color: rgba(var(--text-primary-rgb), 0.7);
    margin-bottom: 20px;
    text-transform: italic;
    letter-spacing: 1px;
}

.wotd-gold-showy {
    font-size: 6rem;
    font-weight: 900;
    color: #fbbf24;
    /* Primary Gold */
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 50%, #d97706 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-transform: uppercase;
    text-align: center;
    letter-spacing: 4px;
    filter: drop-shadow(0 0 15px rgba(251, 191, 36, 0.4)) drop-shadow(0 0 30px rgba(251, 191, 36, 0.2));
    animation: wotdShowyEntrance 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards,
        wotdPulse 3s ease-in-out infinite 0.8s;
}

@keyframes wotdShowyEntrance {
    0% {
        opacity: 0;
        transform: scale(0.5) rotate(-5deg);
        filter: blur(10px) brightness(2);
    }

    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
        filter: blur(0) brightness(1);
    }
}

@keyframes wotdPulse {

    0%,
    100% {
        transform: scale(1);
        filter: drop-shadow(0 0 15px rgba(251, 191, 36, 0.4));
    }

    50% {
        transform: scale(1.02);
        filter: drop-shadow(0 0 25px rgba(251, 191, 36, 0.6));
    }
}

/* Equal Height for MP and LIC Charts (User Request) */
.result-section:nth-child(1),
.result-section:nth-child(2) {
    flex: 0 0 250px;
    /* Fixed height for both */
    min-height: 200px;
}

/* --- TOOLS PAGE (Split Layout) --- */
.tools-split-layout {
    display: flex;
    height: 100%;
    min-height: 500px;
    background: rgba(var(--text-primary-rgb), 0.05);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(var(--text-primary-rgb), 0.1);
}

.tools-sidebar {
    flex: 0 0 220px;
    width: 220px;
    min-width: 220px;
    max-width: 220px;
    background: var(--bg-panel);
    border-right: 1px solid var(--input-border);
    padding: 20px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-sizing: border-box;
    overflow-y: auto;
}

.tool-nav-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--muted-text);
    padding: 12px 16px;
    text-align: left;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    width: 100%;
    box-sizing: border-box;
}

@media (min-width: 901px) {
    #page-tools,
    #page-settings,
    #page-mods {
        height: calc(100vh - 120px) !important;
        max-height: calc(100vh - 120px) !important;
        overflow: hidden !important;
        padding-top: 20px !important;
        padding-bottom: 20px !important;
        box-sizing: border-box !important;
    }
    .tools-split-layout {
        width: 100% !important;
        max-width: 98% !important;
        flex: 1 1 auto !important;
        height: 0 !important;
        min-height: 0 !important;
        max-height: none !important;
    }
    .tools-sidebar {
        flex: 0 0 300px !important;
        width: 300px !important;
        min-width: 300px !important;
        max-width: 300px !important;
        padding: 20px 8px !important;
        gap: 10px !important;
    }
    .tool-nav-btn {
        height: auto !important;
        padding: 15px 20px !important;
        border-radius: 8px !important;
        border: 1px solid transparent !important;
        background: transparent !important;
        justify-content: flex-start !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 4px !important;
    }
    .tool-nav-btn:hover {
        background: var(--input-bg) !important;
        color: var(--text-primary) !important;
    }
    .tool-nav-btn.active {
        background: rgba(79, 172, 254, 0.15) !important;
        border: 1px solid rgba(79, 172, 254, 0.3) !important;
        color: #4facfe !important;
    }
    .tool-btn-title {
        font-size: 1rem !important;
        font-weight: 600 !important;
        margin-bottom: 0 !important;
    }
    .tool-btn-desc {
        font-size: 0.8rem !important;
        line-height: 1.4 !important;
        margin-top: 0 !important;
    }
    .tool-nav-btn:not(.active) .tool-btn-title {
        color: var(--text-60, rgba(255, 255, 255, 0.6)) !important;
    }
    .tool-nav-btn:not(.active) .tool-btn-desc {
        color: var(--text-40, rgba(255, 255, 255, 0.4)) !important;
    }
    .tool-nav-btn:not(.active):hover .tool-btn-title {
        color: var(--text-primary) !important;
    }
    .tool-pane.active {
        overflow-y: auto !important;
        height: 100% !important;
    }
    .combo-results-container {
        overflow-y: visible !important;
        flex: unset !important;
    }
    .tools-content {
        background: rgba(0, 0, 0, 0.25) !important;
        border-left: 1px solid rgba(255, 255, 255, 0.08) !important;
        padding: 30px !important;
        box-sizing: border-box !important;
    }
}

.tool-btn-title {
    font-weight: 600;
    font-size: 0.95rem;
}

.tool-btn-desc {
    font-size: 0.72rem;
    color: rgba(var(--text-primary-rgb), 0.45) !important;
    font-weight: 400;
    line-height: 1.3;
    text-align: left;
    margin-top: 2px;
}

.tool-nav-btn:hover {
    background: var(--input-bg);
    color: var(--text-primary);
}

.tool-nav-btn.active {
    background: rgba(79, 172, 254, 0.15);
    /* Light blue tint */
    color: #4facfe;
    border: 1px solid rgba(79, 172, 254, 0.3);
}

.tool-nav-btn.active .tool-btn-desc {
    color: rgba(var(--text-primary-rgb), 0.7) !important;
}

.tool-nav-btn:disabled {
    opacity: 0.3;
    filter: grayscale(0.8);
    cursor: not-allowed;
    background: transparent !important;
    border-color: transparent !important;
    color: rgba(var(--text-primary-rgb), 0.4) !important;
}

/* Content Area (2/3) */
.tools-content {
    flex: 1;
    padding: 24px 0;
    /* Vertical only, tools manage horizontal spacing */
    overflow-y: auto;
    background: rgba(var(--text-primary-rgb), 0.02);
    min-width: 0;
    /* Essential for flex inner shrinkage */
}

.tool-header,
.combo-control-panel {
    padding-left: 0 !important;
    padding-right: 15px;
}

.tool-header {
    margin-bottom: 20px;
    text-align: left;
}

.tool-pane {
    display: none;
    height: 100%;
    flex-direction: column;
}

.tool-pane.active {
    display: flex;
    align-items: flex-start;
    overflow-y: auto;
    width: 100%;
}

.tool-header,
.combo-control-panel,
.profile-container,
.profile-content-tabs,
.seq-results-container,
.combo-results-container,
.lists-container,
.random-word-container,
.wotd-container,
.manual-grid-scroll,
.manual-grid {
    width: 100%;
    max-width: 1200px;
}

.tool-header h2 {
    margin: 0 0 5px 0;
    font-size: 1.8rem;
    background: linear-gradient(to right, var(--text-primary), #666);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.tool-header p {
    color: var(--muted-text);
    margin: 0 0 25px 0;
    font-size: 0.95rem;
}

/* Combo Checker Controls */
.combo-control-panel {
    background: rgba(var(--text-primary-rgb), 0.05);
    padding: 20px 20px 20px 0;
    border-radius: 10px;
    margin-bottom: 25px;
    border: 1px solid rgba(var(--text-primary-rgb), 0.05);
}

.input-row {
    display: flex;
    gap: 12px;
    justify-content: flex-start;
}

#combo-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(var(--text-primary-rgb), 0.15);
    color: var(--text-primary);
    padding: 15px 22px;
    border-radius: 12px;
    font-size: 1.25rem;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 1.5px;
}

#profile-search-input {
    flex: 1;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    color: var(--text-primary);
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
}

#profile-search-input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(233, 69, 96, 0.2);
    background: rgba(var(--text-primary-rgb), 0.05);
}

#profile-search-btn {
    padding: 0 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--text-primary);
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

#profile-search-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

#combo-dict {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(var(--text-primary-rgb), 0.1);
    color: var(--text-primary);
    padding: 15px;
    border-radius: 12px;
    font-size: 1.1rem;
    cursor: pointer;
}

#combo-search-btn {
    background: linear-gradient(135deg, #4ade80, #22c55e);
    border: none;
    color: var(--text-primary);
    padding: 0 24px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    transition: transform 0.1s;
}

#combo-search-btn:active {
    transform: scale(0.96);
}

/* Combo Results (Grouped Layout) */
.combo-results-container {
    display: flex;
    flex-direction: column;
    gap: 25px;
    flex: 1;
    min-height: 0;
    overflow-y: hidden;
    /* Main vertical scroll handled by .tool-pane on desktop */
}

.result-section {
    display: flex;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    border: 1px solid rgba(var(--text-primary-rgb), 0.05);
    flex: 1;
    min-height: 0;
    /* Important for flex nesting */
    overflow: hidden;
}

.result-section h3 {
    margin: 0;
    padding: 10px 15px 5px;
    font-size: 1rem;
    color: var(--text-primary);
    background: rgba(var(--text-primary-rgb), 0.05);
}

.chart-desc {
    padding: 0 15px 10px;
    font-size: 0.8rem;
    color: rgba(var(--text-primary-rgb), 0.4);
    background: rgba(var(--text-primary-rgb), 0.05);
    border-bottom: 1px solid rgba(var(--text-primary-rgb), 0.05);
}

.horizontal-scroll-container {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    flex: 1;
    padding: 10px;
    gap: 10px;
    overscroll-behavior-x: contain;
}

/* Individual Group Column (e.g. "0MP", "1MP") */
.group-column {
    min-width: 150px;
    width: 180px;
    display: flex;
    flex-direction: column;
    background: rgba(var(--text-primary-rgb), 0.03);
    border: 1px solid rgba(var(--text-primary-rgb), 0.05);
    border-radius: 6px;
    overflow: hidden;
}

.group-header {
    background: rgba(var(--text-primary-rgb), 0.1);
    padding: 6px 10px;
    font-weight: bold;
    font-size: 0.9rem;
    text-align: center;
    color: rgba(var(--text-primary-rgb), 0.8);
    position: sticky;
    top: 0;
}

.group-table-container {
    flex: 1;
    overflow-y: auto;
}

.group-table {
    width: 100%;
    border-collapse: collapse;
}

.group-table td {
    padding: 4px 10px;
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(var(--text-primary-rgb), 0.03);
    color: rgba(var(--text-primary-rgb), 0.7);
}

.group-table tr:hover td {
    background: rgba(var(--text-primary-rgb), 0.05);
    color: var(--text-primary);
}

.group-row {
    padding: 4px 10px;
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(var(--text-primary-rgb), 0.03);
    color: rgba(var(--text-primary-rgb), 0.7);
    box-sizing: border-box;
}

.group-row:hover {
    background: rgba(var(--text-primary-rgb), 0.05);
    color: var(--text-primary);
}

/* Specific Colors for MP/LIC Headers */
.result-section:nth-child(1) h3 {
    color: #facc15;
}

/* Yellow MP */
.result-section:nth-child(2) h3 {
    color: #60a5fa;
}

/* Blue LIC */

.result-section:nth-child(1) .group-header {
    color: #facc15;
}

.result-section:nth-child(2) .group-header {
    color: #60a5fa;
}

/* Make MP Chart Shorter (User Request) */
.result-section:first-child {
    flex: 0 0 250px;
    /* Fixed height for MP */
    min-height: 200px;
}

/* Word found by another player (Fourth Priority: Neutral) */
.word-item.found-by-other {
    background: rgba(var(--text-primary-rgb), 0.1);
    border: 1px solid rgba(var(--text-primary-rgb), 0.2);
    color: rgba(var(--text-primary-rgb), 0.8);
}

/* Live Feed Items (Aesthetic) */
.feed-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(90deg, rgba(var(--text-primary-rgb), 0.05) 0%, rgba(var(--text-primary-rgb), 0.02) 100%);
    padding: 4px 10px;
    /* Aggressively reduced padding */
    border-radius: 6px;
    margin-bottom: 3px;
    /* Reduced margin */
    border-left: 3px solid rgba(var(--text-primary-rgb), 0.2);
    /* Thinner border */
    transition: all 0.2s ease;
    animation: slideInRight 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.feed-item:hover {
    background: linear-gradient(90deg, rgba(var(--text-primary-rgb), 0.1) 0%, rgba(var(--text-primary-rgb), 0.05) 100%);
    transform: translateX(2px);
}

.feed-item.myself {
    background: linear-gradient(90deg, rgba(64, 156, 255, 0.15) 0%, rgba(64, 156, 255, 0.05) 100%);
    border-left-color: #409cff;
    box-shadow: 0 1px 4px rgba(64, 156, 255, 0.1);
}

.feed-word {
    font-weight: 700;
    font-size: 0.95rem;
    /* Further reduced font size */
    color: var(--text-primary);
    letter-spacing: 0.5px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.word-item.penalty-word {
    color: #ff3333 !important;
    font-weight: 800;
    background: rgba(255, 0, 0, 0.05);
}

.word-item.penalty-word .found-indicator {
    color: #ff3333 !important;
    filter: drop-shadow(0 0 5px rgba(255, 0, 0, 0.3));
}

.feed-item.myself .feed-word {
    color: #a8d5ff;
}

.feed-info {
    font-size: 0.7rem;
    /* Further reduced font size */
    color: rgba(var(--text-primary-rgb), 0.7);
    background: rgba(0, 0, 0, 0.2);
    padding: 1px 6px;
    /* Minimal padding */
    border-radius: 8px;
    font-weight: 500;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Spinner Overlay */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.spinner-overlay.hidden {
    display: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.spinner-content {

    background: var(--bg-primary);
    border: 3px solid var(--accent-color);
    border-radius: 16px;
    padding: 20px;
    width: 90%;
    max-width: 500px;
    position: relative;
    box-shadow: 0 0 50px rgba(0, 0, 0, 1), 0 0 100px rgba(var(--accent-rgb), 0.2);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.spinner-scroll-area {
    width: 100%;
    max-height: 75vh;
    overflow-y: auto;
    padding-right: 5px; /* space for scroll bar */
}

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

.change-positive { color: #1b8a4f; font-weight: 800; text-shadow: 0 0 5px rgba(27, 138, 79, 0.4); }
.change-negative { color: #f43f5e; font-weight: 800; text-shadow: 0 0 5px rgba(244, 63, 94, 0.4); }
.change-neutral { opacity: 0.5; color: var(--muted-text); }

.spinner-content h2 {
    color: var(--text-primary);
    font-size: 1.5rem;
    margin-bottom: 15px;
    text-align: center;
}

.spinner-params {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.param-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 15px;
    background: rgba(var(--text-primary-rgb), 0.05);
    border-radius: 10px;
    border: 1px solid rgba(var(--text-primary-rgb), 0.1);
    transition: all 0.3s ease;
}

.param-item:hover {
    background: rgba(var(--text-primary-rgb), 0.1);
    border-color: rgba(233, 69, 96, 0.3);
    transform: translateX(5px);
}

.param-label {
    font-weight: 600;
    color: var(--text-primary);
    opacity: 0.8;
    font-size: 1.05rem;
}

.param-value {
    font-weight: 800;
    color: var(--text-primary);
    font-size: 1.25rem;
    background: rgba(var(--text-primary-rgb), 0.1);
    padding: 6px 18px;
    border-radius: 8px;
    border: 1px solid rgba(var(--text-primary-rgb), 0.05);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    min-width: 100px;
    text-align: center;
}

/* Dynamic Difficulty Colors */
.param-value.diff-easy {
    color: #10b981 !important;
    text-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.3);
}
.param-value.diff-medium {
    color: #60a5fa !important;
    text-shadow: 0 0 10px rgba(96, 165, 250, 0.4);
    background: rgba(96, 165, 250, 0.1);
    border-color: rgba(96, 165, 250, 0.3);
}
.param-value.diff-hard {
    color: #ef4444 !important;
    text-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
}

/* Word Count Variety */
.param-value.wc-high {
    color: #8b5cf6 !important;
    text-shadow: 0 0 15px rgba(139, 92, 246, 0.5);
    background: rgba(139, 92, 246, 0.15);
    border-color: rgba(139, 92, 246, 0.4);
}

/* RARE 1% MODE: 500+ Words */
.param-value.wc-rare {
    background: linear-gradient(135deg, #ff00cc 0%, #3333ff 100%);
    color: #fff !important;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 0 20px rgba(255, 0, 204, 0.4), 0 0 40px rgba(51, 51, 255, 0.2);
    animation: wcRareShimmer 2s linear infinite;
    position: relative;
    overflow: hidden;
}

@keyframes wcRareShimmer {
    0% { filter: hue-rotate(0deg) brightness(1); }
    50% { filter: hue-rotate(15deg) brightness(1.3); transform: scale(1.05); }
    100% { filter: hue-rotate(0deg) brightness(1); }
}




.close-spinner-btn {
    position: sticky;
    top: 15px;
    margin-right: 15px;
    float: right;
    z-index: 2000;
    width: 32px;
    height: 32px;
    background: rgba(233, 69, 96, 0.2);
    border: 2px solid #e94560;
    border-radius: 50%;
    color: #e94560;


    font-size: 1.5rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: all 0.3s ease;
}

.close-spinner-btn:hover {
    background: #e94560;
    color: var(--text-primary);
    transform: rotate(90deg);
    box-shadow: 0 0 20px rgba(233, 69, 96, 0.6);
}

.board-cell.selected {
    background: var(--accent-color);
    color: var(--text-primary);
    transform: scale(1.1);
    box-shadow: 0 0 15px var(--accent-color);
    z-index: 2;
}

.board-cell.typing-highlight {
    background: var(--highlight-typing-color, #ffcc00) !important;
    /* User selected highlight for typing */
    color: #000 !important;
    transform: scale(1.1);
    box-shadow: 0 0 20px var(--highlight-typing-color, #ffcc00);
    z-index: 3;
    transition: all 0.1s ease;
    border-color: #fff !important;
}

.board-cell.review-highlight {
    background: #ffd700 !important;
    /* Gold */
    color: #000 !important;
    transform: scale(1.1);
    box-shadow: 0 0 25px rgba(255, 215, 0, 0.8), 0 0 10px #fff;
    z-index: 4;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 2px solid #fff !important;
    animation: reviewPulse 1.5s ease-in-out infinite;
}

@keyframes reviewPulse {

    0%,
    100% {
        box-shadow: 0 0 20px rgba(255, 215, 0, 0.6), 0 0 5px #fff;
        transform: scale(1.1);
    }

    50% {
        box-shadow: 0 0 35px rgba(255, 215, 0, 0.9), 0 0 15px #fff;
        transform: scale(1.15);
    }
}



/* Rating Indicator */
.rating-indicator {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 2px;
    margin-right: 8px;
    border: 1.5px solid #000;
    vertical-align: middle;
    box-sizing: border-box;
}

/* Split Points Logic Styles */

/* Container for notepads replacing the board */
.split-notepads-container {
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    width: 100%;
    max-width: 600px;
    height: 100%;
    max-height: 480px;
    /* Match board height approx */
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    grid-template-rows: auto;
    align-items: start;
    gap: 10px;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 992px) {
    .play-header .header-title-group,
    .play-header #return-lobby-btn {
        display: none !important;
    }

    .split-notepads-container {
        display: flex !important;
        flex-direction: column !important;
        max-height: 450px !important;
        overflow-y: auto !important;
        touch-action: pan-y !important;
        gap: 20px !important;
        width: 100% !important;
    }
    .user-notepad {
        height: auto !important;
        min-height: 200px !important;
        touch-action: pan-y !important;
        flex-shrink: 0 !important;
        width: 100% !important;
    }
    .notepad-list {
        overflow-y: hidden !important;
        touch-action: pan-y !important;
        height: 180px !important;
    }
}

/* Individual User Notepad */
.user-notepad {
    background: rgba(var(--text-primary-rgb), 0.05);
    border: 1px solid rgba(var(--text-primary-rgb), 0.1);
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 250px;
    transition: all 0.2s ease;
    cursor: pointer;
    min-width: 0;
    min-height: 0;
    max-width: 100%;
}

.user-notepad:hover {
    background: rgba(var(--text-primary-rgb), 0.08);
    transform: translateY(-2px);
}

.user-notepad.selected {
    border-color: #409cff;
    box-shadow: 0 0 15px rgba(64, 156, 255, 0.3);
    background: rgba(64, 156, 255, 0.1);
}

.user-notepad.highlight-shared {
    border-color: #ffd700 !important;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.45) !important;
    background: rgba(255, 215, 0, 0.08) !important;
}

/* Notepad Header */
.notepad-header {
    padding: 10px 15px;
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(var(--text-primary-rgb), 0.05);
}

.notepad-header strong {
    color: var(--text-primary);
    font-size: 0.95rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 120px;
}

.notepad-header span {
    color: #a8d5ff;
    font-weight: 700;
}

/* Tabs */
.notepad-tabs {
    display: flex;
    border-bottom: 1px solid rgba(var(--text-primary-rgb), 0.05);
    background: rgba(0, 0, 0, 0.1);
}

.notepad-buttons button {
    flex: 1;
    background: transparent;
    border: none;
    padding: 8px 5px;
    color: rgba(var(--text-primary-rgb), 0.6);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
}

.notepad-tab {
    flex: 1;
    background: #d0d0d0;
    border: none;
    padding: 8px 5px;
    color: #000;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
}

.notepad-tab:hover {
    color: #000;
    background: #e0e0e0;
}

.notepad-tab.active {
    color: #000;
    border-bottom-color: #409cff;
    background: #fff;
}

/* List Area */
.notepad-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.notepad-main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
    background: rgba(var(--text-primary-rgb), 0.02);
}

.notepad-scroll-controls {
    display: flex;
    flex-direction: column;
    width: 32px;
    background: rgba(0, 0, 0, 0.3);
    border-left: 1px solid rgba(var(--text-primary-rgb), 0.1);
}

.notepad-scroll-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: rgba(var(--text-primary-rgb), 0.6);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    user-select: none;
}

.notepad-scroll-btn:hover {
    background: rgba(64, 156, 255, 0.2);
    color: var(--text-primary);
}

.notepad-scroll-btn:active {
    background: rgba(64, 156, 255, 0.4);
    transform: scale(0.9);
}

.notepad-scroll-btn.up {
    border-bottom: 1px solid rgba(var(--text-primary-rgb), 0.05);
}

/* List Items */
.notepad-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    padding: 4px 8px;
    border-radius: 4px;
    background: rgba(var(--text-primary-rgb), 0.08);
    color: var(--text-primary);
    margin-bottom: 2px;
    white-space: nowrap;
}

.notepad-item:nth-child(odd) {
    background: rgba(var(--text-primary-rgb), 0.12);
}

.notepad-item.invalid {
    color: #ff6b6b;
    text-decoration: line-through;
    opacity: 0.7;
}

.notepad-item.active {
    background: #ffd700 !important;
    color: #000 !important;
    font-weight: 800;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
    border: 1px solid #000;
}


/* Toggle Link/Button styling */
.active-room-btn {
    background: rgba(64, 156, 255, 0.2);
    border: 1px solid rgba(64, 156, 255, 0.4);
    color: var(--text-primary);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.active-room-btn:hover {
    background: rgba(64, 156, 255, 0.4);
}

/* Spectator Panel (Aesthetic) */
.spectator-panel {
    background: rgba(16, 21, 30, 0.95);
    padding: 40px 60px;
    border-radius: 20px;
    text-align: center;
    border: 1px solid rgba(64, 156, 255, 0.3);
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8), inset 0 0 20px rgba(64, 156, 255, 0.1);
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
    max-width: 400px;
    width: 90%;
    position: relative;
    overflow: hidden;
    animation: fadeIn 0.5s ease;
}

.spectator-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, #409cff, #e94560);
}

.spectator-title {
    font-size: 2.5rem;
    font-weight: 800;
    margin: 0;
    background: linear-gradient(135deg, #409cff 0%, #a8d5ff 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 0 0 30px rgba(64, 156, 255, 0.4);
}

.spectator-text {
    color: #cbd5e1;
    font-size: 1.1rem;
    line-height: 1.5;
    margin: 0;
}

.spectator-btn {
    padding: 12px 30px;
    background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
    color: var(--text-primary);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(46, 204, 113, 0.4);
    position: relative;
    overflow: hidden;
}

.spectator-btn::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(var(--text-primary-rgb), 0.2), transparent);
    transform: rotate(45deg);
    transition: all 0.5s ease;
    opacity: 0;
}

.spectator-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(46, 204, 113, 0.6);
}

.spectator-btn:hover::after {
    opacity: 1;
    left: 100%;
}

.spectator-btn:disabled {
    background: #555;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.spectator-full-text {
    color: #e74c3c;
    font-weight: 700;
    font-size: 1.2rem;
    background: rgba(231, 76, 60, 0.1);
    padding: 10px 20px;
    border-radius: 8px;
    border: 1px solid rgba(231, 76, 60, 0.3);
}

/* Spectator Panel Styles - Integrated Single Panel */
#spectator-status-panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    background: transparent;
    backdrop-filter: none;
    border: none;
    box-shadow: none;
    animation: fadeIn 0.4s ease-out;
    gap: 12px;
    padding: 0;
    box-sizing: border-box;
    overflow: hidden;
}

.spectator-title {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 800;
    color: #38bdf8;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    opacity: 0.9;
}

.spectator-actions {
    width: 100%;
    display: flex;
    justify-content: center;
}

.premium-btn {
    background: linear-gradient(135deg, #0ea5e9 0%, #2563eb 100%);
    color: var(--text-primary);
    border: none;
    padding: 8px 18px;
    font-size: 0.85rem;
    font-weight: 700;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    transition: all 0.2s ease;
    letter-spacing: 0.01em;
}

.premium-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 15px rgba(37, 99, 235, 0.4);
    filter: brightness(1.1);
}

.premium-btn:active {
    transform: translateY(0);
}

.spectator-full-badge {
    background: rgba(var(--text-primary-rgb), 0.05);
    border: 1px solid rgba(var(--text-primary-rgb), 0.1);
    color: rgba(var(--text-primary-rgb), 0.6);
    padding: 6px 16px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
}

@keyframes slideUpFade {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulseIconSimple {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.8;
    }

    50% {
        transform: scale(1.1);
        opacity: 1;
    }
}

/* Modern Tabs for 24h Rooms */
.tabs-container {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
    background: rgba(0, 0, 0, 0.2);
    padding: 5px;
    border-radius: 10px;
}

.tab-btn {
    flex: 1;
    padding: 8px 4px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: rgba(var(--text-primary-rgb), 0.6);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.tab-btn:hover {
    background: rgba(var(--text-primary-rgb), 0.1);
    color: var(--text-primary);
}

.tab-btn.active {
    background: #2563eb;
    color: var(--text-primary);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

/* Clues Grid & Items */
.clues-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: 5px;
}

.clue-item {
    background: rgba(var(--text-primary-rgb), 0.04);
    border: 1px solid rgba(var(--text-primary-rgb), 0.1);
    border-radius: 8px;
    padding: 8px 6px;
    text-align: center;
    color: rgba(var(--text-primary-rgb), 0.95);
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 52px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.clue-prefix {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--accent-color);
    letter-spacing: 1px;
    margin-bottom: 1px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.clue-divider {
    width: 25%;
    height: 1px;
    background: rgba(var(--text-primary-rgb), 0.08);
    margin: 2px 0;
    border-radius: 1px;
}

.clue-stats {
    font-size: 0.72rem;
    opacity: 0.75;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.clue-item:hover {
    background: rgba(var(--text-primary-rgb), 0.07);
    border-color: rgba(var(--text-primary-rgb), 0.15);
    transform: translateY(-2px);
}

/* Previous Day Data Styling */
.word-item.prev-found {
    background: rgba(16, 185, 129, 0.15) !important;
    border: 1px solid rgba(16, 185, 129, 0.3) !important;
    color: #34d399 !important;
}

.word-item.prev-missed {
    background: rgba(244, 63, 94, 0.08) !important;
    border: 1px solid rgba(244, 63, 94, 0.15) !important;
    color: #fb7185 !important;
    opacity: 0.9;
}

[class*="theme-white"] .word-item.prev-missed,
[class*="theme-light-"] .word-item.prev-missed {
    color: #9f1239 !important;
}

/* --- SETTINGS PAGE --- */
.page-title-header {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0 0 20px 0;
    text-shadow: 0 4px 10px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 1400px;
    box-sizing: border-box;
    padding: 0;
    text-align: left;
}

#page-tools,
#page-settings,
#page-mods {
    display: none;
    flex-direction: column;
    align-items: center;
    padding: 15px 40px 40px 40px;
    color: var(--text-primary);
    overflow-y: auto;
    width: 100%;
    min-height: calc(100vh - 120px);
    box-sizing: border-box;
}

#page-tools.active,
#page-settings.active,
#page-mods.active {
    display: flex !important;
    opacity: 1 !important;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 30px;
    width: 100%;
    max-width: 1000px;
}

.setting-panel {
    background: rgba(var(--text-primary-rgb), 0.08);
    border: 1px solid rgba(var(--text-primary-rgb), 0.15);
    border-radius: 20px;
    /* Highly rounded as requested */
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    backdrop-filter: blur(15px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.setting-panel:hover {
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.setting-header {
    display: flex;
    flex-direction: column;
    gap: 5px;
    border-bottom: 1px solid rgba(var(--text-primary-rgb), 0.1);
    padding-bottom: 15px;
}

.setting-header:has(.toggle-switch) {
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
    cursor: pointer !important;
    transition: background-color 0.2s ease, opacity 0.2s ease;
}

.setting-header:has(.toggle-switch):hover {
    opacity: 0.85;
}

/* Custom Toggle Switch Styles */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 65px;  /* Increased size for premium readability & access */
    height: 36px; /* High-fidelity height */
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-switch .slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(var(--text-primary-rgb), 0.15);
    transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(var(--text-primary-rgb), 0.15);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.25);
}

.toggle-switch .slider::before {
    position: absolute;
    content: "";
    height: 28px; /* Prominent toggle knob size */
    width: 28px;
    left: 3px;
    bottom: 3px;
    background-color: #fff;
    transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

.toggle-switch input:checked + .slider {
    background-color: var(--accent-color, #ff007f);
    box-shadow: 0 0 15px rgba(255, 0, 127, 0.5); /* Neon glowing effect */
}

.toggle-switch input:focus + .slider {
    box-shadow: 0 0 1px var(--accent-color, #ff007f);
}

.toggle-switch input:checked + .slider::before {
    transform: translateX(29px); /* Adjusted movement path */
}

/* Rounded shape for sliders */
.toggle-switch .slider.round {
    border-radius: 36px;
}

.toggle-switch .slider.round::before {
    border-radius: 50%;
}

.setting-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: #e94560;
    letter-spacing: 0.5px;
}

.setting-desc {
    font-size: 0.95rem;
    opacity: 0.7;
    font-weight: 300;
}

/* Slider Style */
.setting-slider-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 10px 0;
}

.slider-label-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    opacity: 0.6;
    text-transform: uppercase;
    letter-spacing: 1px;
}

input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    background: transparent;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 28px;
    width: 28px;
    border-radius: 50%;
    background: #e94560;
    cursor: grab;
    margin-top: -10px;
    box-shadow: 0 0 15px rgba(233, 69, 96, 0.6);
    border: 2px solid #fff;
    transition: transform 0.1s;
}

input[type=range]::-webkit-slider-thumb:active {
    cursor: grabbing;
    transform: scale(1.1);
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 8px;
    cursor: pointer;
    background: var(--slider-track, rgba(var(--text-primary-rgb), 0.15));
    border-radius: 4px;
}

input[type=range]::-moz-range-track {
    width: 100%;
    height: 8px;
    cursor: pointer;
    background: var(--slider-track, rgba(var(--text-primary-rgb), 0.15));
    border-radius: 4px;
}

/* Preview Board Meter */
.preview-board-container {
    background: rgba(0, 0, 0, 0.25);
    padding: 30px;
    border-radius: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 250px;
    margin-top: 10px;
    overflow: hidden;
    border: 1px dashed rgba(var(--text-primary-rgb), 0.1);
}

.preview-board {
    display: inline-grid;
    /* Match game-board */
    gap: 4px;
    grid-template-columns: repeat(4, 1fr);
    background: rgba(0, 0, 0, 0.2);
    padding: 12px;
    border-radius: 12px;
}

.preview-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.3rem;
    color: #a8d5ff;
    font-weight: 700;
}

#clues-list {
    max-height: 72vh;
    overflow-y: auto;
    padding-right: 4px;
    scrollbar-width: thin;
    scrollbar-color: rgba(var(--text-primary-rgb), 0.3) transparent;
}

#clues-list::-webkit-scrollbar {
    width: 6px;
}

#clues-list::-webkit-scrollbar-track {
    background: transparent;
}

#clues-list::-webkit-scrollbar-thumb {
    background-color: rgba(var(--text-primary-rgb), 0.3);
    border-radius: 3px;
}

/* Leaderboard Styles */
.leaderboard-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    color: var(--text-primary);
    font-family: 'Outfit', sans-serif;
}

.lb-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    border-bottom: 1px solid rgba(var(--text-primary-rgb), 0.1);
    padding-bottom: 15px;
}

.lb-header h2 {
    font-size: 2rem;
    margin: 0;
    letter-spacing: 2px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent-color) 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.lb-tabs {
    display: flex;
    gap: 10px;
    background: rgba(var(--text-primary-rgb), 0.05);
    padding: 5px;
    border-radius: 12px;
    border: 1px solid rgba(var(--text-primary-rgb), 0.1);
}

.lb-tab {
    background: transparent;
    border: none;
    color: rgba(var(--text-primary-rgb), 0.6);
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.lb-tab:hover {
    color: var(--text-primary);
    background: rgba(var(--text-primary-rgb), 0.05);
}

.lb-tab.active {
    background: #409cff;
    color: var(--text-primary);
    box-shadow: 0 4px 12px rgba(64, 156, 255, 0.3);
}

.lb-controls-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 15px;
}

.lb-filters {
    display: flex;
    gap: 15px;
}

.lb-filters select {
    background: rgba(var(--text-primary-rgb), 0.05);
    border: 1px solid rgba(var(--text-primary-rgb), 0.1);
    color: var(--text-primary);
    padding: 10px 15px;
    border-radius: 8px;
    font-family: inherit;
    cursor: pointer;
    outline: none;
}

.lb-filters select:hover {
    border-color: rgba(var(--text-primary-rgb), 0.3);
}

.lb-search input {
    background: rgba(var(--text-primary-rgb), 0.05);
    border: 1px solid rgba(var(--text-primary-rgb), 0.1);
    padding: 10px 15px;
    border-radius: 8px;
    color: var(--text-primary);
    width: 250px;
    outline: none;
    transition: all 0.2s;
}

.lb-search input:focus {
    border-color: #409cff;
    box-shadow: 0 0 0 2px rgba(64, 156, 255, 0.2);
}

.lb-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 25px;
    margin-bottom: 40px;
}

.lb-card {
    background: var(--toast-bg);
    border: 1px solid rgba(var(--text-primary-rgb), 0.08);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    height: 425px;
    /* Reduced by half */
}

.lb-card-header {
    padding: 15px 20px;
    background: rgba(var(--text-primary-rgb), 0.03);
    border-bottom: 1px solid rgba(var(--text-primary-rgb), 0.05);
    font-weight: 800;
    letter-spacing: 1px;
    font-size: 0.9rem;
    color: rgba(var(--text-primary-rgb), 0.8);
    text-transform: uppercase;
}

.lb-table-wrapper {
    overflow-y: auto;
    flex: 1;
}

.lb-table {
    width: 100%;
    border-collapse: collapse;
}

.lb-table td {
    padding: 12px 15px;
    border-bottom: 1px solid rgba(var(--text-primary-rgb), 0.03);
    font-size: 0.95rem;
}

.lb-row:hover {
    background: rgba(var(--text-primary-rgb), 0.05);
}

.lb-row.highlight-search {
    background: rgba(64, 156, 255, 0.15);
    border-left: 3px solid #409cff;
}

.col-rank {
    width: 40px;
    font-family: 'JetBrains Mono', monospace;
    color: rgba(var(--text-primary-rgb), 0.4);
    font-weight: bold;
}



.col-val {
    text-align: right;
    font-weight: 800;
    font-size: 1.05rem;
}

.col-val.highlight {
    color: #4facfe;
}

.col-meta {
    text-align: right;
    font-size: 0.8rem;
    color: rgba(var(--text-primary-rgb), 0.5);
    width: 80px;
}

.col-date {
    text-align: right;
    font-size: 0.75rem;
    color: var(--text-40);
    width: 90px;
    white-space: nowrap;
    padding-left: 10px;
}

.col-action {
    width: 40px;
    text-align: center;
}

.lb-user-cell {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.lb-user-cell:hover .username {
    text-decoration: underline;
}

.lb-replay-btn {
    background: none;
    border: none;
    color: #409cff;
    cursor: pointer;
    opacity: 0.7;
    font-size: 1.2rem;
    padding: 0;
}

.lb-replay-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

.lb-loading {
    padding: 50px;
    text-align: center;
    color: rgba(var(--text-primary-rgb), 0.5);
    font-style: italic;
    grid-column: 1 / -1;
}

.lb-attribution {
    text-align: center;
    font-size: 0.8rem;
    color: rgba(var(--text-primary-rgb), 0.3);
    margin-top: 20px;
}


/* Local Card Search */
.lb-card-search {
    display: flex;
    align-items: center;
    gap: 5px;
}

.lb-local-input {
    background: rgba(var(--text-primary-rgb), 0.05);
    border: 1px solid rgba(var(--text-primary-rgb), 0.1);
    color: var(--text-primary);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    width: 100px;
}

.lb-local-btn {
    background: #409cff;
    color: var(--text-primary);
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
}

.lb-local-btn:hover {
    background: #2980b9;
}

.lb-local-msg {
    font-size: 0.7rem;
    margin-left: 5px;
}

@media (max-width: 992px) {
    .leaderboard-container {
        padding: 10px 0 !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .lb-grid {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
        width: 100% !important;
        box-sizing: border-box !important;
        min-width: 0 !important;
    }

    .lb-card {
        width: 100% !important;
        box-sizing: border-box !important;
        min-width: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        height: auto !important;
        max-height: 450px !important;
    }

    .lb-card-header {
        padding: 12px 10px !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px !important;
        width: 100% !important;
        box-sizing: border-box !important;
        min-width: 0 !important;
    }

    .lb-card-header-text {
        width: 100% !important;
        white-space: normal !important;
        line-height: 1.2 !important;
    }

    .lb-card-search {
        width: 100% !important;
        box-sizing: border-box !important;
        min-width: 0 !important;
        justify-content: space-between !important;
        flex-wrap: wrap !important;
    }

    .lb-local-input {
        width: 120px !important;
        flex: 1 !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
        font-size: 16px !important; /* Prevent iOS Safari Zoom on Focus */
    }

    .lb-table-wrapper {
        width: 100% !important;
        box-sizing: border-box !important;
        min-width: 0 !important;
        overflow-x: auto !important; /* Guarantee internal table scroll if needed, but table fits perfectly */
    }

    .lb-table {
        width: 100% !important;
        table-layout: auto !important;
        box-sizing: border-box !important;
        min-width: 0 !important;
    }

    .lb-table td {
        padding: 8px 6px !important;
        font-size: 0.85rem !important;
        box-sizing: border-box !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    .lb-table td.col-rank {
        width: 30px !important;
        min-width: 30px !important;
    }

    .lb-table td.col-user {
        max-width: 120px !important;
    }

    .lb-table td.col-user .username {
        max-width: 80px !important;
        display: inline-block !important;
        vertical-align: middle !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }

    .lb-table td.col-val {
        font-size: 0.9rem !important;
        max-width: none !important;
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: unset !important;
    }

    .lb-table td.col-meta {
        width: 50px !important;
        font-size: 0.75rem !important;
    }

    .lb-table td.col-date {
        width: 50px !important;
        font-size: 0.7rem !important;
        padding-left: 4px !important;
    }

    .lb-table td.col-action {
        width: 25px !important;
    }

    .lb-controls-row {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
        width: 100% !important;
        box-sizing: border-box !important;
        min-width: 0 !important;
    }

    .lb-filters {
        flex-wrap: wrap !important;
        gap: 8px !important;
        width: 100% !important;
        box-sizing: border-box !important;
        min-width: 0 !important;
    }

    .lb-filters select {
        flex: 1 1 30% !important;
        min-width: 0 !important;
        padding: 8px 10px !important;
        font-size: 0.8rem !important;
        box-sizing: border-box !important;
    }

    .lb-search {
        width: 100% !important;
        box-sizing: border-box !important;
        min-width: 0 !important;
    }

    .lb-search input {
        width: 100% !important;
        box-sizing: border-box !important;
        min-width: 0 !important;
        font-size: 16px !important; /* Prevent iOS Safari Zoom */
    }
}

/* Personal Timer /* Winner Celebration Pulse (Golden) */
@keyframes winnerAlertPulse {
    0% {
        background-color: rgba(255, 215, 0, 0.2);
        box-shadow: inset 0 0 40px rgba(255, 215, 0, 0.3);
    }
    50% {
        background-color: rgba(255, 215, 0, 0.5);
        box-shadow: inset 0 0 80px rgba(255, 215, 0, 0.6);
    }
    100% {
        background-color: rgba(255, 215, 0, 0.2);
        box-shadow: inset 0 0 40px rgba(255, 215, 0, 0.3);
    }
}

.winner-flash {
    animation: winnerAlertPulse 2.5s infinite ease-in-out !important;
    background-image: none !important;
}

.winner-flash * {
    color: #ffffff !important;
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.9);
}

/* Personal Timer Styles */
@keyframes timerAlertPulse {
    0% {
        background-color: rgba(255, 0, 0, 0.4);
        box-shadow: inset 0 0 50px rgba(255, 0, 0, 0.6);
    }
    50% {
        background-color: rgba(255, 0, 0, 0.8);
        box-shadow: inset 0 0 100px rgba(255, 0, 0, 1);
    }
    100% {
        background-color: rgba(255, 0, 0, 0.4);
        box-shadow: inset 0 0 50px rgba(255, 0, 0, 0.6);
    }
}

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

.timer-flash {
    animation: timerAlertPulse 2s infinite ease-in-out !important;
    background-image: none !important;
}

.timer-flash * {
    color: #ffffff !important;
    text-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
}
/* 3D Cube Styles */
:root {
    --cube-face-size: 220px;
    --cube-half-size: 110px; /* S/2 */
    --cube-container-size: 320px;
    --cube-cell-font-size: calc(var(--cube-face-size) * 0.175);
}

.cube-container {
    perspective: 1200px;
    perspective-origin: 50% 50%;
    width: var(--cube-container-size);
    height: var(--cube-container-size);
    margin: 20px auto;
    position: relative;
    user-select: none;
    display: block;
    max-width: 95vw;
    box-sizing: border-box;
}

.cube {
    width: 100%;
    height: 100%;
    position: absolute;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform: rotateX(-25deg) rotateY(45deg); /* Default isometric view */
}

.cube-face {
    position: absolute;
    width: var(--cube-face-size);
    height: var(--cube-face-size);
    border: 3px solid rgba(0, 0, 0, 0.4); 
    background: rgba(255, 255, 255, 0.98);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 8px;
    padding: 10px;
    box-sizing: border-box;
    backface-visibility: visible;
    /* Center the face in the container */
    left: calc((var(--cube-container-size) - var(--cube-face-size)) / 2);
    top: calc((var(--cube-container-size) - var(--cube-face-size)) / 2);
    box-shadow: inset 0 0 40px rgba(0,0,0,0.1), 0 5px 25px rgba(0,0,0,0.2);
}

/* Face positions using half-size for translation */
.face-front  { transform: rotateY(  0deg) translateZ(var(--cube-half-size)); }
.face-back   { transform: rotateY(180deg) translateZ(var(--cube-half-size)); }
.face-right  { transform: rotateY( 90deg) translateZ(var(--cube-half-size)); }
.face-left   { transform: rotateY(-90deg) translateZ(var(--cube-half-size)); }
.face-top    { transform: rotateX( 90deg) translateZ(var(--cube-half-size)); }
.face-bottom { transform: rotateX(-90deg) translateZ(var(--cube-half-size)); }

.cube-cell {
    background: rgba(0, 0, 0, 0.03) !important;
    border: 1px solid #000 !important;
    border-radius: 6px;
    display: flex !important;
    align-items: center;
    justify-content: center;
    position: relative !important;
    font-size: var(--cube-cell-font-size) !important;
    font-weight: 900;
    width: auto !important; /* OVERRIDE .board-cell */
    height: auto !important; /* OVERRIDE .board-cell */
    margin: 0 !important;
    color: #111;
    cursor: pointer;
    pointer-events: auto !important;
    transition: all 0.2s ease;
    text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000 !important;
}

.cube-cell:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: #ffd700;
    transform: translateZ(5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.4);
}

.cube-cell.active {
    background: linear-gradient(135deg, #ffd700, #ffb700);
    color: #000;
    border-color: #fff;
    box-shadow: 0 0 25px rgba(255, 215, 0, 0.6);
    transform: translateZ(10px);
    text-shadow: none;
}

.cube-cell.flash-valid {
    animation: cube-success-pulse 0.8s ease-out forwards;
}

@keyframes cube-success-pulse {
    0% { background: #4ade80; transform: scale(1.1) translateZ(20px); box-shadow: 0 0 30px #4ade80; }
    100% { background: rgba(255, 255, 255, 0.05); transform: scale(1) translateZ(0); }
}

/* Arrow controls helper text */
.cube-hint {
    display: none;
}

.cube-rotate-hint {
    margin-top: 10px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-primary);
    opacity: 0.6;
    letter-spacing: 2px;
    text-transform: uppercase;
    text-align: center;
}

.cube-rotate-hint.hidden {
    display: none;
}

/* Cube Cell Synesthesia */
.cube-cell[data-letter*="A"] { color: var(--letter-A-color, #111111) !important; }
.cube-cell[data-letter*="B"] { color: var(--letter-B-color, #111111) !important; }
.cube-cell[data-letter*="C"] { color: var(--letter-C-color, #111111) !important; }
.cube-cell[data-letter*="D"] { color: var(--letter-D-color, #111111) !important; }
.cube-cell[data-letter*="E"] { color: var(--letter-E-color, #111111) !important; }
.cube-cell[data-letter*="F"] { color: var(--letter-F-color, #111111) !important; }
.cube-cell[data-letter*="G"] { color: var(--letter-G-color, #111111) !important; }
.cube-cell[data-letter*="H"] { color: var(--letter-H-color, #111111) !important; }
.cube-cell[data-letter*="I"] { color: var(--letter-I-color, #111111) !important; }
.cube-cell[data-letter*="J"] { color: var(--letter-J-color, #111111) !important; }
.cube-cell[data-letter*="K"] { color: var(--letter-K-color, #111111) !important; }
.cube-cell[data-letter*="L"] { color: var(--letter-L-color, #111111) !important; }
.cube-cell[data-letter*="M"] { color: var(--letter-M-color, #111111) !important; }
.cube-cell[data-letter*="N"] { color: var(--letter-N-color, #111111) !important; }
.cube-cell[data-letter*="O"] { color: var(--letter-O-color, #111111) !important; }
.cube-cell[data-letter*="P"] { color: var(--letter-P-color, #111111) !important; }
.cube-cell[data-letter*="Q"] { color: var(--letter-Q-color, #111111) !important; }
.cube-cell[data-letter*="R"] { color: var(--letter-R-color, #111111) !important; }
.cube-cell[data-letter*="S"] { color: var(--letter-S-color, #111111) !important; }
.cube-cell[data-letter*="T"] { color: var(--letter-T-color, #111111) !important; }
.cube-cell[data-letter*="U"] { color: var(--letter-U-color, #111111) !important; }
.cube-cell[data-letter*="V"] { color: var(--letter-V-color, #111111) !important; }
.cube-cell[data-letter*="W"] { color: var(--letter-W-color, #111111) !important; }
.cube-cell[data-letter*="X"] { color: var(--letter-X-color, #111111) !important; }
.cube-cell[data-letter*="Y"] { color: var(--letter-Y-color, #111111) !important; }
.cube-cell[data-letter*="Z"] { color: var(--letter-Z-color, #111111) !important; }

/* Bonus Indicator Tags (Word List) */
.list-bonus-tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    color: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    flex-shrink: 0;
}

.bonus-cell-tag {
    background: #32cd32; /* Lime green */
    border: 1px solid #28a428;
}

.bonus-word-tag {
    background: #ffd700; /* Gold */
    color: #000;
    border: 1px solid #daa520;
}

.eo-tag {
    background: #ff4500; /* OrangeRed */
    border: 1px solid #cc3700;
}

.bl-tag {
    background: #32cd32; /* Lime green */
    border: 1px solid #28a428;
}

.points-math {
    white-space: nowrap;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.95rem;
    font-weight: 800;
    color: #fff;
    background: rgba(0, 0, 0, 0.45);
    padding: 3px 10px;
    border-radius: 6px;
    flex-shrink: 0; /* USER REQUEST: Never squish the math breakdown */
    margin-left: auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.word-item {
    display: flex !important;
    flex-wrap: wrap !important; /* USER REQUEST: Allow content to occupy a second line */
    justify-content: space-between !important;
    align-items: center !important;
    gap: 6px 14px !important;
    cursor: pointer;
    padding: 10px 14px !important;
    min-width: 0;
}

.word-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: auto;
    flex: 1 1 auto;
}

.word-text {
    font-size: 1.15rem;
    font-weight: 700;
    white-space: normal; /* No more ellipsis truncation */
    overflow: visible;
    min-width: 0;
    line-height: 1.2;
    word-break: break-all; /* Break extremely long words if needed */
}

.found-indicator, .list-bonus-tag {
    flex-shrink: 0;
}

/* Tablet & Smaller Mac Device Scaling for Play Page */
@media (max-width: 1200px) {
    :root {
        --cell-size: 50px; /* Scale board cells down gracefully on small displays */
    }
    .play-grid {
        --left-panel-w: 320px;
        --right-panel-w: 380px;
    }
}

@media (max-width: 992px) {
    :root {
        --cell-size: 45px;
    }
    /* Extra safety for very narrow screens (e.g. iPhone SE) */
    @media (max-width: 380px) {
        :root {
            --cell-size: 40px;
        }
    }
    .play-grid {
        display: flex !important;
        flex-direction: row !important;
        grid-template-columns: none !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        scroll-snap-type: x mandatory !important;
        scroll-padding: 0 !important;
        -webkit-overflow-scrolling: touch !important;
        scroll-behavior: smooth !important;
        gap: 0 !important;
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100% !important; /* Take full height of container */
        padding: 0 !important;
        margin: 0 !important;
        /* Hide scrollbar */
        scrollbar-width: none !important;
        -ms-overflow-style: none !important;
    }
    .play-grid::-webkit-scrollbar {
        display: none !important;
    }

    #page-play.active {
        height: 100vh !important;
        height: 100dvh !important;
        overflow-y: hidden !important;
        overflow-x: hidden !important;
        padding: 0 !important;
        margin: 0 !important;
        width: 100vw !important;
        max-width: 100vw !important;
    }

    .left-panel-container, 
    .board-panel, 
    .words-panel {
        flex: 0 0 100% !important;
        width: 100% !important;
        min-width: 100% !important;
        max-width: 100% !important;
        scroll-snap-align: start !important;
        scroll-snap-stop: always !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        height: 100% !important; /* Take full height of play-grid */
        padding: 10px 10px 0 10px !important; /* Remove bottom padding to let buttons touch bottom */
        margin: 0 !important;
        position: relative !important;
        box-shadow: none !important;
        border: none !important;
        clip-path: inset(0);
        /* Prevent sub-pixel bleeding on iOS */
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
        
        /* Force flex column layout to allow stretching children */
        display: flex !important;
        flex-direction: column !important;
    }

    /* USER REQUEST: Make Words and Definitions panels touch on mobile */
    .words-panel {
        gap: 0 !important;
    }
    .words-panel .words-table-box {
        border-radius: 12px !important;
    }
    .words-panel .definitions-panel {
        border-radius: 12px !important;
    }

    /* USER REQUEST: Make Players and Chat panels touch on mobile */
    .left-panel-container {
        gap: 0 !important;
    }
    /* Sleek premium rating bar inside mobile left panel */
    .left-panel-container #game-color-bar {
        margin-bottom: 10px !important;
        border-radius: 6px !important;
        overflow: hidden !important;
        height: 14px !important;
        border: none !important;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15) !important;
    }
    .left-panel-container .players-panel {
        border-radius: 12px !important;
    }
    .left-panel-container .chat-panel {
        border-radius: 12px !important;
    }

    .play-header {
        padding: 8px 12px !important;
        margin-bottom: 10px !important;
        border-radius: 12px !important;
        height: auto !important;
        width: 100% !important; /* Expand horizontally to full width */
        box-sizing: border-box !important;
        
        /* Use Flex Column to strictly enforce stacking order */
        display: flex !important;
        flex-direction: column !important;
        gap: 10px !important;
        align-items: center !important;
        position: relative !important; /* For absolute positioning of return button */
    }
    .header-title-group {
        display: flex !important;

        align-items: center !important;
        gap: 8px !important;
        justify-content: center !important;
        width: 100% !important;
        padding-right: 100px !important; /* Leave space for return button on right */
        box-sizing: border-box !important;
        order: 1 !important; /* Force first */
    }
    .header-title-group h2 {
        font-size: 1rem !important;
        margin: 0 !important;
    }
    .header-meta {
        font-size: 0.9rem !important;
        opacity: 0.8 !important;
        white-space: nowrap !important;
    }
    .play-header .return-btn {
        position: absolute !important;
        top: 8px !important;
        right: 8px !important;
        margin: 0 !important;
        font-size: 0.8rem !important;
        padding: 5px 10px !important;
        z-index: 5 !important;
    }
    .spinner-set-label {
        display: block !important;
    }
    .timer-display {
        display: grid !important;
        grid-template-columns: 1fr auto 1fr !important; /* True centering for middle item */
        align-items: center !important;
        min-width: 320px !important; /* Make it longer horizontally */
        width: auto !important;
        margin: 5px auto !important; /* Center the box itself and add small margin */
        padding: 5px 15px !important;
        order: 3 !important; /* Force third (below params) */
    }
    .timer-display .timer-label {
        justify-self: start !important;
    }
    .timer-display .timer-value {
        justify-self: center !important;
        min-width: auto !important; /* Remove the large 220px min-width on mobile */
        font-size: 1.5rem !important; /* Slightly smaller but still readable */
    }
    .timer-display .rotate-btn,
    .timer-display #toggle-board-btn {
        justify-self: end !important;
    }


    .game-params {
        font-size: 0.85rem;
        text-align: center !important;
        display: flex !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 4px 8px !important;
        width: 100% !important;
        order: 2 !important; /* Force second (below title) */
    }



    .players-panel {
        height: auto !important;
        min-height: 350px !important; /* Made larger to give more space to players list */
        max-height: none !important;
        flex: 1 !important; /* Grow to fill space */
    }

    .words-table-box {
        height: auto !important; /* Allow it to flex */
        flex: 1 1 0% !important; /* Allow it to shrink if needed */
        max-height: none !important;
    }
    .chat-panel {
        height: 200px !important; /* Made smaller to give more space to players list */
        flex: none !important;
        max-height: none !important;
        margin-top: 15px !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important; /* Prevent content from overflowing or stretching the box */
    }






    .definitions-panel {
        flex: 0 0 150px !important; /* Give more space to definitions panel */
        max-height: none !important;
        margin-top: 15px !important;
    }


    .board-panel {
        height: auto !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: flex-start !important;
    }
    /* Hide word input section on mobile as requested */
    .word-input-section {
        display: none !important;
    }

    /* Style the rotate button when it is inside the timer on mobile */
    .timer-display .rotate-btn,
    .timer-display #toggle-board-btn {
        margin-left: auto !important; /* Push it to the far right of the flex container */
        padding: 2px 8px !important; /* Smaller padding to prevent spill */
        font-size: 0.75rem !important; /* Smaller text */
        height: auto !important;
        line-height: 1.2 !important; /* Prevent vertical expansion */
        box-sizing: border-box !important;
        border-radius: 4px !important;
        background: rgba(var(--text-primary-rgb), 0.2) !important;
        border: 1px solid rgba(var(--text-primary-rgb), 0.3) !important;
        color: var(--text-primary) !important;
        cursor: pointer !important;
        align-self: center !important; /* Center vertically */
    }

    /* Remove the vertical stacking order as we are now a horizontal carousel */
    .players-panel, .board-panel, .words-table-box, .definitions-panel, .chat-panel {
        order: unset !important;
    }
}

/* Widescreen Desktop / PC scaling to stretch panels and board cells nicely */

/* Standard Widescreen (min-width: 1400px) */
@media (min-width: 1400px) {
    :root {
        --cell-size: 64px; /* Slightly larger board cells for better legibility */
    }
    .play-grid {
        --left-panel-w: 440px;
        --right-panel-w: 480px;
        gap: 16px !important;
    }
    .player-item {
        padding: 10px 18px !important;
        height: 68px !important;
        gap: 6px !important;
    }
    #players-list {
        gap: 10px !important;
        max-height: none !important;
    }
}

/* Big Desktop Monitors / Large Laptops (min-width: 1600px) */
@media (min-width: 1600px) {
    :root {
        --cell-size: 68px; /* Prominent board cells */
        --chat-font-size: 14px !important;
        --def-font-size: 16px !important;
    }
    .play-grid {
        --left-panel-w: 480px;
        --right-panel-w: 520px;
        gap: 20px !important;
    }
    .player-item {
        padding: 12px 20px !important;
        height: 74px !important;
        gap: 8px !important;
    }
    #players-list {
        gap: 12px !important;
        max-height: none !important;
    }
}

/* Extremely Large / Ultra-wide PC Monitors (min-width: 1920px) */
@media (min-width: 1920px) {
    :root {
        --cell-size: 72px; /* Large, gorgeous high-fidelity board */
        --chat-font-size: 15px !important;
        --def-font-size: 17px !important;
    }
    .play-grid {
        --left-panel-w: 520px; /* Tons of space for users and scores */
        --right-panel-w: 560px; /* Massive space for words list and tabs */
        gap: 24px !important;
    }
    .player-item {
        padding: 14px 24px !important;
        height: 80px !important;
        gap: 10px !important;
        font-size: 1rem !important;
    }
    #players-list {
        gap: 14px !important;
        max-height: 600px !important;
    }
}

/* PC Widescreen Horizonal Space Overrides */
@media (min-width: 1400px) {
    .tool-header,
    .combo-control-panel,
    .profile-container,
    .profile-content-tabs,
    .seq-results-container,
    .combo-results-container,
    .lists-container,
    .random-word-container,
    .wotd-container,
    .manual-grid-scroll,
    .manual-grid {
        max-width: 1600px;
    }
    
    .leaderboard-container {
        max-width: 1600px;
    }

    .settings-grid {
        max-width: 1400px !important; /* Expand settings panels horizontally on PC */
    }
}

/* Tools split-layout mobile responsiveness (sub-nav moves to top row, content spans full-width) */
@media (max-width: 900px) {
    .faq-scoring-table th,
    .faq-scoring-table td {
        padding: 4px 4px !important;
        font-size: 0.7em !important;
    }
    .faq-table-container {
        overflow-x: auto !important;
        max-width: 100% !important;
    }


    .tools-split-layout {
        display: flex !important;
        flex-direction: row !important;
        overflow-x: auto !important;
        scroll-snap-type: x mandatory !important;
        -webkit-overflow-scrolling: touch !important;
        scroll-behavior: smooth !important;
        gap: 0 !important;
        width: 100% !important;
        height: calc(100vh - 120px) !important;
        box-sizing: border-box !important;
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
        background: transparent !important;
        border: none !important;
    }

    .tools-sidebar,
    .tools-content {
        flex: 0 0 100% !important;
        width: 100% !important;
        min-width: none !important;
        max-width: none !important;
        scroll-snap-align: center !important;
        scroll-snap-stop: always !important;
        height: 100% !important;
        box-sizing: border-box !important;
        overflow-y: auto !important;
    }

    .tools-sidebar {
        flex-direction: column !important;
        border-right: none !important;
        border-bottom: none !important;
        padding: 15px !important;
        gap: 10px !important;
        background: var(--bg-panel) !important;
    }

    .tool-nav-btn {
        width: 100% !important;
        text-align: left !important;
        padding: 12px 16px !important;
        font-size: 1rem !important;
        box-sizing: border-box !important;
    }

    .tools-content {
        padding: 15px !important;
    }

    #tools-mobile-back-btn {
        display: inline-block !important;
    }

    /* Responsive input rows for all tools */
    .input-row {
        flex-direction: column !important;
        align-items: stretch !important;
        width: 100% !important;
        gap: 8px !important;
    }
    .input-row > input,
    .input-row > select,
    .input-row > button {
        width: 100% !important;
        box-sizing: border-box !important;
        padding: 12px !important;
        height: auto !important;
    }

    /* Random Word / Is Valid Mobile Fixes */
    .random-word-large {
        font-size: clamp(1.2rem, 8vw, 2.5rem) !important;
        letter-spacing: 1px !important;
    }
    .random-word-container {
        padding: 15px !important;
        min-height: auto !important;
    }
    #valid-definition-display {
        max-width: 100% !important;
        font-size: 1rem !important;
    }
    #random-word-definition .pronunciation {
        font-size: 1.1rem !important;
        letter-spacing: 1px !important;
    }
    #random-word-definition .definition-text {
        font-size: 1rem !important;
        max-width: 100% !important;
    }

    /* Unscramble Tool Mobile Fixes */
    #tool-unscramble .input-row {
        flex-direction: column !important;
        align-items: stretch !important;
        width: 100% !important;
        gap: 8px !important;
    }
    #tool-unscramble .input-row > input,
    #tool-unscramble .input-row > select,
    #tool-unscramble .input-row > button {
        width: 100% !important;
        box-sizing: border-box !important;
    }
    .unscramble-container {
        flex-direction: column !important;
        height: auto !important;
        gap: 20px !important;
    }
    #unscramble-found-container {
        width: 100% !important;
        height: auto !important;
        max-height: none !important;
    }
    .unscramble-game-area {
        width: 100% !important;
        height: auto !important;
        padding: 20px !important;
        transition: padding 0.3s ease, gap 0.3s ease;
    }
    #unscramble-jumbled {
        font-size: 2.5rem !important;
        letter-spacing: 5px !important;
        transition: font-size 0.3s ease, margin-bottom 0.3s ease;
    }
    .unscramble-game-area:focus-within {
        padding: 10px 15px !important;
        gap: 8px !important;
    }
    .unscramble-game-area:focus-within #unscramble-jumbled {
        font-size: 1.8rem !important;
        margin-bottom: 0 !important;
        letter-spacing: 3px !important;
    }
    .unscramble-game-area:focus-within #unscramble-count-info {
        display: none !important;
    }
    .unscramble-game-area:focus-within .input-dashboard {
        margin-top: 5px !important;
        gap: 8px !important;
    }

    /* Word of the Day Mobile Fixes */
    .wotd-gold-showy {
        font-size: clamp(1.2rem, 8vw, 2.5rem) !important;
        letter-spacing: 1px !important;
    }
    .wotd-definition {
        font-size: 1rem !important;
        max-width: 100% !important;
        margin-top: 15px !important;
    }

    /* Combo input padding fix */
    #combo-input {
        padding: 12px 15px !important;
        font-size: 1.1rem !important;
    }

    /* Combo Checker MP Tables Vertical Height Fix for Mobile */
    .combo-results-container {
        overflow-y: visible !important;
        height: auto !important;
    }

    /* Sequence and Subanagrams Tool Results Vertical Height Fix for Mobile */
    .seq-results-container {
        height: 380px !important;
        max-height: 380px !important;
        flex: 0 0 auto !important;
        margin-top: 15px !important;
        margin-bottom: 15px !important;
        overflow-y: hidden !important;
    }
    .result-section,
    .result-section:first-child,
    .result-section:nth-child(1),
    .result-section:nth-child(2) {
        flex: 0 0 auto !important;
        height: auto !important;
        min-height: auto !important;
        overflow: visible !important;
    }
    .horizontal-scroll-container {
        height: 260px !important;
        min-height: 260px !important;
    }
    .group-column {
        height: 100% !important;
        max-height: 240px !important;
    }
    .group-table-container {
        max-height: 200px !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    /* Profile layout stack vertically on mobile */
    .profile-layout {
        flex-direction: column !important;
        align-items: center !important;
        gap: 20px !important;
    }
    .profile-left-column {
        width: 100% !important;
    }
    .profile-avatar-container {
        width: 120px !important;
        height: 120px !important;
        border-radius: 20px !important;
    }
    .profile-avatar.large {
        width: 120px !important;
        height: 120px !important;
        font-size: 3rem !important;
        border-radius: 20px !important;
    }
    .profile-username-large {
        font-size: 2.2rem !important;
        text-align: center !important;
    }
    .profile-quote-minimal {
        text-align: center !important;
    }
    .profile-metadata-row {
        justify-content: center !important;
        gap: 8px !important;
        margin-bottom: 20px !important;
    }

    /* Profile stats grid responsive columns */
    .profile-stats-grid {
        grid-template-columns: repeat(2, 1fr) !important; /* Stacks cleanly in pairs */
        gap: 8px !important;
    }
    .stat-box {
        padding: 10px !important;
    }
    .stat-num {
        font-size: 1.1rem !important;
    }

    /* profile-tabs-header styling on mobile scroll */
    .profile-tabs-header {
        display: flex !important;
        flex-direction: row !important;
        overflow-x: auto !important;
        white-space: nowrap !important;
        gap: 6px !important;
        scrollbar-width: none !important;
    }
    .profile-tabs-header::-webkit-scrollbar {
        display: none !important;
    }
    .profile-tab-toggle {
        flex-shrink: 0 !important;
        padding: 8px 12px !important;
        font-size: 0.8rem !important;
    }

    /* Personal Timer numbers size */
    #timer-hours, #timer-minutes {
        width: 80px !important;
        height: 60px !important;
        font-size: 1.8rem !important;
    }
    #tool-timer .combo-control-panel {
        padding: 15px !important;
        border-radius: 12px !important;
    }
    #timer-start-btn, #timer-stop-btn {
        height: 50px !important;
        font-size: 1.2rem !important;
        border-radius: 10px !important;
    }
    #timer-display-container {
        padding: 20px !important;
        margin-top: 20px !important;
        border-radius: 12px !important;
    }
    #timer-countdown-display {
        font-size: 3rem !important;
    }
    #tool-timer .input-row:first-child {
        flex-direction: row !important;
        justify-content: center !important;
        align-items: center !important;
        gap: 15px !important;
    }
    #tool-timer .input-row:first-child > div {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
    }

    /* Manual solver grid scale */
    .manual-cell {
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 1 !important;
        font-size: 1.4rem !important;
        padding: 0 !important;
        text-align: center !important;
    }
    .manual-grid-scroll {
        padding: 10px !important;
    }

    /* Chart descriptions and titles font sizes */
    .result-section h3 {
        font-size: 0.9rem !important;
    }
    .chart-desc {
        font-size: 0.75rem !important;
    }

    /* Leaderboard Times row placement on mobile */
    .lb-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 15px !important;
        margin-bottom: 20px !important;
    }
    .lb-tabs {
        width: 100% !important;
        overflow-x: auto !important; /* Allow scroll if extremely narrow */
        white-space: nowrap !important;
        scrollbar-width: none !important;
        display: flex !important;
    }
    .lb-tabs::-webkit-scrollbar {
        display: none !important;
    }
    .lb-tab {
        flex: 1 !important;
        text-align: center !important;
        padding: 8px 10px !important;
        font-size: 0.8rem !important;
    }

    /* Round Replay Overlay readability overhaul on mobile */
    .history-review-modal {
        width: 100% !important;
        height: 100% !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
        border: none !important;
    }

    .history-review-layout {
        overflow-y: auto !important;
        display: block !important;
        height: calc(100vh - 70px) !important;
    }

    .history-review-main {
        display: flex !important;
        flex-direction: column-reverse !important; /* Stack vertically with board at top and walkthrough at bottom */
        padding: 15px !important;
        gap: 20px !important;
        overflow-y: visible !important;
    }

    .review-board-main {
        width: 100% !important;
        padding: 15px !important;
        border-radius: 16px !important;
        margin-bottom: 10px !important;
    }

    .history-walkthrough-section {
        width: 100% !important;
        height: auto !important;
        flex: none !important;
    }

    .walkthrough-list {
        max-height: none !important; /* Expand full list in vertical scroll */
        min-height: auto !important;
        overflow-y: visible !important;
    }

    .walkthrough-item {
        padding: 12px 0 !important;
        gap: 12px !important;
    }

    .walkthrough-time {
        font-size: 0.85rem !important;
        min-width: 55px !important;
    }

    .walkthrough-word {
        font-size: 1.1rem !important;
    }

    .walkthrough-points {
        font-size: 0.85rem !important;
    }

    .history-review-modal .overlay-header {
        padding: 15px 20px !important;
    }
    
    .header-main h2 {
        font-size: 1.5rem !important;
    }

    /* Mobile: Timeline heading on its own row, Watch Replay + hint side-by-side below */
    .history-walkthrough-section .section-header {
        gap: 14px !important;
        margin-bottom: 20px !important;
        padding: 16px !important;
        background: rgba(255,255,255,0.04) !important;
        border-radius: 14px !important;
        border: 1px solid rgba(255,255,255,0.08) !important;
    }

    .history-walkthrough-section .section-header h3 {
        font-size: 1.1rem !important;
        margin: 0 !important;
        padding-bottom: 12px !important;
        border-bottom: 1px solid rgba(255,255,255,0.1) !important;
    }

    .history-walkthrough-section .replay-subheader {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 12px !important;
        flex-wrap: nowrap !important;
        padding: 10px 14px !important;
        background: rgba(255,255,255,0.06) !important;
        border-radius: 10px !important;
    }

    .history-walkthrough-section .section-hint {
        font-size: 0.75rem !important;
        text-align: right !important;
        max-width: 45% !important;
        line-height: 1.4 !important;
        padding-left: 8px !important;
    }

    .history-walkthrough-section .replay-controls {
        flex-shrink: 0 !important;
    }


    /* Mobile overrides for page-tools, page-settings, page-mods, page-lobby, and page-forums */
    #page-tools,
    #page-settings,
    #page-mods,
    #page-lobby,
    #page-forums {
        display: none;
        padding-left: 0 !important;
        padding-right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
        padding: 0 !important;
        height: calc(100vh - 120px) !important;
        overflow-y: hidden !important;
        flex-direction: column !important;
    }

    #page-tools.active,
    #page-settings.active,
    #page-mods.active,
    #page-lobby.active,
    #page-forums.active {
        display: flex !important;
    }

    #page-tools .tools-split-layout,
    #page-settings .tools-split-layout,
    #page-mods .tools-split-layout,
    #page-lobby .lobby-grid,
    #page-forums .forum-container {
        flex: 1 !important;
        min-height: 0 !important;
        height: auto !important;
    }

    /* Keep header locked on mobile for Profile, Donate, Leaderboards, and Tournaments */
    #page-profile,
    #page-donate,
    #page-leaderboards,
    #page-tournaments {
        display: none;
        padding-left: 0 !important;
        padding-right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
        padding: 10px 15px !important;
        height: calc(100vh - 120px) !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    #page-profile.active,
    #page-donate.active,
    #page-leaderboards.active,
    #page-tournaments.active {
        display: block !important;
    }

    #page-leaderboards {
        padding: 10px 6px !important;
    }
}

/* Mobile full-bleed board styling */
@media (max-width: 992px) {
    body, html {
        overflow-x: hidden !important;
        max-width: 100vw !important;
        width: 100% !important;
        box-sizing: border-box !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    #page-play {
        padding-left: 0 !important;
        padding-right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        overflow-x: visible !important;
    }

    .page-title-header {
        padding: 0 15px !important;
        margin: 15px 0 !important;
        font-size: 1.8rem !important;
    }

    .settings-grid {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
    }

    .setting-panel {
        padding: 20px !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
    }

    /* Carousel panels already defined above */

    /* Keep side spacing for non-board panels so content is snug and elegant */
    .players-panel,
    .definitions-panel,
    .chat-panel {
        margin-left: 10px !important;
        margin-right: 10px !important;
        width: calc(100% - 20px) !important;
        max-width: calc(100% - 20px) !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
    }

    .players-panel {
        overflow-x: hidden !important;
    }

    .player-actions-row {
        gap: 4px !important;
        width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
    }

    .player-actions-row .find-me-btn {
        font-size: 0.7rem !important;
        padding: 6px 2px !important;
        letter-spacing: 0 !important;
        white-space: normal !important;
        line-height: 1.1 !important;
        height: auto !important;
        min-height: 28px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
        box-sizing: border-box !important;
        min-width: 0 !important;
    }

    #players-list {
        width: 100% !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
    }

    .player-item {
        width: 100% !important;
        box-sizing: border-box !important;
        min-width: 0 !important;
        padding: 6px 10px !important;
        overflow: hidden !important;
    }



    .player-row-top,
    .player-row-bottom {
        min-width: 0 !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .player-username {
        min-width: 0 !important;
    }

    .chat-panel {
        width: calc(100% - 20px) !important;
        max-width: calc(100% - 20px) !important;
        box-sizing: border-box !important;
        min-width: 0 !important;
        overflow-x: hidden !important;
    }

    .chat-input-section {
        width: 100% !important;
        box-sizing: border-box !important;
        min-width: 0 !important;
    }

    #chat-input,
    #chat-input:focus,
    #chat-input:active,
    #word-input,
    #word-input:focus,
    #word-input:active {
        font-size: 16px !important; /* CRITICAL: PREVENTS IOS SAFARI FROM AUTOMATICALLY ZOOMING IN WHEN PUT INTO FOCUS */
        box-sizing: border-box !important;
        min-width: 0 !important;
    }

    /* Full bleed styling for 2D board panel and grid cells */
    .board-panel,
    .board-panel.full-bleed-mobile {
        padding-left: 0 !important;
        padding-right: 0 !important;
        scroll-snap-align: center !important;
        scroll-snap-stop: always !important;
        border-radius: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important; /* Allow shrinking to screen size on mobile */
        box-sizing: border-box !important;
        overflow-x: hidden !important; /* Prevent horizontal wiggle */

        background: rgba(0, 0, 0, 0.15); /* Premium subtle row dark theme */
        border-left: none !important;
        border-right: none !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        align-items: flex-start !important;
        justify-content: flex-start !important;
        justify-self: start !important;
    }

    @keyframes mobile-low-time-pulse {
        0% { background-color: rgba(255, 50, 50, 0.2); box-shadow: inset 0 0 15px rgba(255, 50, 50, 0.2); }
        50% { background-color: rgba(255, 50, 50, 0.5); box-shadow: inset 0 0 30px rgba(255, 50, 50, 0.5); }
        100% { background-color: rgba(255, 50, 50, 0.2); box-shadow: inset 0 0 15px rgba(255, 50, 50, 0.2); }
    }

    .board-panel.low-time-warning,
    .board-panel.full-bleed-mobile.low-time-warning {
        animation: mobile-low-time-pulse 3s infinite ease-in-out !important;
        border: 1px solid rgba(255, 50, 50, 0.4) !important;
        will-change: background-color, box-shadow !important;
    }

    /* Keep non-board sub-controls inside board panel snug and aligned */
    .board-panel .validation-status,
    .board-panel .word-input-section,
    .board-panel .cube-rotate-hint,
    .board-panel.full-bleed-mobile .validation-status,
    .board-panel.full-bleed-mobile .word-input-section,
    .board-panel.full-bleed-mobile .cube-rotate-hint {
        margin-left: 10px !important;
        margin-right: 10px !important;
        width: calc(100% - 20px) !important;
        box-sizing: border-box !important;
    }


    /* Make timer smaller on mobile and fit contents */
    .board-panel .timer-display {
        padding: 5px 15px !important; /* Tight fit */
        gap: 6px !important;
        width: auto !important; /* Force auto width */
        margin: 5px auto !important; /* Center the box */
        display: flex !important; /* Ensure flex for alignment */
        justify-content: flex-start !important; /* Keep timer on the left, preventing jump to center */
        align-items: center !important;
    }

    .board-panel .timer-display .timer-label {
        font-size: 1rem !important;
    }
    .board-panel .timer-display .timer-value {
        font-size: 1.3rem !important;
    }

    .board-panel .game-board,
    .board-panel.full-bleed-mobile .game-board {
        width: auto !important;
        max-width: none !important;
        padding: 0 !important;
        border-radius: 0 !important;
        gap: 3px !important;
        display: grid !important;
        justify-content: center !important;
        align-content: start !important;
        overflow-x: auto !important;
        grid-template-columns: repeat(var(--board-cols, 4), var(--cell-size, 50px)) !important;
        grid-template-rows: repeat(var(--board-rows, 4), var(--cell-size, 50px)) !important;
        box-sizing: border-box !important;
        background: transparent !important;
        border: none !important;
        margin: -15px auto 0 auto !important; /* Move up 15px total and center */
        float: none !important;


    }

    .board-panel .game-board .board-cell,
    .board-panel.full-bleed-mobile .game-board .board-cell {
        width: var(--cell-size, 50px) !important;
        height: var(--cell-size, 50px) !important;
        aspect-ratio: 1 / 1 !important;
        min-width: 0 !important;
        min-height: 0 !important;
        margin: 0 !important;
        box-sizing: border-box !important;
        font-size: calc(var(--cell-size) * 0.6) !important;
        line-height: normal !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .board-panel .game-board .board-cell .dual-letter-container span,
    .board-panel.full-bleed-mobile .game-board .board-cell .dual-letter-container span {
        font-size: 0.52em !important;
        line-height: 1 !important;
    }
}

/* --- PREMIUM BOARD LOADER STYLING --- */
.board-loader-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    width: 100%;
    color: var(--text-secondary);
    gap: 20px;
    font-style: normal;
    text-align: center;
    padding: 40px 20px;
    box-sizing: border-box;
}

.board-loader-spinner {
    width: 50px;
    height: 50px;
    border: 3.5px solid rgba(244, 63, 94, 0.1);
    border-top: 3.5px solid var(--accent-color, #f43f5e);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    box-shadow: 0 0 20px rgba(244, 63, 94, 0.3), inset 0 0 10px rgba(244, 63, 94, 0.1);
}

.board-loader-text {
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: 2px;
    color: var(--text-primary, #ffffff);
    text-transform: uppercase;
    animation: boardLoaderPulse 1.5s ease-in-out infinite alternate;
    text-shadow: 0 0 10px var(--accent-color, #f43f5e);
    padding: 0 15px;
    box-sizing: border-box;
}

@keyframes boardLoaderPulse {
    0% {
        opacity: 0.45;
        transform: scale(0.96);
    }
    100% {
        opacity: 1;
        transform: scale(1.04);
    }
}

/* Word validation flash effects */
/* Word validation flash effects (Full-screen overlay) */
body.flash-red::after,
#page-play.flash-red::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 99999;
    background-color: rgba(255, 0, 0, 0.35) !important;
    box-shadow: inset 0 0 60px rgba(255, 0, 0, 0.6) !important;
    animation: flash-fade 0.5s ease-out forwards;
}

body.flash-green::after,
#page-play.flash-green::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 99999;
    background-color: rgba(0, 255, 0, 0.3) !important;
    box-shadow: inset 0 0 60px rgba(0, 255, 0, 0.6) !important;
    animation: flash-fade 0.5s ease-out forwards;
}

body.flash-blue::after,
#page-play.flash-blue::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 99999;
    background-color: rgba(0, 0, 255, 0.3) !important;
    box-shadow: inset 0 0 60px rgba(0, 0, 255, 0.6) !important;
    animation: flash-fade 0.5s ease-out forwards;
}

@keyframes flash-fade {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

/* Hide by default on desktop */
.mobile-nav-indicators {
    display: none;
}

/* Show only on mobile carousel */
@media (max-width: 992px) {
    .mobile-nav-indicators {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        padding: 10px 15px !important;
        background: rgba(var(--text-primary-rgb), 0.15) !important;
        backdrop-filter: blur(10px) !important;
        border-top: 1px solid rgba(var(--text-primary-rgb), 0.15) !important;
        font-size: 0.9rem !important;
        color: var(--text-primary) !important;
        position: sticky !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 100 !important;
        box-sizing: border-box !important;
        
        /* Force spanning the full screen width by canceling parent 10px padding */
        margin-left: -10px !important;
        margin-right: -10px !important;
        width: calc(100% + 20px) !important;
        margin-top: auto !important; /* Push to the very bottom if flex container has space */
    }

    .mobile-nav-indicators .nav-arrow {
        display: flex;
        align-items: center;
        gap: 5px;
        font-weight: 500;
        background: none;
        border: none;
        color: inherit;
        font-family: inherit;
        font-size: inherit;
        cursor: pointer;
        padding: 0;
    }

    .mobile-nav-indicators .nav-right {
        margin-left: auto; /* Push to right if only one */
        margin-right: 10px !important; /* Shift slightly to the left to guarantee full visibility of the arrow */
    }
}

/* Force word input section visibility on laptops and desktops */
body.is-desktop .word-input-section {
    display: flex !important;
}

/* ==========================================================================
   VERTICAL ELONGATED NOTEPAD POPUP (ROUND END NOTEPAD)
   ========================================================================== */

/* Notepad Modal Overlay */
.notepad-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 15, 25, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 25000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.notepad-overlay.hidden {
    display: none !important;
    opacity: 0;
}

/* Elongated Notepad Card */
.notepad-card {
    background: #fdf6e3; /* Warm ivory legal pad color */
    border: 2px solid #e6d8b3;
    border-radius: 6px;
    width: 340px;
    height: 580px; /* Vertically elongated */
    position: relative;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6), 0 0 40px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: visible;
    font-family: 'Courier New', Courier, monospace; /* Classic vintage typewriter typewriter font */
    animation: notepadReveal 0.4s cubic-bezier(0.2, 1, 0.3, 1);
}

@keyframes notepadReveal {
    from {
        transform: scale(0.9) translateY(40px) rotate(-1.5deg);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0) rotate(0deg);
        opacity: 1;
    }
}

/* Binder Rings on Top of Notepad */
.notepad-binder-rings {
    position: absolute;
    top: -15px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-around;
    padding: 0 30px;
    pointer-events: none;
    z-index: 10;
}

.binder-ring {
    width: 14px;
    height: 30px;
    background: linear-gradient(90deg, #657b83, #eee, #33444a);
    border-radius: 7px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.4);
}

/* Notepad Header (Legal Pad Binding Band) */
.notepad-header {
    background: #1a5fb4; /* Premium deep royal blue binding band */
    color: #fff;
    padding: 18px 15px 12px 15px;
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 3px double #0d3a68;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.notepad-title {
    font-family: 'Outfit', 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.4);
}

.notepad-close {
    background: rgba(255, 255, 255, 0.25);
    border: none;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    color: #fff;
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    line-height: 1;
}

.notepad-close:hover {
    background: #fff;
    color: #1a5fb4;
    transform: scale(1.1);
}

/* Notepad Lined Body */
.notepad-body {
    flex: 1;
    position: relative;
    background: repeating-linear-gradient(
        #fdf6e3,
        #fdf6e3 27px,
        rgba(147, 161, 161, 0.3) 28px
    );
    padding: 28px 10px 65px 45px; /* Fits left margin and bottom controls */
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Red Margin Line */
.notepad-margin-line {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 36px;
    width: 2px;
    background-color: rgba(220, 50, 47, 0.35); /* Soft margin line */
    pointer-events: none;
}

/* Words Container inside Notepad */
.notepad-words-container {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: none; /* Hide scrollbars for vintage paper effect */
    display: flex;
    flex-direction: column;
    scroll-behavior: smooth;
}

.notepad-words-container::-webkit-scrollbar {
    display: none; /* Hide scrollbars on Safari/Chrome */
}

/* Individual notepad line */
.notepad-word-line {
    height: 28px;
    line-height: 28px;
    display: flex;
    justify-content: space-between;
    padding-right: 15px;
    font-size: 1.1rem;
    font-weight: 700;
    color: #073642; /* Beautiful retro ink color */
}

.notepad-word-num {
    color: #93a1a1;
    font-size: 0.85rem;
    margin-right: 8px;
    font-weight: normal;
}

.notepad-word {
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.notepad-word-points {
    color: #2aa198; /* Custom teal scoring badge */
    font-size: 0.9rem;
    font-style: italic;
    font-family: 'Inter', sans-serif;
    font-weight: 800;
}

/* Bottom Controls panel */
.notepad-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(to top, #fdf6e3 80%, transparent);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 25px;
    padding-bottom: 12px;
    z-index: 100;
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 6px;
}

/* Floating round arrows style */
.notepad-scroll-btn {
    width: 38px;
    height: 38px;
    background: #1a5fb4;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(26, 95, 180, 0.4);
    transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
    user-select: none;
    outline: none;
}

.notepad-scroll-btn:hover:not(.disabled) {
    transform: translateY(-2px);
    background: #3583e4;
    box-shadow: 0 6px 14px rgba(53, 131, 228, 0.55);
}

.notepad-scroll-btn:active:not(.disabled) {
    transform: translateY(1px);
}

.notepad-scroll-btn.disabled {
    background: #93a1a1;
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.4;
}


/* Responsive Dynamic Chatbox Enlargement Styles */
.chat-panel {
    position: relative;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Close/Collapse Button positioning */
.chat-collapse-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 50%;
    color: var(--text-primary);
    width: 28px;
    height: 28px;
    font-size: 20px;
    line-height: 24px;
    text-align: center;
    cursor: pointer;
    z-index: 10005;
    transition: background 0.2s, transform 0.2s;
    display: none;
}

.chat-collapse-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.chat-collapse-btn:active {
    transform: scale(0.95);
}

/* Desktop layout overrides */
@media (min-width: 993px) {
    .left-panel-container.chat-expanded {
        height: 100%;
    }
    .left-panel-container.chat-expanded .players-panel,
    .left-panel-container.chat-expanded .definitions-panel {
        display: none !important;
    }
    .chat-panel.expanded {
        height: 100% !important;
        flex: 1 !important;
        box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
    }
}

/* Mobile layout overrides (Full screen on click) */
@media (max-width: 992px) {
    .chat-panel.expanded {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        z-index: 99999 !important;
        border-radius: 0 !important;
        padding: 20px !important;
        box-sizing: border-box !important;
        background: var(--bg-primary) !important;
        box-shadow: none !important;
    }
    
    .chat-panel.expanded #chat-history {
        margin-top: 25px;
        flex: 1 !important;
    }
}

/* Premium Word Validation Tile-specific Pulse Flash Effects */
body .board-cell.tile-flash-blue {
    background: #0088ff !important;
    color: #ffffff !important;
    box-shadow: 0 0 15px rgba(0, 136, 255, 0.8) !important;
    border-color: #0088ff !important;
    z-index: 100 !important;
    transition: none !important;
}
body .board-cell.tile-flash-blue * {
    color: #ffffff !important;
    transition: none !important;
    animation: none !important;
}

body .board-cell.tile-flash-green {
    background: #32cd32 !important;
    color: #ffffff !important;
    box-shadow: 0 0 15px rgba(50, 205, 50, 0.8) !important;
    border-color: #32cd32 !important;
    z-index: 100 !important;
    transition: none !important;
}
body .board-cell.tile-flash-green * {
    color: #ffffff !important;
    transition: none !important;
    animation: none !important;
}

body .board-cell.tile-flash-red {
    background: #e74c3c !important;
    color: #ffffff !important;
    box-shadow: 0 0 15px rgba(231, 76, 60, 0.8) !important;
    border-color: #e74c3c !important;
    z-index: 100 !important;
    transition: none !important;
}
body .board-cell.tile-flash-red * {
    color: #ffffff !important;
    transition: none !important;
    animation: none !important;
}

body .board-cell.tile-flash-purple {
    background: #8e44ad !important;
    color: #ffffff !important;
    box-shadow: 0 0 15px rgba(142, 68, 173, 0.8) !important;
    border-color: #8e44ad !important;
    z-index: 100 !important;
    transition: none !important;
}
body .board-cell.tile-flash-purple * {
    color: #ffffff !important;
    transition: none !important;
    animation: none !important;
}

/* Custom Draggable Scrollbar Styles for lists in Tools */
.list-scroll-area-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: row;
    overflow: hidden;
    min-height: 0;
}

/* Hide native scrollbar in Webkit browsers (Chrome, Safari, etc.) on mobile specifically,
   but keep custom scrollbar visible and functional */
@media (max-width: 768px) {
    .list-scroll-area::-webkit-scrollbar {
        width: 0px;
        background: transparent;
        display: none;
    }
    .list-scroll-area {
        scrollbar-width: none; /* Firefox */
        -ms-overflow-style: none; /* IE/Edge */
    }
}

.custom-scrollbar-track {
    position: absolute;
    top: 5px;
    bottom: 5px;
    right: 4px;
    width: 16px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    z-index: 100;
    backdrop-filter: blur(2px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    display: none; /* Shown dynamically via JS when list overflows */
    touch-action: none;
}

.custom-scrollbar-thumb {
    position: absolute;
    top: 0;
    left: 2px;
    width: 12px;
    background: linear-gradient(180deg, rgba(0, 210, 255, 0.4), rgba(58, 123, 213, 0.4));
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid rgba(0, 210, 255, 0.3);
    box-shadow: 0 0 8px rgba(0, 210, 255, 0.2);
    touch-action: none;
}

.custom-scrollbar-thumb:active,
.custom-scrollbar-thumb.dragging {
    background: linear-gradient(180deg, rgba(0, 210, 255, 0.7), rgba(58, 123, 213, 0.7));
    border: 1px solid rgba(0, 210, 255, 0.6);
    box-shadow: 0 0 12px rgba(0, 210, 255, 0.5);
    width: 14px;
    left: 1px;
}

/* Find Count Tool Styles */
#find-count-input {
    flex: 1;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    color: var(--text-primary);
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 1rem;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 1px;
    transition: all 0.3s ease;
}

#find-count-input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(233, 69, 96, 0.2);
    background: rgba(var(--text-primary-rgb), 0.05);
}

#find-count-btn {
    padding: 12px 24px;
    background: linear-gradient(135deg, #8a2be2, #4a00e0);
    color: var(--text-primary);
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

#find-count-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
    filter: brightness(1.1);
}

#find-count-btn:active {
    transform: translateY(0);
}

/* Widescreen Panel Adaptations using CSS Container Queries */

@container leftpanel (max-width: 280px) {
    .players-panel {
        padding: 10px !important;
    }
    .player-actions-row {
        flex-direction: column !important;
        gap: 6px !important;
    }
    .player-actions-row .find-me-btn {
        padding: 6px 0 !important;
        font-size: 0.72rem !important;
        margin-bottom: 0 !important;
    }
    .player-item {
        padding: 4px 10px !important;
        height: 52px !important;
    }
    .player-username {
        min-width: 50px !important;
        font-size: 0.85rem !important;
    }
    .chat-input-section button {
        padding: 8px 8px !important;
        font-size: 0.8rem !important;
    }
}

@container leftpanel (max-width: 200px) {
    .player-rank,
    .rating-square {
        display: none !important;
    }
    .player-flag {
        font-size: 0.9rem !important;
    }
    .player-item {
        height: 48px !important;
        padding: 4px 6px !important;
    }
    .player-rating-val {
        font-size: 0.75rem !important;
    }
    .player-score-val {
        font-size: 0.9rem !important;
    }
}

@container wordspanel (max-width: 280px) {
    .words-table-box {
        padding: 10px 8px !important;
    }
    .word-tab {
        font-size: 0.72rem !important;
        padding: 6px 1px !important;
    }
    .words-tabs {
        margin-bottom: 8px !important;
        padding: 2px !important;
    }
    .word-item {
        padding: 4px 4px !important;
    }
}

/* Desktop Timer Panel (min-width: 993px) */
@media (min-width: 993px) {
    .timer-display {
        background: rgba(var(--text-primary-rgb), 0.1) !important;
        padding: 10px 20px !important;
        border-radius: 10px !important;
        font-size: 1.5rem !important;
        font-weight: 700 !important;
        color: var(--text-primary) !important;
        display: flex !important;
        gap: 10px !important;
        border: none !important;
        align-items: center !important;
        justify-content: center !important;
        margin: 0 auto 15px auto !important;
        width: fit-content !important;
        max-width: none !important;
    }
    .timer-display .timer-label {
        font-size: 1.5rem !important;
        font-weight: 700 !important;
        display: inline !important;
    }
    .timer-display .timer-value {
        font-size: 2.2rem !important;
        font-weight: 800 !important;
        min-width: 220px !important;
        text-align: center !important;
        display: inline-block !important;
        font-family: 'Courier New', Courier, monospace !important;
    }
    .timer-display .rotate-btn {
        display: none !important;
    }
}

/* Mobile Timer Panel (max-width: 992px) */
@media (max-width: 992px) {
    .timer-display {
        background: rgba(var(--text-primary-rgb), 0.1) !important;
        padding: 6px 12px !important;
        border-radius: 8px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        width: calc(100% - 20px) !important;
        max-width: 280px !important;
        box-sizing: border-box !important;
        margin: 5px auto !important;
        flex-shrink: 0 !important;
    }
    .timer-display .timer-label {
        font-size: 0.95rem !important;
        font-weight: 700 !important;
        display: inline !important;
    }
    .timer-display .timer-value {
        font-size: 1.2rem !important;
        font-weight: 800 !important;
        min-width: auto !important;
        width: auto !important;
        display: inline-block !important;
    }
    .timer-display .rotate-btn {
        display: block !important;
    }
}

/* Score Sum Leaderboard Styles */
#score-sum-list {
    max-height: 72vh;
    overflow-y: auto;
    padding-right: 4px;
    scrollbar-width: thin;
    scrollbar-color: rgba(var(--text-primary-rgb), 0.3) transparent;
}
#score-sum-list::-webkit-scrollbar {
    width: 6px;
}
#score-sum-list::-webkit-scrollbar-track {
    background: transparent;
}
#score-sum-list::-webkit-scrollbar-thumb {
    background-color: rgba(var(--text-primary-rgb), 0.3);
    border-radius: 3px;
}

/* Prevent copying / selection of Added Words list items */
.list-item.added-word {
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
}
