/* ── Variables ── */
:root {
  --bg-page: #101014;
  --bg-sidebar: #18181c;
  --bg-header: #1c1c22;
  --bg-surface: #25252b;
  --bg-input: #2f2f36;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --danger: #ef4444;
  --success: #22c55e;
  --warn: #f59e0b;
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --border: #3f3f46;
  --radius: 8px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  background: var(--bg-page);
  color: var(--text-main);
  font-family: var(--font);
  font-size: 14px;
  overflow-x: hidden;
}

.hidden {
  display: none !important;
}

.spacer {
  flex: 1;
}

/* ── Scrollbars ── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #52525b;
}

/* ══════════════════════════════════════════
   SCREEN WRAPPERS
══════════════════════════════════════════ */
.screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  gap: 32px;
  overflow: hidden;
}

/* ══════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  white-space: nowrap;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-main);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-input);
}

.btn-ghost {
  background: transparent;
  color: var(--text-main);
  border-color: var(--border);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-surface);
}

.btn-danger {
  background: rgba(239, 68, 68, .1);
  color: var(--danger);
  border-color: rgba(239, 68, 68, .3);
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger);
  color: #fff;
}

.btn-success {
  background: rgba(34, 197, 94, .1);
  color: var(--success);
  border-color: rgba(34, 197, 94, .3);
}

.btn-success:hover:not(:disabled) {
  background: var(--success);
  color: #fff;
}

.btn-lg {
  padding: 13px 26px;
  font-size: 1rem;
  border-radius: 10px;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

/* ══════════════════════════════════════════
   HOST SETUP
══════════════════════════════════════════ */
#screen-host-setup {
  gap: 24px;
}

.setup-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 36px;
  max-width: 480px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.setup-card h2 {
  font-size: 1.3rem;
  font-weight: 700;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

#qrcode-wrapper {
  background: #fff;
  padding: 16px;
  border-radius: 12px;
  line-height: 0;
}

.room-code {
  font-family: monospace;
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: .18em;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 24px;
}

.setup-actions {
  display: flex;
  gap: 10px;
  width: 100%;
}

.setup-actions .btn {
  flex: 1;
}

/* ══════════════════════════════════════════
   HOST DASHBOARD
══════════════════════════════════════════ */
#screen-host-dashboard {
  min-height: 100vh;
  display: grid;
  grid-template-rows: 58px 1fr;
  padding: 0;
  gap: 0;
  align-items: stretch;
  justify-content: stretch;
}

