/* ============================================================
   THE WAITING GAME — Restaurant-Themed Static Game Site
   ============================================================ */

:root {
    --cream: #fdf8ef;
    --parchment: #f5e9cc;
    --parchment-dark: #e8d5a8;
    --brown: #3d1c02;
    --brown-light: #6b3a1f;
    --burgundy: #7a1e1e;
    --gold: #b8963e;
    --gold-light: #d4b05a;
    --text: #3d1c02;
    --text-muted: #6b3a1f;
    --p1: #8b1a1a;
    --p2: #1a3580;
    --radius: 4px;
    --shadow: 0 2px 12px rgba(61, 28, 2, 0.15);
    --shadow-lg: 0 4px 24px rgba(61, 28, 2, 0.2);
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html { font-size: 16px; }

body {
    background-color: var(--cream);
    color: var(--text);
    font-family: 'Lora', Georgia, serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ============================================================
   LAYOUT WRAPPERS
   ============================================================ */

.site-header,
.game-nav,
.game-stage,
.ad-slot,
.site-footer {
    width: 100%;
    max-width: 860px;
    padding: 0 1rem;
}

/* ============================================================
   HEADER
   ============================================================ */

.site-header {
    text-align: center;
    padding: 2.5rem 1rem 1.5rem;
    border-bottom: 2px solid var(--gold);
}

.header-ornament {
    color: var(--gold);
    font-size: 1rem;
    letter-spacing: 0.4em;
    margin: 0.35rem 0;
}

.site-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: clamp(2rem, 6vw, 3.5rem);
    font-weight: 700;
    color: var(--brown);
    letter-spacing: 0.02em;
    line-height: 1.1;
    margin: 0.25rem 0;
}

.site-tagline {
    font-size: 1rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

/* ============================================================
   AD SLOTS
   ============================================================ */

.ad-slot {
    margin: 0.75rem auto;
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--parchment);
    border: 1px solid var(--parchment-dark);
    border-radius: var(--radius);
}

.ad-slot:empty::after {
    content: 'Advertisement';
    color: var(--text-muted);
    font-size: 0.75rem;
    opacity: 0.4;
}

/* ============================================================
   NAVIGATION
   ============================================================ */

.game-nav {
    margin: 0.75rem auto;
    padding: 1rem;
    background: var(--parchment);
    border: 2px solid var(--gold);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.menu-section-title {
    text-align: center;
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 0.9rem;
    color: var(--gold);
    letter-spacing: 0.18em;
    margin-bottom: 0.75rem;
}

.menu-items {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.menu-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
    background: none;
    border: 1px solid var(--gold);
    border-radius: var(--radius);
    padding: 0.6rem 1.25rem;
    cursor: pointer;
    font-family: 'Lora', Georgia, serif;
    color: var(--brown);
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    min-width: 120px;
}

.menu-item:hover {
    background: var(--parchment-dark);
    border-color: var(--brown);
}

.menu-item.active {
    background: var(--brown);
    border-color: var(--brown);
    color: var(--cream);
}

.item-name {
    font-size: 0.95rem;
    font-weight: 600;
}

.item-desc {
    font-size: 0.7rem;
    font-style: italic;
    opacity: 0.75;
}

/* ============================================================
   GAME STAGE
   ============================================================ */

.game-stage {
    margin: 0 auto 1rem;
}

.game-panel {
    display: none;
    background: var(--parchment);
    border: 2px solid var(--gold);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
}

.game-panel.active {
    display: block;
}

/* ============================================================
   SHARED GAME COMPONENTS
   ============================================================ */

.game-header {
    text-align: center;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--gold);
}

.game-header h2 {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.75rem;
    color: var(--brown);
}

.game-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 0.2rem;
}

.btn-reset {
    display: block;
    margin: 1.25rem auto 0;
    padding: 0.55rem 2rem;
    background: none;
    border: 2px solid var(--burgundy);
    border-radius: var(--radius);
    color: var(--burgundy);
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 0.95rem;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.btn-reset:hover {
    background: var(--burgundy);
    color: var(--cream);
}

/* ============================================================
   TIC TAC TOE
   ============================================================ */

.ttt-status {
    text-align: center;
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.1rem;
    color: var(--brown);
    margin-bottom: 1rem;
    min-height: 1.5em;
}

.ttt-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    max-width: 300px;
    margin: 0 auto;
    background: var(--gold);
    border: 3px solid var(--gold);
    border-radius: var(--radius);
}

