/* --- FORCE Connections tile text larger on wide screens --- */
@media (min-width: 561px) {
    .connections-word {
        font-size: clamp(16px, 1vw, 1px) !important;
    }
}
@media (min-width: 1400px) {
    .connections-word {
        font-size: clamp(16px, 1vw, 1px) !important;
    }
}
/* =============================================================
     Color Theme Tokens (Centralized)
     Edit ONLY the variables below to create new color themes.
     Semantic grouping: base, text, surfaces, states, game-specific.
     ============================================================= */
:root {
        /* Base / Surfaces (Light Theme) */
    --color-bg: #f5f5f5;
    --color-bg-alt: #ffffff;
    --color-surface: #ffffff;
    --color-surface-alt: #e0e0e0;
    --color-border: #cecece;
    --color-border-strong: #888888;

    /* Neutral Palette (compressed) */
     --color-neutral-0: #ffffff;
     --color-neutral-50: #f5f5f5;
     --color-neutral-100: #e0e0e0;
     --color-neutral-150: #cecece;
     --color-neutral-300: #ababab;
     --color-neutral-400: #8f8f8f;
     --color-neutral-500: #888888;
     --color-neutral-600: #666666;
     --color-neutral-800: #444444;
     --color-neutral-900: #232323;
     --color-neutral-950: #18191b;
         --color-black: #000000;
         --color-black-alt: #111111;
         --color-off-black: #151515;
         --color-deep-panel: #1f2330;
         --color-panel-accent: #22272b;

    /* Text */
    --color-text: #111111;
    --color-text-muted: #888888;
    --color-text-invert: #ffffff;
    --color-heading: #ffffff;

    /* Accents & States */
    --color-accent: #e0e0e0; /* Primary accent (was yellow) */
    --color-accent-alt: #9200db; /* Secondary accent / rare highlight */
    --color-success: #43a047;
    --color-success-hover: #4fb255;
    --color-error: #d32f2f;
    --color-error-strong: #ff0000;
    --color-warning: #ff9d1f;

        /* Shadows */
        --shadow-sm: 0 2px 6px #0001;
        --shadow-md: 0 2px 8px #0002;
        --shadow-lg: 0 4px 16px #0002;

    /* Sudoku Specific */
    --color-sudoku-editable-bg: #889cb5;
    --color-sudoku-selection-bg: #3a4458; /* consider unify with accent */
    --color-sudoku-editable-bg-dark: #4a4a4a;
    --color-sudoku-subgrid-fixed-light: #b0b0b0;
    --color-sudoku-subgrid-fixed-dark: #5a5a5a;
    --color-sudoku-highlight-rowcol: #757f8f; /* consider derive from accent */
    --color-sudoku-highlight-same: var(--color-accent); /* legacy alias */
    --color-sudoku-same: #ffc400; /* dedicated same-number highlight (orange) */
    --color-sudoku-conflict: var(--color-error-strong);
    --color-sudoku-conflict-inner-outline: #f5f5f5; /* new: inner ring/outline color for conflict dot */
    --color-sudoku-fixed-bg: #3a4458; /* darker fixed (non-editable) cells */
    --color-sudoku-given-bg: #697ca1; /* new: explicit given (non-editable) cell background */
    --color-sudoku-cell-border: #202125; /* border between cells */
    --color-sudoku-board-outline: #000000; /* outer board outline */
    --color-sudoku-subgrid-border: var(--color-sudoku-board-outline); /* 3x3 subgrid separators unified */

    /* Wordle Specific */
    --color-wordle-correct: var(--color-success);
    --color-wordle-present: var(--color-accent);
    --color-wordle-absent: #151515;
    --color-wordle-key-bg: #232323;
    --color-wordle-key-border: #444444;
        --color-wordle-outline: #42527c; /* legacy fallback */

    /* Connections Group Colors (NYT style) */
    --color-connections-group-1: #f9df6d; /* NYT Yellow */
    --color-connections-group-2: #b0e07c; /* NYT Green */
    --color-connections-group-3: #a6d1ff; /* NYT Blue */
    --color-connections-group-4: #c6a5e8; /* NYT Purple */
    /* Connections found answer bar text */
    --color-connections-answer-text: var(--color-text);
    /* Connections message text color */
    /* Use defined accent (was referencing undefined --accent, causing fallback to black) */
    --color-connections-message: var(--color-accent);
    /* Unified action button variables */
    --color-action-primary: #333333; /* Shuffle / Hint / New Game (Connections) + Sudoku New Game */
    --color-action-primary-hover: #1b1b1b; /* can customize hover separately */
    --color-action-positive: var(--color-success); /* Submit (Connections) + Check (Sudoku) */
    --color-action-positive-hover: var(--color-success-hover);

    --foreground: var(--color-text-invert);
    --winning-blocks: var(--color-accent);
}

