/* ========================================
   Vocabulary Duck Race - Style System
   Mobile-first responsive design
   ======================================== */

:root {
  /* Color Palette */
  --primary: #ff9f1c;
  --primary-dark: #e88a00;
  --secondary: #2ec4b6;
  --secondary-dark: #1a9e92;
  --accent: #e71d36;
  --accent-soft: #ff6b6b;

  /* Backgrounds */
  --bg-dark: #0f1419;
  --bg-card: #1a2332;
  --bg-card-hover: #243447;
  --bg-input: #2d3748;

  /* Text */
  --text-primary: #ffffff;
  --text-secondary: #a0aec0;
  --text-muted: #718096;

  /* Status */
  --success: #48bb78;
  --error: #fc8181;
  --warning: #f6e05e;

  /* --------------------------------------------------------
     Semantic aliases (admin UI compatibility)
     admin.html uses: --surface / --surface-elevated / --danger
     -------------------------------------------------------- */
  /* Use higher opacity to avoid "see-through" modals/inputs on admin tools */
  --surface: rgba(26, 32, 44, 0.98);
  --surface-elevated: rgba(45, 55, 72, 0.98);
  --danger: var(--error);

  /* Race track */
  --track-bg: #1e3a5f;
  --track-lane: #2d5a87;
  --water: #0077b6;
  --water-light: #00b4d8;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;

  /* Border radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(255, 159, 28, 0.3);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 400ms ease;

  /* Admin layout helpers */
  --admin-topbar-height: 64px;
}

/* ========================================
   Base Reset & Typography
   ======================================== */

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Wave background animation */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    radial-gradient(ellipse at 20% 80%, rgba(0, 119, 182, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(46, 196, 182, 0.1) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(255, 159, 28, 0.05) 0%, transparent 60%);
  pointer-events: none;
  z-index: -1;
}

h1,
h2,
h3,
h4 {
  font-weight: 700;
  line-height: 1.2;
}

h1 {
  font-size: 2rem;
}

h2 {
  font-size: 1.5rem;
}

h3 {
  font-size: 1.25rem;
}

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

a:hover {
  color: var(--primary-dark);
}

/* ========================================
   Layout Components
   ======================================== */

.container {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: var(--space-md);
}

.container--wide {
  /* Wider desktop layout (admin/dashboard no longer feels "squeezed" in the center) */
  max-width: 1200px;
}

@media (min-width: 1600px) {
  .container--wide {
    max-width: 1400px;
  }
}

/* ========================================
   PREMIUM SCREENS (Join / Lobby / Results)
   ======================================== */

.auth-shell {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: var(--space-xl);
  align-items: center;
  padding: var(--space-xl) 0;
}

.auth-hero {
  padding: var(--space-xl);
  border-radius: var(--radius-xl);
  background:
    radial-gradient(900px 400px at 10% 0%, rgba(255, 159, 28, 0.20), transparent 55%),
    radial-gradient(700px 380px at 90% 20%, rgba(46, 196, 182, 0.18), transparent 60%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(0, 0, 0, 0.12));
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: var(--shadow-lg);
}

.auth-hero__brand {
  display: flex;
  gap: var(--space-md);
  align-items: center;
  margin-bottom: var(--space-lg);
}

.auth-hero__icon {
  font-size: 3rem;
  line-height: 1;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.35));
}

.auth-hero__app {
  font-weight: 800;
  letter-spacing: 0.02em;
  font-size: 1.1rem;
}

.auth-hero__tag {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.auth-hero__title {
  font-size: 2.25rem;
  margin-bottom: var(--space-sm);
}

.auth-hero__subtitle {
  color: var(--text-secondary);
  max-width: 52ch;
}

.auth-hero__chips {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
  margin-top: var(--space-lg);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  font-size: 0.85rem;
  white-space: nowrap;
}

.auth-card {
  border-radius: var(--radius-xl);
}

.auth-card__footer {
  margin-top: var(--space-md);
  display: flex;
  gap: var(--space-sm);
  justify-content: center;
  align-items: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.app-brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow-sm);
  font-size: 1.25rem;
}

.roomcode-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-full);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.roomcode-pill__label {
  color: var(--text-muted);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  font-weight: 700;
}

.roomcode-pill__value {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.pill--muted {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
}

/* Lobby */
.lobby-shell {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  padding: var(--space-md);
  min-height: 0;
}

.lobby-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-md);
  border-radius: var(--radius-xl);
  background: rgba(26, 35, 50, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: var(--shadow-md);
}

.lobby-topbar__left {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  min-width: 0;
}

.lobby-title {
  min-width: 0;
}