/* Header */
.host-header {
  display: flex;
  align-items: center;
  padding: 0 18px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  gap: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 900;
  font-size: 1.15rem;
  background: linear-gradient(135deg, #818cf8, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
}

.brand-logo {
  width: 24px;
  height: 24px;
  object-fit: contain;
  /* logos are often PNG with transparency, preserve it */
  filter: none;
  /* reset any gradient text clip for the img */
  -webkit-text-fill-color: initial;
  background: none;
}

.host-tag {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.room-pill {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--primary);
  letter-spacing: .05em;
}

.player-count {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  transition: background .3s;
  flex-shrink: 0;
}

.status-dot.online {
  background: var(--success);
  box-shadow: 0 0 7px rgba(34, 197, 94, .55);
}

.status-dot.connecting {
  background: var(--warn);
  animation: blink 1s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}

/* Body layout */
.host-body {
  display: grid;
  grid-template-columns: 320px 1fr;
  overflow: hidden;
  height: calc(100vh - 58px);
}

/* Left sidebar */
.host-left {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.panel-block {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.panel-block:last-child {
  border-bottom: none;
  flex: 1;
}

.panel-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* Mode switch */
.mode-switch {
  display: flex;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

/* 3-button buzz mode selector — same look as mode-switch */
.buzz-mode-switch {
  display: flex;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.buzz-mode-switch button,
.mode-switch button {
  flex: 1;
  padding: 8px 10px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}

.buzz-mode-switch button.active,
.mode-switch button.active {
  background: var(--primary);
  color: #fff;
}

/* Description below the buzz mode selector */
.buzz-mode-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin: 4px 0 0;
  min-height: 1.2em;
}

/* Toggle rows */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 0;
  gap: 10px;
}

.toggle-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toggle-info span {
  font-size: 0.85rem;
  color: var(--text-main);
}

.toggle-info small {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.toggle {
  position: relative;
  width: 38px;
  height: 20px;
  flex-shrink: 0;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all .18s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  left: 2px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--text-muted);
  border-radius: 50%;
  transition: all .18s;
}

.toggle input:checked + .toggle-slider {
  background: var(--primary);
  border-color: var(--primary);
}

.toggle input:checked + .toggle-slider::before {
  transform: translate(18px, -50%);
  background: #fff;
}

/* Players panel — always fills the remaining sidebar space */
.players-panel {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  /* override the generic panel-block:last-child rule so it doesn't fight */
  min-height: 0;
}

.players-empty {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Players list */
.players-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  border-left-width: 3px;
}

.player-card-top {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  gap: 8px;
}

.player-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.player-name-text {
  flex: 1;
  font-weight: 700;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-score-num {
  font-family: monospace;
  font-weight: 700;
  font-size: 1.1rem;
  min-width: 38px;
  text-align: right;
}

/* Sound button on player card */
.sound-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 2px 4px;
  border-radius: 4px;
  color: var(--text-muted);
  transition: color .15s, background .15s;
  flex-shrink: 0;
  line-height: 1;
}

.sound-btn:hover {
  color: var(--primary);
  background: rgba(99, 102, 241, .12);
}

.sound-btn.has-custom {
  color: var(--success);
}

.remove-team-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.8rem;
  padding: 2px 5px;
  border-radius: 4px;
  color: var(--text-muted);
  transition: color .15s, background .15s;
  flex-shrink: 0;
  line-height: 1;
}

.remove-team-btn:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, .12);
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
  padding: 0 6px 6px;
}

.sc-btn {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 4px;
  padding: 3px 4px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font);
  transition: all .1s;
  text-align: center;
}

.sc-btn:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.sc-btn.neg:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

/* Right panel */
.host-right {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 20px;
  gap: 18px;
}

/* Persistent scoreboard bar — always visible once players join */
.host-scoreboard {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.sb-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface);
  border: 1px solid;
  border-radius: 20px;
  padding: 5px 12px 5px 8px;
  font-size: 0.83rem;
}

.sb-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sb-name {
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 4px;
}

.sb-score {
  font-family: monospace;
  font-weight: 900;
  font-size: 1rem;
  margin-left: 4px;
}

/* member count inside scoreboard chip */
.sb-members {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 800;
}

/* Buzz display */
.buzz-display {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  transition: border-color .3s, box-shadow .3s;
}

.buzz-display.has-buzz {
  border-color: var(--buzz-color, var(--primary));
  box-shadow: 0 0 50px -12px var(--buzz-color, var(--primary));
}

.buzz-display.has-buzz::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--buzz-color, var(--primary));
  opacity: .05;
}

.buzz-idle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  text-align: center;
}

.buzz-idle-icon {
  font-size: 3rem;
  opacity: .25;
}

.buzz-idle p {
  font-size: 0.95rem;
}

.buzz-active {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  position: relative;
  z-index: 1;
}

.buzz-kicker {
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .18em;
  color: var(--text-muted);
}

.buzz-winner-name {
  font-size: 3.8rem;
  font-weight: 900;
  letter-spacing: -.04em;
  line-height: 1;
  text-align: center;
}

.buzz-rank-pill {
  background: rgba(255, 255, 255, .1);
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 0.85rem;
  font-weight: 700;
}

/* Block timer */
.block-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  background: rgba(239, 68, 68, .08);
  border: 1px solid rgba(239, 68, 68, .25);
  border-radius: var(--radius);
  color: var(--danger);
  font-size: 0.875rem;
  font-weight: 600;
}

/* Buzz order */
.section-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.buzz-order-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.buzz-order-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 14px;
}