.theme-dark {
    /* Dark Theme Overrides */
    --color-bg: #18191b;
    --color-bg-alt: #1f2330;
    --color-surface: #232323;
    --color-surface-alt: #353535;
    --color-border: #444444;
    --color-border-strong: #666666;

    --color-text: #e0e0e0;
    --color-text-muted: #888888;
    --color-text-invert: #111111;
    --color-heading: #e0e0e0;

        --color-wordle-key-bg: #232323;
        --color-wordle-key-border: #444444;
        --color-wordle-absent: #000000;
        --shadow-sm: 0 2px 6px #0009;
        --shadow-md: 0 2px 8px #000a;
        --shadow-lg: 0 4px 16px #000a;

    /* Sudoku dark adjustments */
    --color-sudoku-editable-bg: #4a4a4a;
    --color-sudoku-selection-bg: #8f8f8f;
    --color-sudoku-fixed-bg: #353535; /* dark theme fixed cells */
    --color-sudoku-given-bg: #353535; /* dark theme given cells */
    --color-sudoku-cell-border: #444444;
    --color-sudoku-board-outline: #444444;
    --color-sudoku-subgrid-border: var(--color-sudoku-board-outline);
    --color-sudoku-same: #f700ff; /* dark theme same-number highlight */
    --color-sudoku-conflict-inner-outline: #a10000; /* dark theme inner outline for conflict dot */
    --color-connections-message: #ffffff; /* dark theme message text white */
    --color-connections-answer-text: #000000; /* dark theme answer bar text black */
}

/* =============================================================
     End Color Theme Tokens
     ============================================================= */

/* Responsive centering for Connections grid */
.connections-board-flex-center {
    display: block;
    width: auto;
    max-width: none;
    margin: 0;
}
/* Center Connections game container */
#connectionsContainer {
    margin-top: 40px;
    width: 100%;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}
/* Connections found group (NYT style) */
/* Found group tiles as horizontal rows at top of grid */
.connections-found-bar {
    grid-column: 1 / span 4;
    width: 100%;
    min-height: 64px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    margin-bottom: 0;
    margin-top: 0;
    margin-right: 0;
    margin-left: 0;
    box-shadow: 0 2px 8px #0001;
    padding: 14px 0 10px 0;
    /* Slightly reduced overall font size */
    font-size: 0.95em;
    border: none;
    pointer-events: none;
}
.connections-found-bar-title {
    font-weight: bold;
    /* Reduced from 1.13em for less overpowering heading */
    font-size: 1.02em;
    margin-bottom: 2px;
    letter-spacing: 0.5px;
    text-align: center; /* center multi-line titles */
    width: 100%;
}
    .sudoku-incorrect {
        background: #d9534f !important; /* red */
        color: #fff !important;
        animation: sudokuPulse 0.6s ease;
    }
    @keyframes sudokuPulse {
        0% { box-shadow: 0 0 0 0 rgba(217,83,79,0.7); }
        70% { box-shadow: 0 0 0 8px rgba(217,83,79,0); }
        100% { box-shadow: 0 0 0 0 rgba(217,83,79,0); }
    }
