/* ============================================================
   Escape Game — Stylesheet
   ============================================================ */

/* ---- Reset & base ---- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --color-bg: #0f1117;
  --color-surface: #1a1d2e;
  --color-surface-raised: #22263a;
  --color-border: #2e3350;
  --color-text: #e2e8f0;
  --color-text-muted: #8892a4;
  --color-primary: #6366f1;
  --color-primary-hover: #4f52d4;
  --color-success: #22c55e;
  --color-danger: #ef4444;
  --color-warning: #f59e0b;
  --color-info: #38bdf8;
  --radius: 0.5rem;
  --radius-lg: 0.75rem;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  --font: system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, monospace;
  --transition: 150ms ease;
}

html {
  font-family: var(--font);
  background: var(--color-bg);
  background-image: radial-gradient(ellipse 80% 50% at 50% -5%,
    color-mix(in srgb, var(--color-primary) 14%, transparent), transparent);
  color: var(--color-text);
  line-height: 1.6;
}

body {
  min-height: 100dvh;
}

a {
  color: var(--color-primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ---- Typography ---- */
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }

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

p.description {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin-top: 0.25rem;
}

/* ---- Shared header ---- */
header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 0.875rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
}

/* ---- Breadcrumb nav ---- */
.breadcrumb {
  list-style: none;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.breadcrumb li {
  display: flex;
  align-items: center;
}

.breadcrumb li + li::before {
  content: "/";
  margin: 0 0.4rem;
  color: var(--color-border);
}

.breadcrumb a {
  color: var(--color-text-muted);
}

.breadcrumb a:hover {
  color: var(--color-text);
  text-decoration: none;
}

.breadcrumb li:last-child {
  color: var(--color-text);
}

/* ---- Admin layout ---- */
main {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ---- Panel ---- */
.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.panel-login {
  max-width: 360px;
  margin: 4rem auto;
}

.btn-login {
  margin-top: 1rem;
  width: 100%;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ---- Cards ---- */
.card-list, .station-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.card {
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.875rem 1rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.card:hover {
  border-color: color-mix(in srgb, var(--color-primary) 28%, var(--color-border));
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.card-actions {
  flex-shrink: 0;
  display: flex;
  gap: 0.5rem;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: background-color var(--transition), opacity var(--transition), transform var(--transition), box-shadow var(--transition);
  white-space: nowrap;
}

.btn:hover { opacity: 0.9; text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary   { background: var(--color-primary);  color: #fff; box-shadow: 0 0 14px color-mix(in srgb, var(--color-primary) 35%, transparent); }
.btn-primary:hover { box-shadow: 0 0 24px color-mix(in srgb, var(--color-primary) 55%, transparent); }
.btn-secondary { background: var(--color-surface-raised); color: var(--color-text); border: 1px solid var(--color-border); }
.btn-success   { background: var(--color-success);  color: #000; }
.btn-danger    { background: var(--color-danger);   color: #fff; }
.btn-warning   { background: var(--color-warning);  color: #000; }
.btn-large     { padding: 0.65rem 1.5rem; font-size: 1rem; }

/* ---- Badges ---- */
.badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-draft    { background: var(--color-surface-raised); color: var(--color-text-muted); }
.badge-active   { background: color-mix(in srgb, var(--color-success) 20%, transparent); color: var(--color-success); }
.badge-finished { background: color-mix(in srgb, var(--color-info) 20%, transparent); color: var(--color-info); }
.badge-playing  { background: color-mix(in srgb, var(--color-primary) 20%, transparent); color: var(--color-primary); }
.badge-at_final { background: color-mix(in srgb, var(--color-warning) 20%, transparent); color: var(--color-warning); }
.badge-showdown { background: color-mix(in srgb, var(--color-danger, #ef4444) 20%, transparent); color: var(--color-danger, #ef4444); }
.badge-unread   { background: color-mix(in srgb, var(--color-warning) 20%, transparent); color: var(--color-warning); }

/* ---- Forms ---- */
.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.field-submit {
  display: flex;
  align-items: flex-end;
}

label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-muted);
}

input[type="text"],
input[type="number"],
textarea {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.5rem 0.75rem;
  width: 100%;
  transition: border-color var(--transition);
}

input:focus,
textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 20%, transparent);
  outline: none;
}

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

.inline-form {
  padding-top: 1rem;
}

/* ---- Alerts ---- */
.alert {
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.alert-error {
  background: color-mix(in srgb, var(--color-danger) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--color-danger) 30%, transparent);
  color: #fca5a5;
}

/* ---- Table ---- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
}

.data-table th {
  color: var(--color-text-muted);
  font-weight: 500;
}

.data-table tr:last-child td {
  border-bottom: none;
}

/* ---- Collapsible (details/summary) ---- */
.collapsible {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
}

.collapsible summary {
  cursor: pointer;
  font-weight: 500;
  color: var(--color-primary);
  user-select: none;
}

.manual-entry {
  margin-top: 0.75rem;
}

.manual-entry-row {
  grid-template-columns: 1fr auto;
  margin-top: 0.75rem;
}

/* ---- Join code display ---- */
.join-code {
  font-family: var(--font-mono);
  font-size: 1rem;
  letter-spacing: 0.1em;
  background: var(--color-surface-raised);
  padding: 0.1rem 0.4rem;
  border-radius: 0.25rem;
}

/* ---- Empty state ---- */
.empty-state {
  color: var(--color-text-muted);
  text-align: center;
  padding: 2rem 0;
  font-style: italic;
}

/* ============================================================
   Player pages
   ============================================================ */

.player-page {
  display: grid;
  grid-template-rows: auto 1fr;
}

.player-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.player-main {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem 3rem;
}

/* ---- Dot track (header station progress) ---- */
.dot-row {
  display: flex;
  align-items: center;
  width: 100%;
}
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot--solved   { background: #4ade80; box-shadow: 0 0 6px rgba(74, 222, 128, 0.7); }
.dot--unlocked { background: #fff; animation: dot-pulse 2s ease-in-out infinite; }
.dot--locked   { background: #4b5563; }
.dot-connector {
  flex: 1;
  height: 2px;
  background: var(--color-border);
  min-width: 6px;
}

/* ---- Player cards ---- */
.join-card,
.station-card,
.waiting-card,
.finished-card {
  background: var(--color-surface);
  border: 1px solid color-mix(in srgb, var(--color-primary) 22%, var(--color-border));
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 100%;
  max-width: 540px;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  box-shadow: var(--shadow), 0 0 40px color-mix(in srgb, var(--color-primary) 7%, transparent);
  animation: card-in 0.35s ease both;
}

/* ---- Question box ---- */
.question-box {
  background: var(--color-surface-raised);
  border-left: 4px solid var(--color-primary);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  box-shadow: -4px 0 18px color-mix(in srgb, var(--color-primary) 18%, transparent);
}

/* ---- Coordinates link ---- */
.coords {
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.coords a {
  color: var(--color-info);
}

/* ---- Station thumbnail (admin) ---- */
.station-card-header {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.station-thumb {
  width: 72px;
  height: 72px;
  object-fit: contain;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  flex-shrink: 0;
}

.upload-form {
  margin-top: 0.5rem;
}

@supports (object-view-box: inset(0 0 0 0)) {
  .station-thumb--clip {
    object-fit: fill;
    object-view-box: inset(
      calc(var(--clip-y) * 1%)
      calc((100 - var(--clip-x) - var(--clip-w)) * 1%)
      calc((100 - var(--clip-y) - var(--clip-h)) * 1%)
      calc(var(--clip-x) * 1%)
    );
  }
}

/* ---- Station photo (player scan page) ---- */
.station-photo {
  margin: 0;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--color-border);
}

.station-photo img {
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  display: block;
}

/* ---- Image clip (player scan page) ---- */
.station-photo--clip {
  position: relative;
  overflow: hidden;
  margin: 0 auto;
}

.station-photo--clip img {
  position: absolute;
  max-height: none;
}

/* ---- Clip editor (admin) ---- */
.clip-form { margin-top: 0.5rem; }

.clip-preview-wrap {
  position: relative;
  display: block;
  margin-bottom: 0.75rem;
}

.clip-source-img {
  display: block;
  width: 100%;
  height: auto;
}

.clip-overlay-rect {
  position: absolute;
  border: 2px solid var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 15%, transparent);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

.clip-handle--se {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 14px;
  height: 14px;
  background: var(--color-primary);
  cursor: se-resize;
  pointer-events: auto;
}

.clip-preview-wrap { cursor: crosshair; }

/* ---- Next-station preview image ---- */
.next-station-photo {
  margin: 0;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--color-border);
}

.next-station-photo img {
  width: 100%;
  max-height: 200px;
  object-fit: contain;
  display: block;
}

.next-station-photo figcaption {
  background: color-mix(in srgb, var(--color-info) 10%, transparent);
  color: var(--color-text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.35rem 0.5rem;
}

/* ---- Inline form row (panel-header use) ---- */
.form-row {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.form-row label {
  white-space: nowrap;
}

.select-compact {
  width: auto;
}

/* ---- Narrow index column ---- */
.col-index {
  width: 2.5rem;
  text-align: center;
}

/* ---- Action column (table) ---- */
.col-action {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}

/* ---- Inline code token ---- */
.code-value {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: 0.25rem;
  padding: 0.1rem 0.35rem;
}

/* ---- QR code value badge (admin) ---- */
.qr-code-value strong {
  font-family: var(--font-mono);
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  padding: 0.1rem 0.4rem;
  border-radius: 0.25rem;
  letter-spacing: 0.05em;
}

/* ---- Scan prompt ---- */
.scan-prompt {
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--color-primary) 8%, transparent),
    color-mix(in srgb, var(--color-primary) 14%, transparent) 50%,
    color-mix(in srgb, var(--color-primary) 8%, transparent));
  background-size: 200% 100%;
  border: 1px solid color-mix(in srgb, var(--color-primary) 32%, transparent);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  color: var(--color-text);
  text-align: center;
  animation: shimmer 3.5s ease infinite;
}

/* ---- Live GPS navigation widget ---- */
.nav-live {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  background: color-mix(in srgb, var(--color-info) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--color-info) 35%, transparent);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  box-shadow: 0 0 16px color-mix(in srgb, var(--color-info) 10%, transparent);
}

.nav-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  width: 100%;
}

.nav-label {
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.75rem;
}

.nav-coords {
  color: var(--color-text-muted);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
  font-family: monospace;
  opacity: 0.75;
}

.nav-status {
  color: var(--color-text-muted);
  font-size: 0.875rem;
  margin: 0;
}

.nav-values {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.nav-direction {
  color: var(--color-text-muted);
  font-weight: 500;
  font-size: 1.5rem;
  line-height: 1;
}

.nav-distance {
  color: var(--color-info);
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1;
}

/* ---- Welcome / lobby page ---- */
.welcome-card {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.backstory {
  background: color-mix(in srgb, var(--color-primary) 8%, transparent);
  border-left: 3px solid var(--color-primary);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 0.85rem 1rem;
  font-size: 1rem;
  line-height: 1.65;
  white-space: pre-wrap;
}

.welcome-waiting {
  color: var(--color-text-muted);
  font-style: italic;
  text-align: center;
  margin: 0;
}

/* ---- Feedback page ---- */
.feedback-card {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.feedback-icon {
  font-size: 3.5rem;
  color: var(--color-success);
  line-height: 1;
  animation: pop-in 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
  filter: drop-shadow(0 0 14px color-mix(in srgb, var(--color-success) 55%, transparent));
}

.feedback-text {
  font-size: 1.05rem;
  color: var(--color-text);
  max-width: 36ch;
}

/* ---- Hint box ---- */
.hint-box {
  border: 1px solid color-mix(in srgb, var(--color-warning) 28%, var(--color-border));
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
  background: color-mix(in srgb, var(--color-warning) 4%, transparent);
}

.hint-box summary {
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--color-warning);
  user-select: none;
}

.hint-box p {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

/* ---- Waiting spinner ---- */
.waiting-message {
  font-size: 1.05rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  align-self: center;
}

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

/* ---- Finished trophy ---- */
.trophy {
  font-size: 4.5rem;
  text-align: center;
  line-height: 1;
  animation: pop-in 0.65s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
  filter: drop-shadow(0 0 18px rgba(245, 158, 11, 0.55));
}

.finished-card h2 {
  text-align: center;
  font-size: 1.5rem;
}

.finished-card p {
  text-align: center;
}

/* ---- Group picker ---- */
.group-picker {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.group-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  cursor: pointer;
  background: var(--color-surface-raised);
  transition: border-color var(--transition);
}

.group-option:has(input:checked) {
  border-color: var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 10%, transparent);
}

.group-option input[type="radio"] {
  accent-color: var(--color-primary);
  width: 1.1rem;
  height: 1.1rem;
  flex-shrink: 0;
}

.group-option-label {
  flex: 1;
}

/* ---- Select input ---- */
.select-input {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.5rem 0.75rem;
  width: 100%;
}

/* ---- Chat ---- */
.chat-log {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  max-height: 260px;
  overflow-y: auto;
}

.chat-bubble {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  max-width: 85%;
}

.chat-admin {
  background: color-mix(in srgb, var(--color-primary) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--color-primary) 25%, transparent);
  align-self: flex-start;
}

.chat-player {
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  align-self: flex-end;
}

.chat-who {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}

.chat-bubble p {
  font-size: 0.9rem;
  margin: 0;
}

.chat-time {
  font-size: 0.7rem;
  color: var(--color-text-muted);
}

.chat-widget {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
}

.chat-widget summary {
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-muted);
  user-select: none;
}

.chat-widget--has-messages summary,
.chat-widget[open] summary {
  color: var(--color-primary);
}

.chat-widget .inline-form {
  padding-top: 0.5rem;
}

/* ---- Countdown ---- */
.countdown {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--color-info);
  text-shadow: 0 0 12px color-mix(in srgb, var(--color-info) 50%, transparent);
}

.countdown--urgent {
  color: var(--color-danger);
  text-shadow: 0 0 12px color-mix(in srgb, var(--color-danger) 50%, transparent);
  animation: dot-pulse 1s ease-in-out infinite;
}

/* ---- Responsive ---- */
@media (max-width: 480px) {
  .field-row {
    grid-template-columns: 1fr;
  }
  .card {
    flex-direction: column;
  }
  .join-card,
  .station-card,
  .waiting-card,
  .finished-card {
    padding: 1.25rem;
  }
}

/* ---- Group leaderboard widget ---- */
.leaderboard-widget {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
}
.leaderboard-summary {
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-muted);
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.leaderboard-summary::-webkit-details-marker { display: none; }
.leaderboard-widget[open] .leaderboard-summary {
  color: var(--color-primary);
  margin-bottom: 0.75rem;
}
.leaderboard-count { font-weight: 400; }
.leaderboard-list { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }
.leaderboard-row {
  display: grid;
  grid-template-columns: 1.5rem 1fr auto;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.5rem;
  border-radius: var(--radius);
  background: var(--color-surface-raised);
}
.leaderboard-row--self {
  background: color-mix(in srgb, var(--color-primary) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--color-primary) 30%, transparent);
}
.leaderboard-rank {
  font-size: 0.8rem; font-weight: 700;
  color: var(--color-text-muted); text-align: center;
}
.leaderboard-row--self .leaderboard-rank { color: var(--color-primary); }
.leaderboard-group-info { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.leaderboard-name {
  font-size: 0.85rem; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.leaderboard-you { font-size: 0.75rem; font-weight: 400; color: var(--color-primary); margin-left: 0.25rem; }
.leaderboard-bar-track { height: 4px; background: var(--color-border); border-radius: 999px; overflow: hidden; }
.leaderboard-bar-fill {
  height: 100%; background: var(--color-text-muted);
  border-radius: 999px; transition: width 0.4s ease; min-width: 3px;
}
.leaderboard-bar-fill--self { background: var(--color-primary); }
.leaderboard-badge { flex-shrink: 0; font-size: 0.65rem; }
.waiting-card .leaderboard-widget {
  border-color: color-mix(in srgb, var(--color-primary) 25%, transparent);
}

/* ---- QR image (admin group cards) ---- */
.qr-img {
  display: block;
  width: 74px;
  height: auto;
  image-rendering: pixelated;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin-top: 0.5rem;
}

/* ---- QR camera scanner ---- */
.btn-scan {
  gap: 0.4rem;
}

.btn-scan svg {
  width: 1.1em;
  height: 1.1em;
  flex-shrink: 0;
}

.qr-dialog {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  max-width: 480px;
  width: 90vw;
  box-shadow: var(--shadow);
  color: var(--color-text);
}

.qr-dialog::backdrop {
  background: rgba(0, 0, 0, 0.7);
}

.qr-video {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius);
  background: #000;
  display: block;
}

.qr-dialog-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.75rem;
}

/* ============================================================
   Visual enhancements
   ============================================================ */

/* ---- Player header gradient title ---- */
.player-header h1 {
  background: linear-gradient(90deg, var(--color-primary), var(--color-info));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ---- Player header layout improvements ---- */
.player-header {
  gap: 0.4rem;
}

/* ---- Admin header glow ---- */
header h1 {
  letter-spacing: -0.02em;
}

/* ---- Panel hover (admin) ---- */
.panel {
  transition: box-shadow var(--transition);
}

/* ---- Spinner glow ---- */
.spinner {
  box-shadow: 0 0 10px color-mix(in srgb, var(--color-primary) 30%, transparent);
}

/* ---- Welcome/backstory card gets the card-in animation too ---- */
.welcome-card {
  animation: card-in 0.35s ease both;
}

/* ============================================================
   Keyframe animations
   ============================================================ */

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

@keyframes pop-in {
  0%   { transform: scale(0.4); opacity: 0; }
  70%  { transform: scale(1.12); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes dot-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.5); }
  50%       { box-shadow: 0 0 0 5px rgba(255, 255, 255, 0); }
}

@keyframes shimmer {
  0%   { background-position: 200% center; }
  100% { background-position: -200% center; }
}

