@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Space+Grotesk:wght@500;600;700&display=swap');

:root {
  --ink: #121212;
  --paper: #f4efdf;
  --red: #ed3d2b;
  --yellow: #ffd438;
  --muted: #777164;
  --line: rgba(18, 18, 18, 0.22);
  --shell: #ece5d2;
  font-family: "Space Grotesk", Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); }
button, a { color: inherit; font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

/* ------------------------------------------------------------- masthead */
.masthead { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 74px; max-width: 1440px; margin: auto; padding: 0 3vw; border-inline: 2px solid var(--ink); border-bottom: 2px solid var(--ink); }
.wordmark { margin: 0; font: 700 .95rem/1 "Space Grotesk", sans-serif; letter-spacing: -.02em; }
.house-status { display: flex; align-items: center; gap: .6rem; margin: 0; font: 500 .65rem/1 "DM Mono", monospace; letter-spacing: .08em; }
.house-status span { width: 8px; height: 8px; background: var(--red); border-radius: 50%; box-shadow: 0 0 0 4px rgba(237,61,43,.14); animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.7); opacity: .55; } }

/* ----------------------------------------------------------------- hero */
main { max-width: 1440px; margin: auto; border-inline: 2px solid var(--ink); }
.intro { position: relative; min-height: 360px; padding: clamp(2.2rem, 4.5vw, 4.4rem) 5vw 2.5rem; overflow: hidden; border-bottom: 2px solid var(--ink); }
.intro::after { position: absolute; content: "●"; right: 2vw; top: 50%; z-index: 0; color: var(--yellow); font-size: clamp(17rem, 34vw, 32rem); line-height: .5; transform: translateY(-46%); }
.intro > * { position: relative; z-index: 1; }
.eyebrow, .label { margin: 0; font: 500 .66rem/1 "DM Mono", monospace; letter-spacing: .11em; text-transform: uppercase; }
h1 { margin: 1.1rem 0 0; max-width: 900px; font-size: clamp(3.4rem, 9.4vw, 9rem); font-weight: 700; line-height: .78; letter-spacing: -.085em; }
h1 span { color: var(--red); }
.lede { max-width: 360px; margin: 1.6rem 0 0 auto; font: 500 clamp(.88rem, 1.5vw, 1.08rem)/1.45 "DM Mono", monospace; }

/* ----------------------------------------------------------- game shell */
.game-shell { background: var(--shell); }
.game-topline { display: flex; align-items: center; justify-content: space-between; gap: 2rem; min-height: 104px; padding: 1.4rem 5vw; border-bottom: 2px solid var(--ink); }
.status { margin: 0; font-size: clamp(1.2rem, 2.4vw, 2.1rem); font-weight: 600; letter-spacing: -.045em; }
.turn-pill { display: flex; flex: none; align-items: center; gap: .65rem; min-width: 148px; padding: .8rem 1rem; color: var(--paper); background: var(--ink); font: 500 .66rem/1 "DM Mono", monospace; }
.turn-pill > span:first-child { width: 8px; height: 8px; background: var(--yellow); border-radius: 50%; }
.turn-pill.house > span:first-child { background: var(--red); }

.game-grid { display: grid; grid-template-columns: minmax(0, 1.42fr) minmax(300px, .58fr); }
.play-area { min-width: 0; padding: clamp(1.6rem, 3.2vw, 3.2rem); border-right: 2px solid var(--ink); }

