@font-face {
  font-family: Terrace;
  src: url("terrace-display.woff") format("woff");
  font-weight: 700;
  font-display: swap;
}

:root {
  color-scheme: light;
  --paper: #f1f1e7;
  --ink: #17231b;
  --faint: #5f6d5e;
  --panel: #14231b;
  --panel-edge: #324539;
  --lime: #dcf96b;
  --amber: #f3c674;
  --muted: #b0bca9;
  --display: Terrace, "Arial Narrow", "Liberation Sans Narrow", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.45 system-ui, sans-serif;
}

button { font: inherit; cursor: pointer; }
button:focus-visible, .arena:focus-visible { outline: 3px solid #93b833; outline-offset: 3px; }
button:active { translate: 0 1px; }
.shell { width: min(1156px, calc(100% - 64px)); margin-inline: auto; }

.top { background: #101b15; color: #f2f5e7; }
.top-inner { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; gap: 11px; align-items: center; font: 700 19px/.95 var(--display); letter-spacing: .03em; }
.brand small { display: block; margin-top: 5px; color: var(--muted); font: 700 9px/1 var(--mono); letter-spacing: .13em; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.tool {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid #435047;
  border-radius: 5px;
  background: transparent;
  color: inherit;
  font: 700 11px/1 var(--mono);
  white-space: nowrap;
}
.tool:hover { border-color: var(--lime); color: var(--lime); }
.sound-on, #sound[aria-pressed="true"] .sound-off { display: none; }
#sound[aria-pressed="true"] .sound-on { display: inline; }

.intro {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  padding-block: 30px 22px;
}
.eyebrow, .overline {
  margin: 0;
  font: 700 11px/1.25 var(--mono);
  letter-spacing: .115em;
}
.intro .eyebrow { display: flex; gap: 8px; align-items: center; }
.eyebrow span { width: 12px; height: 8px; background: #406b37; clip-path: polygon(0 100%, 32% 0, 100% 0, 68% 100%); }
h1, h2 { margin: 0; font-family: var(--display); font-weight: 700; }
h1 {
  margin-top: 6px;
  font-size: clamp(54px, 7.1vw, 92px);
  line-height: .94;
  letter-spacing: -.015em;
  white-space: nowrap;
}
h1 em {
  display: inline-block;
  position: relative;
  isolation: isolate;
  padding-inline: .025em .1em;
  font-style: normal;
  transform: skewX(-7deg);
}
h1 em::before {
  position: absolute;
  z-index: -1;
  inset: 65% 0 5%;
  background: var(--lime);
  content: "";
}
.intro > p {
  margin: 0 0 2px;
  color: #45604a;
  font-weight: 650;
  font-size: 16px;
  line-height: 1.32;
  padding-left: 15px;
  border-left: 2px solid #9db196;
}

.arcade { display: grid; grid-template-columns: minmax(0, 1fr) 266px; gap: 16px; align-items: stretch; }
.stage, .board {
  border: 1px solid var(--panel-edge);
  border-radius: 10px;
  background: var(--panel);
  color: #f0f2e7;
  box-shadow: 0 4px 0 #0b191817;
}
.stage { display: flex; flex-direction: column; min-width: 0; align-self: start; }
.stage-bar, .stage-foot {
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: space-between;
  padding: 0 14px;
}
.stage-bar {
  min-height: 42px;
  color: #b9c6b7;
  font: 700 11px/1.1 var(--mono);
  letter-spacing: .065em;
}
.live { display: inline-flex; align-items: center; gap: 7px; color: var(--lime); }
.live i { width: 7px; height: 7px; background: currentColor; box-shadow: 0 0 8px #dcf96755; }
.venue { text-align: center; }
.keeper-tag { white-space: nowrap; }
.keeper-tag b { color: #e7f1dd; }
.arena {
  width: 100%;
  aspect-ratio: 16 / 9;
  position: relative;
  background: #253d2e;
  touch-action: none;
  user-select: none;
  cursor: grab;
}
.arena:active { cursor: grabbing; }
.arena:focus-visible { outline-offset: -4px; z-index: 1; }
canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.stage-foot {
  min-height: 47px;
  color: #b8c7b5;
  font-size: 12px;
}
.gesture, .key-guide { display: flex; align-items: center; gap: 7px; }
.gesture svg { color: var(--lime); flex: 0 0 auto; }
kbd { padding: 2px 5px; border: 1px solid #82978066; border-radius: 4px; font: 700 11px/1.2 var(--mono); white-space: nowrap; }
.key-guide kbd + kbd { margin-left: 4px; }
.spot-hint {
  position: absolute;
  bottom: 19%;
  left: 50%;
  translate: -50% 0;
  border: 1px solid #d7f9a75e;
  border-radius: 4px;
  background: #13271be8;
  color: #edf8c9;
  padding: 4px 7px;
  font: 700 clamp(8px, 1.05vw, 11px)/1 var(--mono);
  letter-spacing: .04em;
  white-space: nowrap;
  pointer-events: none;
}
.spot-hint span { color: var(--lime); }
.mobile-score { display: none; }
.callout {
  position: absolute;
  left: 50%;
  top: 57%;
  translate: -50% -50%;
  min-width: 4.15em;
  padding: .08em .35em .14em;
  border: 3px solid var(--ink);
  background: var(--lime);
  color: var(--ink);
  text-align: center;
  font: 700 clamp(29px, 5.4vw, 67px)/1.02 var(--display);
  white-space: nowrap;
  box-shadow: 5px 6px #101b14b8;
  transform: skewX(-7deg);
  animation: stamp .22s ease-out both;
  pointer-events: none;
}
.callout[data-outcome="miss"] { background: #ffce83; }
.goal-reward {
  display: block;
  margin: 5px 0 2px;
  font: 700 clamp(9px, 1.55vw, 12px)/1.2 var(--mono);
  letter-spacing: .04em;
}
@keyframes stamp {
  from { opacity: .1; transform: skewX(-7deg) scale(.78); }
  to { opacity: 1; transform: skewX(-7deg) scale(1); }
}

.board { padding: 18px; display: flex; flex-direction: column; }
.board-top { display: flex; justify-content: space-between; align-items: center; color: var(--muted); }
.board-top svg { color: #839d83; }
.score-line { display: flex; align-items: baseline; gap: 9px; margin: 3px 0 16px; }
.score-line strong { font: 700 clamp(63px, 7vw, 90px)/.95 var(--display); color: var(--lime); font-variant-numeric: tabular-nums; }
.score-line span { font: 700 12px/1 var(--mono); letter-spacing: .10em; color: #c3d0be; }
.records { display: grid; grid-template-columns: 1.25fr 1fr; gap: 8px; margin: 0 0 18px; }
.records > div { min-width: 0; padding: 10px; border: 1px solid #455749; border-radius: 5px; background: #203127; }
.records dt, .track-row > span { font: 700 10px/1.2 var(--mono); letter-spacing: .035em; color: #c3cfbd; }
.records dd { margin: 3px 0 0; font: 700 36px/1 var(--display); }
.tracking { margin-bottom: 20px; }
.track-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 38px;
  border-top: 1px solid #374b3a;
}
.track-row:last-child { border-bottom: 1px solid #374b3a; }
.lives, .history { display: flex; gap: 5px; align-items: center; padding: 0; margin: 0; list-style: none; }
.lives i { width: 13px; height: 13px; clip-path: polygon(24% 0, 76% 0, 100% 24%, 100% 76%, 76% 100%, 24% 100%, 0 76%, 0 24%); background: var(--lime); }
.lives .spent { background: #43564a; }
.history li {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 1px solid #4b5d4f;
  border-radius: 3px;
  background: #26382c;
  color: var(--ink);
  font: 700 11px/1 var(--mono);
}
.history li[data-outcome="goal"] { background: var(--lime); border-color: var(--lime); }
.history li[data-outcome="miss"] { background: var(--amber); border-color: var(--amber); }

.reward-card {
  margin: 0 0 14px;
  padding: 10px;
  border: 1px solid #506b48;
  border-radius: 5px;
  background: #25392b;
}
.reward-head, .reward-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 5px 8px;
}
.reward-head {
  color: #c3d4bc;
  font: 700 9px/1.25 var(--mono);
  letter-spacing: .02em;
}
.reward-head span:last-child { color: var(--lime); }
.reward-controls { margin-top: 7px; }
.reward-total {
  margin: 0;
  color: var(--lime);
  font: 700 12px/1 var(--mono);
  white-space: nowrap;
}
.reward-total strong { font: 700 32px/1 var(--display); }
.claim-button {
  min-height: 37px;
  padding: 0 8px;
  border: 1px solid #718a57;
  border-radius: 4px;
  color: var(--lime);
  background: #17271c;
  font: 700 11px/1 var(--mono);
}
.claim-button:hover { background: var(--lime); color: var(--ink); }

.action {
  min-height: 46px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  border: 1px solid #ecffb0;
  border-radius: 5px;
  background: var(--lime);
  color: #152016;
  text-align: left;
  font: 700 13px/1 var(--mono);
  letter-spacing: .03em;
}
.action:hover { background: #eeffa3; }
.restart { margin-top: auto; width: 100%; }
.page-foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 0 20px;
  color: #546552;
  font-size: 11px;
}
.page-foot span:first-child { font: 700 11px/1.45 var(--mono); letter-spacing: .06em; }

.gameover {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 8px;
  background: #0a190ecc;
  cursor: auto;
  touch-action: manipulation;
}
.result-card {
  width: min(100%, 330px);
  border: 1px solid #769658;
  border-radius: 7px;
  padding: 16px 22px;
  background: #172a1e;
  box-shadow: 5px 5px #07170f99;
  text-align: center;
}
.result-card .eyebrow { color: var(--lime); }
.result-card h2 { font-size: clamp(34px, 6vw, 62px); line-height: 1.03; }
.result-card p:not(.eyebrow) { margin: 3px 0 12px; color: #d4e2ce; font-size: 13px; }
.result-card .action { width: 100%; min-height: 40px; }

dialog {
  width: min(448px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  border: 1px solid #788a76;
  border-radius: 10px;
  padding: 0;
  background: #18291e;
  color: #f4f6ea;
  box-shadow: 7px 7px #0a160e66;
}
dialog::backdrop { background: #09140cc9; }
.rules-card { padding: 21px; }
.rules-top { display: flex; align-items: center; justify-content: space-between; color: var(--lime); }
.rules-card h2 { font-size: 48px; line-height: 1; }
.close {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid #788a76;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  font-size: 24px;
}
.close:hover { background: #344837; }
.rules-list { padding-left: 22px; }
.rules-list li { padding: 3px 0 7px 3px; color: #d7e4d3; }
.rules-list b { color: #fff; }
.keys-note { font-size: 13px; color: #d7e4d3; }
.rules-card .action { width: 100%; margin-top: 18px; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 900px) {
  .shell { width: calc(100% - 40px); }
  .arcade { grid-template-columns: minmax(0, 1fr) 227px; gap: 12px; }
  .board { padding: 14px; }
  .score-line { margin-bottom: 12px; }
  .records { margin-bottom: 11px; }
  .tracking { margin-bottom: 12px; }
  .records > div { padding: 7px; }
  .records dd { font-size: 30px; }
}

@media (max-width: 720px) {
  .shell { width: calc(100% - 24px); }
  .top-inner { min-height: 59px; }
  .brand { font-size: 17px; gap: 7px; }
  .brand img { width: 34px; height: 34px; }
  .brand small { font-size: 8px; }
  .tool { min-width: 39px; padding-inline: 8px; font-size: 10px; }
  .tool #sound-label { display: none; }
  .intro { padding-block: 21px 17px; }
  .intro > p { display: none; }
  h1 { font-size: clamp(47px, 12vw, 70px); }
  .arcade { grid-template-columns: minmax(0, 1fr); }
  .stage-bar, .stage-foot { padding-inline: 9px; }
  .stage-bar { min-height: 39px; font-size: 9px; gap: 7px; }
  .stage-foot { min-height: 42px; gap: 7px; }
  .mobile-score {
    display: block;
    position: absolute;
    left: 8px;
    top: 8px;
    padding: 4px 6px;
    background: #122519ed;
    border: 1px solid #607454;
    border-radius: 3px;
    color: #e5f6b5;
    font: 700 9px/1 var(--mono);
    pointer-events: none;
  }
  .board { display: grid; grid-template-columns: 1fr 1.35fr; column-gap: 11px; }
  .board-top { grid-column: 1; gap: 6px; }
  .board-top svg { width: 17px; height: 17px; }
  .score-line { grid-row: 2; grid-column: 1; margin: 3px 0 12px; }
  .score-line strong { font-size: 61px; }
  .records { grid-row: 1 / span 2; grid-column: 2; align-self: center; }
  .tracking, .reward-card, .restart { grid-column: 1 / -1; }
  .restart { min-height: 42px; }
}
@media (max-width: 420px), (hover: none) {
  .key-guide { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .callout { animation: none; }
}
