/* ════════════════════════════════════════════════════════
   VIBE METER — Design System & Global Styles
   ════════════════════════════════════════════════════════ */

:root {
  /* Colors */
  --bg:           #0d0d1a;
  --bg2:          #13132a;
  --card:         rgba(255,255,255,0.04);
  --card-hover:   rgba(255,255,255,0.07);
  --border:       rgba(255,255,255,0.08);
  --border-bright:rgba(255,255,255,0.18);

  --primary:      #7c3aed;
  --primary-glow: rgba(124,58,237,0.35);
  --secondary:    #db2777;
  --secondary-glow:rgba(219,39,119,0.35);
  --accent:       #06b6d4;
  --success:      #10b981;
  --warning:      #f59e0b;
  --danger:       #ef4444;

  --text:         #f1f5f9;
  --text-muted:   #94a3b8;
  --text-dim:     #64748b;

  /* Gradient shortcuts */
  --grad-primary: linear-gradient(135deg, #7c3aed, #db2777);
  --grad-meter:   linear-gradient(to right, #10b981, #06b6d4, #7c3aed, #db2777, #ef4444);
  --grad-bg:      linear-gradient(135deg, #0d0d1a 0%, #1a0d2e 50%, #0d1a2e 100%);

  /* Sizing */
  --radius:       14px;
  --radius-sm:    8px;
  --radius-lg:    20px;
  --shadow:       0 8px 32px rgba(0,0,0,0.4);
  --shadow-lg:    0 16px 64px rgba(0,0,0,0.6);
  --post-phrase-top-offset: 7.5rem;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--grad-bg);
  min-height: 100vh;
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

/* ── Typography ─────────────────────────────────────── */
h1 { font-size: clamp(1.8rem, 5vw, 3rem); font-weight: 900; }
h2 { font-size: clamp(1.4rem, 4vw, 2rem); font-weight: 800; }
h3 { font-size: clamp(1.1rem, 3vw, 1.4rem); font-weight: 700; }
p  { color: var(--text-muted); }

.gradient-text {
  background: var(--grad-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Main Layout ────────────────────────────────────── */
#app-wrapper {
  display: flex;
  align-items: flex-start;
  gap: 0;
  max-width: 1180px;
  margin: 0 auto;
}

#app {
  flex: 1;
  min-width: 0;
  padding: 2rem 1.25rem 4rem;
  min-height: 100vh;
}

#app-wrapper.post-phrase-stage #app {
  padding-top: var(--post-phrase-top-offset);
}

#app > *:first-child:last-child {
  min-height: 100%;
}

/* Center content column when there is no sidebar */
#app-wrapper:not(.with-sidebar) #app {
  max-width: 700px;
  margin: 0 auto;
}

/* Sidebar hidden by default; shown when wrapper has .with-sidebar */
#leaderboard-sidebar {
  display: none;
  width: 260px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow-y: auto;
  padding: 1.65rem 0.5rem 2rem 0.5rem;
  flex-direction: column;
  align-items: center;
}

#app-wrapper.post-phrase-stage #leaderboard-sidebar {
  margin-top: 2rem;
  padding-top: var(--post-phrase-top-offset);
}

#app-wrapper.with-sidebar #leaderboard-sidebar {
  display: flex;
}

/* ── Leaderboard Sidebar ────────────────────────────── */
.lb-header {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: 0.75rem;
  text-align: center;
  width: 100%;
}

.lb-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
}

.lb-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--card);
  border: 1px solid var(--border);
  font-size: 0.9rem;
  transition: background 0.2s;
}

.lb-row.lb-you {
  border-color: var(--primary);
  border-width: 2px;
  background: rgba(124,58,237,0.18);
  box-shadow: 0 0 0 1px var(--primary) inset, 0 2px 12px rgba(124,58,237,0.25);
}

.lb-row.lb-disconnected {
  opacity: 0.4;
  filter: grayscale(0.7);
}