/* --------------------------------------------------------------- board */
.board-frame { max-width: 660px; margin: auto; padding-top: 34px; }
.board { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; aspect-ratio: 7 / 6; container-type: inline-size; background: var(--ink); border: 2px solid var(--ink); box-shadow: 13px 13px 0 var(--red); }
.column { position: relative; display: grid; grid-template-rows: repeat(6, minmax(0, 1fr)); gap: 2px; min-width: 0; padding: 0; background: var(--ink); border: 0; cursor: pointer; }
.column:disabled { cursor: default; }
.column:focus-visible { z-index: 2; outline: 4px solid #1976d2; outline-offset: 2px; }
.cell { position: relative; min-width: 0; background: var(--paper); }
.column:not(:disabled):hover .cell,
.column:not(:disabled):focus-visible .cell { background: #f8ecb9; }
.cell::before { position: absolute; content: ""; inset: 11%; border-radius: 50%; }
.cell.x::before { background: var(--ink); }
.cell.o::before { background: var(--red); }
.cell.winner { background: var(--yellow); }
.cell.winner::before { box-shadow: 0 0 0 3px var(--ink); }

/* the ghost disc showing where your drop would land */
.cell.landing::after { position: absolute; content: ""; inset: 11%; border: 3px dashed rgba(18,18,18,.42); border-radius: 50%; opacity: 0; transition: opacity .12s ease; }
.column:not(:disabled):hover .cell.landing::after,
.column:not(:disabled):focus-visible .cell.landing::after { opacity: 1; }
.arrow { position: absolute; top: -30px; left: 0; right: 0; color: var(--red); font-size: 1.05rem; line-height: 1; text-align: center; opacity: 0; transition: opacity .12s ease, transform .12s ease; }
.column:not(:disabled):hover .arrow,
.column:not(:disabled):focus-visible .arrow { opacity: 1; transform: translateY(3px); }

/* a column the House has bolted shut */
.column.closed .cell { background: repeating-linear-gradient(45deg, #e7ddc4 0 7px, #d6c9a8 7px 14px); }
.closed-tag { position: absolute; inset: 0; z-index: 1; display: grid; place-items: center; opacity: 0; pointer-events: none; }
.column.closed .closed-tag { opacity: 1; }
.closed-tag b { padding: 1.05rem .55rem; color: var(--paper); background: var(--ink); font: 500 .58rem/1 "DM Mono", monospace; letter-spacing: .3em; writing-mode: vertical-rl; }

@keyframes drop {
  from { transform: translateY(calc(var(--from, -6) * 118%)); }
  72%  { transform: translateY(0) scale(1, 1); }
  84%  { transform: translateY(0) scale(1.08, .86); }
  to   { transform: translateY(0) scale(1, 1); }
}
@keyframes fall { from { transform: translateY(calc(var(--drop, 1) * -118%)); } to { transform: none; } }
@keyframes vanish { 0% { transform: none; } 22% { transform: scale(1.18); } 100% { transform: scale(.05); opacity: 0; } }
@keyframes cell-flash { 45% { background: var(--red); } }
@keyframes seize {
  0%   { background: var(--ink); transform: scale(1); }
  34%  { background: var(--ink); transform: scale(1.22) rotate(-9deg); }
  52%  { background: var(--yellow); }
  100% { background: var(--red); transform: scale(1); }
}
.cell.dropping::before { animation: drop .42s cubic-bezier(.4, 0, .7, 1) both; }
.cell.falling::before { animation: fall .44s cubic-bezier(.4, 0, .7, 1) both; }
.cell.vanishing::before { animation: vanish .48s ease-in both; }
.cell.vanishing { animation: cell-flash .48s ease both; }
.cell.seized::before { animation: seize .56s cubic-bezier(.3, .9, .3, 1) both; }

.new-game { display: flex; justify-content: space-between; width: 100%; max-width: 660px; margin: 2rem auto 0; padding: 1rem 1.1rem; color: var(--paper); background: var(--ink); border: 2px solid var(--ink); font: 500 .73rem/1 "DM Mono", monospace; letter-spacing: .03em; cursor: pointer; }
.new-game:hover { color: var(--ink); background: var(--yellow); }
.new-game span { font-size: 1.1rem; }

/* ----------------------------------------------------------- scorecard */
.scorecard { min-width: 0; padding: clamp(1.8rem, 3.4vw, 3.4rem); background: var(--paper); }
.score-head, .log-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-bottom: 1rem; border-bottom: 2px solid var(--ink); }
.score-head > span, .log-head > span { color: var(--muted); font: 400 .6rem/1 "DM Mono", monospace; }
.scores { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 2px solid var(--ink); }
.scores > div { display: flex; min-width: 0; flex-direction: column; padding: 1.3rem 1rem 1rem 0; }
.scores > div + div { padding-left: 1.4rem; border-left: 2px solid var(--ink); }
.scores span { font: 500 .64rem/1 "DM Mono", monospace; }
.scores strong { margin-top: .4rem; font-size: clamp(3.4rem, 7vw, 6rem); line-height: 1; letter-spacing: -.09em; }
.house-score strong { color: var(--red); }
.fine-print { padding: .75rem 0 2.2rem; color: var(--muted); font: 400 .56rem/1.6 "DM Mono", monospace; }
.incident-log { min-height: 210px; max-height: 330px; margin: 0; padding: 0; overflow: auto; list-style: none; border-bottom: 1px solid var(--line); }
.incident-log li { position: relative; padding: 1rem 0 1rem 2.2rem; border-bottom: 1px solid var(--line); font: 500 .72rem/1.4 "DM Mono", monospace; }
.incident-log li::before { position: absolute; left: 0; top: .85rem; display: grid; width: 24px; height: 24px; content: attr(data-number); place-items: center; color: var(--paper); background: var(--red); border-radius: 50%; font-size: .56rem; }
.incident-log .empty-log { padding: 2.5rem 0; color: var(--muted); text-align: center; }
.incident-log .empty-log::before { display: none; }
.empty-log span { font-size: .6rem; }
.appeal { width: 100%; margin-top: 1.25rem; padding: .9rem; background: transparent; border: 2px solid var(--ink); font: 500 .67rem/1 "DM Mono", monospace; cursor: pointer; }
.appeal:hover { color: var(--paper); background: var(--red); }

footer { display: flex; align-items: center; justify-content: space-between; gap: 2rem; min-height: 100px; max-width: 1440px; margin: auto; padding: 1.5rem 3vw; color: var(--paper); background: var(--ink); font: 400 .58rem/1.4 "DM Mono", monospace; }
footer p { margin: 0; }
.toast { position: fixed; right: 1.3rem; bottom: 1.3rem; z-index: 10; max-width: min(360px, calc(100vw - 2.6rem)); padding: 1rem 1.2rem; color: var(--paper); background: var(--red); border: 2px solid var(--ink); box-shadow: 6px 6px 0 var(--ink); font: 500 .7rem/1.45 "DM Mono", monospace; transform: translateY(180%); transition: transform .25s ease; }
.toast.show { transform: translateY(0); }

@media (max-width: 980px) {
  .intro { min-height: 300px; }
  .game-grid { grid-template-columns: 1fr; }
  .play-area { border-right: 0; border-bottom: 2px solid var(--ink); }
  .scorecard { min-height: 540px; }
}
@media (max-width: 560px) {
  .masthead { min-height: 64px; padding-inline: 1rem; }
  .house-status { font-size: .52rem; }
  .house-status span { display: none; }
  .intro { min-height: 250px; padding: 2rem 1.2rem 1.6rem; }
  .intro::after { right: -12vw; }
  .lede { margin-left: 0; }
  .game-topline { min-height: 118px; align-items: flex-start; flex-direction: column; gap: 1.1rem; padding: 1.4rem 1.2rem; }
  .play-area, .scorecard { padding: 1.4rem 1.2rem; }
  .board { box-shadow: 7px 7px 0 var(--red); }
  .board-frame { padding-top: 26px; }
  .arrow { top: -23px; font-size: .85rem; }
  .closed-tag b { padding: .8rem .4rem; letter-spacing: .18em; font-size: .5rem; }
  footer { align-items: flex-start; flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
