:root {
  --paper: #f3ead8;
  --cream: #fff8ee;
  --ink: #2a2118;
  --muted: #6d5c4a;
  --dusk: #1f4d6e;
  --sky: #6ea8c9;
  --reed: #3f7a3a;
  --flame: #e4572e;
  --gold: #e7a31a;
  --line: #d7c4a8;
  --tv: #24180f;
  --font: "Segoe UI", "Trebuchet MS", system-ui, sans-serif;
  --display: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  --radius: 22px;
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 80% -10%, rgb(110 168 201 / 35%), transparent 55%),
    radial-gradient(700px 380px at 0% 100%, rgb(231 163 26 / 22%), transparent 50%),
    var(--paper);
  line-height: 1.45;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -40px;
  z-index: 20;
  padding: 8px 12px;
  background: var(--flame);
  color: #fff;
  text-decoration: none;
}

.skip-link:focus {
  top: 12px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.topbar,
main,
footer {
  position: relative;
  z-index: 1;
  width: min(920px, calc(100% - 32px));
  margin-inline: auto;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 8px;
}

.logo {
  display: flex;
  gap: 10px;
  align-items: center;
  color: inherit;
  text-decoration: none;
  font-family: var(--display);
  font-weight: 800;
  letter-spacing: -0.03em;
}

.logo small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.logo-mark {
  width: 36px;
  height: 36px;
  border-radius: 50% 50% 46% 52%;
  background:
    radial-gradient(circle at 70% 38%, #2a2118 2px, transparent 3px),
    #e7a31a;
  box-shadow: 10px 8px 0 -12px #e4572e;
}

.icon-btn,
.boot-btn,
.pad button,
.waves button {
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgb(228 87 46 / 28%);
}

.icon-btn {
  padding: 8px 14px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--cream);
  color: var(--ink);
  font-weight: 700;
}

.icon-btn[aria-pressed="true"] {
  background: var(--gold);
}

.icon-btn:focus-visible,
.boot-btn:focus-visible,
.pad button:focus-visible,
.waves button:focus-visible,
.logo:focus-visible {
  outline: 3px solid var(--flame);
  outline-offset: 3px;
}

.intro {
  padding: 8px 0 18px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--dusk);
  font-size: 13px;
  font-weight: 700;
}

h1 {
  margin: 0 0 12px;
  font-family: var(--display);
  font-size: clamp(30px, 6vw, 52px);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.lead {
  margin: 0;
  max-width: 46ch;
  color: var(--muted);
  font-size: 18px;
}

.tv {
  padding: 12px;
  border-radius: 28px 28px 36px 36px;
  background:
    linear-gradient(180deg, #6b4423, #3a2412 40%, #24180f);
  box-shadow: 0 18px 0 #1a1008, 0 28px 40px rgb(42 33 24 / 25%);
}

.tv-chrome,
.tv-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 6px 10px 10px;
  color: #f3ead8;
  font-size: 13px;
  font-weight: 700;
}

.tv-chrome b,
.tv-chrome #sandbox-state {
  color: #ffd36a;
}

body.online .tv {
  box-shadow: 0 18px 0 #1a1008, 0 28px 40px rgb(31 77 110 / 28%);
}

body.miss .tv {
  box-shadow: 0 18px 0 #4a140c, 0 28px 40px rgb(228 87 46 / 28%);
}

.viewport {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: 10px;
  background: #6ea8c9;
}

body.online .viewport {
  touch-action: none;
}

#grid {
  display: block;
  width: 100%;
  height: auto;
  margin-inline: auto;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  align-content: center;
  justify-items: center;
  padding: 20px;
  overflow: auto;
  text-align: center;
  background: rgb(243 234 216 / 88%);
  color: var(--ink);
  touch-action: manipulation;
}

.overlay[hidden] {
  display: none;
}

