:root {
  --bg: #080b14;
  --panel: #121a2e;
  --line: #1f2b45;
  --text: #e6ecff;
  --muted: #8b9ac2;
  --accent: #5ee7a8;
  --accent-2: #6aa8ff;
  --danger: #ff6b81;
  --radius: 16px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 15% -10%, #14224a 0%, transparent 60%),
    radial-gradient(900px 500px at 90% 0%, #10303a 0%, transparent 55%),
    var(--bg);
  color: var(--text);
  font: 16px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Inter, sans-serif;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a { color: inherit; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px clamp(16px, 4vw, 40px);
  flex-wrap: wrap;
}

.brand {
  font-weight: 800;
  letter-spacing: -0.02em;
  font-size: 1.15rem;
  text-decoration: none;
}
.brand span { color: var(--accent); }

.tabs {
  display: flex;
  gap: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  padding: 5px;
  border-radius: 999px;
}

.tabs a {
  text-decoration: none;
  padding: 7px 16px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  transition: color .15s ease, background .15s ease;
}
.tabs a:hover { color: var(--text); }
.tabs a.active {
  background: linear-gradient(180deg, rgba(94, 231, 168, .22), rgba(94, 231, 168, .1));
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(94, 231, 168, .35);
}

main {
  flex: 1;
  padding: clamp(8px, 2vw, 24px) clamp(16px, 4vw, 40px) 40px;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
}

.layout {
  display: flex;
  justify-content: center;
}

.play {
  width: 100%;
  max-width: 620px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .035), rgba(255, 255, 255, .012));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(16px, 3vw, 26px);
}

.play-head h1 {
  margin: 0 0 4px;
  font-size: clamp(1.5rem, 4vw, 2rem);
  letter-spacing: -0.03em;
}
.hint { margin: 0 0 18px; color: var(--muted); font-size: .9rem; }

.stage {
  position: relative;
  border-radius: 14px;
  background: #0a0f1c;
  border: 1px solid var(--line);
  overflow: hidden;
}

.stage-board {
  aspect-ratio: 720 / 640;
  max-width: 620px;
  margin: 0 auto;
}

#dartboard {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: manipulation;
}

.stage-tap {
  height: clamp(200px, 34vh, 300px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  transition: background .12s ease, border-color .12s ease;
  border-radius: 14px;
  font-weight: 700;
}
.stage-tap.waiting { background: #1a2338; }
.stage-tap.go { background: #0e3b2f; border-color: var(--accent); }
.stage-tap.early { background: #3a1220; border-color: var(--danger); }
.reaction-face { font-size: clamp(1.5rem, 5vw, 2.2rem); letter-spacing: -0.02em; }
.reaction-sub { color: var(--muted); font-size: .85rem; font-weight: 500; }
.stage-tap.go .reaction-sub { color: var(--accent); }

.slap-stage {
  position: relative;
  height: clamp(280px, 46vh, 420px);
  display: grid;
  place-items: center;
  perspective: 900px;
  perspective-origin: 50% 45%;
  overflow: hidden;
  cursor: none;
  touch-action: manipulation;
  background: radial-gradient(circle at 50% 45%, #16233a 0%, #0a0f1c 70%);
}

.slap-scene {
  transform-style: preserve-3d;
  display: grid;
  place-items: center;
}

.slap-card {
  width: clamp(170px, 46%, 260px);
  aspect-ratio: 4 / 3;
  border-radius: 14px;
  overflow: hidden;
  transform-style: preserve-3d;
  will-change: transform;
  box-shadow:
    0 24px 40px rgba(0, 0, 0, 0.55),
    0 2px 0 rgba(255, 255, 255, 0.12) inset;
  background: #131c2d;
}

.slap-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
  -webkit-user-drag: none;
  transition: filter .09s ease;
}

.slap-card.hit img {
  filter: brightness(1.55) saturate(1.15) contrast(1.05);
}

.slap-fx {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

.ripple {
  position: absolute;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.85);
  animation: slap-ripple .34s ease-out forwards;
}

@keyframes slap-ripple {
  from { transform: scale(0.4); opacity: 0.95; }
  to { transform: scale(9); opacity: 0; }
}

.slap-hand {
  position: absolute;
  left: 0;
  top: 0;
  width: 62px;
  height: 70px;
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  margin: -62px 0 0 -26px;
  transform-origin: 40% 92%;
  transition: opacity .15s ease;
  will-change: transform;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.45));
}

.slap-hand.visible { opacity: 1; }

.slap-hand.swing {
  animation: slap-swing .2s cubic-bezier(.3, .9, .4, 1);
}

@keyframes slap-swing {
  0% { transform: rotate(-34deg) scale(0.94); }
  45% { transform: rotate(12deg) scale(1.06); }
  100% { transform: rotate(0deg) scale(1); }
}

@media (pointer: coarse) {
  .slap-stage { cursor: pointer; }
  .slap-hand { display: none; }
}

.hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 16px 2px 0;
  color: var(--muted);
  font-size: .9rem;
}
.hud strong { color: var(--text); font-size: 1.05rem; }

.actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .05);
  color: var(--text);
  padding: 11px 20px;
  border-radius: 11px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform .1s ease, background .15s ease, border-color .15s ease;
}
.btn:hover { background: rgba(255, 255, 255, .09); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(180deg, var(--accent), #43c98a);
  border-color: transparent;
  color: #04120c;
}
.btn.primary:hover { filter: brightness(1.07); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.status { min-height: 1.4em; margin: 12px 2px 0; color: var(--muted); font-size: .88rem; }
.status.ok { color: var(--accent); }
.status.err { color: var(--danger); }

.foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 18px clamp(16px, 4vw, 40px) 26px;
  color: var(--muted);
  font-size: .78rem;
  border-top: 1px solid rgba(255, 255, 255, .05);
  flex-wrap: wrap;
}

.music-btn {
  padding: 7px 14px;
  font-size: .78rem;
  border-radius: 999px;
}
.music-btn.on {
  color: var(--accent);
  border-color: rgba(94, 231, 168, .45);
  background: rgba(94, 231, 168, .12);
}

/* Kept tiny and in-flow: display:none can stop playback in some browsers. */
.music-frame {
  position: fixed;
  right: 0;
  bottom: 0;
  width: 1px;
  height: 1px;
  border: 0;
  opacity: 0.01;
  pointer-events: none;
}
