/* ============================================
   ROPE MASTERS - Primary teal theme (#1e5752)
   ============================================ */

@font-face {
  font-family: 'Kenney Future';
  src: url('../assets/Kenney Future.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

:root {
  --primary: #1e5752;
  --primary-dark: #163f3c;
  --primary-darker: #0e2826;
  --primary-mid: #2a7a73;
  --primary-light: #4aa39c;
  --primary-lighter: #6bb8b2;
  --primary-lightest: #9dd4d0;
  --surface: #e0f2f1;
  --surface-warm: #f0f9f8;

  /* Tug of War: team colors in teal family (left = lighter, right = darker) */
  --tug-team-a: #4aa39c;
  --tug-team-a-dark: #2a7a73;
  --tug-team-a-glow: rgba(74, 163, 156, 0.35);
  --tug-team-b: #2a7a73;
  --tug-team-b-dark: #1e5752;
  --tug-team-b-glow: rgba(30, 87, 82, 0.4);

  /* Legacy (victory screen / elsewhere if needed) */
  --team-a-primary: #c2410c;
  --team-a-secondary: #ea580c;
  --team-a-accent: #b45309;
  --team-a-glow: rgba(194, 65, 12, 0.4);
  --team-a-dark: #7c2d12;
  --team-b-primary: #1d4ed8;
  --team-b-secondary: #2563eb;
  --team-b-accent: #1e40af;
  --team-b-glow: rgba(29, 78, 216, 0.4);
  --team-b-dark: #1e3a8a;
}

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

html {
  font-size: clamp(14px, 2.5vw, 16px);
  -webkit-font-smoothing: antialiased;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Nunito', system-ui, sans-serif;
  background: var(--primary);
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  touch-action: pan-x pan-y;
  -webkit-user-select: none;
  user-select: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.app {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.app::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(30, 87, 82, 0.75) 0%, rgba(14, 40, 38, 0.85) 100%),
    url('../assets/grass/background.png') center center / cover no-repeat;
  z-index: -1;
}

.app.loading-question .question-text {
  opacity: 0.85;
  animation: loadingPulse 1s ease-in-out infinite;
}
@keyframes loadingPulse {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 1; }
}

/* ============================================
   Rotate overlay (portrait) + fullscreen
   ============================================ */

.rotate-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--primary);
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.rotate-overlay-content {
  text-align: center;
  color: #fff;
  max-width: 280px;
}

.rotate-icon {
  font-size: 4rem;
  display: block;
  margin-bottom: 16px;
  animation: rotate-hint 2s ease-in-out infinite;
}

@keyframes rotate-hint {
  0%, 100% { transform: rotate(-30deg); }
  50% { transform: rotate(30deg); }
}

.rotate-message {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.4;
}

@media (orientation: portrait) {
  .rotate-overlay {
    display: flex;
  }
}

/* Fullscreen: use full viewport */
html:fullscreen .app,
html:-webkit-full-screen .app,
html:-moz-full-screen .app {
  width: 100vw;
  height: 100vh;
  max-height: 100vh;
}

/* ============================================
   Game Header - Wooden sign
   ============================================ */

.game-header {
  background: linear-gradient(180deg, var(--primary-darker) 0%, var(--primary-dark) 30%, var(--primary) 100%);
  padding: 8px 16px;
  border-bottom: 4px solid var(--primary-darker);
  box-shadow:
    0 4px 0 var(--primary-darker),
    0 6px 16px rgba(0,0,0,0.4),
    inset 0 2px 0 rgba(255,255,255,0.15);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.header-top {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.game-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: flex-start;
}

.logo-img {
  height: 44px;
  width: auto;
  max-width: 120px;
  object-fit: contain;
  display: block;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border: 3px solid var(--primary-lightest);
  border-radius: 12px;
  background: linear-gradient(180deg, var(--primary-light) 0%, var(--primary) 100%);
  box-shadow: 0 3px 0 var(--primary-dark), 0 4px 10px rgba(0,0,0,0.2);
  display: grid;
  place-items: center;
  cursor: pointer;
  touch-action: manipulation;
}

.icon-btn img {
  width: 22px;
  height: 22px;
  filter: brightness(0) invert(1);
}

.icon-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--primary-dark);
}

.icon-btn.active {
  background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%);
  border-color: #bfdbfe;
  box-shadow: 0 3px 0 #1e3a8a, 0 4px 10px rgba(0,0,0,0.2);
}

.header-nav-btn {
  width: auto;
  min-width: 68px;
  padding: 0 12px;
  font-family: 'Nunito', system-ui, sans-serif;
  font-size: 0.9rem;
  font-weight: 800;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Global Countdown - Big & visible for kids */
.global-timer {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.35);
  padding: 8px 16px;
  border-radius: 12px;
  border: 3px solid var(--primary-lightest);
  box-shadow: 0 3px 0 var(--primary-mid), 0 4px 12px rgba(0,0,0,0.3);
}

.global-timer.hidden {
  display: none;
}

.global-timer-team {
  font-family: 'Fredoka', cursive;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--surface);
}

.global-timer-value {
  font-family: 'Fredoka', cursive;
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
  min-width: 2ch;
  text-align: center;
  text-shadow: 0 2px 0 rgba(0,0,0,0.5);
}

.global-timer-value.warning {
  color: #fca5a5;
  animation: timerPulse 0.6s ease infinite;
}