.lobby-title__teacher {
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lobby-title__meta {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.lobby-topbar__right {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.lobby-grid {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
  min-height: 0;
}

.lobby-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.lobby-wait-card {
  display: flex;
  gap: var(--space-md);
  align-items: center;
}

.lobby-wait-card__duck {
  font-size: 2.25rem;
  line-height: 1;
}

.lobby-wait-card__title {
  font-weight: 800;
}

.lobby-wait-card__subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.player-list--scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

/* Results */
.results-shell {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  padding: var(--space-md) 0 var(--space-2xl);
}

.results-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-lg);
  border-radius: var(--radius-xl);
  background:
    radial-gradient(800px 260px at 10% 10%, rgba(255, 159, 28, 0.18), transparent 60%),
    radial-gradient(800px 260px at 90% 30%, rgba(46, 196, 182, 0.16), transparent 55%),
    rgba(26, 35, 50, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: var(--shadow-md);
}

.results-hero__icon {
  font-size: 2.25rem;
  line-height: 1;
}

.results-hero__title {
  margin: 0;
}

.results-hero__subtitle {
  color: var(--text-secondary);
  margin-top: 0.35rem;
}

.results-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: var(--space-md);
}

.results-board {
  margin: 0;
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.results-board li {
  list-style: decimal;
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  display: flex;
  justify-content: space-between;
  gap: var(--space-md);
  align-items: center;
}

.results-board__name {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.results-board__meta {
  color: var(--text-secondary);
  font-size: 0.85rem;
  white-space: nowrap;
}

.results-board li.is-me {
  border-color: rgba(255, 159, 28, 0.6);
  box-shadow: 0 0 0 2px rgba(255, 159, 28, 0.15);
}

.results-self {
  color: var(--text-secondary);
  line-height: 1.7;
}

.hanzi-input {
  font-weight: 700;
  letter-spacing: 0.02em;
}

@media (max-width: 900px) {
  .auth-shell {
    grid-template-columns: 1fr;
    padding: var(--space-lg) 0;
  }

  .auth-hero {
    padding: var(--space-lg);
  }

  .lobby-shell {
    height: auto;
  }

  .lobby-grid {
    grid-template-columns: 1fr;
  }

  .results-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  /* Keep join screen mostly one-screen on phones */
  .auth-hero__title {
    font-size: 1.35rem;
  }

  .auth-hero__subtitle {
    display: none;
  }

  .auth-hero__features {
    display: none;
  }
}

/* Utility: remove container padding when we need a full-viewport layout */
.container--no-pad {
  padding: 0;
  /* Allow children to use % heights when parent has a fixed height */
  height: 100%;
}

/* ========================================
   Fullscreen / No-page-scroll helper
   (Used while playing to avoid the browser showing a page scrollbar)
   ======================================== */

body.no-page-scroll {
  /* Prevent the browser/page itself from scrolling */
  overflow: hidden;
}

body.no-page-scroll .page {
  height: 100vh;
  height: 100svh;
  height: 100dvh;
  overflow: hidden;
}

body.no-page-scroll .page__content {
  min-height: 0;
  /*
    IMPORTANT:
    We still need a scrollbar when the viewport is small or content is long.
    Previously this was set to overflow:hidden, which caused content to be cut off.
  */
  overflow-y: auto;
  overflow-x: hidden;
}

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page__header {
  text-align: center;
  padding: var(--space-xl) var(--space-md);
}

.page__content {
  flex: 1;
  /* Containers already provide consistent padding.
     Keeping this at 0 avoids double-padding and reduces vertical scrolling. */
  padding: 0;
}

/* ========================================
   Card Component
   ======================================== */

.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Compact variant for dashboard-style layouts */
.card--compact {
  padding: var(--space-md);
}

.card+.card {
  margin-top: var(--space-md);
}

.card__title {
  font-size: 1.125rem;
  margin-bottom: var(--space-md);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.card__title::before {
  content: '';
  width: 4px;
  height: 1.2em;
  background: var(--primary);
  border-radius: var(--radius-full);
}

/* ========================================
   Form Elements
   ======================================== */

.form-group {
  margin-bottom: var(--space-md);
}

.form-group--compact {
  margin-bottom: var(--space-sm);
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

.input {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  font-size: 1rem;
  color: var(--text-primary);
  /* Higher separation from dark surfaces (accessibility & clarity) */
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(0, 0, 0, 0.08)),
    var(--bg-input);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 1px 0 rgba(0, 0, 0, 0.25);
}

.input:hover {
  border-color: rgba(255, 255, 255, 0.18);
}

.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow:
    0 0 0 3px rgba(255, 159, 28, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.input::placeholder {
  color: var(--text-muted);
}

.input--code {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

select.input {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23a0aec0' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* ========================================
   Buttons
   ======================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--primary);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  min-height: 44px;
}

.btn:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

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

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

/* Admin pages sometimes use an explicit primary modifier */
.btn--primary {
  background: var(--primary);
}

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

.btn--outline {
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
}

.btn--outline:hover {
  background: var(--primary);
  color: var(--text-primary);
}

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

.btn--danger:hover {
  background: var(--accent-soft);
}

.btn--large {
  padding: var(--space-md) var(--space-xl);
  font-size: 1.125rem;
  min-height: 56px;
}

.btn--full {
  width: 100%;
}

.btn--sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
  min-height: 36px;
}

.btn--icon {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: var(--radius-full);
}

/* ========================================
   Duck Race Logo & Branding
   ======================================== */

.logo {
  font-size: 2.5rem;
  font-weight: 800;
  text-align: center;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 2px 10px rgba(255, 159, 28, 0.3);
}

.logo__icon {
  font-size: 3rem;
  display: block;
  margin-bottom: var(--space-sm);
  animation: duck-bob 2s ease-in-out infinite;
}

@keyframes duck-bob {

  0%,
  100% {
    transform: translateY(0) rotate(-5deg);
  }

  50% {
    transform: translateY(-8px) rotate(5deg);
  }
}

.subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-top: var(--space-sm);
}

/* ========================================
   Room Code Display
   ======================================== */

.room-code {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-lg);
  text-align: center;
  box-shadow: var(--shadow-glow);
}

.room-code__label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.9;
}

.room-code__value {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  font-family: 'Courier New', monospace;
}

/* ========================================
   Player List
   ======================================== */

.player-list {
  list-style: none;
}

.player-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-input);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-sm);
  animation: slide-in 0.3s ease;
}

