:root {
    --ink: #171315;
    --ink-soft: #403a3d;
    --paper: #f3efe7;
    --paper-deep: #e5ded1;
    --red: #a32939;
    --red-dark: #761c29;
    --sage: #83927c;
    --line: rgba(23, 19, 21, .16);
    --shadow: 0 24px 70px rgba(26, 18, 20, .16);
    --serif: Georgia, 'Times New Roman', serif;
    --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
    margin: 0;
    min-height: 100vh;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--sans);
    line-height: 1.55;
}
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: .22em; }
button, input { font: inherit; }
img { max-width: 100%; }

.site-header {
    min-height: 76px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 14px clamp(20px, 5vw, 76px);
    border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; letter-spacing: -.02em; }
.brand strong { font-weight: 750; }
.brand-mark {
    width: 36px; height: 36px; display: grid; place-items: center;
    border: 1px solid var(--ink); border-radius: 50%;
    font: italic 700 23px/1 var(--serif);
}
.site-nav { display: flex; align-items: center; gap: 22px; font-size: .9rem; }
.site-nav a:not(.button), .link-button { text-decoration: none; border-bottom: 1px solid transparent; }
.site-nav a:not(.button):hover, .link-button:hover { border-bottom-color: currentColor; }
.account-name { color: var(--ink-soft); }
.inline-form { display: inline; margin: 0; }
.link-button { border: 0; background: transparent; padding: 0; color: inherit; cursor: pointer; }

main { min-height: calc(100vh - 146px); }
.site-footer {
    min-height: 70px; display: flex; justify-content: space-between; align-items: center;
    padding: 18px clamp(20px, 5vw, 76px); border-top: 1px solid var(--line);
    color: var(--ink-soft); font-size: .78rem; letter-spacing: .06em; text-transform: uppercase;
}

.button {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: 46px; padding: 10px 22px; border: 1px solid var(--ink); border-radius: 999px;
    background: var(--ink); color: white; font-weight: 700; font-size: .9rem;
    text-decoration: none; cursor: pointer; transition: transform .18s ease, background .18s ease, color .18s ease;
}
.button:hover { transform: translateY(-1px); background: var(--red-dark); border-color: var(--red-dark); }
.button-small { min-height: 38px; padding: 7px 16px; }
.button-quiet { background: transparent; color: var(--ink); }
.button-quiet:hover { color: white; }
.button-full { width: 100%; margin-top: 20px; }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; }
.eyebrow { display: block; color: var(--red); font-size: .72rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }

