:root {
  --bg: #070d16;
  --panel: rgba(8, 14, 24, 0.82);
  --line: rgba(255, 255, 255, 0.14);
  --text: #f3f7ff;
  --muted: #8fa6c6;
  --accent: #ffb020;
  --hot: #ff5a36;
  --ok: #3dffa8;
  --p2: #4da3ff;
  --font: ui-monospace, "Cascadia Code", "Segoe UI Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.stage {
  position: relative;
  width: 100%;
  height: 100%;
  aspect-ratio: 16 / 9;
  max-height: 100%;
  margin: 0 auto;
  background:
    radial-gradient(900px 420px at 15% 0%, rgba(255, 90, 54, 0.2), transparent 55%),
    radial-gradient(700px 380px at 90% 10%, rgba(77, 163, 255, 0.16), transparent 50%),
    #070d16;
}

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

.topbar {
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(0,0,0,.55), transparent);
}

.pill {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 70px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  backdrop-filter: blur(6px);
}

.pill span {
  font-size: 9px;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.pill strong {
  font-size: 13px;
  color: var(--accent);
}

.pill.live strong { color: var(--ok); }
.pill.timer strong { color: #fff; }

.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(4, 8, 14, 0.72);
}

.overlay.hidden { display: none; }

.card {
  width: min(440px, 100%);
  padding: 22px 18px;
  border: 2px solid rgba(255, 176, 32, 0.35);
  border-radius: 16px;
  background: linear-gradient(160deg, rgba(18,28,48,.96), rgba(8,12,22,.96));
  text-align: center;
}

.card h1 {
  margin: 0 0 10px;
  font-size: clamp(16px, 3.4vw, 24px);
  color: var(--accent);
}

.card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.card .sub {
  margin-top: 10px;
  color: var(--ok);
  font-size: 12px;
}

.actions {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.btn.primary {
  background: linear-gradient(180deg, #ffc14d, var(--hot));
  color: #1a1008;
  box-shadow: 0 6px 0 #8c2a12;
}

.btn.ghost {
  background: rgba(255,255,255,.08);
  color: var(--text);
  border: 1px solid var(--line);
}

.controls {
  position: absolute;
  inset: auto 0 0 0;
  z-index: 4;
  display: none;
  justify-content: space-between;
  align-items: end;
  padding: 12px;
  pointer-events: none;
}

.controls.show { display: flex; }

.pad, .bomb-wrap {
  pointer-events: auto;
}

.pad {
  display: grid;
  grid-template-columns: 54px 54px 54px;
  grid-template-rows: 54px 54px 54px;
  gap: 6px;
}

.pad button, .bomb-btn {
  width: 54px;
  height: 54px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(10, 16, 28, 0.78);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
}

.pad .up { grid-column: 2; grid-row: 1; }
.pad .left { grid-column: 1; grid-row: 2; }
.pad .right { grid-column: 3; grid-row: 2; }
.pad .down { grid-column: 2; grid-row: 3; }

.bomb-btn {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: linear-gradient(180deg, #ff7a4d, #c62828);
  box-shadow: 0 6px 0 #7a1616;
  font-size: 12px;
}

.pad button:active, .bomb-btn:active {
  transform: translateY(2px);
}

@media (pointer: coarse) {
  .controls { display: flex; }
}