.connections-found-bar-items {
    font-weight: normal;
    /* Reduced slightly to match new scale */
    font-size: 0.9em;
    margin-bottom: 0;
    text-align: center; /* center multi-line word list */
    width: 100%;
}
.connections-mistakes {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 4px 0 8px 0;
    font-weight: 600;
    font-size: 0.95em;
    letter-spacing: 0.5px;
    color: #fff;
}
.connections-mistakes .mistake-dots {
    display: flex;
    gap: 8px;
    align-items: center;
}
.connections-mistakes .mistake-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: inset 0 0 0 2px #cecece;
}
.theme-dark .connections-mistakes .mistake-dot { background:var(--color-neutral-600); box-shadow: inset 0 0 0 2px var(--color-neutral-800); }
.connections-mistakes .mistake-dot.used { background:var(--color-neutral-900); opacity:0.28; box-shadow:none; }
.theme-dark .connections-mistakes .mistake-dot.used { background:var(--color-off-black); }
.connections-board-inner {
    display: grid;
    grid-template-columns: repeat(4, 154px); /* adjusted for gap to keep overall width ~640px */
    grid-auto-rows: 80px;
    gap: 8px; /* equal horizontal & vertical spacing */
    margin-left: auto;
    margin-right: auto;
    margin-top: 0;
    margin-bottom: 0;
}
/* Connections Styles (NYT/Wordle inspired) */
.connections-board {
    /* Center container exactly to inner 4x4 tile grid width (4 * 128px) */
    width: 640px; /* 4 * 160px */
    max-width: 100%;
    margin: 8px auto 18px auto;
    display: flex;
    justify-content: center;
}
.connections-word {
    background: #5c6fa8;
    color: var(--foreground);
    border: 2px solid var(--color-wordle-outline);
    border-radius: 4px;
    /* Larger responsive font: scales more aggressively on wide screens */
    /* Slightly increased base scaling for better readability */
    font-size: clamp(32px, 4.7vw, 88px);
    font-weight: bold; /* make tile text bold */
    padding: 0;
    height: 80px;
    width: 154px; /* match adjusted column width accounting for gap */
    cursor: pointer;
    box-shadow: none;
    outline: none;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    /* Removed font-size transition to prevent flicker when tiles rerender */
    /* Allow wrapping to next line if word list is long */
    white-space: normal;
    text-align: center;
    padding: 4px; /* small inner padding for multi-line */
    line-height: 1.05;
    overflow: hidden; /* clip if more than two lines */
}
/* Mobile override keep small tiles readable */
@media (max-width: 560px) {
    /* Modestly bump mobile size */
    .connections-word { font-size: 19px;}
}
/* Extra large desktop screens: push base size higher so short words appear large */
@media (min-width: 1400px) {
    /* Maintain proportionally larger scaling on very wide screens */
    .connections-word { font-size: clamp(36px, 5vw, 100px); }
}
.connections-word:hover {
    background: #5c6fa8;
    color: var(--foreground);
    border-color: var(--color-wordle-outline);
    transform: none;
    transition: none;
}
/* Container for found groups always at the top */
.connections-found-groups-container {
    width: 100%;
    max-width: 352px;
    margin: 0 auto 10px auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.connections-word.selected {
    background: #e0e0e0;
    color: #222;
    border-color: #e0e0e0;
    transition: none;
}
.connections-word:disabled {
    background: #444;
    color: #aaa;
    border-color: #888;
    cursor: default;
    transition: none;
}
.connections-shuffle-btn, .connections-submit-btn {
    /* Base style (backgrounds applied via specific ID grouping for clarity) */
    color: #fff;
    border: none;
    border-radius: 7px;
    padding: 7px 18px;
    font-weight: bold;
    font-size: 1em;
    cursor: pointer;
    margin-bottom: 0;
    margin-top: 0;
    transition: background 0.2s;
}
/* Primary action buttons (non-submit) */
.connections-shuffle-btn,
#connectionsNextBtn,
#connectionsHintBtn,
#connectionsHintClose,
#sudokuResetBtn {
    background: var(--color-action-primary);
}
.connections-shuffle-btn:hover,
#connectionsNextBtn:hover,
#connectionsHintBtn:hover,
#connectionsHintClose:hover,
#sudokuResetBtn:hover {
    background: var(--color-action-primary-hover);
    transform: none; /* prevent upward float on hover */
}
/* Positive/confirm action buttons */
#connectionsSubmitBtn, #sudokuCheckBtn { background: var(--color-action-positive); }
#connectionsSubmitBtn:hover, #sudokuCheckBtn:hover { background: var(--color-action-positive-hover); }
/* Prevent hover lift (generic button:hover adds translate) for Connections action buttons */
.connections-shuffle-btn,
#connectionsNextBtn,
#connectionsHintBtn,
#connectionsHintClose,
.connections-shuffle-btn:hover,
#connectionsNextBtn:hover,
#connectionsHintBtn:hover,
#connectionsHintClose:hover,
#connectionsSubmitBtn,
#connectionsSubmitBtn:hover,
#sudokuCheckBtn,
#sudokuCheckBtn:hover,
.connections-shuffle-btn:hover,
#connectionsNextBtn:hover,
#connectionsHintBtn:hover,
#connectionsHintClose:hover {
    transform: none !important;
}
/* Connections hint modal overrides */
#connectionsHintModal .modal-content {
    background: #1f2330;
    color: #fff;
}
#connectionsHintModal .connections-hint-level {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 6px;
    background: rgba(255,255,255,0.05);
}
#connectionsHintModal .connections-hint-level.revealed {
    background: rgba(255,255,255,0.12);
}
#connectionsHintModal .connections-hint-level-title {
    font-weight: bold;
}
#connectionsHintModal .connections-hint-level-word { font-family: monospace; font-weight: 600; }
.connections-message {
    font-weight: bold;
    color: var(--color-connections-message);
    margin-left: 8px;
}
.connections-stats {
    color: #fff;
    font-size: 20;
    font-weight: 500;
    background: rgba(60,70,108,0.7);
    border-radius: 10px;
    padding: 12px 24px;
    min-width: 220px;
    text-align: center;
    margin: 8px auto 10px auto; /* center horizontally */
}
/* Connections actions: column wrapper (buttons + message) */
#connectionsContainer .connections-actions {
    width: 640px; /* match grid width (widened) */
    max-width: 100%;
    margin: 10px auto 6px auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
}
/* Row just for buttons */
#connectionsContainer .connections-button-row {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 18px;
}
#connectionsContainer .connections-actions .connections-message {
    margin-left: 0;
    text-align: center;
}

