/* Player screen (/play). Loaded after stylesheet.css; uses its tokens. */

.player-page {
  padding-bottom: var(--space-6);
}

/* ---- Status bar: code / name / team / sound, as a row of pills ---- */
.player-status {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  justify-content: center;
  align-items: center;
  margin: var(--space-4) auto var(--space-4);
  max-width: 480px;
}
.status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  box-shadow: var(--shadow-1);
  font-size: var(--fs-sm);
  color: var(--ink-2);
  max-width: 100%;
}
.status-sound {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
}
.status-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
}
.status-value {
  font-weight: 700;
  color: var(--ink);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Team chip: a stateful button, not a bare Bootstrap outline button */
.team-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 6px 16px;
  margin: 0;
  border-radius: 999px;
  border: 1px solid var(--primary);
  background: #fff;
  color: var(--primary);
  font-weight: 700;
  font-size: var(--fs-sm);
  line-height: 1.2;
  cursor: pointer;
  box-shadow: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.team-chip:hover { background: rgba(11, 125, 9, 0.08); }
.team-chip:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Sound toggle: an icon button built on the #mute checkbox play.js reads */
.sound-toggle-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}
.sound-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 18px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.sound-toggle-btn .icon-on { display: none; }
.sound-toggle-btn .icon-off { display: block; }
.sound-toggle-input:checked + .sound-toggle-btn {
  background: rgba(11, 125, 9, 0.14);
  color: var(--primary);
}
.sound-toggle-input:checked + .sound-toggle-btn .icon-on { display: block; }
.sound-toggle-input:checked + .sound-toggle-btn .icon-off { display: none; }
.sound-toggle-input:focus-visible + .sound-toggle-btn {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.sound-toggle-input:disabled + .sound-toggle-btn {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ---- Timer: a pill with a big number, matching the host screen ---- */
#roundTimer {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: var(--space-2);
  border: none;
  margin: 0 auto var(--space-4);
  padding: var(--space-2) var(--space-5);
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  width: fit-content;
  max-width: calc(100% - 32px);
}
.timer-label {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
#timerDisplay {
  font-family: 'BuzzIn Wordmark', 'Montserrat', sans-serif;
  font-size: var(--fs-2xl);
  font-weight: 800;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

#noConnection {
  max-width: 480px;
  margin: 0 auto var(--space-4);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-4);
  font-weight: 600;
}

/* Spacebar hint: only worth showing to a mouse-and-keyboard player */
.spacebarHint {
  display: none;
  text-align: center;
  color: var(--muted);
  margin: 0 auto var(--space-3);
}
@media (hover: hover) and (pointer: fine) {
  .spacebarHint:not(.invisible) {
    display: block;
  }
}

.buzz-row-layout {
  margin-left: 0;
  margin-right: 0;
  /* Don't let an empty buzz-list/points card stretch to match the taller
     buzzer column; Bootstrap's .row defaults to align-items: stretch. */
  align-items: flex-start;
}
@media (min-width: 768px) {
  /* Let the buzzer/buzzes/points columns shrink to their content and sit
     closer together instead of stretching across Bootstrap's 33% columns. */
  .buzz-row-layout {
    justify-content: center;
  }
  .buzz-row-layout > [class*="col-"] {
    flex: 0 1 auto;
    width: auto;
    max-width: 440px;
  }
}

/* ---- The buzzer: an arcade-style dome drawn in CSS. Each state sets its
   colours through custom properties; the label and icon come from play.js. */
#buzzer {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(72vw, 280px);
  height: min(72vw, 280px);
  padding: 0;
  margin: 0 auto var(--space-5);
  border: none;
  border-radius: 50%;
  overflow: hidden;
  color: var(--ink);
  cursor: pointer;
  background-color: var(--buzz);
  background-image: none;
  box-shadow: 0 0 0 12px rgba(31, 217, 24, 0.16);
  transition: transform 0.06s ease-out, box-shadow 0.15s ease-out, background-color 0.15s ease-out;
  -webkit-tap-highlight-color: transparent;
}
#buzzer:focus-visible {
  outline: 4px solid var(--accent);
  outline-offset: 6px;
}
/* Press: a quick, flat scale-down. No sinking dome, no rim. */
#buzzer:active,
#buzzer.buzzed {
  transform: scale(0.96);
}
#buzzLabel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: 'BuzzIn Wordmark', 'Montserrat', sans-serif;
  font-weight: 900;
  font-size: 66px;
  letter-spacing: -0.02em;
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
}
#buzzLabel i {
  display: none;
  font-size: 32px;
}
#buzzer:not(.buzzBackground) #buzzLabel { font-size: 40px; }