.ttt-cell {
    background: var(--cream);
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 3rem;
    font-weight: 700;
    cursor: pointer;
    border-radius: 2px;
    transition: background 0.1s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.ttt-cell.empty:hover {
    background: var(--parchment);
}

.ttt-cell.ttt-x { color: var(--p1); cursor: default; }
.ttt-cell.ttt-o { color: var(--p2); cursor: default; }

.ttt-cell.winning {
    background: var(--parchment-dark);
}

/* ============================================================
   DOTS & BOXES
   ============================================================ */

.dab-scores {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    gap: 0.5rem;
}

.dab-score {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
}

.dab-score .player-name {
    font-size: 0.8rem;
    font-weight: 600;
}

.dab-score .score {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
}

.dab-score.player1 .player-name,
.dab-score.player1 .score { color: var(--p1); }

.dab-score.player2 .player-name,
.dab-score.player2 .score { color: var(--p2); }

.dab-turn {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1rem;
    color: var(--brown);
    text-align: center;
    flex: 1;
}

.dab-board {
    display: grid;
    margin: 0 auto;
    width: fit-content;
    /* columns/rows set dynamically in JS */
}

.dab-dot {
    width: 12px;
    height: 12px;
    background: var(--brown);
    border-radius: 50%;
    align-self: center;
    justify-self: center;
}

.dab-hline,
.dab-vline {
    cursor: pointer;
    position: relative;
    border-radius: 3px;
    transition: background 0.1s;
}

/* Expand touch/click area without affecting layout */
.dab-hline::after {
    content: '';
    position: absolute;
    top: -10px;
    bottom: -10px;
    left: 0;
    right: 0;
}

.dab-vline::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: -10px;
    right: -10px;
}

.dab-hline {
    width: 48px;
    height: 12px;
    align-self: center;
}

.dab-vline {
    width: 12px;
    height: 48px;
    justify-self: center;
}

.dab-hline.empty:hover,
.dab-vline.empty:hover {
    background: rgba(61, 28, 2, 0.2);
}

.dab-hline.drawn {
    background: var(--brown);
    cursor: default;
}

.dab-vline.drawn {
    background: var(--brown);
    cursor: default;
}

.dab-hline.drawn::after,
.dab-vline.drawn::after {
    display: none;
}