@media (max-width: 560px) {
    /* Scale Connections to roughly match Sudoku width (~320px) */
    .connections-board-inner { grid-template-columns: repeat(4, 72px); grid-auto-rows:72px; gap:6px; }
    .connections-board { width: 306px; }
    #connectionsContainer .connections-actions { width: 320px; max-width:100%; }
    .connections-word { width: 72px; height: 72px; } /* square tiles so vertical gap matches horizontal */
    /* Switch to grid layout so Hint button can sit beneath others without stretching */
    #connectionsContainer .connections-button-row { 
        display: grid; 
        grid-template-columns: repeat(3, auto); 
        justify-content: center; 
        align-items: center; 
        gap: 18px; 
    }
    /* Keep 'New Game' label on one line; widen if needed so height matches other buttons */
    #connectionsNextBtn { white-space: nowrap; min-width: 118px; }
    /* Place Hint button on its own line, centered, intrinsic width */
    #connectionsHintBtn { grid-column: 1 / span 3; justify-self: center; }
}
.theme-dark #connectionsContainer .connections-button-row { flex-wrap: nowrap; }
.theme-dark .connections-board {
    background: #18191b !important;
}
.theme-dark .connections-word {
    background: #232323 !important;
    color: #e0e0e0 !important;
    border-color: #444 !important;
}
.theme-dark .connections-word.selected {
    background: #e0e0e0 !important;
    color: #232323 !important;
    border-color: #e0e0e0 !important;
}
.theme-dark .connections-word:disabled {
    background: #353535 !important;
    color: #888 !important;
    border-color: #666 !important;
}
.theme-dark .connections-stats {
    background: #232323 !important;
    color: #e0e0e0 !important;
}
.sudoku-fixed {
    cursor: pointer;
}
/* Highlight for same numbers in Sudoku */
.sudoku-same-number {
    background: var(--color-sudoku-same) !important;
    color: #222 !important;
}
.sudoku-highlight.sudoku-same-number, .sudoku-same-number.sudoku-highlight {
    background: var(--color-sudoku-same) !important; /* ensure same-number color wins */
}
.theme-dark .sudoku-same-number {
    background: var(--color-sudoku-same) !important;
    color: #ffffff !important; /* improved contrast */
}
.theme-dark .sudoku-highlight.sudoku-same-number, .theme-dark .sudoku-same-number.sudoku-highlight {
    background: var(--color-sudoku-same) !important;
}
/* Sudoku Row/Col Highlight */
.sudoku-highlight {
    background: var(--color-sudoku-highlight-rowcol) !important;
}
.theme-dark .sudoku-highlight {
    background: #ababab !important;
}
.sudoku-subgrid-fixed {
    background-color: var(--color-sudoku-subgrid-fixed-light) !important; /* explicit darker shade for light theme */
    color: #1e1e1e !important;
}
.theme-dark .sudoku-subgrid-fixed {
    background-color: var(--color-sudoku-subgrid-fixed-dark) !important; /* explicit slightly darker shade in dark theme */
    color: #e0e0e0 !important;
}
/* Conflict red dot (duplicate in row or column) */
.sudoku-cell.sudoku-conflict {
    position: relative;
}
.sudoku-cell.sudoku-conflict::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    background: var(--color-error-strong);
    border-radius: 100%;
    bottom: 2px;
    right: 2px;
    box-shadow: 0 0 2px rgba(0,0,0,0.6);
    pointer-events: none;
}
.theme-dark .sudoku-cell.sudoku-conflict::after {
    background: var(--color-error-strong);
    /* Inner outline now variable-driven */
    box-shadow: inset 0 0 0 2px var(--color-sudoku-conflict-inner-outline), 0 0 2px rgba(0,0,0,0.9);
}
/* Sudoku Styles */
.sudoku-board {
    display: grid;
    grid-template-columns: repeat(9, var(--sudoku-cell-size));
    grid-template-rows: repeat(9, var(--sudoku-cell-size));
    gap: 0;
    background: none; /* remove beveled container */
    border: none; /* outer board border handled per-cell in JS */
    border-radius: 0;
    box-shadow: none;
    padding: 0; /* cells now flush */
    margin-bottom: 12px;
}
.sudoku-board-wrapper {
    width: calc(var(--sudoku-cell-size) * 9); /* exact grid width (no outer padding) */
    display: flex;
    flex-direction: column;
    align-items: center;
}
.sudoku-cell {
    width: var(--sudoku-cell-size);
    height: var(--sudoku-cell-size);
    text-align: center;
    font-size: 1.3em;
    font-weight: bold;
    color: #fff;
    background: #22272b;
    border: 1px solid var(--color-sudoku-cell-border);
    outline: none;
    transition: background 0.2s, color 0.2s;
    box-sizing: border-box;
    border-radius: 0px; /* Bevel the edges */
    display: flex;
    align-items: center;
    justify-content: center;
    /* Remove default box-shadow/bevel if any */
    box-shadow: 0 2px 6px #0001;
}
.sudoku-cell.sudoku-editable { cursor: pointer; }
.sudoku-cell.sudoku-selected { outline:none; background:var(--color-sudoku-selection-bg); }
.sudoku-cell.sudoku-editable.sudoku-selected { background:var(--color-sudoku-selection-bg); color:var(--color-text-invert); }
.theme-dark .sudoku-cell.sudoku-selected { outline:none; background:var(--color-sudoku-selection-bg); }
.theme-dark .sudoku-cell.sudoku-editable.sudoku-selected { background:var(--color-sudoku-selection-bg); color:var(--color-text-invert); }
.sudoku-cell.sudoku-editable { background:var(--color-sudoku-editable-bg); color:var(--color-text); }
.sudoku-cell.sudoku-editable.sudoku-selected { color:#222; }
.theme-dark .sudoku-cell.sudoku-editable { background:var(--color-sudoku-editable-bg); color:#ffffff; }
.theme-dark .sudoku-cell.sudoku-editable.sudoku-selected { color:#fff; }
/* Editable cells keep same light background whether empty or filled for clarity */
.sudoku-cell:disabled, .sudoku-fixed {
    background: var(--color-sudoku-given-bg);
    color: var(--color-text-invert);
    font-weight: bold;
    cursor: default;
}
.theme-dark .sudoku-cell:disabled, .theme-dark .sudoku-fixed {
    background: var(--color-sudoku-given-bg);
    color: #ffffff;
}
.sudoku-reset-btn {
    /* Background applied via ID-specific rules for New Game / Check */
    color: #fff;
    border: none;
    border-radius: 7px;
    padding: 7px 18px;
    font-weight: bold;
    font-size: 1em;
    cursor: pointer;
    margin-bottom: 0;
    margin-top: 12px; /* Move button up to center between board and tracker */
    transition: background 0.2s; /* remove transform animation */
    transform: none; /* ensure no default transform */
}
.sudoku-reset-btn:hover { transform: none; }
/* Background + hover for #sudokuResetBtn / #sudokuCheckBtn handled above with shared variables */
/* Center Sudoku controls horizontally */
.sudoku-controls {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    margin-bottom: 8px;
}
.sudoku-buttons-row { display:flex; gap:14px; align-items:center; justify-content:center; }
.sudoku-controls #sudokuResetBtn { margin-top: 12px; }
.sudoku-controls #sudokuMessage { margin-left: 0; text-align: center; }
.sudoku-message {
    font-weight: bold;
    color: #fff; /* changed from accent to white */
    margin-left: 8px;
}
.sudoku-stats {
    color: #fff;
    font-size: 20px;
    font-weight: 500;
    background: rgba(60,70,108,0.7);
    border-radius: 10px;
    padding: 12px 24px;
    min-width: 220px;
    text-align: center;
    margin-bottom: 10px;
}
.sudoku-number-pad {
    display: grid;
    width: calc(var(--sudoku-cell-size) * 9); /* match board width (no padding) */
    grid-template-columns: repeat(5, 1fr);
    grid-auto-rows: 56px; /* larger tap targets */
    gap: 0;
    margin: 0 0 24px 0; /* close to board */
    border: none;
    border-radius: 10px;
    overflow: visible;
    box-sizing: border-box;
    position: relative;
    padding-bottom: 20px;
}
.sudoku-number-pad button {
    width: 100%;
    height: 100%;
    background: #455689; /* more vivid blue (default theme) */
    border: none;
    border: none; /* Remove top border segment */
    border-right: 1px solid #5b71ac; /* adjusted to match new blue */
    border-bottom: 1px solid #5b71ac; /* adjusted to match new blue */
    color:#fff; /* ensure white text in default theme */
    font-weight: bold;
    font-size: 1.2em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: none; /* no hover animation */
}
.sudoku-number-pad button, .sudoku-number-pad button:hover, .sudoku-number-pad button:active { transform:none !important; }
.sudoku-number-pad button.sudoku-pad-pressed { filter:brightness(1.25); }
.sudoku-number-pad button.erase-btn { font-size: 0.68em; letter-spacing: 0.5px; }
/* Greyed out digit when present in every 3x3 subgrid */
.sudoku-number-pad button.sudoku-pad-covered {
    background: #2f3a55 !important;
    color: #888 !important;
    cursor: default;
}
.theme-dark .sudoku-number-pad button.sudoku-pad-covered {
    background: #2a2a2a !important;
    color: #666 !important;
}
/* Added: bevel top corners via the first and fifth buttons (row 1) */
.sudoku-number-pad button:nth-child(1) { border-top-left-radius:10px; }
.sudoku-number-pad button:nth-child(5) { border-top-right-radius:10px; }
/* Added: bevel bottom corners via the sixth and tenth buttons (row 2) */
.sudoku-number-pad button:nth-child(6) { border-bottom-left-radius:10px; }
.sudoku-number-pad button:nth-child(10) { border-bottom-right-radius:10px; }
/* Remove right border on every 5th (end of row) cell */

/* Remove bottom border for last row buttons */
.sudoku-number-pad button:nth-last-child(-n+5) { border-bottom:none; }
.theme-dark .sudoku-number-pad { border:none; border-radius:10px; overflow:visible; width: calc(var(--sudoku-cell-size) * 9 + 16px); }
.theme-dark .sudoku-number-pad button { background:#232323; border-right:1px solid #444; border-bottom:1px solid #444; border-top:none; }
/* Dark theme: no extra top border */
.theme-dark .sudoku-number-pad button:nth-last-child(-n+5) { border-bottom:none; }
.theme-dark .sudoku-number-pad button:hover { background:#333; }
.theme-dark .sudoku-number-pad button:active { background:#444; }
.theme-dark .sudoku-stats {
    background: #232323 !important;
    color: #e0e0e0 !important;
}
/* Toggle Switch for Wordle Settings */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    margin-left: 8px;
}
.switch input { display: none; }
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #ccc;
    transition: .3s;
    border-radius: 24px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: #fff;
    transition: .3s;
    border-radius: 50%;
    box-shadow: 0 1px 4px #0002;
}
input:checked + .slider {
    background-color: var(--color-accent);
}
input:checked + .slider:before {
    transform: translateX(20px);
}
/* Wordle Hint Link Styling */
.wordle-hint-link {
    /* Change the text color here: */
    color: #888;
    /* Change the background color here: */
    background: #cecece;
    font-weight: bold;
    font-size: 1.08em;
    border-radius: 7px;
    padding: 3px 16px;
    transition: background 0.2s, color 0.2s;
    text-decoration: none;
    /* box-shadow removed to disable glow */
    display: inline-block;
}
.wordle-hint-link:hover, .wordle-hint-link:focus {
    background: #fff;
    color: #111;
    /* box-shadow removed to disable glow */
    outline: none;
}
/* Wordle Help Modal (Black & White) */
#wordleHelpModal .wordle-help-modal-content {
    background: #fff !important;
    color: #111 !important;
    border: 2px solid #111;
    box-shadow: 0 8px 32px #0002;
    font-size: 1.1em;
}
.theme-dark #wordleHelpModal .wordle-help-modal-content {
    background: #111 !important;
    color: #fff !important;
    border: 2px solid #fff;
}
/* Wordle 'word doesn't exist' message color */
#wordleModalMessage {
    color: #fff !important;
}
/* Settings Cog and Theme Dropdown */
.settings-menu-wrapper {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}
#settingsCog {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-accent);
    padding: 4px;
    border-radius: 50%;
    transition: background 0.2s;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}