.global-timer-unit {
  font-size: 1rem;
  font-weight: 700;
  color: var(--surface);
}

.logo-icon {
  font-size: 1.5rem;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
  animation: logoBounce 2s ease-in-out infinite;
}

@keyframes logoBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.game-title {
  font-family: 'Fredoka', 'Kenney Future', cursive;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--surface);
  text-shadow: 0 2px 0 var(--primary), 0 4px 8px rgba(0,0,0,0.5);
}

.logo-subtitle {
  font-size: 0.9rem;
  color: #86efac;
  font-weight: 600;
  margin-left: 8px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* ============================================
   Start Screen / Teacher Setup
   ============================================ */

/* Hide game and header when onboarding or mode screens are visible */
#app:has(> #start-screen:not(.hidden)) > .game-header,
#app:has(> #start-screen:not(.hidden)) > .game-container,
#app:has(> #quiz-screen:not(.hidden)) > .game-header,
#app:has(> #quiz-screen:not(.hidden)) > .game-container,
#app:has(> #lesson-screen:not(.hidden)) > .game-header,
#app:has(> #lesson-screen:not(.hidden)) > .game-container,
#app:has(> #flashcard-screen:not(.hidden)) > .game-header,
#app:has(> #flashcard-screen:not(.hidden)) > .game-container {
  display: none !important;
}

.start-screen {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  flex-direction: column;
  padding: 0;
  background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary-darker) 100%);
}

.start-screen.hidden {
  display: none;
}

.platform-home-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
}

.platform-home-header-inner {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 56px;
  padding: 6px 16px;
}

.platform-home-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  flex: 1 1 auto;
}

.platform-home-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-shrink: 0;
}

.platform-home-brand {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.platform-home-logo {
  height: 32px;
  width: auto;
  display: block;
  max-width: 190px;
  object-fit: contain;
}

.platform-home-search {
  position: relative;
  flex: 1 1 460px;
  max-width: 560px;
  display: flex;
  align-items: center;
}

.platform-home-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #6b7280;
  font-size: 0.95rem;
  pointer-events: none;
}

.platform-home-search-input {
  width: 100%;
  height: 38px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  background: #fff;
  color: #111827;
  font-size: 0.88rem;
  padding: 0 12px 0 34px;
  outline: none;
}

.platform-home-search-input:focus {
  border-color: #6bb8b2;
  box-shadow: 0 0 0 2px rgba(107, 184, 178, 0.25);
}

.platform-home-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.platform-home-link {
  text-decoration: none;
  color: #334155;
  font-size: 0.84rem;
  font-weight: 700;
  padding: 8px 10px;
  border-radius: 9px;
  border: 1px solid transparent;
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.platform-home-link:hover {
  background: #f1f5f9;
  border-color: #e2e8f0;
  color: #0f172a;
}

.platform-home-link-primary {
  color: #fff;
  background: #1e5752;
  border-color: #1e5752;
}

.platform-home-link-primary:hover {
  background: #163f3c;
  border-color: #163f3c;
  color: #fff;
}

.platform-home-mobile-toggle {
  display: none;
  margin-left: auto;
  height: 36px;
  width: 36px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  color: #374151;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.platform-home-mobile-menu {
  display: none;
  border-top: 1px solid #e5e7eb;
  background: #fff;
  padding: 10px 14px 12px;
}

.platform-home-mobile-menu:not(.hidden) {
  display: grid;
  gap: 6px;
}

.platform-home-search-mobile {
  max-width: none;
  margin-bottom: 6px;
}

.platform-home-mobile-link {
  display: block;
  text-decoration: none;
  color: #334155;
  font-size: 0.88rem;
  font-weight: 700;
  padding: 8px 10px;
  border-radius: 9px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
}

.platform-home-mobile-link-primary {
  color: #fff;
  background: #1e5752;
  border-color: #1e5752;
}

/* Global utility: any element with .hidden is not shown */
.hidden {
  display: none !important;
}

.start-card {
  flex: 1;
  width: 100%;
  max-width: none;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(180deg, var(--surface-warm) 0%, var(--surface) 100%);
  background-size: auto;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 32px 24px;
  overflow-y: auto;
}

/* Game-style centered panel for each step */
.course-select-step {
  width: 100%;
  max-width: 900px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 28px 20px;
  border-radius: 20px;
  border: 4px solid var(--primary-darker);
  box-shadow: 0 6px 0 var(--primary-darker), 0 12px 32px rgba(0,0,0,0.2);
  background: linear-gradient(180deg, var(--surface-warm) 0%, var(--surface) 100%);
}
.course-select-step.hidden {
  display: none !important;
}

.start-title {
  font-family: 'Fredoka', cursive;
  font-size: 1.75rem;
  color: var(--primary);
  text-align: center;
  margin-bottom: 6px;
}

.start-subtitle {
  text-align: center;
  color: var(--primary-dark);
  font-weight: 700;
  margin: 0 0 18px;
  font-size: 1rem;
}

.welcome-logo-wrap {
  text-align: center;
  margin-bottom: 14px;
}
.welcome-logo {
  max-width: 220px;
  height: auto;
  max-height: 96px;
  object-fit: contain;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.15));
}
.welcome-loading-courses {
  font-size: 0.9rem;
  color: var(--primary);
  margin: 8px 0;
  opacity: 0.9;
}
.welcome-loading-courses.hidden {
  display: none !important;
}
.welcome-continue-wrap {
  margin: 12px 0;
}
.welcome-continue-wrap .back-btn {
  margin: 0;
}
.course-grid-empty {
  text-align: center;
  color: var(--primary);
  padding: 20px;
}
.course-grid-empty .back-btn {
  margin-top: 12px;
  display: inline-block;
}
#welcome-get-started {
  margin-top: 4px;
  min-width: 220px;
  padding-left: 32px;
  padding-right: 32px;
}