.dab-box {
    width: 48px;
    height: 48px;
    border-radius: 2px;
    transition: background 0.25s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.dab-box.p1 { background: rgba(139, 26, 26, 0.2); }
.dab-box.p2 { background: rgba(26, 53, 128, 0.2); }

/* ============================================================
   WORD SEARCH
   ============================================================ */

.ws-layout {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
    justify-content: center;
    flex-wrap: wrap;
}

.ws-grid-container {
    overflow-x: auto;
}

.ws-grid {
    display: grid;
    gap: 2px;
    user-select: none;
    -webkit-user-select: none;
}

.ws-cell {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Lora', Georgia, serif;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 3px;
    background: var(--cream);
    transition: background 0.08s;
    -webkit-tap-highlight-color: transparent;
}

.ws-cell.selecting {
    background: var(--parchment-dark);
}

.ws-cell.found {
    background: var(--gold-light);
    cursor: default;
}

.ws-sidebar {
    min-width: 130px;
    flex-shrink: 0;
}

.ws-sidebar h3 {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1rem;
    color: var(--brown);
    margin-bottom: 0.6rem;
    white-space: nowrap;
}

.ws-wordlist {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.ws-wordlist li {
    font-size: 0.875rem;
    color: var(--brown);
    transition: color 0.2s, opacity 0.2s;
}

.ws-wordlist li.found {
    text-decoration: line-through;
    opacity: 0.45;
}

.ws-complete {
    text-align: center;
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.15rem;
    color: var(--burgundy);
    margin-top: 0.75rem;
    font-style: italic;
}

/* ============================================================
   SNAKE
   ============================================================ */

.snake-scores {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
    gap: 1rem;
}

.snake-score {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 100px;
}

.snake-score .player-name {
    font-size: 0.8rem;
    font-weight: 600;
}

.snake-score .score {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
}

.snake-score.p1 .player-name,
.snake-score.p1 .score { color: var(--p1); }

.snake-score.p2 .player-name,
.snake-score.p2 .score { color: var(--p2); }

#snake-canvas {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
    border: 2px solid var(--gold);
    border-radius: var(--radius);
}

.snake-status {
    text-align: center;
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.1rem;
    color: var(--brown);
    margin: 0.75rem 0;
    min-height: 1.5em;
}

.snake-controls {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-top: 0.5rem;
}

.snake-ctrl-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.ctrl-label {
    font-size: 0.7rem;
    font-style: italic;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.ctrl-row {
    display: flex;
    gap: 3px;
}

.ctrl-btn {
    width: 44px;
    height: 44px;
    background: var(--parchment-dark);
    border: 1px solid var(--gold);
    border-radius: var(--radius);
    color: var(--brown);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    transition: background 0.1s;
    touch-action: manipulation;
}

.ctrl-btn:active {
    background: var(--gold-light);
}

.ctrl-spacer {
    width: 44px;
    height: 44px;
}

/* ============================================================
   FOOTER
   ============================================================ */

.site-footer {
    text-align: center;
    padding: 1.5rem 1rem;
    margin-top: auto;
    border-top: 1px solid var(--gold);
    color: var(--text-muted);
    font-size: 0.85rem;
    font-style: italic;
}

.footer-rule {
    color: var(--gold);
    letter-spacing: 0.5em;
    margin-bottom: 0.4rem;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 600px) {
    .game-panel {
        padding: 1rem;
    }

    .menu-item {
        min-width: 100px;
        padding: 0.5rem 0.75rem;
    }

    .item-name {
        font-size: 0.85rem;
    }

    .ttt-cell {
        font-size: 2.25rem;
    }

    .ws-cell {
        width: 21px;
        height: 21px;
        font-size: 0.65rem;
    }

    .dab-hline { width: 36px; }
    .dab-vline { height: 36px; }
    .dab-box   { width: 36px; height: 36px; font-size: 1rem; }
}

/* ============================================================
   CONNECT FOUR
   ============================================================ */

.c4-status {
    text-align: center;
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.1rem;
    color: var(--brown);
    margin-bottom: 0.75rem;
    min-height: 1.5em;
}

.c4-wrapper {
    overflow-x: auto;
}

.c4-board {
    width: fit-content;
    margin: 0 auto;
}

.c4-indicator-row {
    display: flex;
    gap: 6px;
    padding: 0 8px;
    margin-bottom: 4px;
}

.c4-indicator {
    width: 44px;
    height: 12px;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.1s;
}

.c4-indicator.active { opacity: 1; }
.c4-ind-p1.active { background: var(--p1); }
.c4-ind-p2.active { background: var(--p2); }

.c4-grid {
    display: grid;
    grid-template-columns: repeat(7, 44px);
    grid-template-rows: repeat(6, 44px);
    gap: 6px;
    background: var(--brown);
    padding: 8px;
    border-radius: 8px;
}

.c4-cell {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--cream);
    transition: background 0.15s;
}

.c4-cell.c4-p1 { background: var(--p1); }
.c4-cell.c4-p2 { background: var(--p2); }
.c4-cell.c4-win {
    box-shadow: 0 0 0 3px var(--gold-light);
}

.c4-col:hover .c4-cell.empty {
    background: var(--parchment-dark);
}

/* ============================================================
   SUDOKU
   ============================================================ */

.sudoku-top {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}

.sudoku-difficulty {
    display: flex;
    gap: 0.4rem;
}

.diff-btn {
    padding: 0.35rem 1rem;
    background: none;
    border: 1px solid var(--gold);
    border-radius: var(--radius);
    font-family: 'Lora', Georgia, serif;
    font-size: 0.85rem;
    color: var(--brown);
    cursor: pointer;
    transition: background 0.1s, color 0.1s;
}

.diff-btn:hover { background: var(--parchment-dark); }
.diff-btn.active {
    background: var(--brown);
    border-color: var(--brown);
    color: var(--cream);
}

.sudoku-layout {
    display: flex;
    gap: 1.25rem;
    justify-content: center;
    align-items: flex-start;
    flex-wrap: wrap;
}

.sudoku-grid {
    display: grid;
    grid-template-columns: repeat(9, 36px);
    grid-template-rows: repeat(9, 36px);
    border: 3px solid var(--brown);
    border-radius: 2px;
    overflow: hidden;
}

.su-cell {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Lora', Georgia, serif;
    font-size: 1rem;
    border: 1px solid var(--parchment-dark);
    cursor: pointer;
    transition: background 0.1s;
    user-select: none;
}

.su-cell.su-given    { font-weight: 700; color: var(--brown); cursor: default; }
.su-cell.su-selected { background: var(--parchment-dark); }
.su-cell.su-related  { background: #f0e8d8; }
.su-cell.su-error    { color: var(--burgundy); background: rgba(122,30,30,0.08); }
.su-cell.su-correct  { color: var(--p2); }

.su-cell.box-right  { border-right: 3px solid var(--brown); }
.su-cell.box-bottom { border-bottom: 3px solid var(--brown); }

.sudoku-numpad {
    display: grid;
    grid-template-columns: repeat(5, 40px);
    gap: 5px;
    align-content: start;
}

.su-num-btn {
    width: 40px;
    height: 40px;
    background: var(--cream);
    border: 1px solid var(--gold);
    border-radius: var(--radius);
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.1rem;
    color: var(--brown);
    cursor: pointer;
    transition: background 0.1s;
}

.su-num-btn:hover { background: var(--parchment-dark); }
.su-erase { font-size: 1rem; }

.sudoku-status {
    text-align: center;
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.1rem;
    color: var(--burgundy);
    margin-top: 0.75rem;
    min-height: 1.5em;
    font-style: italic;
}

/* ============================================================
   BATTLESHIP
   ============================================================ */

.bs-handoff {
    text-align: center;
    padding: 2rem 1rem;
}

.bs-handoff-icon {
    font-size: 3rem;
    margin-bottom: 0.75rem;
}

.bs-handoff h3 {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.5rem;
    color: var(--brown);
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.bs-handoff p {
    font-style: italic;
    color: var(--text-muted);
    margin-bottom: 1.25rem;
}

.bs-handoff-btn {
    padding: 0.7rem 2rem;
    background: var(--brown);
    border: none;
    border-radius: var(--radius);
    color: var(--cream);
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.15s;
}

.bs-handoff-btn:hover { background: var(--brown-light); }

.bs-turn-label {
    text-align: center;
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1rem;
    color: var(--brown);
    margin-bottom: 0.75rem;
    font-style: italic;
}

.bs-grids {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

.bs-grid-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
}

.bs-grid-label {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 0.9rem;
    color: var(--gold);
    letter-spacing: 0.1em;
}

.bs-grid {
    display: flex;
    flex-direction: column;
}

.bs-label-row,
.bs-row {
    display: flex;
}

.bs-corner,
.bs-col-label,
.bs-row-label {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    color: var(--text-muted);
    font-family: 'Lora', Georgia, serif;
}

.bs-cell {
    width: 26px;
    height: 26px;
    border: 1px solid var(--parchment-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    background: var(--cream);
    transition: background 0.1s;
    cursor: default;
}

.bs-cell.bs-ship   { background: var(--parchment-dark); }
.bs-cell.bs-hit    { background: rgba(139,26,26,0.2); color: var(--p1); font-weight: 700; }
.bs-cell.bs-miss   { background: rgba(26,53,128,0.1);  color: var(--text-muted); }
.bs-cell.bs-targetable {
    cursor: crosshair;
}
.bs-cell.bs-targetable:hover { background: rgba(184,150,62,0.25); }

.bs-fleet {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
}

.bs-ship-item {
    font-size: 0.7rem;
    font-family: 'Lora', Georgia, serif;
    color: var(--brown);
}

.bs-ship-item.sunk {
    text-decoration: line-through;
    opacity: 0.5;
}

.bs-result {
    text-align: center;
    margin-top: 0.75rem;
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
}

.bs-hit-msg  { color: var(--p1); font-size: 1.15rem; }
.bs-miss-msg { color: var(--p2); font-size: 1.15rem; }

.bs-pass-btn {
    padding: 0.55rem 1.75rem;
    background: none;
    border: 2px solid var(--burgundy);
    border-radius: var(--radius);
    color: var(--burgundy);
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.bs-pass-btn:hover {
    background: var(--burgundy);
    color: var(--cream);
}

@media (max-width: 600px) {
    .bs-cell {
        width: 22px;
        height: 22px;
        font-size: 0.6rem;
    }
    .bs-corner,
    .bs-col-label,
    .bs-row-label { width: 16px; height: 22px; font-size: 0.55rem; }

    .sudoku-grid {
        grid-template-columns: repeat(9, 32px);
        grid-template-rows: repeat(9, 32px);
    }
    .su-cell { width: 32px; height: 32px; font-size: 0.9rem; }

    .sudoku-numpad { grid-template-columns: repeat(5, 36px); }
    .su-num-btn { width: 36px; height: 36px; font-size: 1rem; }

    .c4-grid {
        grid-template-columns: repeat(7, 38px);
        grid-template-rows: repeat(6, 38px);
    }
    .c4-cell { width: 38px; height: 38px; }
    .c4-indicator { width: 38px; }
}
