:root {
  --bg: #15110d;
  --panel: #231c15;
  --ink: #fff6e6;
  --muted: #bfae96;
  --accent: #ffcf3f;
  --hot: #ff5a3c;
  --peach: #ff9f7a;
  --good: #7ddc6f;
  --w: 480px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 20% 0%, #3a2818 0%, transparent 55%),
    radial-gradient(circle at 90% 100%, #2c1d2a 0%, transparent 50%);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Hind Siliguri", sans-serif;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

#app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 0 0;
}

/* ---------- HUD ---------- */
#hud {
  width: var(--w);
  max-width: 100%;
  display: grid;
  grid-template-columns: 1.2fr 0.9fr 1.3fr 1fr auto;
  gap: 6px;
  padding: 6px 4px;
  font-family: "Bangers", system-ui, sans-serif;
  letter-spacing: 1px;
}
.stat {
  background: var(--panel);
  border: 2px solid #3d3024;
  border-radius: 10px;
  padding: 3px 8px 4px;
  display: flex;
  flex-direction: column;
  line-height: 1;
  min-width: 0;
}
.stat .label { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; }
.stat .value { font-size: 22px; color: var(--accent); white-space: nowrap; }
#combo.hot { color: var(--hot); }
.ammo-bar { height: 4px; background: #000; border-radius: 3px; margin-top: 3px; overflow: hidden; }
#ammoFill { height: 100%; width: 100%; background: linear-gradient(90deg, #c9912c, #ffd86b); transition: width .1s; }
#ammoStat.low .value { color: var(--hot); animation: blink .5s steps(2) infinite; }
#ammoStat.low #ammoFill { background: var(--hot); }
@keyframes blink { 50% { opacity: .35; } }

#soundBtn {
  background: var(--panel);
  border: 2px solid #3d3024;
  border-radius: 10px;
  color: var(--ink);
  font-size: 18px;
  width: 42px;
  cursor: pointer;
}

/* ---------- Arena ---------- */
#arena {
  position: relative;
  width: var(--w);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .6), 0 0 0 3px #3d3024;
  background: #000;
}
#shaker { position: absolute; inset: 0; }
#video {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  display: block;
  object-fit: fill;
  background: #000;
  pointer-events: none;
}
#deck {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background:
    repeating-linear-gradient(-45deg, #ffcf3f 0 12px, #1b1b1b 12px 24px) top / 100% 8px no-repeat,
    radial-gradient(ellipse at 30% 60%, #5a4d30 0%, transparent 60%),
    linear-gradient(#3c3423, #1f1a11);
  padding: 16px 12px 8px;
  pointer-events: none;
}
#deckTitle {
  font-family: "Bangers", sans-serif;
  font-size: calc(var(--w) * 0.05);
  letter-spacing: 2px;
  color: #d8c79c;
  text-shadow: 2px 2px 0 #000;
  line-height: 1;
}
#deckTitle span { color: var(--hot); }
#tip {
  margin-top: 6px;
  max-width: 55%;
  font-size: calc(var(--w) * 0.028);
  color: #cbbd9c;
  line-height: 1.25;
  min-height: 2.5em;
  transition: opacity .3s;
}
#fx {
  position: absolute;
  inset: 0;
  touch-action: none;
  cursor: none;
}

/* ---------- Overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(12, 8, 5, .74);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  z-index: 5;
  text-align: center;
  overflow-y: auto;
}
.overlay.hidden, .hidden { display: none !important; }
.card { width: 100%; max-width: 420px; }

h1 {
  font-family: "Bangers", sans-serif;
  font-size: clamp(44px, calc(var(--w) * 0.16), 80px);
  margin: 0;
  line-height: .95;
  letter-spacing: 3px;
  color: var(--accent);
  text-shadow: 4px 4px 0 var(--hot), 8px 8px 0 #000;
  transform: rotate(-3deg);
}
h2 {
  font-family: "Bangers", sans-serif;
  font-size: clamp(24px, calc(var(--w) * 0.07), 36px);
  margin: 6px 0 10px;
  letter-spacing: 2px;
  color: var(--ink);
  text-shadow: 3px 3px 0 #000;
}
h2 span { color: var(--hot); }
.tag { margin: 0 0 12px; color: var(--muted); font-size: 15px; }
.rules {
  list-style: none;
  padding: 10px 12px;
  margin: 0 0 16px;
  text-align: left;
  background: rgba(255, 255, 255, .06);
  border: 1px dashed rgba(255, 255, 255, .18);
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.35;
}
.rules li { padding: 3px 0; display: flex; gap: 8px; }
.rules li > b:first-child { width: 22px; flex: none; text-align: center; }
.small { font-size: 12px; color: var(--muted); margin: 10px 0 0; }
kbd {
  font-family: inherit;
  border: 1px solid var(--muted);
  border-radius: 4px;
  padding: 0 4px;
}

.btn {
  font-family: "Bangers", sans-serif;
  font-size: 24px;
  letter-spacing: 2px;
  padding: 10px 22px;
  border-radius: 14px;
  border: 3px solid #000;
  background: #e9dcc3;
  color: #1b130c;
  box-shadow: 0 5px 0 #000;
  cursor: pointer;
  transition: transform .06s, box-shadow .06s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #000; }
.btn.primary {
  background: linear-gradient(#ffd95e, #ffae2b);
  font-size: 28px;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 50% { transform: scale(1.05); } }
.row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }

#finalScore {
  font-family: "Bangers", sans-serif;
  font-size: clamp(56px, calc(var(--w) * 0.2), 96px);
  line-height: 1;
  color: var(--accent);
  text-shadow: 4px 4px 0 #000;
}
#newBest {
  font-family: "Bangers", sans-serif;
  color: var(--good);
  font-size: 22px;
  letter-spacing: 1px;
  animation: blink .6s steps(2) infinite;
}
#rank {
  font-family: "Bangers", sans-serif;
  font-size: 24px;
  color: var(--peach);
  margin: 6px 0 12px;
  letter-spacing: 1px;
}
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.grid > div {
  background: rgba(255, 255, 255, .07);
  border-radius: 10px;
  padding: 8px 4px;
}
.grid span {
  display: block;
  font-family: "Bangers", sans-serif;
  font-size: 28px;
  color: var(--ink);
}
.grid small { color: var(--muted); font-size: 12px; }

@media (max-width: 420px) {
  .stat .value { font-size: 18px; }
  .stat .label { font-size: 10px; }
  .rules { font-size: 13px; }
  .tag { font-size: 13px; }
}
