:root {
  --bg: #071322;
  --bg-elevated: #0f2137;
  --bg-card: #1a3450;
  --primary: #f97316;
  --primary-hover: #ea6c0a;
  --accent: #22d3ee;
  --danger: #ef4444;
  --warning: #fbbf24;
  --text: #e8f4fd;
  --text-muted: #6ea8ca;
  --border: #1e4068;

  /* Layout constants — keep in sync with JS-controlled positioning */
  --header-h: 56px;
  --topbar-h: 48px;
  --sidebar-w: 280px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
.hidden { display: none !important; }

.conn-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  padding: 0.6rem 1rem;
  text-align: center;
  font-size: 0.875rem;
  font-weight: 600;
  background: var(--warning);
  color: #1a1a1a;
  transform: translateY(-100%);
  transition: transform 0.25s ease;
}

.conn-bar.visible {
  transform: translateY(0);
}

.conn-bar.reconnected {
  background: var(--accent);
  color: #071322;
}

.conn-bar.nudge {
  animation: conn-bar-nudge 0.5s ease;
}

@keyframes conn-bar-nudge {
  0%   { filter: brightness(1); }
  25%  { filter: brightness(1.6); }
  50%  { filter: brightness(0.8); }
  75%  { filter: brightness(1.5); }
  100% { filter: brightness(1); }
}

#globe-3d {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
}

body {
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #000;
  color: var(--text);
  overflow: hidden;
}

