/* Darts — tokens from /assets/base.css */

html, body { height: 100%; }

body {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 16px 16px 16px;
  min-height: 100vh;
  overflow: hidden;
}

.app {
  width: 100%;
  max-width: 540px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-top: 8px;
}

.top {
  width: 100%;
  text-align: center;
  padding-left: 52px;
  padding-right: 8px;
}
.top h1 {
  font-size: clamp(1.5rem, 3vw, 2rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.panel {
  width: 100%;
  background: linear-gradient(145deg, rgba(16, 20, 38, 0.95), #090c18 50%, #05060f 100%);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 26px;
  padding: 20px 18px 18px;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: stretch;
}

.hidden { display: none !important; }

/* Menu groups (used by the settings overlay) */
.menu-group {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.menu-label {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.menu-hint {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  max-width: 380px;
  line-height: 1.5;
}

.seg {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 3px;
  gap: 2px;
}
.seg-btn {
  background: transparent;
  border: none;
  border-radius: var(--radius-pill);
  color: var(--muted);
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
}

/* Board */
.board-wrap {
  position: relative;
  /* Board fills the top square of the canvas, the throw zone sits below
     (1:1.3). Cap size so the panel always fits the viewport - the 280px
     reserve covers title + status row + status msg + buttons + padding. */
  width: min(100%, 440px, calc((100vh - 280px) / 1.3));
  aspect-ratio: 10 / 13;
  margin: 0 auto;
}
canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* Scoreboard - compact bar above the board */
.scoreboard {
  width: 100%;
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 10px;
}
.sb-player {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 14px;
  min-width: 92px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  transition: border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}
.sb-player[hidden] { display: none; }
.sb-player.active {
  border-color: rgba(138, 124, 255, 0.55);
  background: rgba(138, 124, 255, 0.06);
  box-shadow: 0 0 16px rgba(138, 124, 255, 0.16);
}
.sb-name {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
}
.sb-score {
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.sb-mid {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
}
.sb-round {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}
.sb-darts { display: flex; gap: 6px; }
.sb-dart {
  min-width: 46px;
  padding: 3px 8px;
  text-align: center;
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed var(--line);
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}
.sb-dart.filled {
  border-style: solid;
  background: rgba(138, 124, 255, 0.08);
  color: var(--text);
  border-color: var(--accent);
}

.status-msg {
  text-align: center;
  font-size: 14px;
  letter-spacing: 0.04em;
  color: var(--muted);
  min-height: 1.4em;
}
.status-msg.win { color: var(--accent); font-weight: 700; }
.status-msg.bust { color: #ff6b8a; font-weight: 700; }
.status-msg.aim { color: var(--text); font-weight: 600; }

/* Buttons */
.primary-btn {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius-pill);
  padding: 11px 24px;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.12s ease, box-shadow 0.18s ease;
}
.primary-btn:hover {
  background: rgba(138, 124, 255, 0.25);
  transform: translateY(-1px);
  box-shadow: 0 0 18px rgba(138, 124, 255, 0.3);
}
.ghost-btn {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  color: var(--text);
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}
.ghost-btn:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
  color: var(--accent);
}
/* [hidden] guard - .util-btn is inline-flex, which beats the hidden attr */
.util-btn[hidden] { display: none; }

/* Overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 22, 0.78);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}
.overlay-card {
  position: relative;
  background: linear-gradient(145deg, #1a1c30, #0d0e1d);
  border: 1px solid rgba(138, 124, 255, 0.3);
  border-radius: 22px;
  padding: 28px 32px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  box-shadow: 0 0 40px rgba(138, 124, 255, 0.2);
  max-width: 320px;
}
.overlay-card h2 {
  font-size: 1.6rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}
.overlay-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.muted { color: var(--muted); font-size: 0.85rem; }

@media (max-width: 600px) {
  .panel { padding: 16px 14px 14px; border-radius: 20px; }
  .sb-player { min-width: 72px; padding: 6px 10px; }
  .sb-score { font-size: 1.3rem; }
  .sb-dart { min-width: 38px; font-size: 11px; padding: 3px 6px; }
}

/* ==========================================================================
   GAMEPLAY FEEDBACK - score pops, bust shake, confetti
   ========================================================================== */

.board-wrap { position: relative; }

.score-pop {
  position: absolute;
  z-index: 10;
  pointer-events: none;
  transform: translate(-50%, -50%);
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 0.03em;
  color: #e9e9f1;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.95);
  animation: score-pop-float 1.05s ease-out forwards;
}

.score-pop.pop-plain { font-size: 17px; color: #cfd0e2; }
.score-pop.pop-miss  { font-size: 16px; color: #8b8da3; }
.score-pop.pop-good  { color: #7cf0c2; }
.score-pop.pop-great { color: #ffd166; font-size: 23px; }
.score-pop.pop-bull  { color: #ff7aa8; font-size: 24px; }
.score-pop.pop-bust  { color: #ff5d5d; font-size: 24px; }

@keyframes score-pop-float {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
  15%  { opacity: 1; transform: translate(-50%, -80%) scale(1.15); }
  30%  { transform: translate(-50%, -80%) scale(1); }
  75%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -160%); }
}

.board-wrap.shake {
  animation: board-shake 0.45s ease-in-out;
}

@keyframes board-shake {
  0%, 100% { transform: translateX(0); }
  15%, 55%, 85% { transform: translateX(-5px); }
  35%, 70% { transform: translateX(5px); }
}

.confetti-dot {
  position: absolute;
  z-index: 11;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  pointer-events: none;
  transform: translate(-50%, -50%);
}


/* Flick-to-throw: the canvas owns all pointer gestures */
#canvas { touch-action: none; }


/* ==========================================================================
   MENU PANEL - site-standard centered menu
   ========================================================================== */

.darts-bg {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.darts-bg-item {
  position: absolute;
  opacity: 0.06;
  color: var(--muted);
}
.darts-bg-item svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
  stroke-width: 1.5;
  fill: none;
}

.app { position: relative; z-index: 1; }

/* On the menu: hide the page header (the panel has its own title) and centre vertically */
body.on-menu .top { display: none; }
body.on-menu .app {
  justify-content: center;
  min-height: calc(100dvh - 32px);
  margin-top: 0;
}

.menu-panel {
  width: 100%;
  max-width: 430px;
  background: linear-gradient(160deg, #141826, #101321);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 38px 34px 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  box-shadow: var(--shadow-soft);
  position: relative;
  z-index: 1;
  animation: menu-entrance 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes menu-entrance {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.menu-logo {
  width: 44px;
  height: 44px;
  stroke: var(--accent);
  stroke-width: 1.6;
  fill: none;
  color: var(--accent);
  filter: drop-shadow(0 0 12px rgba(138, 124, 255, 0.45));
}

.menu-title {
  font-size: clamp(28px, 5vw, 38px);
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: center;
  line-height: 1.2;
  margin: 0;
}

.menu-form {
  width: 100%;
  display: flex;
  flex-direction: column;
}
.menu-step { display: flex; flex-direction: column; gap: 16px; }
.menu-step:not(.hidden) > * {
  animation: menu-field-in 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.menu-step:not(.hidden) > *:nth-child(1) { animation-delay: 0.06s; }
.menu-step:not(.hidden) > *:nth-child(2) { animation-delay: 0.12s; }
.menu-step:not(.hidden) > *:nth-child(3) { animation-delay: 0.18s; }
.menu-step:not(.hidden) > *:nth-child(4) { animation-delay: 0.24s; }
.menu-step:not(.hidden) > *:nth-child(5) { animation-delay: 0.3s; }

@keyframes menu-field-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.menu-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.menu-row-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.menu-start-btn {
  width: 100%;
  background: var(--accent);
  color: #14122b;
  border: none;
  border-radius: var(--radius-pill);
  padding: 14px 24px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  margin-top: 4px;
  box-shadow: 0 10px 22px rgba(138, 124, 255, 0.4);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}
.menu-start-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 32px rgba(138, 124, 255, 0.6);
}

.menu-stats[hidden] { display: none; }
.menu-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}
.menu-stats .icon {
  width: 16px;
  height: 16px;
  opacity: 0.5;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

@media (max-width: 600px) {
  .menu-panel { padding: 30px 22px 24px; }
}


/* ==========================================================================
   ONLINE - create/join overlay + waiting state
   ========================================================================== */

.online-card { width: 100%; max-width: 340px; }

.online-step {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
}
.online-step.hidden { display: none !important; }

.online-main-btn { width: 100%; }

.online-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.online-divider::before,
.online-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.online-join { display: flex; gap: 8px; }
.online-join input {
  flex: 1;
  min-width: 0;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  text-align: center;
  padding: 9px 14px;
}
.online-join input::placeholder { color: var(--muted); opacity: 0.5; letter-spacing: 0.2em; }
.online-join input:focus { outline: none; border-color: var(--accent); }

.online-config-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.online-wait-label {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-align: center;
}
.online-code {
  margin: 0;
  font-size: 42px;
  font-weight: 800;
  letter-spacing: 0.25em;
  text-indent: 0.25em;
  color: var(--accent);
  text-shadow: 0 0 24px rgba(138, 124, 255, 0.5);
  cursor: pointer;
  user-select: all;
  text-align: center;
}
.online-wait-sub {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  animation: darts-wait-pulse 1.6s ease-in-out infinite;
}
@keyframes darts-wait-pulse {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 1; }
}

.online-status {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}
.online-status.error { color: #ff5d7a; }
.online-status[hidden] { display: none; }


/* ===== Stepped menu: Local/Online choice cards (2026-06-05) ===== */
.menu-choices { display: flex; gap: 12px; width: 100%; }
.choice-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 20px 12px 16px;
  background: var(--surface, rgba(255,255,255,0.03));
  border: 1px solid var(--line);
  border-radius: var(--radius-md, 12px);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.15s ease, box-shadow 0.2s ease;
}
.choice-card:hover {
  background: var(--surface-hover, rgba(255,255,255,0.09));
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 0 18px rgba(138, 124, 255, 0.18);
}
.choice-icon { width: 30px; height: 30px; color: var(--accent); margin-bottom: 4px; }
.choice-label { font-size: 15px; font-weight: 700; letter-spacing: 0.03em; }
.choice-desc { font-size: 12px; color: var(--muted); }
.step-back {
  align-self: flex-start;
  background: none; border: none;
  color: var(--muted);
  font-family: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; padding: 2px 4px; margin-bottom: -4px;
  transition: color 0.15s ease;
}
.step-back:hover { color: var(--text); }