.tug-mode-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 4px;
  width: 100%;
  max-width: 360px;
}
.tug-mode-btn {
  width: 100%;
  min-width: 0;
}

/* Solo Tug of War: hide right panel, show Goal strip */
.game-container[data-tug-mode="solo"] .panel-team-b {
  display: none;
}
.game-container[data-tug-mode="solo"] .panel-rope::after {
  content: 'Goal';
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-family: 'Fredoka', cursive;
  font-size: 1.25rem;
  font-weight: 700;
  color: rgba(255,255,255,0.9);
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
  pointer-events: none;
}

.back-btn {
  align-self: flex-start;
  background: none;
  border: none;
  color: var(--primary);
  font-weight: 700;
  cursor: pointer;
  padding: 8px 0;
  margin-bottom: 12px;
  font-size: 0.95rem;
  opacity: 0.9;
  transition: opacity 0.2s;
}
.back-btn:hover {
  opacity: 1;
}

.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 8px;
  max-height: 65vh;
  overflow-y: auto;
  width: 100%;
}

.course-card {
  width: 100%;
  max-width: 160px;
  justify-self: center;
  padding: 18px 14px;
  border-radius: 14px;
  border: 3px solid var(--primary-mid);
  background: linear-gradient(180deg, var(--surface-warm) 0%, var(--surface) 100%);
  cursor: pointer;
  text-align: center;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 0 var(--primary-darker);
}
.course-card:hover, .course-card:active {
  transform: translateY(2px) scale(1.02);
  box-shadow: 0 2px 0 var(--primary-darker);
}
.course-card-icon {
  font-size: 2.25rem;
  display: block;
  margin-bottom: 10px;
}
.course-card-name {
  font-family: 'Fredoka', cursive;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}

.grade-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-bottom: 8px;
}
.grade-btn {
  min-width: 48px;
  padding: 14px 18px;
  border-radius: 14px;
  border: 3px solid var(--primary-mid);
  background: linear-gradient(180deg, var(--surface-warm) 0%, var(--surface) 100%);
  font-weight: 700;
  color: #1c1917;
  cursor: pointer;
  font-size: 1rem;
  box-shadow: 0 3px 0 var(--primary-darker);
  transition: transform 0.15s, box-shadow 0.15s;
}
.grade-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 0 var(--primary-darker);
  background: var(--surface);
}

.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 8px;
  width: 100%;
  max-width: 400px;
}

.mode-grid.mode-cards {
  max-width: 860px;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.mode-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  padding: 18px 16px;
  border-radius: 14px;
  border: 3px solid var(--primary-mid);
  background: linear-gradient(180deg, var(--surface-warm) 0%, var(--surface) 100%);
  cursor: pointer;
  box-shadow: 0 4px 0 var(--primary-darker);
  transition: transform 0.15s, box-shadow 0.15s;
}

.mode-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 var(--primary-darker);
}

.mode-card-title {
  font-family: 'Fredoka', cursive;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary);
  margin-bottom: 6px;
}

.mode-card-desc {
  font-size: 0.85rem;
  color: var(--primary-darker);
  line-height: 1.35;
  opacity: 0.95;
}

.mode-btn {
  padding: 20px 14px;
  border-radius: 14px;
  border: 3px solid var(--primary-mid);
  background: linear-gradient(180deg, var(--surface-warm) 0%, var(--surface) 100%);
  font-weight: 700;
  color: #1c1917;
  cursor: pointer;
  font-size: 0.95rem;
  box-shadow: 0 4px 0 var(--primary-darker);
  transition: transform 0.15s, box-shadow 0.15s;
}
.mode-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 var(--primary-darker);
}

/* Setup step: centered game panel */
#setup-step {
  max-width: 420px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 28px 20px;
  border-radius: 20px;
  border: 4px solid var(--primary-darker);
  box-shadow: 0 6px 0 var(--primary-darker), 0 12px 32px rgba(0,0,0,0.2);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.6) 0%, rgba(254, 249, 195, 0.5) 100%);
}
.setup-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
  width: 100%;
}

.setup-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.setup-field span {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.setup-field select,
.setup-field input {
  min-height: 44px;
  border: 3px solid var(--primary-mid);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 1rem;
  font-weight: 700;
  background: var(--surface-warm);
  color: #1c1917;
}

#start-game-btn {
  min-width: 200px;
  padding-left: 32px;
  padding-right: 32px;
}

/* ============================================
   Victory Overlay
   ============================================ */

.victory-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(30, 87, 82, 0.9);
  backdrop-filter: blur(12px);
  opacity: 1;
  transition: opacity 0.5s ease;
}

.victory-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Explanation overlay (after each answer) */
.explanation-overlay {
  position: fixed;
  inset: 0;
  z-index: 950;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(30, 87, 82, 0.85);
  backdrop-filter: blur(8px);
  padding: 20px;
}
.explanation-overlay.hidden {
  display: none !important;
}
.explanation-card {
  background: linear-gradient(180deg, var(--surface-warm) 0%, var(--surface) 100%);
  border: 4px solid var(--primary-darker);
  border-radius: 16px;
  padding: 24px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}
