:root {
    --ink: #102f31;
    --muted: #607274;
    --paper: #f5f1e8;
    --card: #fffdf8;
    --coral: #ef6b57;
    --teal: #1ba6a0;
    --gold: #f1b94a;
    --line: rgba(16, 47, 49, .13);
    font-family: Inter, ui-rounded, "SF Pro Rounded", system-ui, -apple-system, sans-serif;
    color: var(--ink);
    background: var(--paper);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body {
    background:
        radial-gradient(circle at 10% 0%, rgba(241,185,74,.2), transparent 30rem),
        linear-gradient(180deg, #f8f5ed, var(--paper));
}
button, input { font: inherit; }
a { color: inherit; }

.site-header {
    height: 68px;
    padding: max(12px, env(safe-area-inset-top)) 18px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 850;
    text-decoration: none;
    letter-spacing: -.03em;
}
.brand-mark {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 11px;
    color: white;
    background: var(--ink);
    box-shadow: inset 0 -3px 0 rgba(0,0,0,.18);
}
.text-button {
    border: 0;
    padding: 8px;
    color: var(--muted);
    background: transparent;
}
.page-shell {
    width: min(100%, 760px);
    margin: 0 auto;
    padding: 24px 18px calc(30px + env(safe-area-inset-bottom));
}
.flash {
    margin-bottom: 16px;
    padding: 13px 15px;
    border-radius: 14px;
    background: #e8f6ef;
    font-weight: 700;
}
.flash.error { background: #ffe8e2; color: #872e22; }
.eyebrow {
    margin: 0 0 8px;
    color: var(--coral);
    font-size: .78rem;
    font-weight: 900;
    letter-spacing: .13em;
    text-transform: uppercase;
}
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 12px; font-size: clamp(2rem, 9vw, 3.4rem); line-height: .98; letter-spacing: -.055em; }
h2 { letter-spacing: -.035em; }
.lead, .hero > p:not(.eyebrow), .form-card > p { color: var(--muted); line-height: 1.55; }
.hero {
    padding: 28px 2px 34px;
}
.hero-actions {
    margin-top: 18px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.hero-actions form { margin: 0; }
.primary-button, .secondary-button {
    min-height: 50px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 16px;
    padding: 13px 19px;
    text-decoration: none;
    font-weight: 850;
    cursor: pointer;
}
.primary-button {
    color: white;
    background: var(--ink);
    box-shadow: 0 8px 22px rgba(16,47,49,.18), inset 0 -3px 0 rgba(0,0,0,.18);
}
.secondary-button { color: var(--ink); background: #ebe5d9; }
.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.section-heading span {
    min-width: 28px;
    padding: 4px 8px;
    border-radius: 99px;
    text-align: center;
    background: #e6dfd1;
    font-weight: 800;
}
.game-list { display: grid; gap: 10px; }
.game-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: rgba(255,253,248,.85);
    text-decoration: none;
    box-shadow: 0 7px 22px rgba(16,47,49,.05);
}
.game-row div:first-child { display: grid; gap: 4px; }
.game-row span { color: var(--muted); font-size: .88rem; }
.mini-score { font-size: 1.55rem; font-weight: 900; letter-spacing: -.07em; }
.empty-state {
    padding: 24px;
    border: 1px dashed rgba(16,47,49,.25);
    border-radius: 18px;
    color: var(--muted);
    text-align: center;
}
.auth-page .page-shell { min-height: calc(100vh - 68px); display: grid; align-items: center; }
.auth-card, .form-card {
    padding: clamp(22px, 6vw, 40px);
    border: 1px solid var(--line);
    border-radius: 28px;
    background: rgba(255,253,248,.9);
    box-shadow: 0 18px 60px rgba(16,47,49,.1);
}
.form-card { margin-top: 16px; }
.back-link { display: inline-block; margin-bottom: 28px; color: var(--muted); text-decoration: none; font-weight: 750; }
.stack-form { display: grid; gap: 16px; margin-top: 24px; }
.stack-form label { display: grid; gap: 7px; font-size: .88rem; font-weight: 800; }
.stack-form input {
    width: 100%;
    min-height: 52px;
    border: 1px solid rgba(16,47,49,.19);
    border-radius: 15px;
    padding: 12px 14px;
    outline: none;
    color: var(--ink);
    background: white;
}
.stack-form input:focus { border-color: var(--teal); box-shadow: 0 0 0 4px rgba(27,166,160,.12); }

.game-page { overflow: hidden; }
.game-page .site-header { display: none; }
.game-page .page-shell { width: 100%; max-width: none; height: 100dvh; padding: 0; }
.game-layout {
    height: 100%;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    background: #0e2a2c;
    color: white;
}
.scoreboard {
    padding: calc(10px + env(safe-area-inset-top)) 14px 9px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 8px;
    background: #102f31;
}
.player {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 9px;
}
.player:last-child { flex-direction: row-reverse; text-align: right; }
.player::before {
    content: "";
    width: 11px;
    height: 11px;
    flex: 0 0 auto;
    border-radius: 50%;
    box-shadow: 0 0 0 4px rgba(255,255,255,.08);
}
.player.coral::before { background: var(--coral); }
.player.teal::before { background: var(--teal); }
.player-name { overflow: hidden; font-size: .8rem; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.player .score { font-size: 1.8rem; line-height: 1; letter-spacing: -.07em; }
.round-pill { padding: 5px 9px; border-radius: 99px; color: #b9c9c9; background: rgba(255,255,255,.08); font-size: .7rem; font-weight: 800; }
.status-panel {
    min-height: 48px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: #dbe7e6;
    background: #173638;
}
.status-panel strong { font-size: .92rem; }
.status-panel span { color: #96adad; font-size: .75rem; }
.board-stage {
    position: relative;
    min-height: 0;
    overflow: hidden;
    touch-action: none;
    background: #081d1e;
}
#board-canvas { width: 100%; height: 100%; display: block; touch-action: none; }
.turn-explanation {
    position: absolute;
    z-index: 2;
    top: 14px;
    left: 14px;
    width: min(255px, calc(100% - 118px));
    padding: 12px 14px;
    display: grid;
    gap: 3px;
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 15px;
    color: white;
    background: rgba(7,25,26,.9);
    box-shadow: 0 10px 28px rgba(0,0,0,.3);
    pointer-events: none;
}
.turn-explanation[hidden] { display: none; }
.turn-explanation small {
    color: #83d5d0;
    font-size: .66rem;
    font-weight: 900;
    letter-spacing: .1em;
    text-transform: uppercase;
}
.turn-explanation strong { font-size: .88rem; }
.turn-explanation span { color: #c4d4d3; font-size: .74rem; line-height: 1.35; }
.aim-hint {
    position: absolute;
    left: 50%;
    bottom: 16px;
    width: max-content;
    max-width: calc(100% - 32px);
    padding: 10px 16px;
    display: grid;
    gap: 2px;
    border-radius: 14px;
    text-align: center;
    color: #173638;
    background: rgba(255,253,248,.9);
    box-shadow: 0 8px 30px rgba(0,0,0,.25);
    transform: translateX(-50%);
    pointer-events: none;
    transition: opacity .2s;
}
.aim-hint span { font-size: .82rem; font-weight: 850; }
.aim-hint small { color: #677; }
.aim-hint.hidden { opacity: 0; }
.game-actions {
    min-height: calc(57px + env(safe-area-inset-bottom));
    padding: 7px 14px calc(7px + env(safe-area-inset-bottom));
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #102f31;
}
.game-actions a { color: #b9c9c9; font-size: .83rem; font-weight: 750; text-decoration: none; }
.game-actions .secondary-button { min-height: 39px; padding: 8px 13px; font-size: .8rem; }
.game-actions .secondary-button[aria-pressed="true"] {
    color: white;
    background: rgba(27,166,160,.72);
}

@media (min-width: 700px) {
    .game-layout { width: min(100%, 720px); margin: 0 auto; box-shadow: 0 0 70px #000; }
}
