:root {
  --bg: #1c1a17;
  --paper: #f5eeda;
  --ink: #453321;
  --accent: #b0402c;
  --muted: #8a7a5f;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--paper);
  font-family: "Courier New", ui-monospace, monospace;
  -webkit-font-smoothing: none;
}

.wrap {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.masthead { text-align: center; margin-bottom: 18px; }
.masthead h1 {
  margin: 0;
  font-size: clamp(22px, 5vw, 40px);
  letter-spacing: 0.35em;
  color: var(--paper);
  text-shadow: 3px 3px 0 var(--accent);
}
.tagline {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.08em;
}

#stage {
  position: relative;
  width: 100%;
  border: 3px solid var(--paper);
  border-radius: 6px;
  overflow: hidden;
  background: var(--paper);
  box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.4);
}

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

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.overlay .panel {
  pointer-events: auto;
  text-align: center;
  color: var(--ink);
  padding: 12px 20px;
}
.overlay.hidden { display: none; }

.overlay h2 {
  margin: 0 0 6px;
  letter-spacing: 0.4em;
  font-size: clamp(16px, 3.5vw, 26px);
}
.big { font-size: 42px; margin-bottom: 4px; }
.hint { margin: 4px 0; font-weight: bold; letter-spacing: 0.1em; }
.hint.small { font-weight: normal; font-size: 11px; color: #7a6a50; }
.key {
  border: 2px solid var(--ink);
  border-radius: 4px;
  padding: 1px 7px;
  font-size: 12px;
}

.score-line { margin: 2px 0 10px; font-weight: bold; letter-spacing: 0.15em; }

.submit-form {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.submit-form.hidden { display: none; }
.submit-form input {
  font-family: inherit;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 7px 10px;
  width: 180px;
  border: 2px solid var(--ink);
  border-radius: 4px;
  background: #fffbe9;
  color: var(--ink);
  outline: none;
}
.submit-form button,
.restart {
  font-family: inherit;
  font-size: 13px;
  font-weight: bold;
  letter-spacing: 0.1em;
  padding: 8px 14px;
  border: 2px solid var(--ink);
  border-radius: 4px;
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
}
.submit-form button:hover, .restart:hover { background: var(--accent); border-color: var(--accent); }
.submit-form button:disabled { opacity: 0.5; cursor: default; }

.restart { margin-top: 8px; background: transparent; color: var(--ink); }
.restart:hover { color: var(--paper); }

.over-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

.turnstile-slot { flex-basis: 100%; display: flex; justify-content: center; }
.turnstile-slot:empty { display: none; }

.submit-msg { min-height: 16px; margin: 2px 0 0; font-size: 12px; color: var(--accent); font-weight: bold; }

.board {
  margin-top: 28px;
  border: 3px solid var(--paper);
  border-radius: 6px;
  padding: 14px 18px 18px;
  background: rgba(245, 238, 218, 0.04);
}
.board h3 {
  margin: 0 0 10px;
  letter-spacing: 0.25em;
  font-size: 15px;
  text-align: center;
}
#leaderboard {
  margin: 0;
  padding: 0 0 0 34px;
  font-size: 14px;
  line-height: 1.9;
}
#leaderboard li { letter-spacing: 0.05em; }
#leaderboard li .pts { float: right; font-weight: bold; }
#leaderboard li.me { color: #ffd75e; }
#leaderboard li.muted { color: var(--muted); list-style: none; }

footer { text-align: center; margin-top: 26px; font-size: 12px; color: var(--muted); }
footer a { color: var(--accent); }