.explanation-title {
  font-family: 'Fredoka', cursive;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 12px;
}
.explanation-text {
  font-size: 1rem;
  line-height: 1.5;
  color: #1c1917;
  margin-bottom: 20px;
}
.explanation-card #explanation-dismiss {
  width: 100%;
}

/* Mode screens (Quiz, Lesson, Flashcards) - game-style centered panels */
.mode-screen {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary-darker) 100%);
  overflow-y: auto;
}
.mode-screen.hidden {
  display: none !important;
}
.quiz-card, .lesson-card, .flashcard-container {
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: linear-gradient(180deg, var(--surface-warm) 0%, var(--surface) 100%);
  border: 6px solid var(--primary-darker);
  border-radius: 20px;
  padding: 28px;
  box-shadow: 0 8px 0 var(--primary-darker), 0 20px 50px rgba(0,0,0,0.25);
  overflow-y: auto;
}
.quiz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-bottom: 20px;
  font-weight: 700;
  color: var(--primary);
  font-size: 0.95rem;
}
.quiz-question-text {
  font-size: 1.2rem;
  font-weight: 700;
  color: #1c1917;
  margin-bottom: 22px;
  line-height: 1.45;
  text-align: center;
  width: 100%;
}
.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}
.quiz-options .option-btn {
  width: 100%;
  min-height: 52px;
  border-radius: 14px;
  padding: 14px 20px;
  font-size: 1rem;
  text-align: center;
  border: 3px solid var(--primary-mid);
  box-shadow: 0 3px 0 var(--primary-darker);
  transition: transform 0.15s, box-shadow 0.15s;
}
.quiz-options .option-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 0 var(--primary-darker);
}
.lesson-title {
  font-family: 'Fredoka', cursive;
  font-size: 1.5rem;
  color: var(--primary);
  margin-bottom: 16px;
  text-align: center;
  width: 100%;
}
.lesson-topic-row {
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.lesson-topic-row label { font-weight: 700; color: var(--primary); }
.lesson-topic-row select {
  padding: 8px 12px;
  border: 2px solid var(--primary-mid);
  border-radius: 10px;
  background: var(--surface-warm);
  font-weight: 600;
  min-width: 140px;
}
.lesson-content {
  font-size: 1rem;
  line-height: 1.65;
  color: #1c1917;
  margin-bottom: 24px;
  white-space: pre-wrap;
  width: 100%;
  text-align: left;
}
.lesson-questions-heading {
  font-family: 'Fredoka', cursive;
  font-size: 1.2rem;
  color: var(--primary);
  margin: 20px 0 12px;
}
.lesson-question-block {
  margin-bottom: 20px;
}
.lesson-question-text {
  font-weight: 700;
  color: #1c1917;
  margin-bottom: 10px;
}
.lesson-question-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 420px;
}
.lesson-question-feedback {
  margin-top: 8px;
  font-size: 0.95rem;
}
.lesson-question-feedback.correct { color: var(--primary-dark); font-weight: 700; }
.lesson-question-feedback.incorrect { color: #b91c1c; }
.quiz-card .back-btn,
.lesson-card .back-btn {
  align-self: center;
  margin-top: 20px;
}
.flashcard-options-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  width: 100%;
}
.flashcard-options-row label { font-weight: 700; color: var(--primary); }
.flashcard-options-row select {
  padding: 8px 12px;
  border: 2px solid var(--primary-mid);
  border-radius: 10px;
  background: var(--surface-warm);
  font-weight: 600;
  min-width: 100px;
}
.flashcard-card {
  width: 100%;
  max-width: 400px;
  min-height: 140px;
  padding: 28px;
  background: #fff;
  border: 4px solid var(--primary-mid);
  border-radius: 16px;
  margin-bottom: 20px;
  box-shadow: 0 4px 0 var(--primary-darker);
}
.flashcard-term {
  font-size: 1.25rem;
  font-weight: 700;
  color: #1c1917;
  text-align: center;
}
.flashcard-definition {
  font-size: 1rem;
  line-height: 1.5;
  color: #444;
  text-align: center;
}
.flashcard-definition.hidden {
  display: none;
}
.flashcard-container .btn-primary {
  margin-bottom: 16px;
  min-width: 180px;
}
.flashcard-nav {
  display: flex;
  gap: 14px;
  justify-content: center;
  margin-top: 8px;
  width: 100%;
  max-width: 320px;
}
.flashcard-nav .mode-btn {
  flex: 1;
  min-width: 0;
}
.flashcard-container .back-btn {
  align-self: center;
  margin-top: 20px;
}

.victory-content {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 40px;
  background: linear-gradient(145deg, var(--primary-dark) 0%, var(--primary-darker) 100%);
  border-radius: 24px;
  border: 6px solid var(--primary-darker);
  box-shadow:
    0 0 0 4px var(--primary-lightest),
    0 20px 60px rgba(0,0,0,0.6),
    inset 0 2px 0 rgba(255,255,255,0.1);
}

.victory-trophy {
  font-size: 4rem;
  margin-bottom: 12px;
  animation: trophySpin 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  filter: drop-shadow(0 4px 12px rgba(157, 212, 208, 0.5));
}