@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
}

.player-item__avatar {
  width: 40px;
  height: 40px;
  background: var(--secondary);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.player-item__name {
  flex: 1;
  font-weight: 600;
}

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

.player-count {
  text-align: center;
  padding: var(--space-md);
  color: var(--text-secondary);
}

.player-count__number {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
}

/* ========================================
   Race Track
   ======================================== */

.race-track {
  background: var(--track-bg);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  overflow: hidden;
  position: relative;
}

.race-track::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(90deg,
      transparent 0px,
      transparent 48px,
      rgba(255, 255, 255, 0.03) 48px,
      rgba(255, 255, 255, 0.03) 50px);
  pointer-events: none;
}

.race-lane {
  display: flex;
  align-items: center;
  background: var(--track-lane);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-sm);
  position: relative;
  min-height: 50px;
  overflow: hidden;
}

.race-lane:last-child {
  margin-bottom: 0;
}

.race-lane__name {
  width: 80px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 2;
}

.race-lane__track {
  flex: 1;
  height: 100%;
  position: relative;
  margin: 0 var(--space-sm);
}

.race-lane__duck {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.5rem;
  transition: left 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
  z-index: 2;
}

.race-lane__finish {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 34px;
  background: repeating-linear-gradient(45deg,
      rgba(255, 255, 255, 0.95) 0px,
      rgba(255, 255, 255, 0.95) 6px,
      rgba(15, 20, 25, 0.95) 6px,
      rgba(15, 20, 25, 0.95) 12px);
  border-radius: var(--radius-sm);
  opacity: 0.98;
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
  z-index: 1;
}

.race-lane__progress {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: linear-gradient(90deg, var(--water) 0%, var(--water-light) 100%);
  border-radius: var(--radius-sm);
  opacity: 0.3;
  transition: width 0.5s ease;
}

/* ========================================
   Question Card
   ======================================== */

.question-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  text-align: center;
  box-shadow: var(--shadow-lg);
  border: 2px solid rgba(255, 159, 28, 0.2);
}

.question-card__number {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: var(--space-sm);
}

.question-card__label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: var(--space-xs);
}

.question-card__prompt {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: var(--space-lg);
  color: var(--text-primary);
}

.question-card__word {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  margin: var(--space-md) 0;
}

/* Completion panel shown when a player finishes early (race continues) */
.completion-panel {
  padding: var(--space-lg) 0;
}

.completion-panel h2 {
  margin: var(--space-sm) 0 0;
}

.completion-panel p {
  margin-left: auto;
  margin-right: auto;
  max-width: 28rem;
}

.options-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-sm);
}

@media (min-width: 480px) {
  .options-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.option-btn {
  padding: var(--space-md);
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
}

.option-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
  transform: scale(1.02);
}

.option-btn:active {
  transform: scale(0.98);
}

.option-btn.selected {
  background: var(--primary);
  border-color: var(--primary);
}

.option-btn.correct {
  background: var(--success);
  border-color: var(--success);
}

.option-btn.wrong {
  background: var(--error);
  border-color: var(--error);
}

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

/* ========================================
   Progress Bar
   ======================================== */

.progress-bar {
  background: var(--bg-input);
  border-radius: var(--radius-full);
  height: 12px;
  overflow: hidden;
  position: relative;
}

.progress-bar__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, var(--secondary) 100%);
  border-radius: var(--radius-full);
  transition: width var(--transition-normal);
  position: relative;
}

.progress-bar__fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg,
      transparent 0%,
      rgba(255, 255, 255, 0.3) 50%,
      transparent 100%);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }

  100% {
    transform: translateX(100%);
  }
}

/* ========================================
   Timer
   ======================================== */

.timer {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-card);
  border-radius: var(--radius-full);
  font-size: 1.25rem;
  font-weight: 700;
  font-family: 'Courier New', monospace;
}

.timer__icon {
  font-size: 1.5rem;
}

.timer--warning {
  color: var(--warning);
  animation: pulse 1s infinite;
}