.order-rank {
  font-size: 1.1rem;
  font-weight: 900;
  color: var(--text-muted);
  width: 28px;
  text-align: center;
}

.order-rank.gold   { color: #fbbf24; }
.order-rank.silver { color: #94a3b8; }
.order-rank.bronze { color: #b45309; }

.order-name {
  font-weight: 600;
  flex: 1;
}

/* Text answers */
.text-ans-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.text-ans-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.text-ans-rank {
  font-size: 1.3rem;
  width: 32px;
  text-align: center;
  flex-shrink: 0;
}

.text-ans-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}

.text-ans-name {
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.text-ans-text {
  font-size: 1.15rem;
  font-weight: 600;
  word-break: break-word;
  color: var(--text-main);
}

/* ══════════════════════════════════════════
   SOUND SETTINGS PANEL
══════════════════════════════════════════ */
.sound-default-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.sound-default-row label {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.sound-file-input {
  display: none;
}

.sound-pick-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px 10px;
  font-family: var(--font);
  font-size: 0.78rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color .15s, color .15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

.sound-pick-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.sound-pick-btn.has-file {
  border-color: var(--success);
  color: var(--success);
}

.sound-preview-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text-muted);
  padding: 3px;
  border-radius: 4px;
  transition: color .15s;
  line-height: 1;
}

.sound-preview-btn:hover { color: var(--primary); }

/* ══════════════════════════════════════════
   PLAYER CARDS GRID (host-right)
══════════════════════════════════════════ */
.player-cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  align-content: flex-start;
  flex: 1;   /* take remaining space in host-right */
}

.cards-empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 60px 20px;
  text-align: center;
}

.cards-empty-icon {
  font-size: 3rem;
  line-height: 1;
  opacity: .5;
}

.cards-empty-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
}

.cards-empty-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
}

/* Individual team/player game card */
.team-game-card {
  --team-color: var(--primary);
  position: relative;
  background: var(--bg-surface);
  border: 2px solid transparent;
  border-radius: 14px;
  padding: 14px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
  transition: border-color .35s, box-shadow .35s;
}

/* Colored tint overlay */
.team-game-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--team-color);
  opacity: 0;
  transition: opacity .35s;
  pointer-events: none;
}

/* Buzz winner state — illuminates the card */
.team-game-card.buzz-winner {
  border-color: var(--team-color);
  box-shadow: 0 0 36px -6px var(--team-color);
}

.team-game-card.buzz-winner::before {
  opacity: .07;
}

/* Buzz rank badge — centré entre header et score */
.tgc-buzz-tag {
  background: var(--team-color);
  color: #fff;
  border-radius: 7px;
  padding: 3px 10px;
  font-size: 0.72rem;
  font-weight: 800;
  align-self: center;
  text-align: center;
  position: relative;
  z-index: 1;
}

.tgc-header {
  display: flex;
  align-items: center;
  gap: 7px;
  position: relative;
  z-index: 1;
}

.tgc-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tgc-name {
  font-weight: 800;
  font-size: 0.92rem;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tgc-score {
  font-size: 3.2rem;
  font-weight: 900;
  letter-spacing: -.04em;
  line-height: 1;
  text-align: center;
  position: relative;
  z-index: 1;
}

.tgc-score-btns {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 3px;
  position: relative;
  z-index: 1;
}

/* ══════════════════════════════════════════
   SCREEN: Player Choose Team
══════════════════════════════════════════ */
#screen-player-choose {
  gap: 24px;
}

.choose-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  max-width: 400px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.team-choice-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.team-choice-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font);
  color: var(--text-main);
  transition: border-color .15s, background .15s, box-shadow .15s;
  text-align: left;
}

.team-choice-btn:hover {
  border-color: var(--tc, var(--primary));
  background: var(--bg-surface);
  box-shadow: 0 0 12px -4px var(--tc, var(--primary));
}

.tc-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tc-name {
  flex: 1;
  font-weight: 700;
  font-size: 0.95rem;
}