#settingsCog:hover {
    background: rgba(125,137,197,0.12);
}
.settings-dropdown {
    margin-top: 8px;
    background: #222c3a;
    color: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.18);
    padding: 16px 18px 12px 18px;
    min-width: 160px;
    font-size: 1em;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    animation: fadeIn 0.2s;
}
.settings-dropdown label {
    margin-bottom: 6px;
}
#themeSelect {
    width: 100%;
    font-size: 1em;
    border-radius: 6px;
    border: 1px solid var(--color-accent);
    padding: 6px 8px;
    background: #36486c;
    color: #fff;
    margin-bottom: 2px;
}
@media (max-width: 600px) {
    .settings-menu-wrapper {
        top: 8px;
        right: 8px;
    }
    .settings-dropdown {
        min-width: 120px;
        font-size: 0.98em;
        padding: 12px 10px 8px 10px;
    }
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Theme Variables */
:root {
    --blue: #7d89c5;
    --blue-dark: #42527c;
    --blue-light: #5187a2;
    --background: #36486c;
    --foreground: #fff;
    --accent: #ffd600;
    --sudoku-cell-size: 36px; /* base size for a Sudoku cell */
}

.theme-dark {
    --blue: #444444;
    --blue-dark: #232323;
    --blue-light: #666666;
    --background: #18191b;
    --foreground: #e0e0e0;
    --accent: #ffd600;
}


body, html {
    background: var(--background) !important;
    color: var(--foreground) !important;
    min-height: 100vh;
}

/* Ensure full-page background is dark in dark mode */
.theme-dark html, .theme-dark body {
    background: #18191b !important;
}

/* Add scroll room at the bottom of the page */
body {
    padding-bottom: 64px;
}

/* Override blue backgrounds and borders in dark mode */
.theme-dark .container,
.theme-dark #wordleContainer {
    background: #18191b !important;
}
.theme-dark #statsBox,
.theme-dark #wordleStats {
    background: #232323 !important;
    color: #e0e0e0 !important;
}
.theme-dark #gameboard .box {
    background-color: #232323 !important;
    color: #bbb !important;
    border-color: #444 !important;
}
.theme-dark #gameboard .box:nth-child(even) {
    background-color: #1e1e1e !important;
}
.theme-dark .wordle-cell {
    background-color: #232323 !important;
    color: #e0e0e0 !important;
    border-color: #444 !important;
}

