/* Shared tokens, nav, hero, tabs and the code viewer are in shared/site.css. */

/* ─── RESET ────────────────────────────────────────────────── */

:root {
    --x-col:   var(--accent);
    --o-col:   var(--text);
    --win-col: var(--accent);
    --font-d: var(--font-display);
    --font-m: var(--font-mono);
}

/* ─── SCREENS ──────────────────────────────────────────────── */
/* the three screens share one grid cell; only the active one shows */
.app-main.ttt-screens { display: grid; align-items: center; justify-items: center; }
.screen {
    grid-area: 1 / 1;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transform: translateY(16px);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0s 0.3s;
}

.screen.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.screen-content {
    width: 100%;
    max-width: 480px;
    padding: 24px 0 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.game-layout { gap: 14px; }

/* ─── TYPOGRAPHY ───────────────────────────────────────────── */
.eyebrow {
    font-family: var(--font-m);
    font-size: 0.75rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--muted);
}

.big-title {
    font-size: clamp(3rem, 10vw, 5.5rem);
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 0.92;
    text-align: center;
    white-space: nowrap;
}

/* ─── MODE PILLS ───────────────────────────────────────────── */
.mode-row {
    display: flex;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 100px;
    padding: 4px;
    width: 100%;
    max-width: 280px;
}

.mode-pill {
    flex: 1;
    padding: 9px 0;
    font-family: var(--font-d);
    font-size: 0.9rem;
    font-weight: 700;
    border: none;
    border-radius: 100px;
    cursor: pointer;
    background: transparent;
    color: var(--muted);
    transition: background 0.2s, color 0.2s;
}

.mode-pill.active {
    background: var(--accent);
    color: var(--on-accent);
}

/* ─── NAME FIELDS ──────────────────────────────────────────── */
.name-fields {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: opacity 0.2s;
}

.field-group.hidden { display: none; }

.field-label {
    font-family: var(--font-m);
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
}

.field-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-family: var(--font-d);
    font-size: 1rem;
    font-weight: 700;
    outline: none;
    transition: border-color 0.2s;
}

.field-input:focus { border-color: var(--accent); }
.field-input::placeholder { color: var(--muted); font-weight: 400; }

.error-msg {
    font-family: var(--font-m);
    font-size: 0.78rem;
    color: #f04d6e;
    text-align: center;
}

.error-msg.hidden { display: none; }

/* ─── PLAY BUTTON ──────────────────────────────────────────── */
.btn-play {
    width: 100%;
    max-width: 280px;
    padding: 15px;
    background: var(--accent);
    color: var(--on-accent);
    border: none;
    border-radius: 12px;
    font-family: var(--font-d);
    font-size: 1rem;
    font-weight: 800;
    cursor: pointer;
    letter-spacing: -0.01em;
    transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
    box-shadow: 0 4px 24px rgba(168,85,247,0.35);
}

.btn-play:hover { transform: translateY(-2px); box-shadow: 0 8px 32px rgba(168,85,247,0.5); }
.btn-play:active { transform: translateY(0); }

/* ─── GAME TOP BAR ─────────────────────────────────────────── */
.game-topbar {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.back-btn {
    font-family: var(--font-m);
    font-size: 0.78rem;
    color: var(--muted);
    background: none;
    border: none;
    cursor: pointer;
    letter-spacing: 0.03em;
    padding: 6px 0;
    transition: color 0.2s;
}

.back-btn:hover { color: var(--text); }

.game-title-small {
    font-family: var(--font-m);
    font-size: 0.75rem;
    color: var(--muted);
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

/* ─── SCORE STRIP ──────────────────────────────────────────── */
.score-strip {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 20px;
    gap: 12px;
}

.score-block {
    display: flex;
    align-items: center;
    gap: 10px;
}

.score-right {
    justify-content: flex-end;
}

.score-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 0 12px;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
}

.score-draws {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--muted);
}

.score-draws-label {
    font-family: var(--font-m);
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
}

.score-sym {
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1;
}

.x-sym { color: var(--x-col); }
.o-sym { color: var(--o-col); opacity: 0.5; }

.score-name {
    font-family: var(--font-m);
    font-size: 0.75rem;
    color: var(--muted);
    max-width: 80px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.score-num {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text);
    min-width: 24px;
    text-align: center;
}