.tc-members {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Separator line "ou" between team list and solo button */
.choose-sep {
  position: relative;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.choose-sep::before,
.choose-sep::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 42%;
  height: 1px;
  background: var(--border);
}

.choose-sep::before { left: 0; }
.choose-sep::after  { right: 0; }

/* ══════════════════════════════════════════
   PLAYER JOIN
══════════════════════════════════════════ */
#screen-player-join {
  gap: 28px;
}


.join-hero {
  text-align: center;
}

.join-logo {
  width: 72px;
  height: 72px;
  object-fit: contain;
  border-radius: 16px;
}

.join-hero h1 {
  font-size: 1.8rem;
  font-weight: 900;
  margin-top: 8px;
}

.join-hero p {
  color: var(--text-muted);
  margin-top: 4px;
}

.join-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px 20px;
  max-width: 400px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* "(optionnel)" label suffix */
.opt-label {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  opacity: .65;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
}

.form-group input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 11px 14px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 1rem;
  transition: border-color .15s;
  width: 100%;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary);
}

.form-group input.mono {
  font-family: monospace;
  text-transform: uppercase;
  letter-spacing: .1em;
  font-size: 1.1rem;
}

.error-msg {
  color: var(--danger);
  font-size: 0.85rem;
  text-align: center;
}

/* ══════════════════════════════════════════
   PLAYER GAME
══════════════════════════════════════════ */
#screen-player-game {
  /* Use dynamic viewport height so the screen doesn't overflow
     the visible browser area on mobile (accounts for address bar) */
  height: 100vh;
  height: 100dvh; /* preferred — supported on all modern browsers */
  max-height: 100dvh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0;
  transition: background 0.6s;
  overflow: hidden;
}

.player-header {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  gap: 10px;
  flex-shrink: 0;
}

.p-color-badge {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
}

.p-name  { font-weight: 700; font-size: 0.95rem; }
.p-room  { font-family: monospace; font-size: 0.78rem; color: var(--text-muted); }

.player-main {
  flex: 1;
  min-height: 0;    /* allow shrinking inside the fixed height parent */
  overflow: visible; /* ne pas clipper le halo du buzzer */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 20px 20px;
}

/* Score */
.my-score { text-align: center; }

.my-score-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.my-score-value {
  font-size: 6rem;
  font-weight: 900;
  letter-spacing: -.05em;
  line-height: 1;
  color: var(--player-color, var(--primary));
}

/* Buzz button */
.buzz-btn-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.buzz-btn {
  width: 220px;
  height: 220px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  font-size: 1.5rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: #fff;
  background: var(--player-color, var(--primary));
  box-shadow:
    0 0 0 6px rgba(255, 255, 255, .06),
    0 8px 40px -6px var(--player-color, var(--primary)),
    inset 0 2px 0 rgba(255, 255, 255, .2);
  transition: transform .12s, box-shadow .15s, opacity .15s;
  position: relative;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.buzz-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, rgba(255, 255, 255, .28), transparent 58%);
  pointer-events: none;
}

.buzz-btn:hover:not(:disabled) {
  transform: scale(1.04);
  box-shadow:
    0 0 0 8px rgba(255, 255, 255, .08),
    0 16px 60px -4px var(--player-color, var(--primary)),
    inset 0 2px 0 rgba(255, 255, 255, .2);
}

.buzz-btn:active:not(:disabled) { transform: scale(.93); }

.buzz-btn:disabled {
  opacity: .35;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none;
}

.buzz-btn.fired {
  animation: buzzPop .55s cubic-bezier(.36, .07, .19, .97);
}

@keyframes buzzPop {
  0%   { transform: scale(1); }
  28%  { transform: scale(1.14); }
  60%  { transform: scale(.93); }
  100% { transform: scale(1); }
}

.buzz-feedback {
  font-size: 1rem;
  font-weight: 700;
  min-height: 22px;
  text-align: center;
  transition: opacity .25s;
}

/* Text mode */
.text-mode-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 380px;
}

.text-mode-wrap p {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
}