@keyframes trophySpin {
  0% { transform: scale(0) rotate(-180deg); opacity: 0; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

.victory-team {
  font-family: 'Fredoka', cursive;
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.victory-team.team-a { color: var(--tug-team-a); text-shadow: 0 0 30px var(--tug-team-a-glow); }
.victory-team.team-b { color: var(--tug-team-b); text-shadow: 0 0 30px var(--tug-team-b-glow); }

.victory-title {
  font-family: 'Fredoka', cursive;
  font-size: 3rem;
  font-weight: 700;
  color: var(--primary-lightest);
  text-shadow: 0 2px 0 var(--primary-mid), 0 4px 20px rgba(0,0,0,0.5);
  margin-bottom: 8px;
}

.victory-subtitle {
  font-size: 1.25rem;
  color: var(--primary-lightest);
  margin-bottom: 28px;
}

.btn-primary, .game-btn {
  font-family: 'Nunito', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  padding: 18px 48px;
  min-height: 56px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(180deg, var(--primary-light) 0%, var(--primary) 100%);
  color: white;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 0 var(--primary-dark), 0 6px 20px rgba(30, 87, 82, 0.4);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.btn-primary:hover, .game-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 var(--primary-dark), 0 8px 25px rgba(30, 87, 82, 0.5);
}

.btn-primary:active, .game-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--primary-dark);
}

#confetti-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ============================================
   Game Container & Panels
   ============================================ */

.game-container {
  display: flex;
  flex: 1;
  min-height: 0;
  gap: 4px;
  overflow: hidden;
  width: 100%;
  max-width: 2200px;
  margin: 0 auto;
}

.panel {
  display: flex;
  flex-direction: column;
  padding: 8px;
  min-height: 0;
  overflow: hidden;
  transition: all 0.3s ease;
}

.panel.active-turn {
  box-shadow: inset 0 0 0 4px var(--primary-lightest);
}

.panel-frame {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(255,255,255,0.98) 0%, var(--surface-warm) 100%);
  border-radius: 12px;
  padding: 12px;
  border: 4px solid var(--primary-mid);
  box-shadow:
    inset 0 2px 8px rgba(255,255,255,0.6),
    0 4px 0 var(--primary-dark),
    0 8px 24px rgba(0,0,0,0.2);
  position: relative;
  overflow: hidden;
}

.panel-frame::before {
  content: '';
  position: absolute;
  inset: 3px;
  border: 1px solid rgba(30, 87, 82, 0.2);
  border-radius: 10px;
  pointer-events: none;
}

.panel-team-a .panel-frame {
  border-color: var(--primary-mid);
  box-shadow:
    inset 0 2px 8px rgba(255,255,255,0.6),
    0 4px 0 var(--primary-dark),
    0 8px 24px rgba(0,0,0,0.2);
}

.panel-team-b .panel-frame {
  border-color: var(--primary-mid);
  box-shadow:
    inset 0 2px 8px rgba(255,255,255,0.6),
    0 4px 0 var(--primary-dark),
    0 8px 24px rgba(0,0,0,0.2);
}

/* Tug of War panels – unified teal gradient */
.panel-team-a {
  flex: 1 1 480px;
  min-width: 380px;
  max-width: 640px;
  background: linear-gradient(165deg, var(--primary) 0%, var(--primary-dark) 40%, var(--primary-darker) 100%);
  box-shadow: inset 0 2px 20px rgba(0,0,0,0.15);
}

.panel-team-b {
  flex: 1 1 480px;
  min-width: 380px;
  max-width: 640px;
  background: linear-gradient(195deg, var(--primary) 0%, var(--primary-dark) 40%, var(--primary-darker) 100%);
  box-shadow: inset 0 2px 20px rgba(0,0,0,0.15);
}