/* Active score highlight */
.score-block.active-turn .score-num { color: var(--accent); }
.score-block.active-turn .score-sym { filter: drop-shadow(0 0 6px currentColor); }

/* ─── TURN BAR ─────────────────────────────────────────────── */
.turn-bar {
    width: 100%;
    display: flex;
    justify-content: center;
}

.turn-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-m);
    font-size: 0.82rem;
    color: var(--muted);
    letter-spacing: 0.04em;
    padding: 6px 14px;
    border-radius: 100px;
    border: 1px solid var(--border);
    transition: border-color 0.3s;
}

.turn-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    animation: pulse 1.5s ease infinite;
}

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

/* ─── BOARD ────────────────────────────────────────────────── */
.board {
    width: 100%;
    max-width: 340px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 10px;
    aspect-ratio: 1;
}

.cell {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.4rem;
    font-weight: 800;
    cursor: pointer;
    user-select: none;
    transition: border-color 0.15s, background 0.15s, transform 0.1s;
    position: relative;
    overflow: hidden;
}

.cell:hover:not(.taken) {
    border-color: rgba(168,85,247,0.3);
    background: rgba(168,85,247,0.05);
}

.cell:active:not(.taken) { transform: scale(0.95); }

.cell.taken { cursor: default; }

.cell .mark {
    animation: markPop 0.2s cubic-bezier(0.34,1.56,0.64,1) both;
}

.cell .mark.x { color: var(--x-col); }
.cell .mark.o { color: var(--o-col); }

@keyframes markPop {
    from { transform: scale(0) rotate(-15deg); opacity: 0; }
    to   { transform: scale(1) rotate(0deg);  opacity: 1; }
}

/* Win highlight */
.cell.win-cell {
    background: var(--accent-dim);
    border-color: var(--accent);
    animation: winPulse 0.5s ease forwards;
}

@keyframes winPulse {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.06); }
    100% { transform: scale(1); }
}

/* ─── RESULT BANNER ────────────────────────────────────────── */
.result-banner {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    animation: fadeUp 0.3s ease both;
}

.result-banner.hidden { display: none; }

#resultText {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.btn-next {
    padding: 10px 20px;
    background: var(--accent);
    color: var(--on-accent);
    border: none;
    border-radius: 8px;
    font-family: var(--font-d);
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity 0.2s, transform 0.15s;
}

.btn-next:hover { transform: translateY(-1px); opacity: 0.9; }

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

/* ─── LEADERBOARD ──────────────────────────────────────────── */
.lb-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s, transform 0.15s;
}

.lb-toggle:hover { border-color: var(--accent); transform: scale(1.08); }

.lb-list {
    width: 100%;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0;
}

.lb-entry {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    animation: fadeUp 0.3s ease both;
}

.lb-rank {
    font-family: var(--font-m);
    font-size: 0.75rem;
    color: var(--muted);
    min-width: 20px;
}

.lb-rank.gold   { color: #f4c542; }
.lb-rank.silver { color: #b0bec5; }
.lb-rank.bronze { color: #cd7f32; }

.lb-name {
    flex: 1;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: -0.01em;
}

.lb-wins {
    font-family: var(--font-m);
    font-size: 0.78rem;
    color: var(--accent);
    font-weight: 400;
}

.lb-empty {
    font-family: var(--font-m);
    font-size: 0.82rem;
    color: var(--muted);
    text-align: center;
    padding: 24px 0;
}

@media (max-width: 480px) {
    .screen-content { padding: 28px 18px 50px; }
    .board { max-width: 300px; gap: 8px; }
    .cell { border-radius: 10px; font-size: 2rem; }
    .score-name { max-width: 60px; font-size: 0.75rem; }
    .score-num { font-size: 1.3rem; }
}

/* ─── EXTRACTED INLINE STYLES ────────────────────────────── */
.topbar-spacer  { width: 60px; }
.lb-title       { font-size: clamp(2.5rem, 7vw, 4.5rem); }
.lb-back-btn    { margin-top: 32px; }

/* the screens stack in one grid cell; minmax(0, 1fr) keeps them inside the page on narrow phones */
.ttt-screens { grid-template-columns: minmax(0, 1fr); }
