:root {
  --bg: #1c1410;
  --panel: #2c2018;
  --panel-edge: #4a3424;
  --text: #f4e6d0;
  --muted: #b89c80;
  --accent: #ffcf4a;
  --danger: #ff6a4a;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%;
  background: radial-gradient(ellipse at 50% 0%, #3a281c 0%, var(--bg) 70%);
  background-color: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.app {
  height: 100%;
  display: flex; flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 10px) 10px calc(env(safe-area-inset-bottom) + 10px);
  max-width: 560px; margin: 0 auto;
}
.hud { display: flex; gap: 10px; align-items: stretch; }
.turns {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 72px; padding: 6px 10px;
  background: var(--panel); border: 2px solid var(--panel-edge); border-radius: 14px;
}
.turns .label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
#turns { font-size: 30px; font-weight: 800; color: var(--accent); line-height: 1.05; }
.turns.low #turns { color: var(--danger); }
.tally {
  flex: 1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px 6px;
  padding: 6px 8px; background: var(--panel); border: 2px solid var(--panel-edge); border-radius: 14px;
}
.tally-item { display: flex; align-items: center; gap: 4px; font-weight: 700; font-size: 14px; }
.tally-item img { width: 22px; height: 22px; }
#chain-info {
  height: 30px; line-height: 30px; text-align: center; font-weight: 700; font-size: 17px; color: var(--muted);
}
#chain-info.ok { color: var(--accent); }
.board-wrap {
  flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
}
#board {
  touch-action: none;
  background: linear-gradient(#2a1d14, #1a120c);
  border: 3px solid #5a4030; border-radius: 12px;
  box-shadow: inset 0 0 30px rgba(0,0,0,.6), 0 6px 20px rgba(0,0,0,.5);
}
.hint { text-align: center; color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.results {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(10, 6, 4, .78); padding: 16px;
  animation: fade .3s ease;
}
.results[hidden] { display: none; }
.card {
  width: 100%; max-width: 340px; padding: 20px;
  background: var(--panel); border: 3px solid var(--panel-edge); border-radius: 20px;
  box-shadow: 0 10px 40px rgba(0,0,0,.6);
}
.card h1 { margin: 0 0 12px; text-align: center; color: var(--accent); font-size: 28px; }
.card ul { list-style: none; margin: 0 0 16px; padding: 0; }
.card li {
  display: flex; align-items: center; gap: 10px; padding: 7px 4px;
  border-bottom: 1px solid rgba(255,255,255,.07); font-size: 18px;
}
.card li img { width: 36px; height: 36px; }
.card li .name { flex: 1; }
.card li .qty { font-weight: 800; font-variant-numeric: tabular-nums; }
.card button {
  width: 100%; padding: 14px; font-size: 18px; font-weight: 800;
  color: #2a1a0a; background: linear-gradient(#ffe27a, #e8a820);
  border: 0; border-radius: 14px; box-shadow: 0 4px 0 #8a5a00;
}
.card button:active { transform: translateY(2px); box-shadow: 0 2px 0 #8a5a00; }
@keyframes fade { from { opacity: 0; } }