.panel-rope {
  flex: 1 1 640px;
  min-width: 420px;
  padding: 8px;
  background: linear-gradient(180deg, var(--primary-lightest) 0%, var(--primary-lighter) 35%, var(--primary-light) 65%, var(--primary) 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 60px rgba(0,0,0,0.08);
}

/* ============================================
   Arena - Grass field
   ============================================ */

.arena-backdrop {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.cloud {
  position: absolute;
  width: 80px;
  height: 40px;
  background: rgba(255,255,255,0.9);
  border-radius: 50%;
  filter: blur(2px);
  animation: cloudFloat 25s linear infinite;
}

.cloud::before, .cloud::after {
  content: '';
  position: absolute;
  background: rgba(255,255,255,0.9);
  border-radius: 50%;
}

.cloud::before {
  width: 40px;
  height: 30px;
  top: -10px;
  left: 10px;
}

.cloud::after {
  width: 50px;
  height: 25px;
  top: 5px;
  right: 5px;
}

.cloud-1 { top: 12%; left: -100px; animation-duration: 28s; }
.cloud-2 { top: 22%; left: -100px; animation-duration: 24s; animation-delay: -8s; }
.cloud-3 { top: 5%; left: -100px; animation-duration: 30s; animation-delay: -15s; }

@keyframes cloudFloat {
  0% { transform: translateX(0); }
  100% { transform: translateX(calc(100vw + 200px)); }
}

.arena-ground {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(180deg, rgba(107, 184, 178, 0.4) 0%, rgba(30, 87, 82, 0.7) 40%, var(--primary-dark) 100%);
  clip-path: polygon(0 25%, 100% 15%, 100% 100%, 0 100%);
  box-shadow: inset 0 -15px 40px rgba(0,0,0,0.2);
}

/* ============================================
   Panel Headers
   ============================================ */

.panel-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.team-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  box-shadow: 0 4px 0 rgba(0,0,0,0.3), 0 6px 16px rgba(0,0,0,0.25);
}

.team-a-avatar {
  background: linear-gradient(180deg, var(--primary-light) 0%, var(--tug-team-a-dark) 100%);
  border: 4px solid var(--primary-lightest);
}

.team-b-avatar {
  background: linear-gradient(180deg, var(--tug-team-b) 0%, var(--tug-team-b-dark) 100%);
  border: 4px solid var(--primary-lightest);
}

.team-icon {
  font-size: 1.75rem;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.team-badge {
  text-align: center;
  padding: 6px 12px;
  border-radius: 12px;
  transition: transform 0.2s;
  position: relative;
}

.team-a-badge {
  background: linear-gradient(135deg, var(--tug-team-a) 0%, var(--tug-team-a-dark) 100%);
  box-shadow: 0 4px 0 var(--primary-dark), 0 6px 15px var(--tug-team-a-glow);
}

.team-b-badge {
  background: linear-gradient(135deg, var(--tug-team-b) 0%, var(--tug-team-b-dark) 100%);
  box-shadow: 0 4px 0 var(--primary-darker), 0 6px 15px var(--tug-team-b-glow);
}

.team-badge.pulse {
  animation: badgePulse 0.5s ease;
}

@keyframes badgePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.turn-badge {
  display: block;
  font-size: 0.75rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-top: 4px;
  animation: turnBlink 1.5s ease-in-out infinite;
}

.turn-badge.hidden {
  display: none !important;
}

@keyframes turnBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.team-name {
  font-family: 'Fredoka', cursive;
  font-size: 1.2rem;
  font-weight: 700;
  color: white;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.team-tagline {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.9);
}

.score-hud {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 16px;
  background: rgba(30, 87, 82, 0.35);
  border-radius: 12px;
  border: 2px solid var(--primary-lightest);
  box-shadow: inset 0 2px 6px rgba(255,255,255,0.15);
}

.panel-team-a .score-hud,
.panel-team-b .score-hud {
  border-color: var(--primary-lightest);
}

.score-label {
  font-size: 0.6rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: rgba(255,255,255,0.9);
}

.score-value {
  font-family: 'Fredoka', cursive;
  font-size: 1.75rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 2px 0 rgba(0,0,0,0.3);
}

.score-value.updated {
  animation: scorePop 0.4s ease;
}

@keyframes scorePop {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* ============================================
   Question Area
   ============================================ */

.question-area {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
}

.question-label {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--primary);
}

.question-text {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary-darker);
  line-height: 1.4;
  padding: 10px;
  flex-shrink: 0;
  background: linear-gradient(180deg, #fff 0%, var(--surface-warm) 100%);
  border-radius: 10px;
  border: 2px solid var(--primary-light);
  box-shadow:
    inset 0 2px 4px rgba(255,255,255,0.6),
    0 2px 0 var(--primary-mid);
}

.options-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-height: 0;
}

.option-btn {
  font-family: 'Nunito', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  padding: 12px 16px;
  min-height: 48px;
  flex-shrink: 0;
  border: 2px solid var(--primary-mid);
  border-radius: 10px;
  background: linear-gradient(180deg, #fff 0%, var(--surface-warm) 100%);
  color: var(--primary-darker);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
  box-shadow: 0 2px 0 var(--primary-dark), 0 4px 10px rgba(30, 87, 82, 0.12);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.panel-team-a .option-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--surface-warm) 0%, var(--primary-lightest) 100%);
  border-color: var(--primary-light);
  box-shadow: 0 2px 0 var(--primary-mid), 0 4px 12px rgba(30, 87, 82, 0.2);
  transform: translateX(4px);
}

.panel-team-b .option-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--surface-warm) 0%, var(--primary-lightest) 100%);
  border-color: var(--primary-lighter);
  box-shadow: 0 2px 0 var(--primary-mid), 0 4px 12px rgba(30, 87, 82, 0.2);
  transform: translateX(-4px);
}

.option-btn:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--primary-darker);
}

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

.option-btn.correct {
  border-color: var(--primary);
  background: linear-gradient(180deg, var(--surface-warm) 0%, var(--primary-lightest) 100%);
  color: var(--primary-darker);
  box-shadow: 0 2px 0 var(--primary-dark);
  animation: correctFlash 0.6s ease;
}