.screen {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

.screen.active {
  display: flex;
}

.screen.active .card,
.screen.active .lobby-container,
.screen.active .game-header,
.screen.active .game-sidebar,
.screen.active #game-prompt,
.screen.active .overlay {
  pointer-events: auto;
}

/* Join Screen */
#screen-join {
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

#screen-landing {
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.landing-globe {
  display: block;
  font-size: 4rem;
  margin-bottom: 0.5rem;
  animation: globe-float 3.5s ease-in-out infinite;
  filter: drop-shadow(0 8px 24px rgba(34, 211, 238, 0.3));
}

@keyframes globe-float {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50%       { transform: translateY(-10px) rotate(2deg); }
}

@keyframes card-enter {
  from { transform: translateY(20px) scale(0.96); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

.card {
  background: rgba(7, 19, 34, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: 16px;
  padding: 2rem;
  width: 100%;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(34, 211, 238, 0.08);
}

#screen-landing .card {
  animation: card-enter 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

#screen-landing .card h1 {
  font-size: 2.4rem;
  font-weight: 900;
  margin-bottom: 0.25rem;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

input[type="text"], select {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  outline: none;
}

input[type="text"]:focus, select:focus {
  border-color: var(--primary);
}

button {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: none;
  background: var(--primary);
  color: white;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s, filter 0.15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button:hover { background: var(--primary-hover); }

button:active:not(:disabled) {
  transform: scale(0.94);
}

.btn-primary {
  background: var(--accent);
  color: #071322;
  font-size: 1.1rem;
  font-weight: 800;
  padding: 0.9rem 1.5rem;
  border-radius: 12px;
  letter-spacing: 0.01em;
}

.btn-primary:hover { filter: brightness(1.1); }

.btn-primary:active:not(:disabled) {
  transform: scale(0.92);
}

.btn-secondary {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  filter: brightness(1.1);
}

.host-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.join-qr {
  margin: 0.75rem 0 1.25rem;
  text-align: center;
}

.join-qr img {
  width: 140px;
  height: 140px;
  border-radius: 8px;
  margin-top: 0.25rem;
}

.join-qr p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.host-game-actions {
  flex-shrink: 0;
}

.host-game-actions button {
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
  white-space: nowrap;
}

.error {
  color: var(--danger);
  font-size: 0.875rem;
  margin-top: 0.5rem;
  min-height: 1.2em;
}

.status {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 0.5rem;
  min-height: 1.2em;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Lobby */
#screen-lobby {
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.lobby-container {
  display: flex;
  flex-direction: row;
  gap: 1rem;
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
}

.panel-game-control, .panel-players {
  background: rgba(7, 19, 34, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: 16px;
  padding: 1.5rem;
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
}

.panel-game-control {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.panel-game-control h3, .panel-players h2 {
  margin-bottom: 1rem;
}

.player-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.player-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.35rem 0.6rem;
  background: var(--bg-card);
  border-radius: 6px;
  font-size: 0.9rem;
}

.player-item > span:first-child {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-name-editable {
  cursor: pointer;
  border-bottom: 1px dashed var(--border);
}

.player-name-editable:hover {
  opacity: 0.8;
}

.player-item .player-name-input {
  flex: 1;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  min-width: 0;
}

.player-item .player-name-confirm {
  padding: 0.2rem 0.5rem;
  font-size: 0.85rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.player-item .player-name-badges {
  flex-shrink: 0;
}

.player-item .host-badge {
  font-size: 0.75rem;
  background: var(--warning);
  color: #000;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-weight: 700;
}

.player-item .spectator-badge {
  font-size: 0.75rem;
  background: var(--text-muted);
  color: #000;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
}

.settings-grid {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
}

/* #2 — consistent label/control alignment */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.35rem 0;
}

.settings-grid label {
  font-size: 0.9rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.setting-row select {
  flex: none;
}

#setting-row-mode {
  justify-content: center;
}

/* #3 — Customise fold with more visual weight */
.settings-fold {
  border-top: 1px solid var(--border);
  margin-top: 0.25rem;
  margin-bottom: 0.75rem;
  padding-top: 0.5rem;
}

.settings-fold > summary {
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  user-select: none;
  padding: 0.35rem 0;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.settings-fold > summary::before {
  content: '▸';
  font-size: 0.7rem;
  transition: transform 0.15s;
  opacity: 0.7;
}

.settings-fold[open] > summary::before {
  transform: rotate(90deg);
}

.settings-fold > summary::-webkit-details-marker {
  display: none;
}

.settings-fold .settings-grid {
  margin-top: 0.5rem;
  margin-bottom: 0;
}

/* #4 — Visual separation before Start button */
.settings-actions {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  margin-top: 0.25rem;
  margin-bottom: 1rem;
}

.settings-actions #btn-start {
  width: 100%;
}

/* #5 — Stepper controls */
.stepper {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  flex: none;
}

.stepper button {
  padding: 0.3rem 0.6rem;
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 700;
  border-radius: 0;
  line-height: 1;
  min-width: 2rem;
}

.stepper button:hover {
  background: var(--border);
  color: var(--text);
}

.stepper input[type="number"] {
  width: 2.75rem;
  padding: 0.3rem 0.25rem;
  text-align: center;
  border: none;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  border-radius: 0;
  font-size: 0.95rem;
  background: var(--bg);
  color: var(--text);
  -moz-appearance: textfield;
  appearance: textfield;
}

.stepper input[type="number"]::-webkit-outer-spin-button,
.stepper input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
}

.host-controls.hidden,
.guest-waiting.hidden,
.host-game-actions.hidden,
#btn-play-again.hidden {
  display: none;
}


/* #6 — QR section as an integrated join card */
.qr-section {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem;
}

.qr-section img {
  width: 140px;
  height: 140px;
  border-radius: 6px;
  flex: none;
  display: block;
}

.qr-meta {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.qr-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.room-url {
  font-size: 0.75rem;
  color: var(--text-muted);
  word-break: break-all;
}

.guest-qr-code {
  width: 140px;
  height: 140px;
  border-radius: 8px;
  display: block;
}

/* #7 — Animated guest waiting state */
.guest-waiting {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.5rem 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.dot-anim {
  display: inline-flex;
  gap: 0.1em;
  margin-left: 0.15em;
}

.dot-anim span {
  opacity: 0;
  animation: dot-fade 1.5s infinite;
}

.dot-anim span:nth-child(1) { animation-delay: 0s; }
.dot-anim span:nth-child(2) { animation-delay: 0.3s; }
.dot-anim span:nth-child(3) { animation-delay: 0.6s; }

@keyframes dot-fade {
  0%, 80%, 100% { opacity: 0; }
  40%            { opacity: 1; }
}

/* Game Screen */
#screen-game {
  flex-direction: column;
}

.game-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  background: rgba(7, 19, 34, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.game-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  height: var(--header-h);
  font-weight: 600;
}

.timer {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
}

.timer.warning { color: var(--warning); }
.timer.danger { color: var(--danger); }

.player-chips {
  display: flex;
  gap: 0.5rem;
  padding: 0 1.25rem;
  background: transparent;
  border-top: 1px solid var(--border);
  overflow-x: auto;
  flex-wrap: nowrap;
  align-items: center;
  height: var(--topbar-h);
  min-width: 0;
  scrollbar-width: none;
}

.player-chips::-webkit-scrollbar { display: none; }

.player-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.7rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.85rem;
  white-space: nowrap;
}

.player-chip .chip-score {
  font-weight: 700;
  color: var(--accent);
}

.player-chip.answered {
  border-color: var(--accent);
  background: rgba(34, 211, 238, 0.15);
}

.player-chip .chip-check {
  display: none;
}

.player-chip.answered .chip-check {
  display: inline;
}


.game-prompt {
  position: fixed;
  /* Position below the header + chips bar, centred on the visible globe
     (full-width minus the right sidebar) */
  top: calc(var(--header-h) + 12px);
  left: calc(50% - var(--sidebar-w) / 2);
  transform: translateX(-50%);
  z-index: 21;
  background: rgba(7, 19, 34, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 0.55rem 1.2rem;
  border-radius: 999px;
  border: 1px solid rgba(34, 211, 238, 0.15);
  font-size: 1.05rem;
  font-weight: 600;
  pointer-events: none;
  max-width: calc(100% - var(--sidebar-w) - 2rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-sidebar {
  position: fixed;
  top: var(--header-h); right: 0; bottom: 0;
  width: var(--sidebar-w);
  background: rgba(7, 19, 34, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  border-radius: 0;
  z-index: 18;
  overflow-y: auto;
  padding: 1rem;
}


.answer-panel {
  padding: 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
}

.answer-btn {
  width: 100%;
  text-align: left;
  background: var(--bg-card);
  border: 2px solid var(--border);
  transition: background 0.15s, border-color 0.15s, transform 0.1s, filter 0.15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  font-weight: 700;
  border-radius: 10px;
}

.answer-btn:active:not(:disabled) {
  transform: scale(0.97);
}

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

.answer-btn.correct {
  background: var(--accent);
  border-color: var(--accent);
  color: #071322;
  font-weight: 800;
  opacity: 1;
  animation: correct-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.answer-btn.wrong {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
  opacity: 1;
  animation: wrong-shake 0.35s ease-out forwards;
}

.answer-btn.selected {
  border-color: var(--accent);
  background: rgba(34, 211, 238, 0.15);
}

.answer-btn.locked {
  pointer-events: none;
  opacity: 0.4;
}

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

/* Overlays */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 19, 34, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.overlay.hidden { display: none; }

.overlay-card {
  background: var(--bg-elevated);
  border-radius: 20px;
  padding: 2rem;
  width: 90%;
  max-width: 480px;
  text-align: center;
  max-height: 80vh;
  overflow-y: auto;
  border: 1px solid var(--border);
}

.overlay:not(.hidden) {
  animation: overlay-fade 0.2s ease-out both;
}

.overlay:not(.hidden) .overlay-card {
  animation: card-slide-up 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.overlay-card h2 {
  font-size: 1.75rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
}

.overlay-card h3 {
  font-size: 1.3rem;
  font-weight: 800;
  margin-bottom: 0.25rem;
}

.qe-answer {
  font-size: 1.25rem;
  margin: 0.75rem 0;
  font-weight: 700;
}

.qe-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 1rem;
  text-align: left;
}

.qe-item {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  background: var(--bg-card);
}

.qe-item .correct-icon { color: var(--accent); }
.qe-item .wrong-icon { color: var(--danger); }

.qe-countdown {
  position: relative;
  width: 64px;
  height: 64px;
  margin: 1.25rem auto 0;
}

.qe-countdown svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.qe-countdown-bg,
.qe-countdown-ring {
  fill: none;
  stroke-width: 8;
  stroke-linecap: round;
}

.qe-countdown-bg {
  stroke: var(--bg-card);
}

.qe-countdown-ring {
  stroke: var(--accent);
  stroke-dasharray: 283;
  stroke-dashoffset: 0;
}

.qe-countdown.animate .qe-countdown-ring {
  animation: qe-countdown-draw 5s linear forwards;
}

@keyframes qe-countdown-draw {
  from { stroke-dashoffset: 0; }
  to   { stroke-dashoffset: 283; }
}

@keyframes correct-pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.07); box-shadow: 0 0 24px rgba(34, 211, 238, 0.6); }
  70%  { transform: scale(0.97); }
  100% { transform: scale(1); box-shadow: 0 0 12px rgba(34, 211, 238, 0.3); }
}

@keyframes wrong-shake {
  0%   { transform: translateX(0); }
  20%  { transform: translateX(-6px); }
  40%  { transform: translateX(6px); }
  60%  { transform: translateX(-4px); }
  80%  { transform: translateX(4px); }
  100% { transform: translateX(0); }
}

@keyframes overlay-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes card-slide-up {
  from { transform: translateY(28px) scale(0.95); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

.qe-countdown-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  cursor: pointer;
}

.qe-countdown-text span:first-child {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.qe-countdown-text span:last-child {
  font-size: 0.9rem;
}

#btn-skip-guess {
  margin-top: 0.75rem;
}

.rankings {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 1rem 0;
}

.rank-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border-radius: 12px;
  border: 1px solid var(--border);
}

.rank-pos {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 900;
  font-size: 1rem;
  flex-shrink: 0;
}

.rank-pos.gold {
  background: linear-gradient(135deg, #fde68a, #fbbf24);
  color: #78350f;
  box-shadow: 0 0 16px rgba(251, 191, 36, 0.5);
}

.rank-pos.silver {
  background: linear-gradient(135deg, #f1f5f9, #cbd5e1);
  color: #334155;
  box-shadow: 0 0 10px rgba(203, 213, 225, 0.5);
}

.rank-pos.bronze {
  background: linear-gradient(135deg, #fcd34d, #b45309);
  color: #fff;
  box-shadow: 0 0 10px rgba(180, 83, 9, 0.3);
}

.countdown {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Proximity mode — globe pins */
.pin-marker {
  pointer-events: none;
}

.pin-marker circle {
  stroke-width: 2;
}

.pin-marker text {
  fill: #fff;
  font-size: 8px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

.pin-marker.active-pin.locked circle {
  stroke: #fff;
  stroke-width: 3;
  filter: drop-shadow(0 0 4px rgba(255,255,255,0.6));
}

.pin-marker.past-pin {
  opacity: 0.4;
}

.pin-marker.past-pin circle {
  r: 6;
  stroke-width: 1;
}

.pin-marker.past-pin text {
  font-size: 5px;
  fill-opacity: 0.5;
}

/* Proximity mode — distance table */
.distance-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75rem 0;
  font-size: 0.9rem;
}

.distance-table th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 600;
  padding: 0.3rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

.distance-table td {
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--bg-card);
}

.distance-table tr.exact-hit td {
  color: var(--accent);
  font-weight: 700;
}

.distance-table tr.no-pin td {
  color: var(--text-muted);
}

/* Responsive */
@media (max-width: 800px) {
  #screen-lobby {
    align-items: flex-end;
    justify-content: stretch;
    padding: 0;
  }

  .lobby-container {
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    max-height: 60vh;
    overflow-y: auto;
    border-radius: 16px 16px 0 0;
    background: rgba(7, 19, 34, 0.92);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    padding: 1rem;
    gap: 0.75rem;
  }

  .panel-game-control,
  .panel-players {
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    padding: 0;
    max-height: none;
  }

  .panel-players { order: -1; }
  .panel-game-control { order: 1; }

  .game-sidebar {
    top: auto;
    right: 0; left: 0; bottom: 0;
    width: 100%;
    max-height: 42vh;
    border-left: none;
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
  }

  .game-header-top {
    padding: 0 0.75rem;
  }

  .player-chips {
    padding: 0 0.75rem;
  }

  /* game-prompt: on mobile there's no sidebar, centre on full width */
  .game-prompt {
    left: 50%;
    max-width: calc(100% - 1.5rem);
  }

  .answer-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    overflow-y: auto;
    touch-action: pan-y;
  }
  .answer-btn {
    text-align: center;
    padding: 0.9rem 0.5rem;
  }
}

@media (max-width: 480px) {
  .card { padding: 1.25rem; }
  .setting-row { grid-template-columns: 1fr; }
  .game-header { padding: 0.5rem 0.75rem; }
  .timer { font-size: 1.2rem; }
}

/* ── Spy Mode ─────────────────────────────────────────── */

.spy-banner {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(7, 19, 34, 0.95);
  border: 1px solid rgba(99, 179, 237, 0.4);
  border-radius: 16px;
  padding: 1.25rem 2rem;
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  text-align: center;
  z-index: 200;
  pointer-events: none;
}

.spy-picking-card, .guesser-waiting-card {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  pointer-events: auto;
}

.spy-picking-header {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.spy-prompt {
  font-size: 1rem;
  color: var(--text-muted);
  margin: 0;
}

#spy-wheel-canvas, #guesser-wheel-canvas {
  /* half-wheel shape: flat bottom, arc on top */
  border-radius: 0;
  cursor: grab;
  touch-action: none;
  max-width: 100%;
}

#spy-wheel-canvas:active { cursor: grabbing; }

.spy-selected-label {
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  min-height: 1.4rem;
  text-align: center;
}

.spy-actions {
  display: flex;
  gap: 0.75rem;
}

/* Desktop: wheel panel centred at bottom */
@media (min-width: 800px) {
  .spy-picking-card {
    align-items: center;
    justify-content: flex-end;
    padding-bottom: 1rem;
  }
  .guesser-waiting-card {
    align-items: center;
    justify-content: flex-end;
    padding-bottom: 1rem;
  }
}

/* Mobile: wheel centred, scaled to fit */
@media (max-width: 799px) {
  .spy-picking-card, .guesser-waiting-card {
    align-items: center;
    justify-content: flex-end;
    padding-bottom: 0.5rem;
  }
  #spy-wheel-canvas, #guesser-wheel-canvas {
    width: 100%;
    height: auto;
  }
}

/* Spy watching panel */
#panel-spy-watching {
  position: fixed;
  bottom: 5rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  pointer-events: none;
  z-index: 10;
}

.spy-watching-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.spy-pin-toasts {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: center;
}

.spy-pin-toast {
  background: rgba(7, 19, 34, 0.88);
  border: 1px solid rgba(99, 179, 237, 0.3);
  border-radius: 8px;
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
  color: #e2e8f0;
  animation: toast-in 0.2s ease-out, toast-out 0.4s 1.6s ease-in forwards;
  white-space: nowrap;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}
