:root {
  --bg: #081410;            /* the dark of a quiet tea house */
  --panel: #16281c;
  --ink: #eef6e6;
  --muted: #9ab894;
  --accent: #a8d43a;        /* ceremonial grade */
  --accent2: #e6d5b0;       /* bamboo */
  --milk: #f3e7d3;          /* the enemy */
  --danger: #e0a37f;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

#shell {
  width: min(860px, 100%);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* --- HUD ------------------------------------------------------------ */
#hud {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.stat {
  background: var(--panel);
  border: 1px solid #2c4632;
  border-radius: var(--radius);
  padding: 8px 6px;
  text-align: center;
  line-height: 1.2;
}

.stat .label {
  display: block;
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat .value {
  display: block;
  font-size: clamp(18px, 4.5vw, 24px);
  font-weight: 700;
}

#lives { letter-spacing: 1px; font-size: clamp(15px, 3.6vw, 19px); }

.value.pop { animation: pop .3s ease; }
@keyframes pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.35); color: var(--accent); }
  100% { transform: scale(1); }
}

/* --- Question banner -------------------------------------------------- */
#question {
  background: linear-gradient(180deg, #1d3323, #132318);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 10px 16px;
  text-align: center;
  font-size: clamp(26px, 7vw, 42px);
  font-weight: 700;
  letter-spacing: .02em;
  box-shadow: 0 0 24px rgba(168, 212, 58, .18);
}

/* --- Stage ---------------------------------------------------------- */
#stage {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid #2c4632;
  background: #060f0b;
  aspect-ratio: 4 / 3;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* --- Screens -------------------------------------------------------- */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  text-align: center;
  background: rgba(8, 20, 16, .93);
  backdrop-filter: blur(3px);
  overflow-y: auto;   /* the stage is short on phones - never clip the button */
}

.screen.hidden { display: none; }

.screen h1 {
  margin: 0;
  font-size: clamp(28px, 7vw, 46px);
  letter-spacing: .02em;
}

.tagline { margin: 0; color: var(--muted); font-size: clamp(14px, 3.4vw, 17px); }

.how {
  list-style: none;
  margin: 6px 0 4px;
  padding: 0;
  color: var(--muted);
  font-size: clamp(13px, 3.2vw, 15px);
  line-height: 1.9;
}

.how b {
  color: var(--ink);
  background: #233a27;
  border: 1px solid #3b5c41;
  border-radius: 6px;
  padding: 1px 7px;
}

.final { margin: 0; font-size: clamp(18px, 4.5vw, 24px); }
.final span { color: var(--accent); font-weight: 700; }
.best { margin: 0; color: var(--muted); }

.btn {
  margin-top: 8px;
  padding: 14px 34px;
  font-size: 18px;
  font-weight: 700;
  font-family: inherit;
  color: #16290a;
  background: linear-gradient(180deg, #c3e657, #93c22c);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 6px 0 #5d8a1c;
  transition: transform .08s ease, box-shadow .08s ease;
}

.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #5d8a1c; }

/* --- Touch controls -------------------------------------------------- */
#touchpad {
  display: grid;
  grid-template-columns: 1fr 1.4fr 1fr;
  gap: 8px;
}

.pad {
  padding: 16px 0;
  font-size: 20px;
  font-weight: 700;
  font-family: inherit;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid #3b5c41;
  border-radius: var(--radius);
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.pad:active { background: #24402a; }
.pad.wide { color: var(--accent2); letter-spacing: .1em; }

/* The 4:3 stage leaves little room for menu copy on a narrow phone. */
@media (max-width: 560px) {
  .screen { gap: 6px; }
  .screen h1 { font-size: 25px; }
  .tagline { font-size: 13px; }
  .how { margin: 2px 0; font-size: 12px; line-height: 1.65; }
  .how b { padding: 1px 5px; }
  .final { font-size: 17px; }
  .best { font-size: 13px; }
  .btn { margin-top: 4px; padding: 11px 26px; font-size: 16px; }
}

/* Keyboard users on a desktop do not need the on-screen pad. */
@media (min-width: 760px) and (hover: hover) {
  #touchpad { display: none; }
}