.lb-bullseye {
  font-size: 0.7rem;
  font-weight: 700;
  color: #fbbf24;
  min-width: 2.2rem;
  text-align: right;
  flex-shrink: 0;
  white-space: nowrap;
}

.lb-medal {
  font-size: 1rem;
  min-width: 1.4rem;
  text-align: center;
  flex-shrink: 0;
}

.lb-pname {
  flex: 1;
  font-weight: 600;
  white-space: nowrap;
}

.lb-pts {
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--primary);
  min-width: 1.8rem;
  text-align: right;
  flex-shrink: 0;
}

.lb-streak-inline {
  width: 2.2rem;
  text-align: right;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fbbf24;
  flex-shrink: 0;
  white-space: nowrap;
}

.lb-delta-inline {
  min-width: 1.8rem;
  text-align: right;
  font-size: 0.85rem;
  font-weight: 800;
  color: #a78bfa;
  flex-shrink: 0;
  white-space: nowrap;
}

.lb-spectators {
  margin-top: 0.75rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
}

.lb-spec-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 0.4rem;
}

.lb-spec-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 0.25rem 0.25rem;
  border-radius: var(--radius-sm);
}

.lb-spec-row.lb-spec-pending { color: var(--text); }

.lb-spec-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-spec-badge {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--success);
  background: rgba(16,185,129,0.1);
  border: 1px solid rgba(16,185,129,0.3);
  padding: 1px 5px;
  border-radius: 99px;
  flex-shrink: 0;
}