.timer--danger {
  color: var(--error);
  animation: pulse 0.5s infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

/* ========================================
   Status Badge
   ======================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: var(--radius-full);
  background: var(--bg-input);
  color: var(--text-secondary);
}

.badge--lobby {
  background: rgba(255, 159, 28, 0.2);
  color: var(--primary);
}

.badge--playing {
  background: rgba(72, 187, 120, 0.2);
  color: var(--success);
}

.badge--closed {
  background: rgba(160, 174, 192, 0.2);
  color: var(--text-muted);
}

/* ========================================
   Toast Notifications
   ======================================== */

.toast-container {
  position: fixed;
  top: var(--space-md);
  right: var(--space-md);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.toast {
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--primary);
  animation: toast-in 0.3s ease;
  max-width: 320px;
}

.toast--success {
  border-color: var(--success);
}

.toast--error {
  border-color: var(--error);
}

.toast--warning {
  border-color: var(--warning);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
}

.toast-exit {
  animation: toast-out 0.3s ease forwards;
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

/* ========================================
   Winner Celebration
   ======================================== */

.winner-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 25, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fade-in 0.5s ease;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

.winner-card {
  text-align: center;
  padding: var(--space-2xl);
  animation: winner-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes winner-pop {
  from {
    opacity: 0;
    transform: scale(0.5);
  }
}

.winner-card__trophy {
  font-size: 5rem;
  animation: trophy-bounce 1s ease infinite;
}

@keyframes trophy-bounce {

  0%,
  100% {
    transform: translateY(0) rotate(-5deg);
  }

  50% {
    transform: translateY(-20px) rotate(5deg);
  }
}

.winner-card__title {
  font-size: 1.5rem;
  color: var(--text-secondary);
  margin-top: var(--space-lg);
}

.winner-card__name {
  font-size: 2.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-top: var(--space-sm);
}

.confetti {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
  z-index: 999;
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  background: var(--primary);
  animation: confetti-fall 3s linear forwards;
}

@keyframes confetti-fall {
  0% {
    transform: translateY(-100vh) rotate(0deg);
    opacity: 1;
  }

  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

/* ========================================
   Loading States
   ======================================== */

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--bg-input);
  border-top-color: var(--primary);
  border-radius: var(--radius-full);
  animation: spin 0.8s linear infinite;
}

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

.loading-text {
  margin-left: var(--space-md);
  color: var(--text-secondary);
}

/* ========================================
   Section Visibility
   ======================================== */

.hidden {
  display: none !important;
}

.fade-in {
  animation: fade-in 0.3s ease;
}

/* ========================================
   Waiting Animation
   ======================================== */

.waiting-animation {
  text-align: center;
  padding: var(--space-xl);
}

.waiting-animation__duck {
  font-size: 4rem;
  animation: duck-swim 3s ease-in-out infinite;
}

@keyframes duck-swim {

  0%,
  100% {
    transform: translateX(-30px) rotate(-5deg);
  }

  50% {
    transform: translateX(30px) rotate(5deg);
  }
}

.waiting-animation__text {
  margin-top: var(--space-md);
  color: var(--text-secondary);
}

.waiting-animation__dots::after {
  content: '';
  animation: dots 1.5s infinite;
}

@keyframes dots {
  0% {
    content: '';
  }

  25% {
    content: '.';
  }

  50% {
    content: '..';
  }

  75% {
    content: '...';
  }
}

/* ========================================
   Responsive Adjustments
   ======================================== */

@media (max-width: 480px) {
  :root {
    font-size: 14px;
  }

  .logo {
    font-size: 2rem;
  }

  .room-code__value {
    font-size: 2rem;
  }

  .question-card__word {
    font-size: 1.5rem;
  }

  .race-lane__name {
    width: 60px;
    font-size: 0.675rem;
  }
}

@media (min-width: 768px) {
  .container {
    padding: var(--space-xl);
  }

  h1 {
    font-size: 2.5rem;
  }
}

/* ========================================
   Utility Classes
   ======================================== */

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

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

.text-success {
  color: var(--success);
}

.text-error {
  color: var(--error);
}

.text-warning {
  color: var(--warning);
}

.mt-sm {
  margin-top: var(--space-sm);
}

.mt-md {
  margin-top: var(--space-md);
}

.mt-lg {
  margin-top: var(--space-lg);
}

.mt-xl {
  margin-top: var(--space-xl);
}

.mb-sm {
  margin-bottom: var(--space-sm);
}

.mb-md {
  margin-bottom: var(--space-md);
}

.mb-lg {
  margin-bottom: var(--space-lg);
}

.flex {
  display: flex;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.grid {
  display: grid;
  gap: var(--space-md);
}

.grid--2 {
  grid-template-columns: 1fr;
}

.grid--3 {
  grid-template-columns: 1fr;
}

@media (min-width: 768px) {
  .grid--2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid--3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.gap-sm {
  gap: var(--space-sm);
}

.gap-md {
  gap: var(--space-md);
}

/* ========================================
   RIVER TRACK - Professional Race View
   ======================================== */

.river-container {
  background: linear-gradient(180deg, #0a1628 0%, #1e3a5f 50%, #0a1628 100%);
  border-radius: var(--radius-xl);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 60px rgba(0, 119, 182, 0.3);
}

.river-container::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    url("data:image/svg+xml,%3Csvg width='100' height='20' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 10 Q25 0 50 10 T100 10' fill='none' stroke='rgba(0,180,216,0.1)' stroke-width='2'/%3E%3C/svg%3E") repeat-x;
  animation: water-flow 3s linear infinite;
  pointer-events: none;
}

@keyframes water-flow {
  0% {
    background-position-x: 0;
  }

  100% {
    background-position-x: 100px;
  }
}

.river-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
  padding: 0 var(--space-sm);
}

.river-title {
  font-size: 0.875rem;
  color: var(--water-light);
  font-weight: 600;
}

.river-markers {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.river-track {
  position: relative;
  background: linear-gradient(90deg,
      rgba(0, 119, 182, 0.4) 0%,
      rgba(0, 180, 216, 0.2) 50%,
      rgba(0, 119, 182, 0.4) 100%);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  border: 2px solid rgba(0, 180, 216, 0.3);
}

/* Start and Finish Lines */
.river-track::before,
.river-track::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 6px;
  z-index: 10;
}

.river-track::before {
  left: 50px;
  background: repeating-linear-gradient(180deg,
      #4ade80 0px,
      #4ade80 8px,
      #fff 8px,
      #fff 16px);
  border-radius: 3px;
  box-shadow: 0 0 10px rgba(74, 222, 128, 0.5);
}

.river-track::after {
  right: 10px;
  background: repeating-linear-gradient(180deg,
      #000 0px,
      #000 8px,
      #fff 8px,
      #fff 16px);
  border-radius: 3px;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.start-label,
.finish-label {
  position: absolute;
  top: -24px;
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  z-index: 11;
}

.start-label {
  left: 38px;
  background: #4ade80;
  color: #000;
}

.finish-label {
  right: 0;
  background: #fff;
  color: #000;
}

/* Lane Styles */
.river-lanes {
  max-height: 400px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--water-light) transparent;
}

.river-lane {
  display: flex;
  align-items: center;
  padding: var(--space-sm) var(--space-md);
  background: linear-gradient(90deg,
      rgba(30, 58, 95, 0.8) 0%,
      rgba(45, 90, 135, 0.5) 50%,
      rgba(30, 58, 95, 0.8) 100%);
  border-radius: var(--radius-md);
  margin-bottom: 6px;
  position: relative;
  min-height: 56px;
  border: 1px solid rgba(0, 180, 216, 0.2);
  transition: all var(--transition-fast);
}

.river-lane:hover {
  background: linear-gradient(90deg,
      rgba(30, 58, 95, 0.95) 0%,
      rgba(45, 90, 135, 0.7) 50%,
      rgba(30, 58, 95, 0.95) 100%);
}

.river-lane--leader {
  border-color: var(--primary);
  box-shadow: 0 0 15px rgba(255, 159, 28, 0.3);
}

.river-lane__rank {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: var(--radius-full);
  background: var(--bg-input);
  color: var(--text-secondary);
  flex-shrink: 0;
}

.river-lane__rank--1 {
  background: linear-gradient(135deg, #ffd700, #ffb700);
  color: #000;
}

.river-lane__rank--2 {
  background: linear-gradient(135deg, #c0c0c0, #a0a0a0);
  color: #000;
}

.river-lane__rank--3 {
  background: linear-gradient(135deg, #cd7f32, #a0522d);
  color: #fff;
}

.river-lane__player {
  width: 90px;
  margin-left: var(--space-sm);
  flex-shrink: 0;
}

.river-lane__name {
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.river-lane__status {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.river-lane__track-area {
  flex: 1;
  height: 40px;
  position: relative;
  margin: 0 var(--space-md);
  background: rgba(0, 119, 182, 0.2);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.river-lane__water {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg,
      rgba(0, 180, 216, 0.3) 0%,
      rgba(0, 119, 182, 0.2) 100%);
  transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.river-lane__duck {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  /* Slightly smaller duck to reduce visual clutter */
  font-size: 1.55rem;
  transition: left 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
  z-index: 5;
}

.river-lane__duck--swimming {
  animation: duck-swim-lane 0.8s ease-in-out infinite;
}

@keyframes duck-swim-lane {

  0%,
  100% {
    transform: translateY(-50%) rotate(-3deg);
  }

  50% {
    transform: translateY(-55%) rotate(3deg);
  }
}

.river-lane__crown {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.875rem;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
  animation: crown-bounce 1s ease-in-out infinite;
}

@keyframes crown-bounce {

  0%,
  100% {
    transform: translateX(-50%) translateY(0);
  }

  50% {
    transform: translateX(-50%) translateY(-3px);
  }
}

.river-lane__progress-text {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-primary);
  background: rgba(0, 0, 0, 0.5);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}

/* ========================================
   ADMIN DASHBOARD LAYOUT
   ======================================== */

.admin-topbar {
  background: var(--bg-card);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding: var(--space-md) var(--space-lg);
  position: sticky;
  top: 0;
  z-index: 100;
}

.admin-topbar__inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.admin-topbar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.admin-topbar__logo {
  font-size: 1.5rem;
}

.admin-topbar__title {
  font-size: 1.25rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.admin-topbar__room {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--bg-input);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
}

.admin-topbar__room-code {
  font-family: 'Courier New', monospace;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.1em;
}

.admin-topbar__copy-btn {
  padding: var(--space-xs) var(--space-sm);
  font-size: 0.75rem;
  min-height: 32px;
}

.admin-topbar__teacher {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.admin-topbar__teacher-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.admin-dashboard {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--space-lg);
}

@media (min-width: 1024px) {
  .admin-dashboard {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
  }
}

.admin-panel {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(255, 255, 255, 0.05);
  overflow: hidden;
}

.admin-panel+.admin-panel {
  margin-top: var(--space-md);
}

@media (min-width: 1024px) {
  .admin-panel+.admin-panel {
    margin-top: 0;
  }
}

.admin-panel__header {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.02);
}

.admin-panel__title {
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.admin-panel__body {
  padding: var(--space-lg);
}

/* ========================================
   TYPING INPUT (NEW QUESTION TYPE)
   ======================================== */

.typing-input-container {
  width: 100%;
  margin-top: var(--space-lg);
}

.typing-input-wrapper {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.typing-input {
  flex: 1;
  min-width: 200px;
  padding: var(--space-md);
  font-size: 1.125rem;
  background: var(--bg-input);
  border: 2px solid rgba(255, 159, 28, 0.3);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

.typing-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(255, 159, 28, 0.2);
}

.typing-input::placeholder {
  color: var(--text-muted);
}

.typing-submit-btn {
  min-width: 120px;
  font-size: 1rem;
  min-height: 52px;
}

.typing-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: var(--space-sm);
  text-align: center;
}

/* ========================================
   FEEDBACK ANIMATIONS
   ======================================== */

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  10%,
  30%,
  50%,
  70%,
  90% {
    transform: translateX(-5px);
  }

  20%,
  40%,
  60%,
  80% {
    transform: translateX(5px);
  }
}

.shake {
  animation: shake 0.5s ease;
}

@keyframes correct-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(72, 187, 120, 0.7);
  }

  70% {
    box-shadow: 0 0 0 15px rgba(72, 187, 120, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(72, 187, 120, 0);
  }
}

.pulse-correct {
  animation: correct-pulse 0.6s ease;
}

@keyframes wrong-flash {

  0%,
  50%,
  100% {
    background-color: var(--bg-input);
  }

  25%,
  75% {
    background-color: rgba(252, 129, 129, 0.3);
  }
}

.flash-wrong {
  animation: wrong-flash 0.5s ease;
}

.feedback-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  pointer-events: none;
}

.feedback-message {
  font-size: 4rem;
  animation: feedback-pop 0.8s ease forwards;
}

@keyframes feedback-pop {
  0% {
    opacity: 0;
    transform: scale(0.5);
  }

  30% {
    opacity: 1;
    transform: scale(1.2);
  }

  100% {
    opacity: 0;
    transform: scale(1);
  }
}

/* ========================================
   BANK MANAGER TABS - PROFESSIONAL
   ======================================== */

.bank-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-input);
  padding: 4px;
  border-radius: var(--radius-md);
  margin-bottom: var(--space-lg);
  overflow-x: auto;
}

.bank-tab {
  flex: 1;
  min-width: max-content;
  padding: var(--space-sm) var(--space-md);
  font-size: 0.8rem;
  font-weight: 600;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.bank-tab:hover {
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.05);
}

.bank-tab.active {
  background: var(--primary);
  color: white;
}

.bank-tab-content {
  display: none;
}

.bank-tab-content.active {
  display: block;
  animation: fade-in 0.2s ease;
}

/* Question Type Badge */
.question-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  border-radius: var(--radius-sm);
}

.question-type-badge--mcq {
  background: rgba(46, 196, 182, 0.2);
  color: var(--secondary);
}

.question-type-badge--typing {
  background: rgba(255, 159, 28, 0.2);
  color: var(--primary);
}

/* ========================================
   PRESENCE INDICATOR
   ======================================== */

.presence-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.presence-dot {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.presence-dot--online {
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
  animation: presence-pulse 2s ease-in-out infinite;
}

@keyframes presence-pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.6;
  }
}

.presence-dot--offline {
  background: var(--text-muted);
}

/* ========================================
   LIVE FEED (SUBMISSIONS)
   ======================================== */

.live-feed {
  max-height: 300px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.feed-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.8rem;
  animation: slide-in 0.3s ease;
}

.feed-item:last-child {
  border-bottom: none;
}

.feed-item__icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.feed-item__name {
  font-weight: 600;
  color: var(--text-primary);
}

.feed-item__action {
  flex: 1;
  color: var(--text-secondary);
}

.feed-item__time {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.feed-item__answer {
  display: inline-flex;
  align-items: center;
  max-width: 260px;
  padding: 2px 8px;
  margin-left: 2px;
  border-radius: var(--radius-full);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  font-size: 0.75rem;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.10);
  color: var(--text-primary);
}

.feed-item--correct .feed-item__answer {
  border-color: rgba(72, 187, 120, 0.25);
}

.feed-item--wrong .feed-item__answer {
  border-color: rgba(252, 129, 129, 0.25);
}

.feed-item--correct .feed-item__icon {
  color: var(--success);
}

.feed-item--wrong .feed-item__icon {
  color: var(--error);
}

/* ========================================
   QUESTION CARD ENHANCED
   ======================================== */

.question-card--typing {
  background: linear-gradient(135deg, var(--bg-card) 0%, rgba(255, 159, 28, 0.05) 100%);
  border-color: rgba(255, 159, 28, 0.3);
}

.question-card__type-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-bottom: var(--space-sm);
  padding: 4px 12px;
  background: rgba(255, 159, 28, 0.1);
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  color: var(--primary);
  text-transform: uppercase;
  font-weight: 700;
}

/* ========================================
   SUBMITTING STATE
   ======================================== */

.btn--submitting {
  position: relative;
  color: transparent;
  pointer-events: none;
}

.btn--submitting::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: var(--radius-full);
  animation: spin 0.8s linear infinite;
}

/* ========================================
   DEBUG PAGE STYLES
   ======================================== */

.debug-container {
  max-width: 800px;
  margin: 0 auto;
  padding: var(--space-lg);
}

.debug-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.debug-card__title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: var(--space-sm);
}

