/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --border: #242424;
  --text: #f0f0f0;
  --muted: #666;
  --accent: #ffffff;
  --player-color: #ffffff;   /* overridden per-player by JS */
  --radius: 20px;
  --transition: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}

/* ── Screen system ── */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 40px 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition), transform var(--transition);
  transform: translateY(12px);
  z-index: 1;
}

/* Show exactly the screen matching the body data-state */
body[data-state="connecting"]   #screen-connecting,
body[data-state="pool"]         #screen-pool,
body[data-state="played"]       #screen-played,
body[data-state="not_selected"] #screen-not-selected,
body[data-state="selected"]     #screen-selected,
body[data-state="playing"]      #screen-playing,
body[data-state="results"]      #screen-results {
  opacity: 1;
  pointer-events: auto;
  transform: none;
}

/* ── Logo ── */
.logo {
  font-size: clamp(36px, 10vw, 56px);
  font-weight: 900;
  letter-spacing: 0.18em;
  color: var(--text);
}

/* ── Status dot (connecting pulse) ── */
.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--muted);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.3; transform: scale(1); }
  50%       { opacity: 1;   transform: scale(1.35); }
}

/* ── Typography ── */
.tagline {
  font-size: clamp(20px, 5.5vw, 28px);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-align: center;
  line-height: 1.2;
}

.hint {
  font-size: 14px;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
  max-width: 260px;
}

/* ── Pool counter ── */
.pool-count {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.pool-count span:first-child {
  font-size: clamp(48px, 14vw, 80px);
  font-weight: 900;
  line-height: 1;
  color: var(--player-color);
  transition: color 0.3s;
}
.pool-label {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ── Color wash (full-bleed player-color background) ── */
.color-wash {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.6s ease;
  z-index: 0;
  pointer-events: none;
  background: var(--player-color);
}
body[data-state="selected"] .color-wash,
body[data-state="playing"]  .color-wash {
  opacity: 0.12;
}

.selected-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
}

/* ── Color chip ── */
.color-chip {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--player-color);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.12), 0 8px 32px rgba(0,0,0,0.5);
  animation: chip-pop 0.4s cubic-bezier(0.34,1.56,0.64,1) both;
}
@keyframes chip-pop {
  from { transform: scale(0.5); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

/* ── Countdown ring ── */
.countdown-ring {
  position: relative;
  width: 120px;
  height: 120px;
}
.ring-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.ring-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 6;
}
.ring-progress {
  fill: none;
  stroke: var(--player-color);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 327;   /* 2π * 52 */
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear, stroke 0.3s;
}
.countdown-num {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 44px;
  font-weight: 900;
  color: var(--text);
}

/* ── Playing screen layout ── */
#screen-playing {
  justify-content: space-between;
  align-items: stretch;
  padding-top: 56px;
  padding-bottom: max(36px, env(safe-area-inset-bottom, 36px));
}

.play-color-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  position: relative;
  z-index: 1;
}

.play-color-swatch {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: var(--player-color);
  box-shadow:
    0 0 0 5px rgba(255,255,255,0.14),
    0 0 60px var(--player-color),
    0 16px 48px rgba(0,0,0,0.5);
  animation: swatch-pulse 2.4s ease-in-out infinite alternate;
}

@keyframes swatch-pulse {
  from { box-shadow: 0 0 0 5px rgba(255,255,255,0.14), 0 0 40px var(--player-color), 0 16px 48px rgba(0,0,0,0.5); }
  to   { box-shadow: 0 0 0 5px rgba(255,255,255,0.22), 0 0 90px var(--player-color), 0 16px 48px rgba(0,0,0,0.5); }
}

.play-color-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.play-color-name {
  font-size: 34px;
  font-weight: 900;
  color: var(--player-color);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Turn buttons ── */
.play-buttons {
  display: flex;
  gap: 14px;
  width: 100%;
  position: relative;
  z-index: 1;
}

.turn-btn {
  flex: 1;
  height: 120px;
  border-radius: 28px;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.03em;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  /* smooth release only — press must feel instant */
  transition: background 0.18s ease, border-color 0.18s ease,
              transform 0.18s ease, box-shadow 0.18s ease;
}

.turn-btn.pressed {
  background: var(--player-color);
  border-color: var(--player-color);
  color: #000;
  transform: scale(0.93);
  box-shadow: 0 0 48px var(--player-color);
  transition: none;
}

/* ── Results ── */
.score-badge {
  font-size: clamp(56px, 16vw, 96px);
  font-weight: 900;
  color: var(--player-color);
  min-height: 1.1em;
  transition: color 0.4s;
}