#buzzSpinner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 2.5rem;
  height: 2.5rem;
  margin: -1.25rem 0 0 -1.25rem;
  color: inherit;
}

/* Ready: flat green with a white label. The green is a step deeper than the brand
   --buzz and the label carries a soft shadow, so white stays legible on it. */
#buzzer.buzzBackground {
  background-color: #17c211;
  color: #ffffff;
  box-shadow: 0 0 0 12px rgba(31, 217, 24, 0.16);
  animation: buzzerIn var(--dur) var(--ease-out), buzzerBreathe 2.8s ease-in-out var(--dur) infinite;
}
#buzzer.buzzBackground #buzzLabel {
  text-shadow: 0 2px 0 rgba(6, 80, 4, 0.45), 0 0 18px rgba(6, 80, 4, 0.3);
}

/* Buzzed: flat red, no animation */
#buzzer.buzzedBackground {
  background-color: var(--danger);
  color: #ffffff;
  box-shadow: 0 0 0 12px rgba(208, 38, 59, 0.22);
  animation: none;
}
#buzzer.buzzedBackground #buzzLabel .fa-check { display: block; }

/* Locked: flat slate grey */
#buzzer.lockedBackground {
  background-color: var(--ink-2);
  color: #ffffff;
  box-shadow: 0 0 0 12px rgba(61, 67, 96, 0.18);
  animation: none;
}
#buzzer.lockedBackground #buzzLabel .fa-lock { display: block; }

/* Penalty: flat amber with dark ink text; subtle flat hazard stripes */
#buzzer.penaltyBackground {
  background-color: var(--warning);
  background-image: repeating-linear-gradient(135deg, rgba(43, 26, 0, 0.14) 0 14px, rgba(43, 26, 0, 0) 14px 28px);
  color: var(--warning-ink);
  box-shadow: 0 0 0 12px rgba(245, 163, 0, 0.24);
  animation: buzzPenaltyShake 0.35s ease-in-out;
}
#buzzer.penaltyBackground #buzzLabel .fa-exclamation-triangle { display: block; }

/* Re-enabled: the buzzer settles back in */
@keyframes buzzerIn {
  from { transform: scale(0.94); }
  to { transform: scale(1); }
}
/* State change: the label pops */
@keyframes buzzLabelPop {
  0% { transform: scale(0.86); opacity: 0.4; }
  100% { transform: scale(1); opacity: 1; }
}
#buzzLabel.pop { animation: buzzLabelPop var(--dur) var(--ease-out); }
@keyframes buzzerBreathe {
  0%, 100% { box-shadow: 0 0 0 10px rgba(31, 217, 24, 0.14); }
  50% { box-shadow: 0 0 0 16px rgba(31, 217, 24, 0.24); }
}
@keyframes buzzPenaltyShake {
  0%, 100% { translate: 0 0; }
  20% { translate: -10px 0; }
  40% { translate: 9px 0; }
  60% { translate: -6px 0; }
  80% { translate: 4px 0; }
}
@media (prefers-reduced-motion: reduce) {
  #buzzer { transition: none; }
  #buzzer.buzzBackground { animation: none; }
  #buzzer.penaltyBackground { animation: none; }
}
@media only screen and (max-width: 360px) {
  #buzzer {
    width: min(80vw, 220px);
    height: min(80vw, 220px);
  }
  #buzzLabel { font-size: 44px; gap: 4px; }
  #buzzer:not(.buzzBackground) #buzzLabel { font-size: 32px; }
  #buzzLabel i { font-size: 24px; }
}

/* ---- Buzz list and points board cards ---- */
.player-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  padding: var(--space-4);
  margin: 0 auto var(--space-5);
  max-width: 420px;
  text-align: left;
}
.player-card-title {
  font-size: var(--fs-lg);
  font-weight: 800;
  color: var(--ink);
  margin: 0 0 var(--space-3);
}

