:root {
    color-scheme: light;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --ink: #0f0c10;
    --paper: #fffef3;
    --paper-deep: #f3eed9;
    --raptor: #c94d26;
    --raptor-dark: #793018;
    --claw: #e2a936;
    --line: rgba(15, 12, 16, 0.22);
    --panel: rgba(255, 254, 243, .82);
    --wash: #efd592;
    --shadow-size: .28rem;
}

html[data-theme="businessday"] {
    --ink: #20262d;
    --paper: #ffffff;
    --paper-deep: #edf1f4;
    --raptor: #7893a6;
    --raptor-dark: #38576d;
    --claw: #dbe5eb;
    --line: rgba(32, 38, 45, .18);
    --panel: rgba(255, 255, 255, .92);
    --wash: #dce6ec;
    --shadow-size: .18rem;
}

* { box-sizing: border-box; }

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at top right, var(--wash) 0, transparent 26rem),
        linear-gradient(145deg, var(--paper), var(--paper-deep));
}

button, select, input { font: inherit; }

.game-shell {
    width: min(46rem, calc(100% - 1.25rem));
    margin: 0 auto;
    padding: clamp(.7rem, 2vw, 1.25rem) 0 1rem;
}

.brand { display: flex; align-items: center; gap: .8rem; margin-bottom: .85rem; }
.brand img { flex: 0 0 auto; width: 46px; height: 46px; padding: .18rem; border: 1px solid var(--ink); border-radius: .55rem; background: var(--paper); box-shadow: var(--shadow-size) var(--shadow-size) 0 var(--raptor); }
.eyebrow { margin: 0 0 .16rem; font-size: .62rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(1.65rem, 4vw, 2.4rem); line-height: .95; letter-spacing: -.045em; }
.subtitle { margin: .32rem 0 0; color: rgba(15, 12, 16, .66); font-size: .86rem; }

.controls {
    display: grid;
    grid-template-columns: minmax(9rem, 1fr) auto auto;
    gap: .7rem;
    align-items: end;
    padding: .7rem;
    border: 1px solid var(--ink);
    background: var(--panel);
    box-shadow: var(--shadow-size) var(--shadow-size) 0 var(--raptor);
}

.controls > label, fieldset { display: grid; gap: .28rem; margin: 0; font-size: .75rem; font-weight: 750; }
fieldset { grid-template-columns: repeat(2, 2.35rem); padding: 0; border: 0; }
legend { margin-bottom: .28rem; }
select, .new-game { min-height: 2.35rem; border: 1px solid var(--ink); border-radius: 0; font-size: .78rem; font-weight: 750; }
select { width: 100%; padding: 0 .55rem; background: white; color: var(--ink); }
.new-game { padding: 0 1.25rem; background: var(--ink); color: var(--paper); cursor: pointer; }
.new-game:hover, .new-game:focus-visible { background: var(--raptor-dark); }
.mark-choice { position: relative; }
.mark-choice input { position: absolute; opacity: 0; pointer-events: none; }
.mark-choice span { display: grid; width: 2.35rem; height: 2.35rem; place-items: center; border: 1px solid var(--ink); background: white; cursor: pointer; font-size: 1rem; font-weight: 900; }
.mark-choice input:checked + span { background: var(--claw); box-shadow: inset 0 0 0 2px white; }
.mark-choice input:focus-visible + span { outline: 3px solid var(--raptor); outline-offset: 2px; }
.mode-description { min-height: 1.2rem; margin: .75rem 0; font-size: .8rem; font-weight: 700; }

.play-area { display: grid; grid-template-columns: minmax(15rem, 19rem) minmax(11rem, 1fr); gap: clamp(1rem, 3vw, 1.75rem); align-items: start; }
.board { display: grid; grid-template-columns: repeat(3, 1fr); width: min(100%, 19rem); aspect-ratio: 1; border: .18rem solid var(--ink); background: var(--ink); gap: .12rem; box-shadow: var(--shadow-size) var(--shadow-size) 0 var(--raptor); }
.board button { display: grid; place-items: center; min-width: 0; border: 0; background: var(--paper); color: var(--ink); cursor: pointer; font-size: clamp(2.8rem, 8vw, 4.6rem); font-weight: 850; line-height: 1; touch-action: manipulation; transition: background 120ms ease, color 120ms ease; }
.board button:not(:disabled):hover, .board button:not(:disabled):focus-visible { background: #f8df9d; outline: .25rem solid var(--raptor); outline-offset: -.35rem; }
.board button.cross { color: var(--raptor-dark); }
.board button.nought { color: #164e63; }
.board button.completed-line { background: var(--claw); color: var(--ink); }
.status-card { padding: .85rem; border-top: .22rem solid var(--raptor-dark); background: rgba(255, 255, 255, .68); }
.status-label { margin: 0; font-size: .72rem; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
.status { min-height: 3rem; margin: .45rem 0 .8rem; font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.05rem, 2.5vw, 1.45rem); line-height: 1.18; }
.malicious-rule { margin: 0 0 .8rem; padding: .7rem; border: 1px solid var(--raptor-dark); background: var(--raptor-dark); color: white; font-size: .76rem; font-weight: 800; }
.score { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0; border: 1px solid var(--ink); background: white; text-align: center; }
.score div { padding: .45rem .25rem; }
.score div + div { border-left: 1px solid var(--line); }
.score dt { font-size: .7rem; font-weight: 800; text-transform: uppercase; }
.score dd { margin: .1rem 0 0; font-size: 1.1rem; font-weight: 900; }
.clear-score { margin-top: .75rem; padding: .45rem .7rem; border: 0; background: transparent; color: var(--raptor-dark); cursor: pointer; font-size: .78rem; font-weight: 800; text-decoration: underline; }
footer { display: flex; justify-content: space-between; gap: 1rem; margin-top: 1rem; border-top: 1px solid var(--line); color: rgba(15, 12, 16, .62); font-size: .68rem; }

@media (max-width: 540px) {
    .game-shell { width: min(100% - 1rem, 34rem); padding-top: .75rem; }
    .brand { margin-bottom: 1rem; }
    .brand img { width: 42px; height: 42px; }
    .controls { grid-template-columns: 1fr auto; }
    .controls > label { grid-column: 1 / -1; }
    .new-game { padding: 0 .9rem; }
    .play-area { grid-template-columns: 1fr; }
    .board { width: min(100%, 19rem); margin: 0 auto; }
    .status { min-height: 0; }
    footer { display: block; }
}

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