.debug-table {
  width: 100%;
  font-size: 0.8rem;
}

.debug-table td {
  padding: 4px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.debug-table td:first-child {
  color: var(--text-muted);
  width: 40%;
}

.debug-log {
  max-height: 200px;
  overflow-y: auto;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: var(--space-sm);
  font-family: monospace;
  font-size: 0.7rem;
  color: var(--text-secondary);
}

/* ========================================
   IN-GAME LAYOUT REFACTOR (fit 1 screen)
   ======================================== */

/* Remove implicit card stacking margins inside app-like shells that already use gap/grid */
.play-shell .card + .card,
.admin-dashboard-shell .card + .card,
.admin-lobby-shell .card + .card,
.admin-game-shell .card + .card,
.lobby-shell .card + .card,
.results-shell .card + .card {
  margin-top: 0;
}

/* Grid layouts already have gap; prevent the global .card + .card margin from shifting grid items */
.admin-game-grid > .card + .card,
.admin-dashboard-grid > .card + .card,
.results-grid > .card + .card,
.lobby-grid > .card + .card {
  margin-top: 0;
}


/* Remove outer padding for full-viewport game screens */
#dashboard-section.page__content {
  padding: 0;
}

#playing-section.page__content {
  padding: 0;
}

/* Player play screen */
.play-shell {
  /* Use modern viewport units with fallbacks to avoid 1px page scrollbars */
  height: 100vh;
  height: 100svh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-sm);
  min-height: 0;
  /*
    Do NOT remove scrolling.
    The UI is tuned to fit a typical PC viewport, but on shorter viewports
    (small laptop, split-screen, browser UI bars), we must allow scrolling
    so nothing gets cut off.
  */
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.play-grid {
  flex: 1 1 auto;
  display: grid;
  /* Track should be the primary focus; question panel stays compact */
  grid-template-columns: 1.4fr 0.6fr;
  gap: var(--space-sm);
  min-height: 0;
}

