:root {
  --ink: #dbeaff;
  --accent: #6ad7ff;
  --warm: #ffb24a;
  --panel: rgba(10, 20, 36, 0.6);
  --panel-line: rgba(120, 220, 255, 0.28);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #05060f;
  color: var(--ink);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  overscroll-behavior: none;
}

#game {
  position: fixed;
  inset: 0;
  display: block;
}

/* Mute toggle sits bottom-left, clear of the HUD score. */
.mute {
  position: fixed;
  left: max(10px, env(safe-area-inset-left));
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 6;
  padding: 7px 10px;
  border-radius: 10px;
  border: 1.5px solid var(--panel-line);
  background: var(--panel);
  color: var(--ink);
  font: 600 11px ui-monospace, Menlo, Consolas, monospace;
  letter-spacing: 0.05em;
  backdrop-filter: blur(4px);
  cursor: pointer;
}
.mute.off { color: var(--warm); border-color: rgba(255, 178, 74, 0.5); }

/* On-screen controls. Hidden until the device is detected as touch first. */
#touch-controls {
  position: fixed;
  inset: 0;
  display: none;
  pointer-events: none;
  z-index: 5;
}
#touch-controls.on { display: block; }

.pad {
  position: absolute;
  bottom: max(22px, env(safe-area-inset-bottom));
  width: 84px;
  height: 84px;
  border-radius: 16px;
  border: 1.5px solid var(--panel-line);
  background: var(--panel);
  color: var(--ink);
  font: 600 13px ui-monospace, Menlo, Consolas, monospace;
  letter-spacing: 0.03em;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  backdrop-filter: blur(4px);
}
.pad:active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(106, 215, 255, 0.12);
}

#btn-left { left: max(16px, env(safe-area-inset-left)); }
#btn-right { left: calc(max(16px, env(safe-area-inset-left)) + 94px); }
#btn-fire {
  right: max(16px, env(safe-area-inset-right));
  width: 150px;
  height: 92px;
  background: rgba(106, 215, 255, 0.1);
  border-color: var(--accent);
  color: var(--accent);
}
#btn-fire:active { border-color: var(--accent); color: #fff; background: rgba(106, 215, 255, 0.22); }

/* On a narrow screen the controls sit a touch closer together. */
@media (max-width: 440px) {
  .pad { width: 72px; height: 72px; }
  #btn-right { left: calc(max(12px, env(safe-area-inset-left)) + 80px); }
  #btn-fire { width: 130px; height: 80px; }
}

/* Post-round company card (data hook C). */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(5, 6, 15, 0.78);
  backdrop-filter: blur(3px);
}
.overlay.on { display: flex; }

.card {
  width: min(420px, 94vw);
  border: 1.5px solid var(--panel-line);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(14, 26, 44, 0.96), rgba(8, 14, 26, 0.96));
  padding: 22px 22px 18px;
  text-align: center;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.5);
}
.pr-title { margin: 0 0 4px; color: var(--accent); font-size: 22px; font-weight: 800; letter-spacing: 0.04em; }
.pr-score { margin: 0 0 2px; font-size: 34px; font-weight: 800; }
.pr-stats { margin: 0 0 14px; font-size: 13px; color: rgba(219, 234, 255, 0.6); }
.pr-line { margin: 0 0 14px; font-size: 15px; line-height: 1.45; color: var(--ink); }
.pr-line b { color: var(--warm); }
.pr-link {
  display: inline-block;
  padding: 11px 16px;
  border-radius: 12px;
  border: 1.5px solid var(--accent);
  background: rgba(106, 215, 255, 0.12);
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: 0.02em;
}
.pr-link:active { background: rgba(106, 215, 255, 0.22); }
.pr-again {
  display: block;
  width: 100%;
  margin: 12px 0 10px;
  padding: 11px 16px;
  border-radius: 12px;
  border: 1.5px solid var(--panel-line);
  background: var(--panel);
  color: var(--ink);
  font: 700 14px ui-monospace, Menlo, Consolas, monospace;
  letter-spacing: 0.02em;
  cursor: pointer;
}
.pr-again:active { border-color: var(--accent); color: var(--accent); }
.pr-seed { margin: 2px 0 0; font-size: 12px; color: rgba(138, 176, 255, 0.8); }

@media (prefers-reduced-motion: reduce) {
  .overlay { backdrop-filter: none; }
}