.theme-dark .wordle-cell.correct {
    background-color: #43a047 !important; /* Same green as default */
    color: #fff !important;
}
.theme-dark .wordle-cell.present {
    background-color: #ffd600 !important;
    color: #232323 !important;
}
.theme-dark .wordle-cell.absent {
    background-color: #000 !important; /* Blacked out for not in word */
    color: #888 !important;
}
.theme-dark .wordle-key {
    background: #232323 !important;
    color: #e0e0e0 !important;
    border: none;
}
.theme-dark .wordle-key.correct {
    background: #43a047 !important; /* Same green as default */
    color: #fff !important;
}
.theme-dark .wordle-key.present {
    background: #ffd600 !important;
    color: #232323 !important;
}
.theme-dark .wordle-key.absent {
    background: #000 !important; /* Blacked out for not in word */
    color: #888 !important;
}
.theme-dark .modal-content {
    background: #232323 !important;
    color: #e0e0e0 !important;
}
.theme-dark #settingsCog {
    color: #bbb !important;
}
.theme-dark .settings-dropdown {
    background: #232323 !important;
    color: #e0e0e0 !important;
    border: 1px solid #444 !important;
}
.theme-dark #themeSelect {
    background: #18191b !important;
    color: #e0e0e0 !important;
    border: 1px solid #444 !important;
}
.theme-dark button,
.theme-dark #restartBtn {
    background-color: #232323 !important;
    color: #e0e0e0 !important;
    border: 1px solid #444 !important;
}
.theme-dark #connectionsSubmitBtn,
.theme-dark #sudokuCheckBtn {
    background: var(--color-action-positive) !important;
    color: #ffffff !important;
    border: none !important;
}
.theme-dark #connectionsSubmitBtn:hover,
.theme-dark #sudokuCheckBtn:hover {
    background: var(--color-action-positive-hover) !important;
}
.theme-dark button:hover,
.theme-dark #restartBtn:hover {
    background-color: #333 !important;
}
/* Wordle Keyboard Styles */
.wordle-keyboard-row {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
}
#wordleBoard {
    display: grid;
    grid-template-rows: repeat(6, 1fr);
    grid-template-columns: repeat(5, 60px);
    gap: 8px;
    margin: 24px auto 16px auto;
    width: 308px;
    max-width: 308px;
    justify-content: center;
}
.wordle-key {
    flex: 1 1 0;
    min-width: 0;
    max-width: 40px;
    height: 48px;
    margin: 0 2px;
    background: #42527c;
    color: #fff;
    font-size: 1.2em;
    font-weight: bold;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, transform 0.1s;
    text-transform: uppercase;
    user-select: none;
    outline: none;
    padding: 0 4px;
    touch-action: manipulation;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}