.option-btn.incorrect {
  border-color: #dc2626;
  background: linear-gradient(180deg, #fee2e2 0%, #fecaca 100%);
  color: #b91c1c;
  box-shadow: 0 3px 0 #b91c1c;
  animation: incorrectShake 0.5s ease;
}

@keyframes correctFlash {
  0% { box-shadow: 0 0 0 0 rgba(30, 87, 82, 0.6); }
  70% { box-shadow: 0 0 0 16px rgba(30, 87, 82, 0); }
  100% { box-shadow: 0 3px 0 var(--primary-dark); }
}

@keyframes incorrectShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

.panel-footer {
  flex-shrink: 0;
  padding-top: 6px;
  min-height: 36px;
}

.feedback-message {
  font-size: 0.95rem;
  font-weight: 700;
  min-height: 22px;
}

.panel-team-a .feedback-message.correct, .panel-team-b .feedback-message.correct { color: var(--primary); }
.panel-team-a .feedback-message.incorrect, .panel-team-b .feedback-message.incorrect { color: #dc2626; }

.timer-display {
  font-family: 'Fredoka', cursive;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  margin-top: 6px;
}

.timer-display.warning {
  color: #dc2626;
  animation: timerPulse 0.5s ease infinite;
}

.timer-display.hidden {
  display: none;
}

@keyframes timerPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ============================================
   Rope Arena
   ============================================ */

.rope-container {
  position: relative;
  width: 100%;
  flex: 1;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

.center-line {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 6px;
  background: linear-gradient(180deg,
    transparent 0%,
    rgba(255, 255, 255, 0.6) 20%,
    rgba(255, 255, 255, 0.95) 50%,
    rgba(255, 255, 255, 0.6) 80%,
    transparent 100%
  );
  border-radius: 3px;
  transform: translateX(-50%);
  z-index: 1;
  box-shadow: 0 0 12px rgba(255,255,255,0.4);
}

.win-boundary {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 8px;
  border-radius: 4px;
  z-index: 2;
}

.win-boundary-a {
  left: 5%;
  background: linear-gradient(180deg, var(--tug-team-a) 0%, var(--tug-team-a-dark) 100%);
  box-shadow: 0 0 20px var(--tug-team-a-glow);
}

.win-boundary-b {
  right: 5%;
  background: linear-gradient(180deg, var(--tug-team-b) 0%, var(--tug-team-b-dark) 100%);
  box-shadow: 0 0 20px var(--tug-team-b-glow);
}

#rope-canvas {
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 120px;
  transform: translateY(-50%);
  touch-action: none;
}

.rope-marker {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  z-index: 10;
  pointer-events: none;
}

.marker-knot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--primary-lightest) 0%, var(--primary-light) 50%, var(--primary) 100%);
  border: 4px solid #fff;
  box-shadow:
    0 0 0 2px var(--primary-dark),
    0 3px 0 rgba(0,0,0,0.25),
    0 4px 16px rgba(30, 87, 82, 0.4);
}

.marker-flag {
  width: 0;
  height: 0;
  border-style: solid;
}

.marker-flag-a {
  border-width: 10px 14px 10px 0;
  border-color: transparent var(--tug-team-a) transparent transparent;
  margin-right: 4px;
  filter: drop-shadow(2px 0 4px rgba(0,0,0,0.3));
}

.marker-flag-b {
  border-width: 10px 0 10px 14px;
  border-color: transparent transparent transparent var(--tug-team-b);
  margin-left: 4px;
  filter: drop-shadow(-2px 0 4px rgba(0,0,0,0.3));
}

.arena-labels {
  position: absolute;
  bottom: 8px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  padding: 0 10%;
  pointer-events: none;
  z-index: 4;
}

.arena-label {
  font-family: 'Fredoka', cursive;
  font-size: 1rem;
  font-weight: 700;
  color: rgba(255,255,255,0.95);
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.arena-label-a { color: var(--primary-lightest); }
.arena-label-b { color: var(--primary-lightest); }

.app.shake {
  animation: appShake 0.3s ease;
}

@keyframes appShake {
  0%, 100% { transform: translateX(0); }
  10% { transform: translateX(-4px); }
  20% { transform: translateX(4px); }
  30% { transform: translateX(-3px); }
  40% { transform: translateX(3px); }
  50% { transform: translateX(-2px); }
  60% { transform: translateX(2px); }
  70% { transform: translateX(-1px); }
  80% { transform: translateX(1px); }
  90% { transform: translateX(0); }
}

/* Large viewports: wider content to reduce empty space */
@media (min-width: 768px) {
  .course-select-step {
    max-width: 960px;
  }
  .course-grid {
    max-height: 70vh;
  }
  .course-card {
    max-width: 180px;
  }
  .mode-grid {
    max-width: 480px;
  }
  .mode-grid.mode-cards {
    max-width: 900px;
  }
  .tug-mode-grid {
    max-width: 400px;
  }
  .quiz-card,
  .lesson-card,
  .flashcard-container {
    max-width: 680px;
  }
  .quiz-options {
    max-width: 480px;
  }
  #setup-step {
    max-width: 480px;
  }
}

/* ============================================
   Responsive - mobile & tablet
   ============================================ */

/* Narrow viewport: allow panels to shrink so row layout fits */
@media (max-width: 900px) {
  .panel-team-a, .panel-team-b { min-width: 0; max-width: none; }
  .panel-rope { min-width: 0; }
}

/* Tablet / narrow desktop: stack rope on top only when enough height */
@media (max-width: 1024px) and (min-height: 520px) {
  .game-container { flex-direction: column; }
  .panel { min-height: 0; }
  .panel-team-a, .panel-team-b { max-width: none; min-width: 0; }
  .panel-rope { order: -1; min-height: 100px; flex: 0 0 auto; }
  .rope-container { min-height: 80px; }
  .victory-title { font-size: 2rem; }
}