.play-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

/* Make the question card scroll internally if needed (instead of page scroll) */
.play-panel--question .question-card {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.play-panel--question .options-grid {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.play-panel--question .typing-input-container {
  margin-top: auto;
}

/* Player race-track should scroll internally (not the page) */
.play-track-card {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.play-track-card .race-track {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.play-progress-card {
  padding: var(--space-md);
}

/* ========================================
   Admin: Premium Dashboard (Fit 1 screen)
   ======================================== */

.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(5, 10, 20, 0.82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.admin-topbar__user {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.admin-topbar__email {
  font-size: 0.875rem;
  color: var(--text-muted);
  max-width: 40vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 600px) {
  .admin-topbar__email {
    display: none;
  }
}

.admin-dashboard-shell {
  /* Admin pages have a topbar; subtract the measured height to avoid body scrolling */
  height: calc(100dvh - var(--admin-topbar-height));
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-sm);
  min-height: 0;
  /* Allow scrolling if the viewport is short (don't cut content) */
  overflow-y: auto;
  overflow-x: hidden;
}

.admin-dashboard-grid {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  /* More "dashboard-like" proportions on desktop */
  grid-template-columns: minmax(340px, 440px) minmax(0, 1fr);
  gap: var(--space-md);
}

@media (min-width: 1200px) {
  .admin-dashboard-shell {
    padding: var(--space-lg);
  }

  .admin-dashboard-grid {
    gap: var(--space-lg);
  }
}

.admin-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.admin-pane__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.admin-pane__title {
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.2;
}

.admin-pane__meta {
  text-align: right;
  font-size: 0.85rem;
  line-height: 1.4;
}

.admin-pane--bank .bm-controls {
  flex: 0 0 auto;
}

.admin-pane--bank .question-list {
  flex: 1 1 auto;
}

/* Validation report shown as an overlay panel (won't break layout) */
#validation-report-card {
  position: fixed;
  right: 14px;
  bottom: 14px;
  width: min(520px, 92vw);
  max-height: 80vh;
  overflow: auto;
  z-index: 1200;
}

@media (min-width: 1000px) {
  /* Desktop: split view, no tabs needed */
  #main-tabs {
    display: none;
  }
}

@media (max-width: 999px) {
  .admin-dashboard-grid {
    grid-template-columns: 1fr;
  }
}

/* Admin playing screen */
.admin-lobby-shell {
  /* Admin page has a topbar; subtract the measured height */
  height: calc(100dvh - var(--admin-topbar-height));
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-sm);
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.admin-lobby-grid {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-sm);
  min-height: 0;
}

.admin-lobby-left,
.admin-lobby-right {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.admin-lobby-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.admin-lobby-players {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.admin-lobby-players .player-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

/* Admin playing screen */
.admin-game-shell {
  /* Admin page has a topbar; subtract the measured height */
  height: calc(100dvh - var(--admin-topbar-height));
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-sm);
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.admin-game-grid {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 1.5fr 0.5fr;
  gap: var(--space-sm);
  min-height: 0;
}

.admin-game-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.admin-game-card .race-track {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.feed-panel {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.15);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.admin-game-actions {
  flex: 0 0 auto;
}

/* Helper details (collapsible notes) */
.helper-details {
  display: inline-block;
  width: min(720px, 100%);
  text-align: left;
  background: rgba(0, 0, 0, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.75rem;
}

.helper-details > summary {
  cursor: pointer;
  list-style: none;
  font-weight: 800;
  color: var(--text-secondary);
}

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

.helper-details > summary::after {
  content: '▾';
  float: right;
  color: var(--text-muted);
}

.helper-details[open] > summary {
  color: var(--text-primary);
}

.helper-details[open] > summary::after {
  content: '▴';
}



/* Height-limited desktop: tighten vertical spacing (common 16:9 laptops like 1366×768) */
@media (min-width: 900px) and (max-height: 820px) {
  .play-shell {
    padding: 0.4rem;
    gap: 0.4rem;
  }

  .play-grid {
    gap: 0.4rem;
  }

  .play-panel {
    gap: 0.4rem;
  }

  .race-track {
    padding: 0.75rem;
  }

  .question-card--compact {
    padding: 0.75rem;
  }

  .question-card--compact .question-card__prompt {
    font-size: 1rem;
    margin-bottom: 0.75rem;
  }

  .play-progress-card {
    padding: 0.75rem;
  }

  .admin-game-shell {
    padding: 0.4rem;
    gap: 0.4rem;
  }

  .admin-game-grid {
    gap: 0.4rem;
  }

  .feed-panel {
    padding: 0.75rem;
  }
}
/* Responsive */
@media (max-width: 900px) {
  /*
    Mobile: do NOT use a fixed 16:9-like layout.
    We keep both panels visible and make the answer box always reachable.
  */

  .play-shell {
    /* Let the page adapt to real viewport changes (browser UI + keyboard) */
    height: auto;
    min-height: 100vh;
    min-height: 100svh;
    min-height: 100dvh;
    padding: var(--space-sm);
    padding-bottom: calc(var(--space-sm) + env(safe-area-inset-bottom));
  }

  .play-grid {
    grid-template-columns: 1fr;
  }

  /* Disable the old mobile tabs UX (it hides the answer box). */
  .play-tabs {
    display: none;
  }

  /* Make the question card behave like a bottom dock */
  .play-panel--question {
    position: sticky;
    bottom: 0;
    z-index: 200;
  }

  .play-panel--question .question-card {
    box-shadow: 0 -12px 30px rgba(0, 0, 0, 0.45);
  }

  .question-card--compact {
    padding: 0.75rem;
  }

  .question-card--compact .question-card__label {
    display: none;
  }

  .question-card--compact .question-card__prompt {
    font-size: 1rem;
    margin-bottom: 0.5rem;
  }

  .typing-input-container {
    margin-top: 0.5rem;
  }

  .typing-input-wrapper {
    flex-wrap: nowrap;
  }

  .typing-input {
    min-width: 0;
    padding: 0.65rem 0.75rem;
    font-size: 1rem;
  }

  .typing-submit-btn {
    min-width: 78px;
    min-height: 44px;
    font-size: 0.95rem;
  }

  .typing-hint {
    text-align: left;
  }

  /* Extra bottom space so the last lanes are not covered by the dock */
  .play-track-card .race-track {
    padding-bottom: calc(180px + env(safe-area-inset-bottom));
  }

  /* Admin pages can keep auto height on mobile */
  .admin-game-shell {
    height: auto;
  }

  .admin-lobby-shell {
    height: auto;
  }

  .admin-lobby-grid {
    grid-template-columns: 1fr;
  }

  .admin-game-grid {
    grid-template-columns: 1fr;
  }

  .admin-game-card .race-track {
    max-height: 360px;
  }

  .feed-panel {
    max-height: 240px;
  }
}


/* Extra-tight layout for very small phones */
@media (max-width: 480px) {
  .question-card--compact .question-card__number {
    font-size: 0.8rem;
  }

  .question-card--compact .question-card__prompt {
    font-size: 0.95rem;
  }

  .typing-submit-btn {
    min-width: 70px;
    padding-left: 0.6rem;
    padding-right: 0.6rem;
  }
}

/* ========================================
   Player: Mobile Tabs + Compact Question
   ======================================== */

.play-tabs {
  display: none;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  padding: 6px;
  gap: 6px;
}

.play-tab {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.play-tab.active {
  background: rgba(255, 159, 28, 0.18);
  color: var(--text-primary);
}

.question-card--compact {
  padding: var(--space-md);
}

.question-card--compact .question-card__prompt {
  font-size: 1.1rem;
  margin-bottom: var(--space-md);
}

.question-card--compact .typing-input-wrapper {
  gap: var(--space-sm);
}

.question-card--compact .typing-submit-btn {
  min-height: 44px;
}

/* Highlight current player in the race track */
.race-lane--me {
  border: 1px solid rgba(255, 159, 28, 0.28);
  background: rgba(255, 159, 28, 0.12);
}
/* ========================================
   Subtle developer credit (copyright mark)
   ======================================== */
.dev-credit{
  position: fixed;
  right: 10px;
  bottom: calc(10px + env(safe-area-inset-bottom));
  font-size: 12px;
  color: var(--text-muted);
  opacity: 0.75;
  z-index: 9999;
}
.dev-credit a{
  color: inherit;
  text-decoration: none;
}
.dev-credit a:hover{
  text-decoration: underline;
  opacity: 1;
}