/* Leaderboard entry: streak-col | [row box] | delta-col */
.lb-entry {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.lb-row { flex: 1; min-width: 0; }

.lb-streak-col {
  width: 2.6rem;
  text-align: right;
  font-size: 0.9rem;
  font-weight: 700;
  color: #fbbf24;
  flex-shrink: 0;
  white-space: nowrap;
}

.lb-delta-col {
  min-width: 2rem;
  text-align: left;
  font-size: 0.9rem;
  font-weight: 800;
  color: #a78bfa;
  flex-shrink: 0;
  white-space: nowrap;
}

.lb-away { font-size: 0.65rem; opacity: 0.5; }

/* Tied players share the same rank — rows are visually merged */
.lb-tie-group {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.lb-tie-group .lb-entry:not(:last-child) .lb-row {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom-color: rgba(255,255,255,0.04);
}

.lb-tie-group .lb-entry:not(:first-child) .lb-row {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

/* ── Results Phrase Suggestions (Sidebar) ─────────────────── */
.sp-panel {
  width: 100%;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.sp-title {
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
}

.sp-trigger {
  font-size: 0.78rem;
  margin-bottom: 0.65rem;
}

/* Popover wrapper (relative anchor for fallback; actual popover is fixed) */
.sp-popover-wrapper {
  position: relative;
  margin-bottom: 0.65rem;
}

/* Floating popover card */
.sp-popover {
  position: fixed;
  background: var(--bg2);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  padding: 0.75rem;
  z-index: 1000;
  box-shadow: var(--shadow-lg);
  animation: sp-pop-in 0.18s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.sp-popover[hidden] { display: none; }

@keyframes sp-pop-in {
  from { opacity: 0; transform: translateY(6px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)   scale(1);    }
}

.sp-popover-header {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.sp-popover input {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.78rem;
  padding: 0.38rem 0.5rem;
  outline: none;
  transition: border-color 0.15s;
  margin-bottom: 0.35rem;
}

.sp-popover input:focus {
  border-color: var(--primary);
}

.sp-popover-footer {
  margin-top: 0.25rem;
}

.sp-popover-submit {
  width: 100%;
  font-size: 0.78rem;
}

/* Success state inside popover */
.sp-popover-ok {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.6rem 0.5rem 0.5rem;
  gap: 0.2rem;
  animation: sp-pop-in 0.22s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.sp-popover-ok[hidden] { display: none; }

.sp-popover-ok-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  margin-top: 0.15rem;
}

.sp-popover-ok-sub {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.sp-empty {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.sp-note {
  margin: 0 0 0.55rem;
  font-size: 0.72rem;
  color: var(--text-dim);
}

.sp-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.sp-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.5rem;
}

.sp-pair {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.sp-vs { color: var(--text-dim); font-size: 0.72rem; }

.sp-meta {
  margin-top: 0.2rem;
  font-size: 0.68rem;
  color: var(--text-dim);
}

.sp-counts {
  transition: color 0.2s;
}

@keyframes sp-counts-flash {
  0%   { color: var(--text-dim); }
  40%  { color: var(--accent);   }
  100% { color: var(--text-dim); }
}

.sp-counts-flash {
  animation: sp-counts-flash 0.45s ease-out;
}

.sp-votes {
  margin-top: 0.35rem;
  display: flex;
  gap: 0.35rem;
}

.sp-vote-btn {
  flex: 1;
  padding: 0.25rem 0.45rem;
  font-size: 0.82rem;
  border: 1px solid var(--border);
  background: var(--card-2);
}

.sp-vote-btn.yes {
  color: #34d399;
}

.sp-vote-btn.no {
  color: #f87171;
}

.sp-vote-btn.yes.active {
  border-color: rgba(16,185,129,0.65);
  background: rgba(16,185,129,0.2);
  color: #6ee7b7;
}

.sp-vote-btn.no.active {
  border-color: rgba(239,68,68,0.65);
  background: rgba(239,68,68,0.2);
  color: #fca5a5;
}

@media (max-width: 860px) {
  #leaderboard-sidebar { display: none !important; }
  #app-wrapper.with-sidebar #leaderboard-sidebar { display: none !important; }
}

/* ── Cards ──────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  backdrop-filter: blur(8px);
}

.card + .card { margin-top: 1rem; }

.card.highlight {
  border-color: var(--primary);
  background: rgba(124,58,237,0.08);
  box-shadow: 0 0 0 1px var(--primary-glow), var(--shadow);
}

.card.success {
  border-color: var(--success);
  background: rgba(16,185,129,0.08);
}

.card.danger {
  border-color: var(--danger);
  background: rgba(239,68,68,0.08);
}

.invite-link-card {
  background: rgba(30, 64, 175, 0.2);
  border: 1px solid rgba(59, 130, 246, 0.75);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.08), 0 10px 24px rgba(15, 23, 42, 0.24);
}

.invite-link-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #bfdbfe;
  white-space: nowrap;
}

/* ── Buttons ────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
}

.btn-primary {
  background: var(--grad-primary);
  color: #fff;
  box-shadow: 0 4px 20px var(--primary-glow);
}

.btn-primary:not(:disabled):hover { transform: translateY(-1px); box-shadow: 0 6px 28px var(--primary-glow); }
.btn-primary:not(:disabled):active { transform: translateY(0); }

.btn-secondary {
  background: var(--card);
  border: 1px solid var(--border-bright);
  color: var(--text);
}

.btn-secondary:not(:disabled):hover { background: var(--card-hover); border-color: var(--primary); }

.btn-success {
  background: var(--success);
  color: #fff;
  box-shadow: 0 4px 20px rgba(16,185,129,0.3);
}

.btn-success:not(:disabled):hover { transform: translateY(-1px); filter: brightness(1.1); }

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:not(:disabled):hover { filter: brightness(1.1); }

.btn-lg {
  padding: 0.85rem 2.5rem;
  font-size: 1.1rem;
  border-radius: var(--radius);
}

.btn-full { width: 100%; }

.btn-group {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ── Form Controls ──────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 0.4rem; }

label {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

input[type="text"],
input[type="number"],
textarea {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  padding: 0.7rem 1rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
}

input[type="text"]:focus,
input[type="number"]:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.6;
}

/* ── Player List / Chips ────────────────────────────── */
.player-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.player-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius-sm);
  background: var(--card);
  border: 1px solid var(--border);
  transition: background 0.2s;
}

.player-item.you { border-color: var(--primary); background: rgba(124,58,237,0.1); }
.player-item.host .player-name::after { content: ' 👑'; font-size: 0.85em; }
.player-item.vibeman { border-color: var(--warning); background: rgba(245,158,11,0.1); }
.player-item.player-disconnected { opacity: 0.45; filter: grayscale(0.6); }

.player-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
  color: #fff;
  flex-shrink: 0;
}

.player-name { font-weight: 600; font-size: 0.95rem; flex: 1; }
.player-score { font-size: 0.85rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.player-tag {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.tag-you { background: var(--primary-glow); color: #c4b5fd; border: 1px solid var(--primary); }
.tag-host { background: rgba(245,158,11,0.2); color: #fbbf24; border: 1px solid var(--warning); }
.tag-vibeman { background: rgba(245,158,11,0.15); color: #fcd34d; border: 1px solid var(--warning); }

/* ── Vibe Meter Bar ─────────────────────────────────── */
.meter-wrap {
  margin: 1rem 0;
}

.meter-labels {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
}

.meter-label-left  { color: #10b981; font-weight: 700; }
.meter-label-right { color: #ef4444; font-weight: 700; }
.meter-label-num   { font-size: 0.72rem; color: var(--text-dim); }

.meter-bar {
  position: relative;
  height: 20px;
  border-radius: 99px;
  background: var(--grad-meter);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
  overflow: visible;
}

/* Guess / Actual markers on the bar */
.meter-marker {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 800;
  color: #fff;
  transition: left 0.5s cubic-bezier(.34,1.56,.64,1);
  z-index: 2;
  white-space: nowrap;
}

.meter-marker-label {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.8);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  pointer-events: none;
  white-space: nowrap;
}

.meter-marker.actual {
  width: 32px;
  height: 32px;
  background: #fff;
  border-color: #fff;
  color: #000;
  font-size: 0.72rem;
  z-index: 3;
  box-shadow: 0 0 0 4px rgba(255,255,255,0.3), 0 4px 16px rgba(0,0,0,0.5);
}

.meter-marker.perfect { border-color: var(--success); box-shadow: 0 0 0 3px rgba(16,185,129,0.4); }
.meter-marker.good    { border-color: var(--warning); }
.meter-marker.ok      { border-color: var(--accent); }
.meter-marker.miss    { border-color: var(--text-dim); opacity: 0.6; }

/* ── Half-Dial Gauge ─────────────────────────────────── */
.dial-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0.5rem 0 0;
  user-select: none;
}

.dial-svg {
  width: 100%;
  max-width: 500px;
  height: auto;
  overflow: visible;
  touch-action: none;
}

/* Track arc */
.dial-track {
  fill: none;
  stroke: rgba(255,255,255,0.1);
  stroke-width: 24;
  stroke-linecap: round;
}

/* Coloured fill arc */
.dial-fill {
  fill: none;
  stroke: url(#dialGrad);
  stroke-width: 24;
  stroke-linecap: round;
  stroke-dasharray: 408.407;
  stroke-dashoffset: 408.407; /* fully hidden until JS sets the value */
}

/* Tick marks */
.dial-tick {
  stroke: rgba(255,255,255,0.2);
  stroke-width: 1.5;
}
.dial-tick-end {
  stroke: rgba(255,255,255,0.5);
  stroke-width: 2.5;
}

/* Needle */
.dial-needle {
  stroke: #fff;
  stroke-width: 3;
  stroke-linecap: round;
  filter: drop-shadow(0 0 4px rgba(124,58,237,0.8));
  transition: x2 0.05s linear, y2 0.05s linear;
  pointer-events: none;
}

/* Center pivot */
.dial-pivot {
  fill: #fff;
  filter: drop-shadow(0 0 6px var(--primary-glow));
  pointer-events: none;
}

/* Numeric readout — sits below the SVG in normal document flow */
.dial-readout {
  font-size: 4rem;
  font-weight: 900;
  line-height: 1;
  margin-top: 1rem;
  background: var(--grad-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  pointer-events: none;
  min-width: 6rem;
  text-align: center;
}

.phrase-input-card {
  padding: 1.25rem 1rem 1rem;
}

.phrase-dial-shell {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.phrase-dial-wrap {
  width: 100%;
  margin: 0;
  --phrase-left-input-center: 7%;
  --phrase-right-input-center: 93%;
  --phrase-input-width: min(34vw, 180px);
}

.phrase-dial-svg {
  max-width: 520px;
}

.phrase-dial-fill {
  opacity: 0.95;
}

.phrase-dial-endpoint {
  fill: rgba(255,255,255,0.92);
  stroke: rgba(124,58,237,0.35);
  stroke-width: 3;
  filter: drop-shadow(0 0 8px rgba(124,58,237,0.28));
}

.phrase-dial-inputs {
  width: min(90%, 500px);
  margin-top: -3rem;
  position: relative;
  height: 50px;
}

.phrase-dial-input-group {
  width: var(--phrase-input-width);
  max-width: 180px;
  position: absolute;
  top: 0;
}

.phrase-dial-input-left {
  left: var(--phrase-left-input-center);
  transform: translateX(-50%);
}

.phrase-dial-input-right {
  left: var(--phrase-right-input-center);
  transform: translateX(-50%);
}

.phrase-dial-inputs input {
  width: 100%;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border-bright);
  box-shadow: 0 10px 24px rgba(0,0,0,0.18);
  text-align: center;
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}

.phrase-dial-inputs input::placeholder {
  text-align: center;
}

@media (max-width: 640px) {
  .phrase-input-card {
    padding: 1rem 0.85rem 0.9rem;
  }

  .phrase-dial-wrap {
    --phrase-left-input-center: 22%;
    --phrase-right-input-center: 78%;
    --phrase-input-width: min(34vw, 150px);
  }

  .phrase-dial-inputs {
    width: 100%;
    height: 40px;
  }

  .phrase-dial-input-group {
    max-width: 150px;
  }
}

/* Phrase labels at the two ends of the arc */
.dial-labels {
  width: 100%;
  max-width: 440px;
  display: flex;
  justify-content: space-between;
  margin-top: 0.4rem;
  padding: 0 0.25rem;
}

.dial-label-left,
.dial-label-right {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  max-width: 42%;
}

.dial-label-right { text-align: right; align-items: flex-end; }

.dial-label-num {
  font-size: 0.72rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.phrase-label-1 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #10b981;
}

.phrase-label-2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #ef4444;
}

/* ── Mini-Dial Grid (Vibe Man waiting screen) ────────── */
.mini-dial-grid {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.5rem;
  /* Column count is set by JS via --mini-cols based on player count */
  grid-template-columns: repeat(var(--mini-cols, 3), minmax(0, 1fr));
}

.mini-dial-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.6rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  transition: border-color 0.25s, background 0.25s;
}

/* Larger cards when column count is 1 or 2 */
.mini-dial-grid[style*="--mini-cols:1"] .mini-dial-card,
.mini-dial-grid[style*="--mini-cols:2"] .mini-dial-card {
  padding: 1.25rem 1rem;
}

.mini-dial-grid[style*="--mini-cols:1"] .mini-value,
.mini-dial-grid[style*="--mini-cols:2"] .mini-value {
  font-size: 2.8rem;
}

.mini-dial-grid[style*="--mini-cols:1"] .mini-name,
.mini-dial-grid[style*="--mini-cols:2"] .mini-name {
  font-size: 0.95rem;
}

.mini-dial-card.mini-dial-submitted {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.08);
}

.mini-dial-card.mini-dial-waiting {
  opacity: 0.55;
}

.mini-value {
  font-size: 1.8rem;
  font-weight: 900;
  line-height: 1;
  margin-top: 0.1rem;
  background: var(--grad-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.mini-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 0.3rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  text-align: center;
}

.mini-lock {
  font-size: 0.7rem;
}

/* ── Phrase Cards ────────────────────────────────────── */
.phrase-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--card);
  border: 1px solid var(--border);
  font-size: 0.9rem;
}

.phrase-card.current {
  border-color: var(--primary);
  background: rgba(124,58,237,0.1);
  box-shadow: 0 0 0 1px var(--primary-glow);
}

.phrase-card .phrase-author {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 0.2rem;
}

.phrase-vs {
  padding: 0.1rem 0.5rem;
  background: var(--border);
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-dim);
  flex-shrink: 0;
}

.phrase-label-1 { color: #10b981; font-weight: 700; }
.phrase-label-2 { color: #ef4444; font-weight: 700; }
.phrase-submitted-badge {
  margin-left: auto;
  font-size: 1rem;
  flex-shrink: 0;
}

/* ── Round Results ──────────────────────────────────── */
.result-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card);
  transition: background 0.2s;
}

.result-row.pts-3 { border-color: var(--success); background: rgba(16,185,129,0.1); }
.result-row.pts-2 { border-color: var(--warning); background: rgba(245,158,11,0.08); }
.result-row.pts-1 { border-color: var(--accent);  background: rgba(6,182,212,0.07); }
.result-row.pts-7 { border-color: #fbbf24;         background: rgba(251,191,36,0.12); }
.result-row.pts-extreme-win  { border-color: #f59e0b; background: rgba(245,158,11,0.13); box-shadow: 0 0 0 1px rgba(245,158,11,0.25); }
.result-row.pts-extreme-miss { border-color: #475569; background: rgba(71,85,105,0.08); opacity: 0.65; }

.result-pts {
  font-size: 1.4rem;
  font-weight: 900;
  min-width: 2.5rem;
  text-align: center;
}

.result-pts.pts-3 { color: var(--success); }
.result-pts.pts-2 { color: var(--warning); }
.result-pts.pts-1 { color: var(--accent);  }
.result-pts.pts-0 { color: var(--text-dim); }
.result-pts.pts-7 { color: #fbbf24; }
.result-pts.pts-extreme-win { color: #f59e0b; }

.result-name { font-weight: 600; flex: 1; }
.result-guess { font-size: 0.85rem; color: var(--text-muted); }
.result-diff { font-size: 0.78rem; color: var(--text-dim); }

/* ── Leaderboard ────────────────────────────────────── */
.leaderboard-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card);
}

.leaderboard-row:first-child  { border-color: #fbbf24; background: rgba(251,191,36,0.08); }
.leaderboard-row:nth-child(2) { border-color: #94a3b8; background: rgba(148,163,184,0.06); }
.leaderboard-row:nth-child(3) { border-color: #cd7c2f; background: rgba(205,124,47,0.06); }

.lb-rank {
  font-size: 1.5rem;
  min-width: 2rem;
  text-align: center;
}

.lb-name { font-weight: 700; font-size: 1.05rem; flex: 1; }

.lb-score {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--primary);
}

/* ── Badges / Chips ─────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.7rem;
  border-radius: 99px;
  font-size: 0.78rem;
  font-weight: 700;
}

.badge-purple { background: var(--primary-glow); color: #c4b5fd; border: 1px solid var(--primary); }
.badge-green  { background: rgba(16,185,129,0.15); color: #6ee7b7; border: 1px solid var(--success); }
.badge-yellow { background: rgba(245,158,11,0.15); color: #fcd34d; border: 1px solid var(--warning); }
.badge-red    { background: rgba(239,68,68,0.15);  color: #fca5a5; border: 1px solid var(--danger); }

/* ── Sections / Spacing ─────────────────────────────── */
.section { margin-bottom: 1.5rem; }
.section-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: 0.75rem;
}

.stack    { display: flex; flex-direction: column; gap: 0.75rem; }
.stack-sm { display: flex; flex-direction: column; gap: 0.4rem;  }
.row      { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; }

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.25rem 0;
}

/* ── Alerts & Callouts ──────────────────────────────── */
.callout {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--primary);
  background: rgba(124,58,237,0.07);
}

.callout.callout-success { border-left-color: var(--success); background: rgba(16,185,129,0.07); }
.callout.callout-warning { border-left-color: var(--warning); background: rgba(245,158,11,0.07); }
.callout.callout-info    { border-left-color: var(--accent);  background: rgba(6,182,212,0.07);  }

.callout-title { font-weight: 700; margin-bottom: 0.25rem; color: var(--text); }
.callout p     { font-size: 0.9rem; }

/* ── Waiting Pulse ──────────────────────────────────── */
.waiting-pulse {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  animation: pulse 1.4s ease-in-out infinite;
  vertical-align: middle;
  margin-right: 0.4rem;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.7); }
}

/* ── Spinner ────────────────────────────────────────── */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin { to { transform: rotate(360deg); } }

.connecting-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 40vh;
  color: var(--text-muted);
}

.screen-shell {
  width: 100%;
}

.screen-shell-centered {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 6rem);
}

.screen-shell-inner {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.screen-shell-inner-compact {
  max-width: 420px;
}

.screen-hero-tight {
  padding-top: 0;
  width: 100%;
}

.join-card,
.lobby-card {
  margin: 0 auto;
  width: 100%;
}

.join-card {
  max-width: 420px;
}

.lobby-card {
  max-width: 560px;
}

/* ── Phase Hero ─────────────────────────────────────── */
.phase-hero {
  text-align: center;
  padding: 2rem 1rem 1.5rem;
}

.phase-hero .emoji-big { font-size: 3.5rem; display: block; margin-bottom: 0.5rem; }
.phase-hero h2 { margin-bottom: 0.35rem; }
.phase-hero p  { max-width: 520px; margin: 0 auto; }

/* ── Phase Topline (Round + Vibe Man) ───────────────── */
.phase-topline {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  text-align: center;
  margin-bottom: 1rem;
}

/* ── Phrase Select Row ─────────────────────────────── */
.phrase-pick-btn { width: 100%; }

.phrase-pick-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
}

.phrase-pick-row .phrase-label-1,
.phrase-pick-row .phrase-label-2 {
  font-size: 1.15rem;
}

.phrase-pick-row .phrase-label-1 { text-align: right; }
.phrase-pick-row .phrase-label-2 { text-align: left; }

.phrase-pick-row .phrase-vs {
  font-size: 1rem;
  text-align: center;
  min-width: 2.2rem;
}

.phrase-pick-by {
  font-size: .75rem;
  color: var(--text-dim);
  text-align: center;
  margin-bottom: -0.5rem;
}

/* ── Big Number ─────────────────────────────────────── */
.big-number {
  font-size: clamp(4rem, 12vw, 7rem);
  font-weight: 900;
  text-align: center;
  line-height: 1;
  background: var(--grad-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0.5rem 0;
}

/* ── Story Display ──────────────────────────────────── */
.story-box {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--text);
  font-style: italic;
  position: relative;
}

.story-box::before {
  content: '"';
  position: absolute;
  top: -0.5rem;
  left: 0.75rem;
  font-size: 3rem;
  color: var(--primary);
  line-height: 1;
  font-family: Georgia, serif;
}

/* ── Progress Bar ───────────────────────────────────── */
.progress-bar {
  height: 6px;
  border-radius: 99px;
  background: var(--border);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--grad-primary);
  border-radius: 99px;
  transition: width 0.4s ease;
}

/* ── Countdown Bar (auto-advance indicator) ─────────── */
.countdown-bar-wrap {
  height: 5px;
  border-radius: 99px;
  background: rgba(255,255,255,0.1);
  overflow: hidden;
}

.countdown-bar {
  height: 100%;
  width: 100%;
  background: var(--grad-primary);
  border-radius: 99px;
  animation: countdown-drain 5s linear forwards;
  transform-origin: left center;
}

@keyframes countdown-drain {
  from { width: 100%; }
  to   { width: 0%; }
}

.countdown-bar-75 {
  height: 100%;
  width: 100%;
  background: var(--grad-primary);
  border-radius: 99px;
  animation: countdown-drain 7.5s linear forwards;
  transform-origin: left center;
}

.countdown-bar-15 {
  height: 100%;
  width: 100%;
  background: var(--grad-primary);
  border-radius: 99px;
  animation: countdown-drain 15s linear forwards;
  transform-origin: left center;
}

.countdown-bar-15.urgent {
  background: #ef4444;
}

.results-timer-ctrl {
  padding: 0.9rem 1rem;
}

.results-timer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

/* ── Results Zone Visualization ─────────────────────── */
.rz-row {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  margin: 1.25rem 0 0.5rem;
  overflow-x: auto;
  padding-bottom: 2px;
}

.rz-side {
  display: flex;
  align-items: flex-end;
  gap: 4px;
}

.rz-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 48px;
}

.rz-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  margin-bottom: 6px;
  max-width: 108px;
}

.rz-chip {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #fff;
  cursor: default;
  flex-shrink: 0;
  transition: transform 0.1s;
}

.rz-chip:hover { transform: scale(1.12); }

.rz-init { font-size: 0.8rem; line-height: 1; }
.rz-pts  { font-size: 0.55rem; line-height: 1.2; opacity: 0.9; }

.rz-me      { box-shadow: 0 0 0 3px var(--primary), 0 0 0 5px var(--primary-glow); }
.rz-extreme { box-shadow: 0 0 10px #ff00cc88; }
.rz-me.rz-extreme { box-shadow: 0 0 0 3px #ff00cc, 0 0 10px #ff00cc88; }

.rz-bar-label {
  font-size: 0.58rem;
  font-weight: 700;
  color: var(--text-dim);
  margin-bottom: 4px;
  white-space: nowrap;
}

.rz-bar-line {
  height: 6px;
  width: 100%;
  min-width: 48px;
  border-radius: 3px;
}

.rz-green  .rz-bar-line { background: #10b981; box-shadow: 0 0 6px #10b98155; }
.rz-yellow .rz-bar-line { background: #fbbf24; box-shadow: 0 0 6px #fbbf2455; }
.rz-orange .rz-bar-line { background: #f97316; box-shadow: 0 0 6px #f9731655; }
.rz-miss   .rz-bar-line { background: #475569; }

.rz-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 6px;
  flex-shrink: 0;
}

.rz-true {
  font-size: 1.3rem;
  font-weight: 900;
  color: #fbbf24;
  text-align: center;
  padding: 5px 8px 4px;
  border-top: 3px solid #fbbf24;
  text-shadow: 0 0 10px #fbbf2466;
  min-width: 50px;
  white-space: nowrap;
}

.rz-spacer { width: 16px; }

/* ── Toast Notifications ────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow);
  animation: slide-in 0.25s ease;
  pointer-events: all;
  max-width: 340px;
}

.toast.error { border-color: var(--danger); color: #fca5a5; }

@keyframes slide-in {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

@keyframes slide-out {
  from { transform: translateX(0);    opacity: 1; }
  to   { transform: translateX(120%); opacity: 0; }
}

.toast.removing { animation: slide-out 0.25s ease forwards; }

/* ── Color Palette for Avatars ──────────────────────── */
.avatar-0  { background: #7c3aed; }
.avatar-1  { background: #db2777; }
.avatar-2  { background: #0891b2; }
.avatar-3  { background: #059669; }
.avatar-4  { background: #d97706; }
.avatar-5  { background: #dc2626; }
.avatar-6  { background: #7c3aed; }
.avatar-7  { background: #0d9488; }

/* ── Fade-in transitions ────────────────────────────── */
.fade-in {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 600px) {
  #app { padding: 1.25rem 1rem 3rem; }
  .card { padding: 1.1rem; }
  .btn-group { flex-direction: column; }
}