#wordleKeyboard {
    width: 308px;
    max-width: 308px;
    margin-left: auto;
    margin-right: auto;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
@media (max-width: 600px) {
    #wordleBoard, #wordleKeyboard {
        max-width: 96vw;
        width: 96vw;
        min-width: 0;
        margin-left: auto;
        margin-right: auto;
    }
    .wordle-keyboard-row {
        max-width: 96vw;
        width: 100%;
        gap: 1vw;
    }
    .wordle-key {
        font-size: 1em;
        max-width: 9vw;
        height: 9vw;
        min-width: 0;
        padding: 0 2vw;
    }
}
.wordle-key:active {
    transform: scale(0.96);
}
.wordle-key.correct {
    background: #43a047;
    color: #fff;
}
.wordle-key.present {
    background: #ffd600;
    color: #34343a;
}
.wordle-key.absent {
    background: #3a4366;
    color: #bbb;
}
/*Tic Tac Toe Styles */
*{
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}

:root {
    --blue: #7d89c5;
    --winning-blocks: #5187a2;
}

html, body {
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    background: #36486c;
    overflow-x: hidden;
    /* Remove fixed heights that prevent scrolling */
}

body {
    min-height: 100vh;
    min-width: 100vw;
    background: #36486c;
    color: var(--color-accent);
    font-family: 'Segoe UI', Arial, Helvetica, sans-serif;
    /* Remove fixed height and use auto for scrolling */
    height: auto;
    overflow-y: auto;
}

h1 {
    font-size: 54px;
    text-transform: uppercase;
}
h1#playerText {
    text-align: center;
    width: 100%;
    display: block;
}

.container {
    padding: 40px;
    /* Remove height: 100vh; so content can grow and scroll */
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    background-color: #36486c;
    min-height: 100vh;
    width: 100%;
}