.text-mode-wrap input {
  width: 100%;
  background: var(--bg-input);
  border: 2px solid var(--border);
  color: var(--text-main);
  padding: 14px 18px;
  border-radius: 12px;
  font-family: var(--font);
  font-size: 1.15rem;
  text-align: center;
  transition: border-color .15s;
}

.text-mode-wrap input:focus {
  outline: none;
  border-color: var(--player-color, var(--primary));
}

/* Other scores bar */
.other-scores {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  padding: 10px 16px 14px;
  min-height: 44px;
  flex-shrink: 0;
}

.score-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 0.83rem;
}

.chip-dot   { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.chip-name  { font-weight: 700; }
.chip-pts   { font-family: monospace; font-weight: 700; color: var(--text-muted); margin-left: 3px; }

/* Team member count badge shown on player card when > 1 member */
.team-members-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 4px;
  border-radius: 9px;
  background: var(--primary);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 800;
  flex-shrink: 0;
  vertical-align: middle;
}


/* ══════════════════════════════════════════
   MODAL — Add Players popup
══════════════════════════════════════════ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .65);
  backdrop-filter: blur(4px);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  max-width: 420px;
  width: 100%;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .5);
  animation: modalIn .2s cubic-bezier(.34, 1.56, .64, 1);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(.92); }
  to   { opacity: 1; transform: scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-weight: 800;
  font-size: 1rem;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius);
  transition: color .15s, background .15s;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text-main);
  background: var(--bg-input);
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.modal-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
}

.modal-qrwrap {
  background: #fff;
  padding: 14px;
  border-radius: 12px;
  line-height: 0;
}

/* Spinner inside modal while peer is connecting */
.modal-qrwrap.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 218px;
  height: 218px;
}

.modal-link-row {
  display: flex;
  gap: 8px;
  width: 100%;
  align-items: center;
}

.modal-link-input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 9px 12px;
  border-radius: var(--radius);
  font-family: monospace;
  font-size: 0.78rem;
  min-width: 0;
  cursor: text;
  user-select: all;
}

.modal-link-input:focus {
  outline: none;
  border-color: var(--primary);
  color: var(--text-main);
}

/* ══════════════════════════════════════════
   GLOBAL OVERLAYS
══════════════════════════════════════════ */
#flash-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  z-index: 9990;
  transition: opacity .08s;
}

#flash-overlay.fire {
  animation: flashFade .85s ease forwards;
}

@keyframes flashFade {
  0%   { opacity: .45; }
  100% { opacity: 0; }
}

#buzz-toast {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%) translateY(-14px);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 22px;
  font-weight: 700;
  font-size: 0.95rem;
  text-align: center;
  opacity: 0;
  transition: opacity .25s, transform .25s;
  z-index: 9995;
  pointer-events: none;
  max-width: 90vw;
}

#buzz-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ══════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════ */
@media (max-width: 720px) {
  .host-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .host-left {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 45vh;
  }

  .host-right { padding: 14px; }

  .buzz-winner-name { font-size: 2.8rem; }
}

/* Small phones: tighten up player game screen so everything fits in viewport */
@media (max-width: 480px) {
  .join-hero h1 { font-size: 1.45rem; }
  .join-logo { width: 56px; height: 56px; }

  .player-main { gap: 14px; padding: 14px 16px; }

  .my-score-value { font-size: 3.8rem; }

  .buzz-btn {
    width: 165px;
    height: 165px;
    font-size: 1.2rem;
  }

  .buzz-feedback { font-size: 0.9rem; }

  .score-grid { grid-template-columns: repeat(4, 1fr); }

  .other-scores { padding: 10px 14px; min-height: 44px; }

  .score-chip { font-size: 0.78rem; padding: 4px 10px; }
}

/* Very small phones (e.g. iPhone SE): further reduce */
@media (max-width: 375px) {
  .my-score-value { font-size: 3rem; }

  .buzz-btn {
    width: 148px;
    height: 148px;
    font-size: 1.1rem;
  }
}