.home-hero {
    width: min(1180px, calc(100% - 40px)); min-height: calc(100vh - 146px); margin: auto;
    display: grid; grid-template-columns: 1.25fr .75fr; align-items: center; gap: clamp(40px, 8vw, 130px);
    padding: 70px 0;
}
.home-copy h1, .library-heading h1, .auth-intro h1, .narrow-card h1 {
    margin: 14px 0 22px; font: 500 clamp(3.1rem, 7vw, 7rem)/.9 var(--serif); letter-spacing: -.055em;
}
.home-copy h1 em { color: var(--red); font-weight: 500; }
.home-copy > p { max-width: 620px; color: var(--ink-soft); font-size: clamp(1rem, 1.6vw, 1.2rem); }
.home-copy .button-row { margin-top: 30px; }
.featured-plaque {
    position: relative; isolation: isolate; min-height: 500px; display: flex; flex-direction: column; justify-content: flex-end;
    padding: 44px; overflow: hidden; color: #f8f3eb; background: #1b1e1b;
    border-radius: 48% 48% 18px 18px; box-shadow: var(--shadow);
}
.featured-plaque::before {
    content: ''; position: absolute; z-index: -1; inset: 8%; border: 1px solid rgba(255,255,255,.18); border-radius: 50% 50% 8px 8px;
    background: radial-gradient(circle at 50% 28%, rgba(142, 163, 130, .45), transparent 38%), repeating-radial-gradient(circle at 50% 30%, transparent 0 38px, rgba(255,255,255,.04) 39px 40px);
}
.featured-plaque h2 { margin: 8px 0 14px; font: italic 500 clamp(3.3rem, 6vw, 5.8rem)/.82 var(--serif); letter-spacing: -.05em; }
.featured-plaque p { max-width: 300px; margin: 0 0 26px; color: rgba(255,255,255,.72); }
.plaque-kicker, .plaque-meta { font-size: .68rem; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
.plaque-kicker { color: #c9d7bf; }
.plaque-meta { color: rgba(255,255,255,.52); }

.auth-shell { min-height: calc(100vh - 146px); display: grid; grid-template-columns: 1fr 1fr; }
.auth-intro { position: relative; overflow: hidden; padding: clamp(50px, 9vw, 130px); background: var(--ink); color: var(--paper); }
.auth-intro h1 { max-width: 620px; color: white; }
.auth-intro p { max-width: 480px; color: rgba(255,255,255,.64); font-size: 1.08rem; }
.stone-orbit { position: absolute; right: -100px; bottom: -120px; width: 420px; height: 420px; border: 1px solid rgba(255,255,255,.1); border-radius: 50%; }
.stone-orbit span { position: absolute; border: 1px solid rgba(255,255,255,.13); border-radius: 50%; }
.stone-orbit span:nth-child(1) { inset: 58px; }
.stone-orbit span:nth-child(2) { inset: 125px; }
.stone-orbit span:nth-child(3) { width: 45px; height: 45px; left: 23px; top: 175px; background: var(--red); border: 0; }
.auth-card { width: min(520px, calc(100% - 48px)); margin: auto; padding: 60px 0; }
.auth-card h2 { margin: 0 0 28px; font: 500 2.2rem/1 var(--serif); }
label { display: block; margin: 18px 0 7px; font-size: .78rem; font-weight: 800; letter-spacing: .04em; }
input {
    width: 100%; min-height: 50px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 7px;
    background: rgba(255,255,255,.55); color: var(--ink); outline: none;
}
input:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(163,41,57,.12); }
.field-note { margin: 5px 0 0; color: var(--ink-soft); font-size: .76rem; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; margin-top: 18px; }
.label-row label { margin-top: 0; }
.label-row a { font-size: .78rem; }
.form-errors { padding: 13px 16px; border-left: 3px solid var(--red); background: rgba(163,41,57,.08); color: #6c1824; font-size: .88rem; }
.form-errors ul { margin: 0; padding-left: 19px; }
.auth-switch, .auth-links { margin-top: 22px; color: var(--ink-soft); font-size: .86rem; text-align: center; }
.auth-links p { margin: 7px 0; }
.narrow-card { width: min(520px, calc(100% - 40px)); margin: 0 auto; padding: clamp(70px, 10vw, 140px) 0; }
.narrow-card h1 { font-size: clamp(3rem, 7vw, 5.4rem); }
.narrow-card > p { color: var(--ink-soft); }

.flash { width: min(760px, calc(100% - 40px)); margin: 20px auto; padding: 13px 17px; border-radius: 7px; font-size: .88rem; }
.flash-success { background: #dce8d7; color: #294124; }
.flash-warning { background: #f3e4bd; color: #604910; }
.flash-error { background: #f2d8dc; color: #721d2a; }
.flash-info { background: #dae5ea; color: #243f4c; }

.library-heading { width: min(1180px, calc(100% - 40px)); margin: auto; padding: 70px 0 44px; display: flex; justify-content: space-between; align-items: end; gap: 40px; }
.library-heading h1 { max-width: 760px; margin-bottom: 0; font-size: clamp(3rem, 6vw, 5.8rem); }
.library-heading > p { max-width: 280px; color: var(--ink-soft); }
.game-grid { width: min(1180px, calc(100% - 40px)); margin: 0 auto 90px; display: grid; gap: 30px; }
.game-card { display: grid; grid-template-columns: .85fr 1.15fr; min-height: 480px; overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,255,.33); box-shadow: var(--shadow); }
.game-card-art { position: relative; min-height: 420px; display: grid; place-items: center; overflow: hidden; background: radial-gradient(circle at 50% 35%, #86947f, #303b35 56%, #171b19); }
.game-card-art::after { content: ''; position: absolute; inset: 24px; border: 1px solid rgba(255,255,255,.18); border-radius: 50% 50% 8px 8px; }
.game-card-art img { position: relative; z-index: 1; width: min(73%, 360px); max-height: 390px; filter: drop-shadow(0 24px 24px rgba(0,0,0,.4)); }
.available-badge { position: absolute; z-index: 2; left: 28px; top: 28px; padding: 7px 12px; border: 1px solid rgba(255,255,255,.35); border-radius: 999px; color: white; font-size: .68rem; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.game-card-copy { display: flex; flex-direction: column; justify-content: center; align-items: flex-start; padding: clamp(38px, 7vw, 88px); }
.game-card-copy h2 { margin: 9px 0 20px; font: italic 500 clamp(3rem, 6vw, 5.7rem)/.88 var(--serif); letter-spacing: -.05em; }
.game-card-copy > p { max-width: 590px; color: var(--ink-soft); font-size: 1.04rem; }
.game-stats { width: 100%; display: flex; gap: 28px; padding: 23px 0; margin: 12px 0 26px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); color: var(--ink-soft); font-size: .76rem; text-transform: uppercase; letter-spacing: .08em; }
.game-stats strong { display: block; color: var(--ink); font: 500 1.55rem/1.2 var(--serif); letter-spacing: 0; text-transform: none; }
.empty-library { padding: 70px; border: 1px dashed var(--line); border-radius: 18px; text-align: center; }
.empty-library h2 { margin: 10px 0; font: 500 2.5rem/1 var(--serif); }

.game-page { background: #0d0d0e; color: #eee9df; }
.game-page .site-header, .game-page .site-footer { display: none; }
.game-page main { min-height: 100vh; }
.game-shell { min-height: 100vh; padding: 18px clamp(12px, 2vw, 28px) 26px; background: radial-gradient(circle at 50% 0, #272327, #0d0d0e 48%); }
.game-topbar { width: min(1320px, 100%); margin: auto; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 2px 0 14px; }
.game-topbar > div { text-align: center; }
.game-topbar h1 { margin: 2px 0 0; font: italic 500 clamp(1.7rem, 3vw, 2.6rem)/1 var(--serif); }
.game-topbar .eyebrow { color: #9aaa90; font-size: .57rem; }
.game-back { justify-self: start; color: rgba(255,255,255,.65); font-size: .82rem; text-decoration: none; }
.icon-button { justify-self: end; width: 38px; height: 38px; border: 1px solid rgba(255,255,255,.24); border-radius: 50%; background: transparent; color: white; cursor: pointer; }
.game-hud { width: min(1320px, 100%); margin: auto; display: grid; grid-template-columns: 1fr 1fr minmax(250px, 2fr) 1fr; border: 1px solid rgba(255,255,255,.12); border-bottom: 0; background: rgba(0,0,0,.34); }
.hud-item { min-height: 64px; padding: 10px 16px; display: flex; flex-direction: column; justify-content: center; border-right: 1px solid rgba(255,255,255,.1); }
.hud-item:last-child { border-right: 0; }
.hud-item span { color: rgba(255,255,255,.48); font-size: .59rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.hud-item strong { font: 500 1.08rem/1.2 var(--serif); }
.game-stage { position: relative; width: min(1320px, 100%); aspect-ratio: 16 / 8.6; min-height: 330px; max-height: calc(100vh - 245px); margin: auto; overflow: hidden; border: 1px solid rgba(255,255,255,.12); background: black; }
.start-prompt, .game-message { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 30px; background: radial-gradient(circle, rgba(5,5,6,.25), rgba(5,5,6,.78)); }
.start-prompt { pointer-events: none; }
.start-prompt[hidden] { display: none; }
.start-prompt span { color: #aabd9e; font-size: .65rem; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
.start-prompt strong { margin: 8px 0; font: 500 clamp(2rem, 5vw, 4.8rem)/1 var(--serif); }
.start-prompt small { color: rgba(255,255,255,.52); }
.game-message[hidden] { display: none; }
.game-message { z-index: 4; backdrop-filter: blur(6px); }
.game-message h2 { margin: 8px 0; font: italic 500 clamp(3rem, 7vw, 6rem)/.9 var(--serif); }
.game-message p { max-width: 560px; color: rgba(255,255,255,.72); }
.game-message .button-row { margin-top: 16px; justify-content: center; }
.game-page .button { border-color: #eee9df; background: #eee9df; color: #161316; }
.game-page .button:hover { background: #c73349; border-color: #c73349; color: white; }
.game-page .button-quiet { background: transparent; color: #eee9df; }
.game-controls { width: min(1320px, 100%); margin: 12px auto 0; display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.control-help { display: flex; flex-wrap: wrap; gap: 18px; color: rgba(255,255,255,.48); font-size: .68rem; }
kbd { min-width: 23px; display: inline-grid; place-items: center; margin-right: 3px; padding: 2px 5px; border: 1px solid rgba(255,255,255,.22); border-radius: 4px; background: rgba(255,255,255,.06); color: rgba(255,255,255,.82); font: inherit; }
.help-dialog { width: min(560px, calc(100% - 30px)); padding: 36px; border: 1px solid rgba(255,255,255,.17); border-radius: 14px; background: #1a181b; color: #eee9df; box-shadow: 0 30px 90px #000; }
.help-dialog::backdrop { background: rgba(0,0,0,.76); backdrop-filter: blur(4px); }
.help-dialog h2 { margin: 8px 0 18px; font: 500 2.3rem/1 var(--serif); }
.help-dialog ol { padding-left: 20px; color: rgba(255,255,255,.7); }
.help-dialog li { margin: 10px 0; }
.dialog-close { position: absolute; right: 15px; top: 12px; border: 0; background: transparent; color: white; font-size: 1.7rem; cursor: pointer; }

@media (max-width: 840px) {
    .home-hero { grid-template-columns: 1fr; padding: 50px 0; }
    .featured-plaque { min-height: 420px; }
    .auth-shell { grid-template-columns: 1fr; }
    .auth-intro { min-height: 360px; padding: 60px 30px; }
    .auth-card { padding: 48px 0 70px; }
    .library-heading { align-items: flex-start; flex-direction: column; }
    .game-card { grid-template-columns: 1fr; }
    .game-card-art { min-height: 350px; }
    .game-hud { grid-template-columns: repeat(3, 1fr); }
    .hud-item:nth-child(3) { border-top: 1px solid rgba(255,255,255,.1); }
    .game-stage { aspect-ratio: 4 / 3; max-height: none; }
    .control-help { display: none; }
    .game-controls { justify-content: center; }
}

@media (max-width: 600px) {
    .site-header { min-height: 66px; padding: 12px 16px; }
    .brand { font-size: .88rem; }
    .brand-mark { width: 31px; height: 31px; font-size: 20px; }
    .site-nav { gap: 12px; font-size: .78rem; }
    .site-nav .account-name { display: none; }
    .home-hero, .library-heading, .game-grid { width: min(100% - 28px, 1180px); }
    .home-copy h1 { font-size: 3.25rem; }
    .featured-plaque { padding: 30px; min-height: 380px; }
    .featured-plaque h2 { font-size: 3.6rem; }
    .site-footer { padding: 18px 16px; }
    .site-footer span:last-child { display: none; }
    .game-card-copy { padding: 34px 24px; }
    .game-stats { gap: 16px; justify-content: space-between; }
    .game-shell { padding: 8px 7px 16px; }
    .game-topbar { padding-bottom: 9px; }
    .game-topbar h1 { font-size: 1.55rem; }
    .game-topbar .eyebrow { display: none; }
    .game-hud { grid-template-columns: repeat(3, 1fr); }
    .hud-item { min-height: 51px; padding: 7px 9px; }
    .hud-item span { font-size: .5rem; }
    .hud-item strong { font-size: .9rem; }
    .game-stage { min-height: 360px; aspect-ratio: auto; height: calc(100vh - 210px); }
    .start-prompt strong { font-size: 2.5rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