#gameboard {
    width: 300px;
    display: flex;
    flex-wrap: wrap;
    margin-top: 40px;
}
.box {
    height: 100px;
    width: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-accent);
    font-size: 75px;
    border-right: 2px solid;
    border-bottom: 2px solid;
    background-color: #42527c; 
}

.box:nth-child(even) {
    background-color: #3a4366;
}
.box:nth-child(3n) {
    border-right: none;
}
.box:nth-child(6) ~ .box {
    border-bottom: none;
} 
button {
    margin-top: 24px;
    padding: 10px 20px;
    background-color: var(--color-accent);
    color: #34343a;
    border: none;          
    outline: none;         
    font-size: 18px;
    transition: 200ms transform;
    font-weight: 600;
}
button:hover {
    cursor: pointer;
    transform: translateY(-4px);
}
.box:nth-child(1) {
    border-top-left-radius: 18px;
}
.box:nth-child(3) {
    border-top-right-radius: 18px;
}
.box:nth-child(7) {
    border-bottom-left-radius: 18px;
}
.box:nth-child(9) {
    border-bottom-right-radius: 18px;
}
#statsBox {
    margin-top: 18px;
    color: #fff;
    font-size: 20px;
    font-weight: 500;
    background: rgba(60,70,108,0.7);
    border-radius: 10px;
    padding: 12px 24px;
    min-width: 220px;
    text-align: center;
}

.modal {
    display: none;
    position: fixed;
    z-index: 999;
    left: 0; top: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    justify-content: center;
    align-items: center;
}
.modal-content {
    background: rgba(52, 52, 52, 0.6);
    color: #fff;
    padding: 32px 24px;
    border-radius: 16px;
    text-align: center;
    min-width: 260px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    backdrop-filter: blur(8px); 
}
#modalMessage {
    font-size: 2em;
    font-weight: bold;
    margin-bottom: 32px;
    margin-top: 8px;
    width: 100%;
}
#restartBtn {
    margin-top: auto;
    align-self: center;
    padding: 12px 32px;
    background-color: rgba(125,137,197,0.5); 
    color: #34343a;
    border: none;
    outline: none;
    font-size: 1.2em;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}
#restartBtn:hover {
    background-color: rgba(125,137,197,0.7);
    transform: translateY(-4px);
}

#wordleContainer {
    margin-top: 40px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#wordleBoard {
    display: grid;
    grid-template-rows: repeat(6, 1fr);
    grid-template-columns: repeat(5, 60px);
    gap: 8px;
    margin: 24px 0 16px 0;
}

.wordle-cell {
    width: 60px;
    height: 60px;
    background-color: #42527c;
    color: #fff;
    font-size: 2em;
    font-weight: bold;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--color-accent);
    text-transform: uppercase;
}

.wordle-cell.correct {
    background-color: #43a047; /* Green */
}

.wordle-cell.present {
    background-color: #ffd600; /* Yellow */
    color: #34343a;
}

.wordle-cell.absent {
    background-color: #3a4366;
}

#wordleInputArea {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

#wordleInput {
    padding: 8px;
    font-size: 1.2em;
    border-radius: 6px;
    border: 2px solid var(--color-accent);
    outline: none;
    width: 160px;
    background: #36486c;
    color: #fff;
}

#wordleSubmit {
    padding: 8px 20px;
    background-color: var(--color-accent);
    color: #34343a;
    border: none;
    outline: none;
    font-size: 1em;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}

#wordleSubmit:hover {
    background-color: #5187a2;
    transform: translateY(-2px);
}

#wordleStats {
    color: #fff;
    font-size: 20px;
    font-weight: 500;
    background: rgba(60,70,108,0.7);
    border-radius: 10px;
    padding: 12px 24px;
    min-width: 220px;
    text-align: center;
    margin-top: 24px; /* Increased margin for separation */
}

/* End of Tic Tac Toe Styles */

/* Wordle Styles */

@keyframes shake {
    0% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-5px); }
    100% { transform: translateX(0); }
}
@keyframes wave {
    0% { transform: scaleY(1); }
    50% { transform: scaleY(1.3); }
    100% { transform: scaleY(1); }
}
.sudoku-difficulty-container {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.sudoku-difficulty-select {
    border-radius: 10px;
    border: 2px solid var(--color-accent);
    background: #fff;
    color: #232323;
    font-weight: bold;
    padding: 6px 16px;
    box-shadow: 0 2px 8px #0001;
    outline: none;
    transition: border 0.2s, box-shadow 0.2s;
}

.sudoku-difficulty-select:focus {
    border-color: var(--color-action-primary);
    box-shadow: 0 0 0 2px var(--color-accent);
}

.theme-dark .sudoku-difficulty-select {
    background: #232323;
    color: #e0e0e0;
    border: 2px solid var(--color-accent);
    box-shadow: 0 2px 8px #0006;
}
