:root {
  --bg-1: #0f172a;
  --bg-2: #1e293b;
  --surface: rgba(15, 23, 42, 0.86);
  --surface-strong: rgba(15, 23, 42, 0.95);
  --line: rgba(148, 163, 184, 0.35);
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #f97316;
  --accent-2: #22d3ee;
  --good: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --shadow: 0 16px 40px rgba(2, 6, 23, 0.45);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 10%, rgba(34, 211, 238, 0.18) 0, transparent 40%),
    radial-gradient(circle at 90% 5%, rgba(249, 115, 22, 0.12) 0, transparent 45%),
    linear-gradient(180deg, var(--bg-2), var(--bg-1));
}

a {
  color: var(--accent-2);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.app-shell {
  width: min(1280px, 96vw);
  margin: 20px auto;
  display: grid;
  gap: 16px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0;
  color: var(--accent-2);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 2px 0 0;
  font-size: clamp(1.6rem, 3.2vw, 2.4rem);
  line-height: 1.1;
}

.top-links {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 0.95rem;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr;
  gap: 16px;
  align-items: start;
}

.side-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(4px);
}

.side-panel h2,
.side-panel h3 {
  margin: 0 0 10px;
}

.panel-copy {
  margin: 8px 0 14px;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.95rem;
}

.meter-block {
  margin-bottom: 12px;
}

.meter-block label {
  display: inline-block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

.meter {
  width: 100%;
  height: 12px;
  background: rgba(148, 163, 184, 0.2);
  border-radius: 999px;
  overflow: hidden;
}

.meter span {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--good), #86efac);
  transition: width 180ms ease-out;
}

.meter.nitro span {
  background: linear-gradient(90deg, var(--accent-2), #67e8f9);
}

.meter-block p {
  margin: 6px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.session-card {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.session-card dl {
  margin: 0;
}

.session-card dl div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 3px 0;
}

.session-card dt {
  color: var(--muted);
  font-size: 0.9rem;
}

.session-card dd {
  margin: 0;
  font-weight: 700;
  font-size: 0.92rem;
}

.record-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.panel-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

button {
  border: 1px solid var(--line);
  color: var(--text);
  background: rgba(30, 41, 59, 0.9);
  padding: 9px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
}

button:hover {
  border-color: rgba(148, 163, 184, 0.6);
}

.primary-btn {
  background: linear-gradient(90deg, #f97316, #fb923c);
  border: none;
  color: #111827;
}

.control-copy {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.4;
}

.stage {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
  aspect-ratio: 16 / 9;
}

#canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #72d7ee;
}

.hud {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 6px 9px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(15, 23, 42, 0.78);
  font-size: 0.82rem;
  color: var(--muted);
}

.chip strong {
  color: var(--text);
  margin-left: 4px;
}

.event-feed {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 6;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(2, 6, 23, 0.72);
  border: 1px solid rgba(34, 211, 238, 0.5);
  font-size: 0.88rem;
  opacity: 0;
  transition: opacity 120ms ease-out;
}

.event-feed.on {
  opacity: 1;
}

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.58);
  display: grid;
  place-items: center;
  z-index: 9;
  padding: 20px;
}

.overlay.hidden {
  display: none;
}

.overlay-card {
  width: min(520px, 100%);
  background: rgba(15, 23, 42, 0.94);
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 14px;
  text-align: center;
  padding: 20px;
}

.overlay-kicker {
  margin: 0;
  color: var(--accent-2);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.overlay-card h2 {
  margin: 7px 0 8px;
  font-size: clamp(1.35rem, 2.5vw, 1.9rem);
}

.overlay-card p {
  margin: 0 0 16px;
  color: var(--muted);
}

.countdown {
  position: absolute;
  inset: auto 0 44% 0;
  margin: auto;
  width: 120px;
  text-align: center;
  z-index: 10;
  color: white;
  font-size: clamp(2.2rem, 7vw, 3.6rem);
  font-weight: 900;
  text-shadow: 0 0 18px rgba(14, 165, 233, 0.75);
}

.countdown.hidden {
  display: none;
}

#mute {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  z-index: 10;
  cursor: pointer;
  border-radius: 50%;
  background: url("../images/mute.png") 0 0;
  background-color: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(148, 163, 184, 0.45);
}

#mute.on {
  background-position: -32px 0;
}

.touch-controls {
  display: none;
  gap: 8px;
  flex-wrap: wrap;
}

.touch-btn {
  min-width: 70px;
  padding: 10px 12px;
  border-radius: 10px;
}

.touch-btn.nitro {
  background: linear-gradient(90deg, #06b6d4, #22d3ee);
  border: none;
  color: #062636;
}

@media (max-width: 1080px) {
  .game-layout {
    grid-template-columns: 1fr;
  }

  .side-panel {
    order: 2;
  }

  .stage {
    order: 1;
  }
}

@media (max-width: 820px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .touch-controls {
    display: flex;
  }
}
