:root {
  --ink: #1d2027;
  --paper: #f4efe4;
  --chalk: #fbfaf6;
  --orange: #f2a93b;
  --red: #d8342c;
  --green: #3f9d5a;
  --muted: #8a8f99;
  --panel: rgba(25, 27, 33, 0.9);
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  color: var(--chalk);
  background: var(--ink);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

#stage {
  position: relative;
  width: 100vw;
  height: 100dvh;
}

canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#hud {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  display: flex;
  gap: 10px;
  align-items: stretch;
  pointer-events: none;
}

#hud[hidden], #pad[hidden], .panel[hidden] { display: none; }

.hud-block {
  background: var(--panel);
  border-radius: 10px;
  padding: 6px 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.hud-block.grow { flex: 1; max-width: 260px; }

.label {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.hud-block strong { font-size: 18px; font-variant-numeric: tabular-nums; white-space: nowrap; }

.strikes { font-size: 16px; letter-spacing: 3px; }
.strikes .x { color: var(--red); }
.strikes .o { color: #4a4f59; }

.meter {
  margin-top: 5px;
  height: 8px;
  border-radius: 4px;
  background: #3a3e47;
  overflow: hidden;
}

.meter div {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--red), var(--orange) 40%, #8bd17c);
  transform-origin: left;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: 0;
}

.icon {
  pointer-events: auto;
  margin-left: auto;
  width: 42px;
  border-radius: 10px;
  background: var(--panel);
  font-size: 18px;
}

.icon.off { opacity: 0.4; text-decoration: line-through; }

#hint {
  position: absolute;
  left: 50%;
  top: calc(max(10px, env(safe-area-inset-top)) + 64px);
  transform: translateX(-50%);
  margin: 0;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--panel);
  font-size: 14px;
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.2s;
}

#hint:empty { opacity: 0; }

#pad {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(12px, env(safe-area-inset-bottom));
  padding: 0 12px;
  display: grid;
  grid-template-columns: 64px 64px 1fr 1.6fr;
  gap: 10px;
}

.pad {
  height: 76px;
  border-radius: 16px;
  background: rgba(25, 27, 33, 0.82);
  border: 2px solid rgba(255, 255, 255, 0.12);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.06em;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  touch-action: none;
}

.pad small { font-size: 10px; font-weight: 400; color: var(--muted); letter-spacing: 0.1em; }
.pad.press { background: var(--orange); color: var(--ink); border-color: transparent; }
.pad.press small { color: rgba(29, 32, 39, 0.7); }
.pad.dip { border-color: rgba(216, 52, 44, 0.6); }
.pad.down { transform: scale(0.96); filter: brightness(1.2); }

.panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(520px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  overflow: auto;
  padding: 26px 26px 22px;
  border-radius: 18px;
  background: var(--panel);
  backdrop-filter: blur(6px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--orange);
}

h1, h2 {
  margin: 0 0 10px;
  font-family: Impact, "Arial Narrow Bold", "Haettenschweiler", sans-serif;
  font-weight: 400;
  letter-spacing: 0.02em;
  line-height: 0.95;
}

h1 { font-size: clamp(48px, 11vw, 76px); }
h2 { font-size: clamp(34px, 7vw, 48px); }

.lede { margin: 0 0 16px; line-height: 1.45; color: #d7d9de; }

.rules {
  margin: 0 0 20px;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
  font-size: 14px;
  line-height: 1.4;
  color: #c9ccd3;
}

.rules li { padding-left: 14px; position: relative; }
.rules li::before { content: ""; position: absolute; left: 0; top: 8px; width: 5px; height: 5px; border-radius: 50%; background: var(--orange); }

kbd {
  display: inline-block;
  min-width: 22px;
  padding: 1px 6px;
  margin-right: 3px;
  border-radius: 5px;
  background: #3a3e47;
  border-bottom: 2px solid #23262d;
  font-family: inherit;
  font-size: 12px;
  text-align: center;
}

.cta {
  padding: 13px 22px;
  border-radius: 12px;
  background: var(--orange);
  color: var(--ink);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.04em;
}

.cta:hover { filter: brightness(1.08); }
.cta.ghost { background: #3a3e47; color: var(--chalk); }
.cta.small { padding: 11px 16px; font-size: 15px; }

.choices { display: flex; flex-wrap: wrap; gap: 10px; }

.fine { margin: 14px 0 0; font-size: 13px; color: var(--muted); }

.verdict {
  display: inline-block;
  margin: 0 0 10px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.verdict.good { background: var(--chalk); color: var(--ink); }
.verdict.cheeky { background: var(--orange); color: var(--ink); }
.verdict.fail { background: var(--red); color: var(--chalk); }

.note-label { display: block; margin-bottom: 6px; font-size: 12px; color: var(--muted); letter-spacing: 0.1em; text-transform: uppercase; }

textarea {
  width: 100%;
  margin-bottom: 14px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid #3a3e47;
  background: #15171c;
  color: var(--chalk);
  font: 13px/1.5 ui-monospace, "Cascadia Code", Consolas, monospace;
  resize: none;
  user-select: text;
  -webkit-user-select: text;
}

@media (max-width: 560px) {
  .hud-block { padding: 5px 9px; }
  .hud-block strong { font-size: 15px; }
  .hud-block.grow { display: none; }
  #pad { grid-template-columns: 54px 54px 1fr 1.4fr; gap: 8px; }
  .pad { height: 68px; font-size: 17px; }
}