/* Short viewport (landscape phone e.g. iPhone 13): keep row, compact everything */
@media (max-height: 480px) {
  .platform-home-header-inner { min-height: 48px; padding: 5px 10px; gap: 10px; }
  .platform-home-left { gap: 8px; }
  .platform-home-logo { height: 28px; max-width: 150px; }
  .platform-home-search-input { height: 34px; font-size: 0.78rem; }
  .platform-home-link { font-size: 0.72rem; padding: 6px 8px; }

  .game-header { padding: 4px 8px; gap: 4px; }
  .header-top { gap: 6px; }
  .game-logo { gap: 6px; }
  .logo-img { height: 36px; max-width: 90px; }
  .game-title { font-size: 1rem; }
  .logo-subtitle { font-size: 0.7rem; margin-left: 4px; }
  .header-actions { gap: 4px; }
  .icon-btn { width: 36px; height: 36px; border-radius: 8px; border-width: 2px; }
  .icon-btn img { width: 18px; height: 18px; }
  .header-nav-btn { min-width: 58px; padding: 0 10px; font-size: 0.78rem; }
  .global-timer { padding: 4px 10px; gap: 4px; }
  .global-timer-value { font-size: 1.35rem; }
  .global-timer-team { font-size: 0.85rem; }
  .global-timer-unit { font-size: 0.8rem; }
  .game-container { gap: 2px; }
  .panel { padding: 4px; min-width: 0; }
  .panel-team-a, .panel-team-b { min-width: 0; max-width: none; flex: 1 1 0; }
  .panel-rope { min-width: 0; flex: 0 0 120px; padding: 4px; }
  .panel-frame { padding: 6px; border-width: 3px; }
  .panel-header { margin-bottom: 4px; gap: 2px; }
  .team-avatar { width: 32px; height: 32px; }
  .team-icon { font-size: 1.2rem; }
  .team-name { font-size: 0.9rem; }
  .team-tagline { font-size: 0.6rem; }
  .score-hud { padding: 4px 8px; }
  .score-value { font-size: 1.2rem; }
  .score-label { font-size: 0.5rem; }
  .question-area { gap: 4px; }
  .question-label { font-size: 0.6rem; }
  .question-text { font-size: 0.8rem; padding: 6px 8px; }
  .options-grid { gap: 4px; }
  .option-btn { padding: 8px 10px; min-height: 40px; font-size: 0.85rem; }
  .panel-footer { min-height: 28px; padding-top: 2px; }
  .feedback-message { font-size: 0.8rem; min-height: 18px; }
  .timer-display { font-size: 1.1rem; }
  .rope-container { min-height: 60px; }
  #rope-canvas { height: 80px; }
  .marker-knot { width: 20px; height: 20px; border-width: 3px; }
  .marker-flag-a { border-width: 6px 10px 6px 0; }
  .marker-flag-b { border-width: 6px 0 6px 10px; }
  .arena-label { font-size: 0.75rem; }
  .victory-content { padding: 20px; }
  .victory-trophy { font-size: 2.5rem; }
  .victory-team { font-size: 1.25rem; }
  .victory-title { font-size: 2rem; }
  .victory-subtitle { font-size: 1rem; margin-bottom: 16px; }
  .btn-primary, .game-btn { padding: 12px 24px; min-height: 44px; font-size: 1rem; }
}

/* Narrow (portrait phone or small width) */
@media (max-width: 600px) {
  .setup-grid { grid-template-columns: 1fr; }
  .start-card { padding: 14px; }
  .start-title { font-size: 1.35rem; }
  .start-subtitle { font-size: 0.9rem; }
}

@media (max-width: 480px) {
  .platform-home-header-inner { min-height: 52px; padding: 7px 10px; }
  .platform-home-left { flex: 1 1 auto; }
  .platform-home-right { margin-left: 0; }
  .platform-home-logo { height: 30px; max-width: 152px; }
  .platform-home-search,
  .platform-home-nav { display: none; }
  .platform-home-mobile-toggle { display: inline-grid; place-items: center; }

  .game-header { padding: 6px 10px; gap: 6px; }
  .header-top { flex-wrap: wrap; }
  .game-logo { flex-wrap: wrap; }
  .logo-img { height: 38px; max-width: 100px; }
  .logo-subtitle { width: 100%; margin-left: 0; margin-top: 2px; }
  .icon-btn { width: 40px; height: 40px; min-width: 40px; border-radius: 10px; }
  .icon-btn img { width: 20px; height: 20px; }
  .header-nav-btn { min-width: 62px; padding: 0 10px; font-size: 0.8rem; }
  .game-title { font-size: 1.15rem; }
  .start-card { padding: 12px; }
  .start-title { font-size: 1.25rem; }
  .setup-field select, .setup-field input { min-height: 44px; font-size: 1rem; }
  .panel-frame { padding: 8px; }
  .question-text { font-size: 0.9rem; padding: 8px; }
  .option-btn { padding: 10px 12px; font-size: 0.9rem; min-height: 48px; }
  .team-icon { font-size: 1.4rem; }
  .team-avatar { width: 40px; height: 40px; }
  .team-name { font-size: 1rem; }
  .global-timer-value { font-size: 1.5rem; }
  .global-timer-team { font-size: 0.9rem; }
  .victory-content { padding: 24px; }
  .victory-title { font-size: 2.25rem; }
}

/* Reduced motion: respect user preference */
@media (prefers-reduced-motion: reduce) {
  .rotate-icon,
  .rotate-overlay .rotate-icon {
    animation: none;
  }
  .course-card:hover,
  .course-card:active,
  .grade-btn:hover,
  .mode-btn:hover,
  .option-btn:hover,
  .btn-primary:hover,
  .game-btn:hover {
    transform: none;
  }
  .feedback-message.updated,
  .score-display .updated {
    transition: none;
  }
}