.buzz-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--line);
}
.buzz-row:last-child { border-bottom: none; }
.buzz-rank {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 700;
  font-size: var(--fs-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}
.buzz-name {
  color: var(--ink-2);
  font-weight: 600;
  overflow-wrap: anywhere;
}
.buzz-row-you {
  background: rgba(11, 125, 9, 0.08);
  border-radius: var(--radius-sm);
  margin: 0 -8px;
  padding: var(--space-2) 8px;
}
.buzz-row-you .buzz-rank {
  background: var(--primary);
  color: #fff;
}
.you-badge {
  display: inline-block;
  margin-left: 6px;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #fff;
  background: var(--primary);
  border-radius: 999px;
  padding: 2px 8px;
  vertical-align: middle;
}
.buzz-row-ellipsis {
  justify-content: center;
  color: var(--muted);
  border-bottom: none;
  padding: 2px 0;
}
.buzzGap {
  color: var(--muted);
  font-weight: normal;
  margin-left: 4px;
}

/* Points board: a segmented control instead of two plain buttons */
.segmented {
  display: flex;
  background: var(--surface-2);
  border-radius: 999px;
  padding: 4px;
  gap: 4px;
  margin: 0 0 var(--space-3);
}
/* With only one kind of points there's nothing to switch between: play.js hides
   both buttons, so hide the empty track too */
.segmented:not(:has(.segmented-btn:not(.invisible))) {
  display: none;
}
.segmented-btn {
  flex: 1 1 0;
  min-height: 40px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font-weight: 700;
  font-size: var(--fs-sm);
  margin: 0;
  padding: 6px 10px;
  cursor: pointer;
  box-shadow: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.segmented-btn.segmented-active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-1);
}
.segmented-btn:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.points-list > div {
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink-2);
  font-weight: 600;
}
.points-list > div:last-child { border-bottom: none; }

/* ---- Join card ---- */
#splash {
  display: flex;
  justify-content: center;
  padding: var(--space-5) 0;
}
.join-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  padding: var(--space-6) var(--space-5);
  text-align: left;
}
.join-title {
  font-family: 'BuzzIn Wordmark', 'Montserrat', sans-serif;
  font-weight: 800;
  font-size: var(--fs-xl);
  color: var(--ink);
  margin: 0 0 var(--space-4);
  text-align: center;
}
.join-field { margin-bottom: var(--space-4); text-align: left; }
.join-field label {
  display: block;
  font-weight: 700;
  color: var(--ink-2);
  margin-bottom: var(--space-1);
  font-size: var(--fs-sm);
  text-align: left;
}
#splash .form-control {
  width: 100%;
  margin: 0;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  font-size: var(--fs-base);
  background: #fff;
  color: var(--ink);
  box-shadow: none;
}
#splash .form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 91, 219, 0.25);
}
.join-code-input {
  font-family: 'BuzzIn Wordmark', 'Montserrat', sans-serif;
  font-weight: 800;
  font-size: var(--fs-xl);
  letter-spacing: 0.12em;
  text-align: center;
}
.join-code-input::-webkit-outer-spin-button,
.join-code-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.join-code-input { -moz-appearance: textfield; }
.join-help {
  display: block;
  margin-top: var(--space-1);
  color: var(--muted);
  font-size: 0.8rem;
}
#joinBtn {
  display: block;
  width: 100%;
  min-height: 48px;
  margin: var(--space-2) 0 0;
  border-radius: var(--radius-sm);
  background: var(--primary);
  border: none;
  color: #fff;
  font-weight: 700;
  font-size: var(--fs-base);
  cursor: pointer;
  box-shadow: none;
  transition: background-color 0.15s ease;
}
#joinBtn:hover { background: var(--primary-hover); }
#joinBtn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.buzz-empty {
  color: var(--muted);
  margin: var(--space-2) 0 0;
  text-align: center;
}

/* Final pass: on desktop the buzzer and its lists sit together, not at the far edges */
@media (min-width: 768px) {
  .buzz-row-layout { gap: var(--space-6); }
  .buzz-row-layout > [class*="col-"] { margin: 0; }
  #buzzerContainer { margin: 0; }
}

/* Motion: new buzzes slide into the list */
@keyframes rowIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}
.buzz-row.is-new { animation: rowIn var(--dur) var(--ease-out) both; }
.buzz-row.is-new .buzz-rank { animation: rankPop var(--dur-slow) var(--ease-out) both; }
@keyframes rankPop {
  0% { transform: scale(0.6); }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); }
}
/* Motion: the last five seconds of the timer turn red and tick */
#timerDisplay { display: inline-block; transition: color var(--dur) ease; }
#timerDisplay.timer-low { color: var(--danger); }
#timerDisplay.timer-tick { animation: timerTick 600ms var(--ease-out); }
@keyframes timerTick {
  0% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

/* the connection light pill: just the light */
.status-conn { padding: 6px 10px; }
