* { box-sizing: border-box; }
:root {
  --ink: #2d1b0e;
  --cream: #fff6d8;
  --gold: #f5c451;
  --board-dark: #6f431f;
  --board-mid: #a96f35;
  --board-light: #c88947;
  --red: #9f2f22;
}

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 25% 15%, rgba(255,255,255,.08), transparent 26%),
    linear-gradient(#2f1d13, #1f140e);
  color: var(--cream);
  font-family: "Courier New", monospace;
}

body {
  padding: 12px;
  overscroll-behavior: none;
}

button { font: inherit; }

.game-shell {
  width: min(980px, 100%);
  margin: 0 auto;
}

.title-wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

h1, h2, p { margin-top: 0; }
h1 {
  margin-bottom: 0;
  font-size: clamp(1.75rem, 6vw, 3.4rem);
  letter-spacing: -2px;
  text-shadow: 3px 3px 0 #7d2e1c;
}
h2 { font-size: clamp(1.5rem, 5vw, 2.4rem); margin-bottom: 10px; }

.eyebrow {
  color: var(--gold);
  font-size: .74rem;
  font-weight: 900;
  letter-spacing: .18em;
  margin-bottom: 4px;
}

.icon-btn, .parm-btn, .primary-btn {
  border: 2px solid #2f1c0d;
  background: linear-gradient(#f5cc73, #c88c38);
  color: #2d1b0e;
  box-shadow: 3px 3px 0 #2b170a;
  border-radius: 8px;
  font-weight: 900;
  cursor: pointer;
}
.icon-btn { width: 46px; height: 42px; font-size: 1.1rem; }
.icon-btn:active, .parm-btn:active, .primary-btn:active { transform: translate(2px,2px); box-shadow: 1px 1px 0 #2b170a; }

.hud {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
  margin-bottom: 8px;
}

.hud-card {
  min-width: 0;
  padding: 8px 9px;
  border: 2px solid #3d240f;
  border-radius: 8px;
  color: #2d1b0e;
  background:
    linear-gradient(90deg, rgba(255,255,255,.14), rgba(0,0,0,.04)),
    #d6a45d;
  box-shadow: inset 0 0 0 2px rgba(255,244,210,.25);
}

.hud-card span {
  display: block;
  font-size: clamp(.55rem, 1.8vw, .72rem);
  font-weight: 900;
  letter-spacing: .08em;
  opacity: .75;
  white-space: nowrap;
}
.hud-card strong {
  display: block;
  margin-top: 2px;
  font-size: clamp(1rem, 4vw, 1.55rem);
}
.parm-card { position: relative; padding-right: 54px; }
.parm-btn {
  position: absolute;
  right: 6px;
  top: 7px;
  bottom: 7px;
  width: 45px;
  font-size: .62rem;
}
.parm-btn:disabled { filter: grayscale(1); opacity: .45; cursor: default; }

.next-strip {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-bottom: 8px;
  padding: 8px 10px;
  background: #392315;
  border: 2px solid #6c4324;
  border-radius: 8px;
}
.strip-label {
  display: block;
  font-size: .65rem;
  color: #e9c990;
  margin-bottom: 4px;
  font-weight: 900;
}
.next-queue { display: flex; gap: 5px; min-height: 30px; }
.next-dot {
  width: 28px;
  height: 24px;
  border: 2px solid rgba(45,27,14,.65);
  box-shadow: inset 2px 2px rgba(255,255,255,.22);
}
.legend { font-size: clamp(.58rem, 1.8vw, .75rem); text-align: right; color: #ead4ae; }

.board-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  max-height: 78vh;
  overflow: hidden;
  border: 5px ridge #4d2e15;
  border-radius: 12px;
  box-shadow: 0 10px 26px #0008;
  background: #a96f35;
}

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

.overlay {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  padding: 18px;
  background: rgba(30,16,8,.68);
  backdrop-filter: blur(2px);
}
.overlay.visible { display: grid; }

.panel {
  width: min(570px, 92%);
  padding: clamp(18px, 4vw, 30px);
  color: #2d1b0e;
  background:
    linear-gradient(rgba(255,255,255,.2), rgba(0,0,0,.04)),
    #e6bd7f;
  border: 4px double #5f3718;
  border-radius: 12px;
  box-shadow: 8px 8px 0 rgba(44,24,10,.7);
  text-align: center;
}
.panel p { line-height: 1.45; }
.primary-btn { padding: 12px 22px; font-size: 1rem; }
.tiny { margin: 14px 0 0; font-size: .68rem; opacity: .75; }

footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  color: #b99873;
  font-size: .64rem;
}
code { color: #efd28d; }

@media (max-width: 650px) {
  body { padding: 7px; }
  .hud { grid-template-columns: repeat(3, 1fr); }
  .parm-card { grid-column: span 2; }
  .next-strip { align-items: flex-start; }
  .legend { max-width: 46%; }
  footer { display: none; }
}