.overlay-kicker {
  margin: 0 0 8px;
  color: var(--dusk);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.overlay h2 {
  margin: 0 0 8px;
  font-family: var(--display);
  font-size: 26px;
}

.overlay p {
  margin: 0 0 16px;
  max-width: 36ch;
  color: var(--muted);
  font-size: 15px;
}

.waves {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: min(100%, 420px);
  margin: 0 0 14px;
}

.waves button {
  min-height: 44px;
  padding: 8px 10px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: var(--cream);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.waves button[aria-pressed="true"] {
  background: var(--gold);
}

.boot-btn {
  min-height: 48px;
  padding: 12px 22px;
  border: 0;
  border-radius: 999px;
  background: var(--flame);
  color: #fff;
  font-weight: 800;
  font-size: 16px;
}

.boot-btn:hover {
  filter: brightness(1.05);
}

.wave-blurb {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.scoreboard {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 16px;
}

.scoreboard div {
  padding: 12px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: var(--cream);
}

.scoreboard span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.scoreboard strong {
  font-size: 22px;
}

.pad {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 12px;
  user-select: none;
  -webkit-user-select: none;
}

.pad-hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.pad button {
  min-height: 44px;
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: var(--cream);
  color: var(--ink);
  font-weight: 800;
}

.extras {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 22px;
}

.extras section {
  padding: 14px;
  border: 2px solid var(--line);
  border-radius: 18px;
  background: rgb(255 248 238 / 70%);
}

.extras h2 {
  margin: 0 0 10px;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--dusk);
}

.previews,
.log,
.keys {
  margin: 0;
  padding: 0;
  list-style: none;
}

.previews,
.log,
.keys {
  display: grid;
  gap: 8px;
}

.previews li,
.hold {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 36px;
  color: var(--muted);
  font-size: 14px;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid var(--ink);
}

.hold {
  flex-direction: column;
  align-items: flex-start;
}

.bag-item {
  margin: 0;
  font-weight: 700;
}

.keys {
  color: var(--muted);
  font-size: 14px;
}

kbd {
  display: inline-block;
  min-width: 1.6em;
  margin-right: 4px;
  padding: 1px 6px;
  border: 2px solid var(--ink);
  border-radius: 6px;
  background: var(--cream);
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.log {
  max-height: 180px;
  overflow: auto;
}

.log li {
  color: var(--muted);
  font-size: 13px;
}

.log li b {
  color: var(--dusk);
  font-weight: 800;
}

.log li.alert b {
  color: var(--flame);
}

.hound {
  display: grid;
  justify-items: center;
  gap: 8px;
}

.hound-stage {
  position: relative;
  width: 72px;
  height: 48px;
}

.hound-stage .head {
  position: absolute;
  left: 18px;
  top: 10px;
  width: 36px;
  height: 28px;
  border-radius: 40% 40% 30% 30%;
  background: #c47a3a;
}

.hound-stage .ear {
  position: absolute;
  left: 14px;
  top: 4px;
  width: 14px;
  height: 22px;
  border-radius: 40%;
  background: #8a4b24;
  transform: rotate(-18deg);
}

.hound-stage .snout {
  position: absolute;
  left: 44px;
  top: 20px;
  width: 18px;
  height: 12px;
  border-radius: 40%;
  background: #e8c39e;
}

.hound-say {
  margin: 0;
  color: var(--dusk);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
}

body.miss .hound-stage {
  animation: giggle 0.35s steps(2) infinite;
}

.log-panel {
  grid-column: 1 / -1;
}

footer {
  padding: 8px 0 28px;
  color: var(--muted);
  font-size: 13px;
}

footer p {
  margin: 0 0 4px;
}

.noscript {
  margin: 20px;
  padding: 12px;
  border: 2px solid var(--flame);
  color: var(--flame);
}

@keyframes giggle {
  0% { transform: translateY(0) rotate(-6deg); }
  100% { transform: translateY(-4px) rotate(6deg); }
}

@media (max-width: 980px) {
  .topbar,
  main,
  footer {
    width: min(100% - 24px, 920px);
  }

  .extras {
    grid-template-columns: 1fr;
  }

  .scoreboard {
    grid-template-columns: 1fr 1fr;
  }

  .keys {
    display: none;
  }

  .stage {
    padding-bottom: calc(92px + env(safe-area-inset-bottom, 0px));
  }

  .pad {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 8;
    margin: 0;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    border-top: 2px solid var(--line);
    background: rgb(243 234 216 / 96%);
  }

  .pad button {
    min-height: 52px;
    font-size: 16px;
  }

  .boot-btn {
    min-width: min(100%, 240px);
  }
}

@media (prefers-reduced-motion: reduce) {
  body.miss .hound-stage {
    animation: none;
  }
}
