/* ============================================
   The Thornwood Collection - Victorian Mystery
   Elegant & Warm Design System
   ============================================ */

/* CSS Custom Properties */
:root {
  /* Color Palette */
  --color-burgundy: #722f37;
  --color-burgundy-dark: #5a252c;
  --color-burgundy-light: #8a3a44;
  --color-forest: #1a3d2e;
  --color-forest-dark: #142e23;
  --color-forest-light: #2a5a45;
  --color-gold: #c9a227;
  --color-gold-light: #e3c65c;
  --color-gold-dark: #a68620;
  --color-cream: #faf8f3;
  --color-cream-dark: #f0ebe0;
  --color-parchment: #f5f0e6;
  --color-ink: #2c2416;
  --color-ink-light: #4a4035;

  /* Typography */
  --font-display: 'Cinzel', 'Times New Roman', serif;
  --font-body: 'Crimson Text', Georgia, serif;
  --font-mono: 'Courier New', monospace;

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

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 300ms ease;
  --transition-slow: 500ms ease;

  /* Shadows */
  --shadow-soft: 0 2px 8px rgba(44, 36, 22, 0.1);
  --shadow-medium: 0 4px 16px rgba(44, 36, 22, 0.15);
  --shadow-strong: 0 8px 32px rgba(44, 36, 22, 0.2);
  --shadow-glow: 0 0 20px rgba(201, 162, 39, 0.3);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

body {
  font-family: var(--font-body);
  background: linear-gradient(135deg, var(--color-burgundy-dark) 0%, var(--color-forest-dark) 100%);
  color: var(--color-ink);
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  overscroll-behavior: none;
}

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

.container {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: var(--space-md);
  animation: fadeIn 0.4s ease;
}

.screen.hidden {
  display: none;
}

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

/* ============================================
   Card Component - The Core Visual
   ============================================ */

.card {
  background: var(--color-cream);
  border-radius: 4px;
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Decorative border effect */
.card::before {
  content: '';
  position: absolute;
  inset: 0;
  border: 3px solid var(--color-gold);
  border-radius: 4px;
  pointer-events: none;
  z-index: 1;
}

.card::after {
  content: '';
  position: absolute;
  inset: 6px;
  border: 1px solid var(--color-gold-dark);
  border-radius: 2px;
  pointer-events: none;
  opacity: 0.5;
  z-index: 1;
}

.card > * {
  position: relative;
  z-index: 0;
}

/* ============================================
   Typography
   ============================================ */

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.3;
  color: var(--color-burgundy);
}

h1 { font-size: 1.5rem; letter-spacing: 0.05em; }
h2 { font-size: 1.35rem; letter-spacing: 0.03em; }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; }

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

.text-center { text-align: center; }
.text-gold { color: var(--color-gold-dark); }
.text-forest { color: var(--color-forest); }
.text-muted { color: var(--color-ink-light); }

/* Story typography */
.date-line {
  font-style: italic;
  color: var(--color-ink-light);
  font-size: 0.85rem;
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--color-gold);
  text-align: center;
}

.signature-line {
  margin-top: var(--space-lg);
  text-align: right;
  font-style: italic;
}

.signature-line em {
  font-family: var(--font-display);
  font-size: 1rem;
  color: var(--color-forest);
  font-style: normal;
}

/* Riddle styling */
.riddle-verse {
  background: linear-gradient(135deg, var(--color-parchment) 0%, var(--color-cream-dark) 100%);
  padding: var(--space-md);
  border-left: 3px solid var(--color-gold);
  margin: var(--space-md) 0;
  font-size: 0.95rem;
  line-height: 1.9;
}

.riddle-hint {
  font-size: 0.85rem;
  color: var(--color-ink-light);
  font-style: italic;
  padding: var(--space-sm) var(--space-md);
  background: rgba(201, 162, 39, 0.1);
  border-radius: 4px;
  margin-top: var(--space-md);
}

/* ============================================
   Header Component
   ============================================ */

.card-header,
.clue-header {
  text-align: center;
  padding: var(--space-lg) var(--space-md) var(--space-md);
  border-bottom: 1px solid var(--color-cream-dark);
  position: relative;
}

.clue-badge,
.artifact-badge {
  display: inline-block;
  background: var(--color-forest);
  color: var(--color-gold-light);
  padding: var(--space-xs) var(--space-md);
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  border-radius: 2px;
  margin-bottom: var(--space-sm);
}

.card-header h1,
.clue-header h1 {
  margin-bottom: var(--space-xs);
}

.card-header .subtitle {
  font-style: italic;
  color: var(--color-ink-light);
  font-size: 0.9rem;
}

/* Gold divider */
.divider {
  width: 60%;
  max-width: 180px;
  height: 2px;
  background: linear-gradient(90deg, transparent 0%, var(--color-gold) 50%, transparent 100%);
  margin: var(--space-md) auto;
}

/* ============================================
   Wax Seal
   ============================================ */

.wax-seal,
.grinch-icon {
  width: 56px;
  height: 56px;
  background: radial-gradient(circle at 30% 30%, #a82c2c 0%, var(--color-burgundy) 50%, var(--color-burgundy-dark) 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-md);
  box-shadow:
    0 4px 8px rgba(0,0,0,0.3),
    inset 0 2px 4px rgba(255,255,255,0.2),
    var(--shadow-glow);
  animation: sealPulse 3s ease-in-out infinite;
  font-size: 1.75rem;
}

.wax-seal::after,
.grinch-icon::after {
  content: 'T';
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-gold-light);
  text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

.grinch-icon::after {
  content: none;
}

.grinch-icon.spin {
  animation: spin 2s linear infinite;
}

@keyframes sealPulse {
  0%, 100% { box-shadow: 0 4px 8px rgba(0,0,0,0.3), inset 0 2px 4px rgba(255,255,255,0.2), 0 0 20px rgba(201, 162, 39, 0.2); }
  50% { box-shadow: 0 4px 8px rgba(0,0,0,0.3), inset 0 2px 4px rgba(255,255,255,0.2), 0 0 30px rgba(201, 162, 39, 0.4); }
}

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

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md) var(--space-lg);
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--transition-normal);
  text-decoration: none;
  min-height: 48px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-burgundy) 0%, var(--color-burgundy-dark) 100%);
  color: var(--color-cream);
  box-shadow: var(--shadow-medium);
}

.btn-primary:hover, .btn-primary:focus {
  background: linear-gradient(135deg, var(--color-burgundy-light) 0%, var(--color-burgundy) 100%);
  transform: translateY(-2px);
  box-shadow: var(--shadow-strong);
}

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

.btn-secondary {
  background: var(--color-cream-dark);
  color: var(--color-forest);
  border: 2px solid var(--color-forest);
}

.btn-secondary:hover, .btn-secondary:focus {
  background: var(--color-forest);
  color: var(--color-cream);
}

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

.btn-large {
  width: 100%;
  padding: var(--space-md) var(--space-lg);
  font-size: 0.9rem;
  margin-top: auto;
}

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

.name-form {
  margin: var(--space-lg) 0;
}

.name-form label {
  display: block;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-forest);
  margin-bottom: var(--space-sm);
  letter-spacing: 0.03em;
}

input[type="text"],
input[type="number"] {
  width: 100%;
  padding: var(--space-md);
  font-family: var(--font-body);
  font-size: 1rem;
  border: 2px solid var(--color-cream-dark);
  border-radius: 4px;
  background: white;
  transition: border-color var(--transition-fast);
  margin-bottom: var(--space-md);
}

input[type="text"]:focus,
input[type="number"]:focus {
  outline: none;
  border-color: var(--color-gold);
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.2);
}

.error-message {
  color: var(--color-burgundy);
  font-size: 0.85rem;
  margin-top: var(--space-sm);
  text-align: center;
}

/* ============================================
   Audio Player
   ============================================ */

.audio-player {
  background: var(--color-forest);
  padding: var(--space-md);
  border-radius: 4px;
  margin: var(--space-md) 0;
}

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

.audio-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--color-gold);
  background: transparent;
  color: var(--color-gold);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  flex-shrink: 0;
  line-height: 1;
}

.audio-btn:hover {
  background: var(--color-gold);
  color: var(--color-forest);
}

.audio-btn.playing {
  background: var(--color-gold);
  color: var(--color-forest);
}

.audio-btn .play-icon,
.audio-btn .pause-icon {
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.audio-btn .play-icon { display: flex; }
.audio-btn .pause-icon { display: none; }
.audio-btn.playing .play-icon { display: none; }
.audio-btn.playing .pause-icon { display: flex; }

.audio-progress-container {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.2);
  border-radius: 3px;
  overflow: hidden;
}

.audio-progress {
  height: 100%;
  background: var(--color-gold);
  width: 0%;
  transition: width 0.1s linear;
  border-radius: 3px;
}

/* ============================================
   Story Content
   ============================================ */

.story-content {
  flex: 1;
  padding: var(--space-md);
  font-size: 0.95rem;
  line-height: 1.7;
  overflow-y: auto;
}

.story-content p {
  margin-bottom: var(--space-md);
}

.story-card {
  display: flex;
  flex-direction: column;
}

.story-card .story-content {
  flex: 1;
  overflow-y: auto;
}

/* ============================================
   Players List
   ============================================ */

.players-section {
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-cream-dark);
}

.players-section h4 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-ink-light);
  margin-bottom: var(--space-sm);
}

.players-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.players-list li {
  background: var(--color-cream-dark);
  padding: var(--space-xs) var(--space-md);
  border-radius: 20px;
  font-size: 0.85rem;
  color: var(--color-forest);
}

.players-list.small li {
  font-size: 0.8rem;
  padding: 2px var(--space-sm);
}

/* ============================================
   Activity Container
   ============================================ */

.activity-card {
  display: flex;
  flex-direction: column;
}

.activity-header {
  text-align: center;
  padding: var(--space-md);
  border-bottom: 1px solid var(--color-cream-dark);
}

.activity-header h2 {
  margin-bottom: var(--space-xs);
  font-size: 1.2rem;
}

.activity-header p {
  color: var(--color-ink-light);
  font-size: 0.9rem;
  margin-bottom: 0;
}

#activity-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: var(--space-md);
  overflow-y: auto;
}

/* ============================================
   Trivia Activity
   ============================================ */

.trivia-container {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.trivia-progress {
  display: flex;
  justify-content: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.trivia-progress .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-cream-dark);
  border: 2px solid var(--color-gold-dark);
  transition: all var(--transition-normal);
}

.trivia-progress .dot.correct {
  background: var(--color-gold);
  border-color: var(--color-gold-dark);
  box-shadow: var(--shadow-glow);
}

.trivia-progress .dot.current {
  border-color: var(--color-burgundy);
  animation: pulse 1.5s ease-in-out infinite;
}

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

.trivia-question {
  font-size: 1.05rem;
  font-weight: 600;
  text-align: center;
  margin-bottom: var(--space-lg);
  color: var(--color-ink);
  line-height: 1.5;
}

.trivia-options {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.trivia-option {
  padding: var(--space-md);
  background: white;
  border: 2px solid var(--color-cream-dark);
  border-radius: 4px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  text-align: left;
  cursor: pointer;
  transition: all var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.trivia-option:hover:not(:disabled) {
  border-color: var(--color-gold);
  background: var(--color-parchment);
}

.trivia-option.correct {
  background: #d4edda;
  border-color: #28a745;
  color: #155724;
}

.trivia-option.incorrect {
  background: #f8d7da;
  border-color: var(--color-burgundy);
  color: var(--color-burgundy-dark);
}

.trivia-option:disabled {
  cursor: default;
}

.trivia-feedback {
  text-align: center;
  padding: var(--space-md);
  border-radius: 4px;
  font-weight: 600;
  margin-top: var(--space-md);
}

.trivia-feedback.correct {
  background: #d4edda;
  color: #155724;
}

.trivia-feedback.incorrect {
  background: #f8d7da;
  color: var(--color-burgundy-dark);
}

.trivia-feedback.hidden {
  display: none;
}

/* Trivia Celebration Overlay */
.trivia-celebration-overlay {
  position: fixed;
  inset: 0;
  background: rgba(44, 36, 22, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.trivia-celebration-overlay.active {
  opacity: 1;
}

.trivia-celebration-overlay.fade-out {
  opacity: 0;
}

.trivia-celebration-content {
  text-align: center;
  transform: scale(0.5);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.trivia-celebration-overlay.active .trivia-celebration-content {
  transform: scale(1);
  opacity: 1;
}

.celebration-checkmark {
  width: 80px;
  height: 80px;
  margin: 0 auto var(--space-md);
}

.celebration-checkmark svg {
  width: 100%;
  height: 100%;
}

.checkmark-circle {
  stroke: var(--color-gold);
  stroke-width: 3;
  stroke-dasharray: 166;
  stroke-dashoffset: 166;
  animation: checkmark-circle 0.6s ease-in-out forwards;
}

.checkmark-check {
  stroke: var(--color-gold);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  animation: checkmark-check 0.3s ease-in-out 0.4s forwards;
}

@keyframes checkmark-circle {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes checkmark-check {
  to {
    stroke-dashoffset: 0;
  }
}

.celebration-text {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-gold);
  text-shadow: 0 2px 10px rgba(201, 162, 39, 0.5);
  margin-bottom: var(--space-xs);
  animation: celebration-text-pop 0.4s ease-out 0.3s backwards;
}

.celebration-subtext {
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--color-cream);
  opacity: 0.9;
  animation: celebration-text-pop 0.4s ease-out 0.5s backwards;
}

@keyframes celebration-text-pop {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.celebration-confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

@keyframes confetti-burst {
  0% {
    opacity: 1;
    transform: translateY(0) translateX(0) rotate(0deg) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-150px) translateX(var(--end-x)) rotate(var(--rotation)) scale(0.5);
  }
}

@keyframes confetti-burst-radial {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0) rotate(0deg);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.2) rotate(calc(var(--rotation) * 0.2));
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--end-x)), calc(-50% + var(--end-y))) scale(0.6) rotate(var(--rotation));
  }
}

/* Incorrect Answer Overlay */
.trivia-incorrect-overlay {
  position: fixed;
  inset: 0;
  background: rgba(80, 30, 30, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.trivia-incorrect-overlay.active {
  opacity: 1;
}

.trivia-incorrect-overlay.fade-out {
  opacity: 0;
}

.trivia-incorrect-content {
  text-align: center;
  transform: scale(0.5);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.trivia-incorrect-overlay.active .trivia-incorrect-content {
  transform: scale(1);
  opacity: 1;
}

.incorrect-x {
  width: 80px;
  height: 80px;
  margin: 0 auto var(--space-md);
}

.incorrect-x svg {
  width: 100%;
  height: 100%;
}

.x-circle {
  stroke: #cc4444;
  stroke-width: 3;
  stroke-dasharray: 166;
  stroke-dashoffset: 166;
  animation: x-circle 0.5s ease-in-out forwards;
}

.x-mark {
  stroke: #cc4444;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 60;
  stroke-dashoffset: 60;
  animation: x-mark 0.3s ease-in-out 0.3s forwards;
}

@keyframes x-circle {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes x-mark {
  to {
    stroke-dashoffset: 0;
  }
}

.incorrect-text {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: #cc4444;
  text-shadow: 0 2px 10px rgba(200, 60, 60, 0.5);
  margin-bottom: var(--space-sm);
  animation: celebration-text-pop 0.4s ease-out 0.3s backwards;
}

.penalty-countdown {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  animation: celebration-text-pop 0.4s ease-out 0.5s backwards;
}

.penalty-label {
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--color-cream);
  opacity: 0.8;
}

.penalty-timer {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 700;
  color: var(--color-cream);
  text-shadow: 0 2px 10px rgba(255, 255, 255, 0.3);
  transition: transform 0.2s ease;
}

.penalty-timer.tick {
  transform: scale(1.2);
}

/* ============================================
   Activity Leaderboard Overlay
   ============================================ */

.activity-leaderboard-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 61, 46, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.activity-leaderboard-overlay.active {
  opacity: 1;
}

.activity-leaderboard-overlay.fade-out {
  opacity: 0;
}

.leaderboard-content {
  text-align: center;
  padding: var(--space-lg);
  max-width: 350px;
  width: 90%;
  transform: scale(0.8);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.activity-leaderboard-overlay.active .leaderboard-content {
  transform: scale(1);
  opacity: 1;
}

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

.leaderboard-trophy {
  width: 70px;
  height: 70px;
  margin: 0 auto var(--space-md);
  animation: trophy-bounce 0.6s ease-out;
}

.leaderboard-trophy svg {
  width: 100%;
  height: 100%;
  fill: var(--color-gold);
  filter: drop-shadow(0 4px 8px rgba(201, 162, 39, 0.4));
}

@keyframes trophy-bounce {
  0% { transform: scale(0) rotate(-15deg); }
  50% { transform: scale(1.2) rotate(5deg); }
  70% { transform: scale(0.9) rotate(-3deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.leaderboard-header h2 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  color: var(--color-gold);
  text-shadow: 0 2px 10px rgba(201, 162, 39, 0.4);
  margin: 0;
}

.leaderboard-list {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: var(--space-sm);
  margin-bottom: var(--space-md);
}

.leaderboard-entry {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  margin-bottom: var(--space-xs);
}

.leaderboard-entry:last-child {
  margin-bottom: 0;
}

/* Only animate when entry is newly added */
.leaderboard-entry.animate-in {
  animation: leaderboard-entry-slide 0.3s ease-out forwards;
}

@keyframes leaderboard-entry-slide {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.leaderboard-entry.is-you {
  background: rgba(201, 162, 39, 0.2);
  border: 1px solid var(--color-gold);
}

.leaderboard-rank {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-gold);
  width: 30px;
}

.leaderboard-entry:first-child .leaderboard-rank {
  color: #ffd700;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.leaderboard-name {
  flex: 1;
  text-align: left;
  color: var(--color-cream);
  font-size: 1rem;
}

.you-badge {
  font-size: 0.7rem;
  background: var(--color-gold);
  color: var(--color-forest-dark);
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
  text-transform: uppercase;
}

.leaderboard-waiting {
  margin-top: var(--space-md);
  padding-bottom: var(--space-lg);
}

.leaderboard-waiting p {
  color: var(--color-cream);
  opacity: 0.8;
  font-size: 0.9rem;
  margin-bottom: var(--space-xs);
}

.waiting-names {
  color: var(--color-gold-light);
  font-style: italic;
  font-size: 0.85rem;
}

.waiting-indicator {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: var(--space-lg);
  position: relative;
  width: 36px;
  height: 36px;
  margin-left: auto;
  margin-right: auto;
}

.waiting-indicator-circle {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: radial-gradient(circle, var(--color-gold) 0%, var(--color-gold-dark) 100%);
}

.waiting-indicator-ping {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--color-gold);
  animation: waitingPing 2s ease-out infinite;
}

.waiting-cross {
  position: relative;
  width: 20px;
  height: 20px;
  color: var(--color-cream);
  z-index: 1;
}

@keyframes waitingPing {
  0% {
    transform: scale(1);
    opacity: 0.6;
  }
  100% {
    transform: scale(2);
    opacity: 0;
  }
}

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

.leaderboard-countdown p {
  color: var(--color-cream);
  opacity: 0.8;
  font-size: 0.9rem;
  margin-bottom: var(--space-xs);
}

.leaderboard-countdown .countdown-number {
  display: block;
  font-family: var(--font-display);
  font-size: 3.5rem;
  font-weight: 700;
  color: var(--color-gold);
  text-shadow: 0 4px 15px rgba(201, 162, 39, 0.5);
  transition: transform 0.2s ease;
}

.leaderboard-countdown .countdown-number.tick {
  transform: scale(1.2);
}

/* ============================================
   Aetheric Conduit Maze Activity
   ============================================ */

.maze-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-sm);
}

.maze-instructions {
  text-align: center;
  font-size: 0.9rem;
  color: var(--color-ink-light);
  margin-bottom: var(--space-md);
  font-style: italic;
}

.maze-grid {
  display: grid;
  gap: 2px;
  background: linear-gradient(135deg, var(--color-forest-dark) 0%, #0d1f17 100%);
  padding: 8px;
  border-radius: 8px;
  border: 2px solid var(--color-gold-dark);
  box-shadow:
    inset 0 2px 8px rgba(0,0,0,0.3),
    0 4px 16px rgba(0,0,0,0.2);
  margin: 0 auto;
  width: 100%;
  max-width: 320px;
  aspect-ratio: 1 / 1;
  overflow: hidden;
}

.maze-cell {
  aspect-ratio: 1 / 1;
  background: var(--color-cream-dark);
  border: 1px solid var(--color-forest);
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  box-sizing: border-box;
  overflow: hidden;
}

.maze-cell svg {
  width: 100%;
  height: 100%;
  display: block;
}

.maze-cell:hover:not(.start):not(.end):not(.empty) {
  background: var(--color-parchment);
  border-color: var(--color-gold);
  transform: scale(1.05);
  z-index: 1;
}

.maze-cell.tapped:not(.start):not(.end):not(.empty) {
  transform: scale(0.95);
  background: var(--color-parchment);
  border-color: var(--color-gold);
}

/* Only use :active on non-touch devices */
@media (hover: hover) and (pointer: fine) {
  .maze-cell:active:not(.start):not(.end):not(.empty) {
    transform: scale(0.95);
    background: var(--color-parchment);
    border-color: var(--color-gold);
  }
}

.maze-cell.rotating {
  animation: tileRotate 0.2s ease;
}

@keyframes tileRotate {
  0% { transform: scale(1); }
  50% { transform: scale(0.9); }
  100% { transform: scale(1); }
}

.maze-cell.empty {
  background: transparent;
  border-color: transparent;
  cursor: default;
}

.maze-cell.start {
  background: linear-gradient(135deg, #b8956c 0%, #96785a 100%);
  border-color: #7a6248;
  cursor: default;
  box-shadow: 0 0 8px rgba(180, 140, 100, 0.6);
}

.maze-cell.end {
  background: linear-gradient(135deg, #4a6b5a 0%, #3a5548 100%);
  border-color: #8b7355;
  cursor: default;
  box-shadow: 0 0 8px rgba(100, 140, 120, 0.5);
}

.maze-cell.connected {
  background: linear-gradient(135deg, #8b7355 0%, #6b5344 100%);
  border-color: #5a4636;
  box-shadow: 0 0 6px rgba(180, 140, 100, 0.5);
  animation: connectedPulse 2s ease-in-out infinite;
}

.maze-cell.partial {
  background: linear-gradient(135deg, #d4c4a8 0%, #c4b498 100%);
  border-color: #a89878;
  box-shadow: 0 0 4px rgba(160, 130, 90, 0.3);
}

@keyframes connectedPulse {
  0%, 100% { box-shadow: 0 0 6px rgba(180, 140, 100, 0.5); }
  50% { box-shadow: 0 0 10px rgba(200, 160, 110, 0.7); }
}

.maze-cell svg {
  width: 100%;
  height: 100%;
}

.maze-status {
  text-align: center;
  margin-top: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-cream-dark);
  border-radius: 4px;
  font-size: 0.9rem;
}

.maze-status .status-hint {
  color: var(--color-ink-light);
  font-style: italic;
}

.maze-status .status-success {
  color: var(--color-forest);
  font-weight: 600;
  font-family: var(--font-display);
}

/* Legacy pipe-tile support */
.pipe-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.pipe-grid {
  display: grid;
  gap: 3px;
  background: var(--color-forest-dark);
  padding: 6px;
  border-radius: 8px;
  margin: var(--space-md) auto;
}

.pipe-tile {
  width: 44px;
  height: 44px;
  background: var(--color-cream-dark);
  border: 2px solid var(--color-forest);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.pipe-tile:hover {
  background: var(--color-parchment);
}

.pipe-tile:active {
  transform: scale(0.95);
}

.pipe-tile.source,
.pipe-tile.destination {
  cursor: default;
}

.pipe-tile.source {
  background: linear-gradient(135deg, #b8956c 0%, #96785a 100%);
  border-color: #7a6248;
  box-shadow: 0 0 8px rgba(180, 140, 100, 0.6);
}

.pipe-tile.destination {
  background: linear-gradient(135deg, #4a6b5a 0%, #3a5548 100%);
  border-color: #8b7355;
  box-shadow: 0 0 8px rgba(100, 140, 120, 0.5);
}

.pipe-tile.connected {
  background: linear-gradient(135deg, #8b7355 0%, #6b5344 100%);
  box-shadow: 0 0 6px rgba(180, 140, 100, 0.5);
}

.pipe-tile svg {
  width: 70%;
  height: 70%;
}

.pipe-tile svg path,
.pipe-tile svg line {
  stroke: var(--color-forest);
  stroke-width: 4;
  stroke-linecap: round;
  fill: none;
}

.pipe-tile.connected svg path,
.pipe-tile.connected svg line {
  stroke: #d4c4a8;
}

.pipe-tile.source svg path,
.pipe-tile.source svg line {
  stroke: #4a3828;
}

.pipe-tile.destination svg path,
.pipe-tile.destination svg line {
  stroke: #c4b498;
}

.pipe-status {
  text-align: center;
  font-family: var(--font-display);
  color: var(--color-forest);
  margin-top: var(--space-md);
  font-size: 0.9rem;
}

/* ============================================
   Memory Match Activity
   ============================================ */

.memory-container {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: var(--space-md) auto;
  width: 100%;
  max-width: 280px;
}

.memory-card {
  aspect-ratio: 1;
  perspective: 1000px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.memory-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.5s ease;
  transform-style: preserve-3d;
}

.memory-card:hover .memory-card-inner {
  transform: scale(1.05);
}

.memory-card.flipped .memory-card-inner {
  transform: rotateY(180deg);
}

.memory-card.matched .memory-card-inner {
  transform: rotateY(180deg);
  animation: matchPop 0.3s ease 0.2s;
}

.memory-card-front,
.memory-card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.memory-card-front {
  background: linear-gradient(135deg, var(--color-forest) 0%, var(--color-forest-dark) 100%);
  border: 2px solid var(--color-forest-dark);
}

.memory-card-front::after {
  content: '';
  width: 60%;
  height: 60%;
  border: 2px solid var(--color-gold);
  border-radius: 4px;
  opacity: 0.4;
}

.memory-card-back {
  background: var(--color-cream);
  border: 2px solid var(--color-gold);
  transform: rotateY(180deg);
}

.memory-card-back svg {
  width: 55%;
  height: 55%;
  stroke: var(--color-burgundy);
  stroke-width: 1.5;
  fill: none;
}

.memory-card.matched .memory-card-back {
  background: var(--color-gold-light);
  border-color: var(--color-gold);
}

.memory-card.matched .memory-card-back svg {
  stroke: var(--color-forest-dark);
}

@keyframes matchPop {
  0% { transform: rotateY(180deg) scale(1); }
  50% { transform: rotateY(180deg) scale(1.1); }
  100% { transform: rotateY(180deg) scale(1); }
}

.memory-stats {
  display: flex;
  justify-content: center;
  gap: var(--space-xl);
  margin-top: auto;
  padding-top: var(--space-md);
}

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

.memory-stat-value {
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--color-burgundy);
}

.memory-stat-label {
  font-size: 0.75rem;
  color: var(--color-ink-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ============================================
   Code Entry Activity
   ============================================ */

.code-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-sm);
}

.code-display {
  display: flex;
  gap: 4px;
  margin: var(--space-md) 0;
  flex-wrap: wrap;
  justify-content: center;
}

.code-digit {
  width: 36px;
  height: 48px;
  border: 2px solid var(--color-cream-dark);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  background: white;
  color: var(--color-ink);
}

.code-digit.yours {
  border-color: var(--color-gold);
  background: var(--color-parchment);
  color: var(--color-burgundy);
  box-shadow: 0 0 8px rgba(201, 162, 39, 0.4);
}

.code-digit.hidden {
  background: var(--color-cream-dark);
  color: var(--color-ink-light);
  font-size: 1rem;
}

.code-instructions {
  text-align: center;
  font-size: 0.9rem;
  margin-bottom: var(--space-md);
  color: var(--color-ink-light);
}

.code-your-numbers {
  background: var(--color-parchment);
  padding: var(--space-md);
  border-radius: 8px;
  text-align: center;
  margin-bottom: var(--space-md);
  border: 2px solid var(--color-gold);
  width: 100%;
  max-width: 300px;
}

.code-your-numbers h4 {
  margin-bottom: var(--space-sm);
  color: var(--color-forest);
  font-size: 0.9rem;
}

.code-your-digits {
  display: flex;
  justify-content: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.code-your-digit {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.code-your-digit .digit {
  font-family: var(--font-mono);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-burgundy);
  background: white;
  width: 44px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  border: 2px solid var(--color-gold);
}

.code-your-digit .position {
  font-size: 0.7rem;
  color: var(--color-ink-light);
  margin-top: 4px;
}

.code-status {
  text-align: center;
  padding: var(--space-sm) var(--space-md);
  background: var(--color-cream-dark);
  border-radius: 4px;
  margin-bottom: var(--space-md);
  font-size: 0.9rem;
}

.code-waiting {
  color: var(--color-gold-dark);
}

.code-success {
  color: #28a745;
}

.code-error {
  color: var(--color-burgundy);
}

.waiting-players {
  font-size: 0.85rem;
  color: var(--color-ink-light);
  margin-top: var(--space-sm);
}

/* ============================================
   Decoder Activity
   ============================================ */

.decoder-container {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.professor-note {
  background: linear-gradient(135deg, var(--color-parchment) 0%, var(--color-cream) 100%);
  border: 1px solid var(--color-gold);
  border-left: 4px solid var(--color-gold);
  border-radius: 4px;
  padding: var(--space-md);
  margin-bottom: var(--space-lg);
  position: relative;
}

.professor-note::before {
  content: '"';
  position: absolute;
  top: -5px;
  left: 10px;
  font-size: 2.5rem;
  color: var(--color-gold);
  font-family: var(--font-display);
  line-height: 1;
  opacity: 0.5;
}

.professor-note p {
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--color-ink);
  line-height: 1.6;
  margin: 0;
  padding-left: var(--space-md);
}

.professor-note p em {
  font-style: italic;
}

.professor-note p strong {
  color: var(--color-burgundy);
  font-weight: 600;
}

.professor-note .note-signature {
  text-align: right;
  font-family: var(--font-display);
  font-size: 0.8rem;
  color: var(--color-gold-dark);
  margin-top: var(--space-sm);
  padding-left: 0;
}

/* DEBUG: Remove this entire block before production */
.debug-win-btn {
  position: fixed;
  bottom: 10px;
  right: 10px;
  padding: 8px 12px;
  background: #ff4444;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
  z-index: 9999;
  opacity: 0.7;
}
.debug-win-btn:hover {
  opacity: 1;
}
/* END DEBUG */

.cipher-shift-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  margin-bottom: 0;
  padding: var(--space-sm) var(--space-md);
  background: var(--color-forest);
  border-radius: 8px 8px 0 0;
}

.btn-shift {
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-cream);
  border: 2px solid var(--color-gold);
  border-radius: 50%;
  color: var(--color-burgundy);
  font-size: 0.75rem;
  line-height: 1;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-shift:hover {
  background: var(--color-gold-light);
  transform: scale(1.1);
}

.btn-shift:active {
  transform: scale(0.95);
}

.shift-indicator {
  font-family: var(--font-display);
  font-size: 0.9rem;
  color: var(--color-cream);
  min-width: 80px;
  text-align: center;
}

.shift-indicator #shift-value {
  font-weight: 700;
  color: var(--color-gold-light);
}

.cipher-key {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(32px, 1fr));
  gap: 3px;
  background: var(--color-forest);
  padding: var(--space-sm);
  border-radius: 0 0 8px 8px;
  margin-bottom: var(--space-md);
}

.cipher-pair {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3px;
  background: var(--color-cream);
  border-radius: 3px;
}

.cipher-symbol {
  font-size: 1.1rem;
  color: var(--color-burgundy);
  line-height: 1.2;
}

.cipher-letter {
  font-size: 0.6rem;
  color: var(--color-ink-light);
  font-family: var(--font-mono);
  text-transform: uppercase;
}

.encoded-message {
  background: var(--color-parchment);
  padding: var(--space-md);
  border-radius: 8px;
  text-align: center;
  font-size: 1.3rem;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-md);
  border: 2px solid var(--color-gold);
  word-break: break-all;
  line-height: 1.8;
}

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

.decoder-input {
  width: 100%;
  padding: var(--space-md);
  font-family: var(--font-mono);
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 2px solid var(--color-cream-dark);
  border-radius: 4px;
}

.decoder-input:focus {
  outline: none;
  border-color: var(--color-gold);
}

.decoder-feedback {
  text-align: center;
  padding: var(--space-md);
  border-radius: 4px;
  font-weight: 600;
}

.decoder-feedback.correct {
  background: #d4edda;
  color: #155724;
}

.decoder-feedback.incorrect {
  background: #f8d7da;
  color: var(--color-burgundy-dark);
}

/* ============================================
   Riddle Screen
   ============================================ */

.riddle-card {
  display: flex;
  flex-direction: column;
}

.riddle-card > div {
  padding: var(--space-md);
}

.success-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  background: linear-gradient(135deg, var(--color-gold) 0%, var(--color-gold-dark) 100%);
  color: var(--color-ink);
  padding: var(--space-sm) var(--space-md);
  border-radius: 20px;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 0 auto var(--space-md);
  box-shadow: var(--shadow-glow);
}

.riddle-box {
  text-align: left;
  flex: 1;
}

.riddle-hint-box {
  background: var(--color-cream-dark);
  padding: var(--space-md);
  border-radius: 4px;
  margin-top: var(--space-md);
  text-align: center;
}

.riddle-hint-box p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--color-ink-light);
}

/* ============================================
   Final / Celebration Screen
   ============================================ */

.final-card {
  display: flex;
  flex-direction: column;
}

.final-card > div {
  padding: var(--space-md);
}

.celebration {
  text-align: center;
  padding: var(--space-lg) var(--space-md);
  position: relative;
}

.celebration h1 {
  font-size: 1.5rem;
  margin-bottom: var(--space-md);
  background: linear-gradient(135deg, var(--color-gold) 0%, var(--color-gold-dark) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.celebration .grinch-icon {
  width: 70px;
  height: 70px;
  font-size: 2rem;
}

.celebration .grinch-icon.happy::after {
  content: '★';
  color: var(--color-gold-light);
}

.completion-stats {
  background: var(--color-parchment);
  padding: var(--space-md);
  border-radius: 8px;
  text-align: center;
  margin: var(--space-md) 0;
  border: 2px solid var(--color-gold);
}

.completion-stats h3 {
  margin-bottom: var(--space-sm);
}

.confetti {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 100;
}

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

/* ============================================
   Error Screen
   ============================================ */

.error-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
  text-align: center;
}

.error-icon {
  width: 56px;
  height: 56px;
  background: var(--color-burgundy);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: var(--space-lg);
}

/* ============================================
   Loading / Waiting Screens
   ============================================ */

#loading-screen .card,
#waiting-screen .card,
#redirecting-screen .card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-xl);
}

#waiting-screen h2,
#redirecting-screen h2 {
  margin-bottom: var(--space-md);
}

#player-name-display {
  font-family: var(--font-display);
  color: var(--color-gold-dark);
}

/* ============================================
   Snowfall Effect (Subtle)
   ============================================ */

.snowflakes {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.snowflake {
  position: absolute;
  color: rgba(255, 255, 255, 0.3);
  font-size: 1rem;
  animation: snow-fall linear infinite;
}

@keyframes snow-fall {
  0% {
    transform: translateY(-10px) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(360deg);
    opacity: 0.2;
  }
}

.snowflake:nth-child(1) { left: 5%; animation-duration: 15s; animation-delay: 0s; font-size: 0.7rem; }
.snowflake:nth-child(2) { left: 15%; animation-duration: 12s; animation-delay: 2s; font-size: 0.9rem; }
.snowflake:nth-child(3) { left: 25%; animation-duration: 18s; animation-delay: 4s; font-size: 0.5rem; }
.snowflake:nth-child(4) { left: 35%; animation-duration: 14s; animation-delay: 1s; font-size: 0.8rem; }
.snowflake:nth-child(5) { left: 45%; animation-duration: 16s; animation-delay: 3s; font-size: 0.6rem; }
.snowflake:nth-child(6) { left: 55%; animation-duration: 13s; animation-delay: 5s; font-size: 1rem; }
.snowflake:nth-child(7) { left: 65%; animation-duration: 17s; animation-delay: 0.5s; font-size: 0.7rem; }
.snowflake:nth-child(8) { left: 75%; animation-duration: 11s; animation-delay: 2.5s; font-size: 0.8rem; }
.snowflake:nth-child(9) { left: 85%; animation-duration: 15s; animation-delay: 4.5s; font-size: 0.6rem; }
.snowflake:nth-child(10) { left: 95%; animation-duration: 14s; animation-delay: 1.5s; font-size: 0.9rem; }

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

/* Small phones (iPhone 13, SE, etc) */
@media (max-width: 414px) {
  .maze-grid {
    max-width: calc(100vw - 56px);
    padding: 4px;
    gap: 1px;
  }
}

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

  .memory-grid {
    gap: 4px;
    max-width: 240px;
  }

  .code-digit {
    width: 32px;
    height: 42px;
    font-size: 1.1rem;
  }

  .code-your-digit .digit {
    width: 38px;
    height: 48px;
    font-size: 1.5rem;
  }

  .pipe-tile {
    width: 38px;
    height: 38px;
  }

  .maze-grid {
    max-width: calc(100vw - 40px);
    padding: 4px;
    gap: 1px;
  }

  .maze-instructions {
    font-size: 0.8rem;
  }
}

/* Tablets and larger phones */
@media (min-width: 500px) {
  .screen {
    padding: var(--space-lg);
    justify-content: center;
  }

  .card {
    max-width: 460px;
    margin: 0 auto;
    border-radius: 8px;
    box-shadow: var(--shadow-strong);
    flex: none;
    min-height: 0;
  }

  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.5rem; }

  .story-content {
    font-size: 1rem;
  }

  .memory-grid {
    max-width: 320px;
  }

  .pipe-tile {
    width: 52px;
    height: 52px;
  }

  .maze-grid {
    max-width: 380px;
    padding: 10px;
    gap: 3px;
  }

  .code-digit {
    width: 40px;
    height: 52px;
    font-size: 1.35rem;
  }

  .code-your-digit .digit {
    width: 48px;
    height: 58px;
    font-size: 1.75rem;
  }
}

/* Desktop */
@media (min-width: 768px) {
  .card {
    max-width: 540px;
  }

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

  .maze-grid {
    max-width: 420px;
  }
}

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

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.mt-auto { margin-top: auto; }
.mb-0 { margin-bottom: 0; }

/* ============================================
   Simon Says Activity
   ============================================ */

.simon-container {
  max-width: 400px;
  margin: 0 auto;
  padding: var(--space-md);
}

.simon-status {
  text-align: center;
  margin-bottom: var(--space-md);
}

.simon-your-turn h3,
.simon-watching h3,
.simon-input h3,
.simon-waiting-turn h3 {
  color: var(--color-forest);
  margin-bottom: var(--space-xs);
}

.simon-waiting-turn {
  opacity: 0.9;
}

.simon-wait-message {
  color: var(--color-gold);
  font-style: italic;
  margin-top: var(--space-sm);
}

.simon-failure-notice {
  background: rgba(114, 47, 55, 0.15);
  border: 1px solid var(--color-burgundy);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
  text-align: center;
}

.simon-failure-notice .failure-icon {
  display: inline-block;
  font-size: 1.5rem;
  color: var(--color-burgundy);
  margin-right: var(--space-xs);
}

.simon-failure-notice .failure-reset {
  display: block;
  font-size: 0.85rem;
  color: var(--color-burgundy);
  margin-top: var(--space-xs);
}

.simon-progress {
  text-align: center;
  margin-bottom: var(--space-xl);
  padding: var(--space-md);
}

.progress-label {
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--color-burgundy);
  margin-bottom: var(--space-sm);
  font-weight: 600;
}

.progress-dots {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.progress-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-cream-dark);
  border: 2px solid var(--color-ink-light);
  transition: all 0.3s ease;
}

.progress-dot.completed {
  background: var(--color-forest);
  border-color: var(--color-forest);
}

.progress-dot.current {
  background: var(--color-gold);
  border-color: var(--color-gold);
  transform: scale(1.3);
  box-shadow: 0 0 10px var(--color-gold);
}

.simon-grid-wrapper {
  position: relative;
  max-width: 280px;
  margin: 0 auto var(--space-lg);
}

.simon-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  aspect-ratio: 1;
}

.simon-cell {
  aspect-ratio: 1;
  border-radius: 4px;
  transition: all 0.15s ease;
  /* Unlit bulb - dark glass with shine */
  background:
    linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.15) 0%,
      rgba(255, 255, 255, 0.05) 40%,
      transparent 50%,
      rgba(0, 0, 0, 0.1) 100%
    ),
    linear-gradient(145deg, #4a4540 0%, #3a3530 50%, #2a2520 100%);
  border: 2px solid #5a5550;
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.1),
    0 2px 4px rgba(0, 0, 0, 0.3);
  position: relative;
}

.simon-cell.clickable {
  cursor: pointer;
}

.simon-cell.clickable:hover {
  border-color: #6a6560;
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.15),
    0 4px 8px rgba(0, 0, 0, 0.3);
}

.simon-cell.flash {
  /* Lit bulb - warm filament glow */
  background:
    linear-gradient(
      135deg,
      rgba(255, 200, 150, 0.3) 0%,
      transparent 40%,
      transparent 60%,
      rgba(0, 0, 0, 0.1) 100%
    ),
    radial-gradient(ellipse at 50% 50%, rgba(255, 150, 100, 0.9) 0%, rgba(180, 80, 50, 0.95) 60%, rgba(120, 50, 30, 1) 100%);
  border-color: #8a5540;
  box-shadow:
    0 0 15px rgba(180, 80, 50, 0.7),
    0 0 30px rgba(180, 80, 50, 0.4);
}

.simon-cell.pressed {
  transform: scale(0.97);
  background:
    linear-gradient(
      135deg,
      rgba(255, 200, 150, 0.25) 0%,
      transparent 40%,
      transparent 60%,
      rgba(0, 0, 0, 0.1) 100%
    ),
    radial-gradient(ellipse at 50% 50%, rgba(255, 140, 90, 0.85) 0%, rgba(160, 70, 45, 0.9) 60%, rgba(100, 45, 25, 1) 100%);
  border-color: #7a4535;
  box-shadow:
    0 0 10px rgba(180, 80, 50, 0.6),
    0 0 20px rgba(180, 80, 50, 0.3);
}

.simon-controls {
  text-align: center;
  margin-bottom: var(--space-lg);
}

.simon-controls .btn {
  min-width: 200px;
}

.simon-players {
  border-top: 1px solid var(--color-cream-dark);
  padding-top: var(--space-md);
}

.simon-player-label {
  font-size: 0.85rem;
  color: var(--color-ink-light);
  margin-bottom: var(--space-xs);
}

.simon-player-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

.simon-player {
  padding: var(--space-xs) var(--space-sm);
  background: var(--color-cream-dark);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

.simon-player.current {
  background: var(--color-gold-light);
  color: var(--color-forest-dark);
  font-weight: 600;
}

.simon-player.is-me {
  border: 1px solid var(--color-gold);
}

.turn-indicator {
  margin-left: var(--space-xs);
  animation: pulse 1s ease-in-out infinite;
}

/* ============================================
   Simon Says Overlays - Unified Design System
   ============================================ */

/* Base overlay styles - shared by all overlays */
.simon-overlay-base {
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 20, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  text-align: center;
  padding: var(--space-xl);
}

/* Result overlays (success/failure) */
.simon-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 20, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s ease;
  backdrop-filter: blur(4px);
}

.simon-overlay.active {
  opacity: 1;
}

.simon-overlay .overlay-content {
  text-align: center;
  color: var(--color-cream);
  padding: var(--space-xl);
}

/* Overlay icons */
.simon-overlay .overlay-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto var(--space-lg);
}

.simon-overlay .overlay-icon svg {
  width: 100%;
  height: 100%;
}

/* Overlay label - small uppercase text above main content */
.simon-overlay .overlay-label {
  font-size: 0.85rem;
  color: var(--color-gold);
  text-transform: uppercase;
  letter-spacing: 3px;
  margin-bottom: var(--space-sm);
}

/* Overlay title - main heading */
.simon-overlay h2 {
  font-family: var(--font-display);
  font-size: 2rem;
  margin-bottom: var(--space-md);
  color: var(--color-cream);
}

/* Overlay message - secondary text */
.simon-overlay .overlay-message {
  font-size: 1.2rem;
  color: var(--color-cream);
  opacity: 0.9;
  margin-bottom: var(--space-sm);
}

/* Overlay detail - tertiary/smaller text */
.simon-overlay .overlay-detail {
  font-size: 1rem;
  color: var(--color-gold);
  margin-top: var(--space-md);
}

/* Success overlay specifics */
.simon-overlay.success h2 {
  color: #6ecf8e;
}

.simon-overlay.success .overlay-icon circle {
  stroke: #6ecf8e;
  stroke-width: 3;
  fill: none;
  stroke-dasharray: 166;
  stroke-dashoffset: 166;
  animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.simon-overlay.success .overlay-icon path {
  stroke: #6ecf8e;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.6s forwards;
}

/* Failure overlay specifics */
.simon-overlay.failure h2 {
  color: #ef8f8f;
}

.simon-overlay.failure .overlay-icon circle {
  stroke: #ef8f8f;
  stroke-width: 3;
  fill: none;
  stroke-dasharray: 166;
  stroke-dashoffset: 166;
  animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.simon-overlay.failure .overlay-icon path {
  stroke: #ef8f8f;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.6s forwards;
}

.simon-overlay.failure .overlay-icon {
  animation: failure-pulse 1s ease-in-out infinite;
}

.simon-overlay.failure h2 {
  animation: failure-shake 0.5s ease-in-out;
}

@keyframes failure-shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

@keyframes failure-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.1); opacity: 0.8; }
}

/* Complete overlay specifics */
.simon-overlay.complete h2 {
  font-size: 2.4rem;
}

/* ============================================
   Waiting Overlay (when not your turn)
   ============================================ */
.simon-waiting-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 20, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 500;
  backdrop-filter: blur(4px);
}

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

/* Waiting overlay icon */
.simon-waiting-overlay .overlay-icon {
  width: 70px;
  height: 70px;
  margin: 0 auto var(--space-lg);
  color: var(--color-gold);
  opacity: 0.8;
}

.simon-waiting-overlay .overlay-icon svg {
  width: 100%;
  height: 100%;
  animation: waiting-pulse 2s ease-in-out infinite;
}

@keyframes waiting-pulse {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.05); }
}

/* Waiting overlay label */
.simon-waiting-overlay .overlay-label {
  font-size: 0.85rem;
  color: var(--color-gold);
  text-transform: uppercase;
  letter-spacing: 3px;
  margin-bottom: var(--space-sm);
}

/* Waiting overlay title (player name) */
.simon-waiting-overlay h2 {
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--color-cream);
  margin-bottom: var(--space-md);
}

/* Progress section */
.simon-waiting-overlay .overlay-progress {
  margin-top: var(--space-lg);
  padding-top: var(--space-lg);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.simon-waiting-overlay .overlay-progress-label {
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: var(--space-sm);
}

.simon-waiting-overlay .progress-dots {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.simon-waiting-overlay .progress-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: 2px solid rgba(255, 255, 255, 0.25);
  transition: all 0.3s ease;
}

.simon-waiting-overlay .progress-dot.completed {
  background: #6ecf8e;
  border-color: #6ecf8e;
}

.simon-waiting-overlay .progress-dot.current {
  background: var(--color-gold);
  border-color: var(--color-gold);
  transform: scale(1.2);
  box-shadow: 0 0 8px var(--color-gold);
}

/* Next up section */
.simon-waiting-overlay .next-up-section {
  margin-top: var(--space-xl);
}

.simon-waiting-overlay .overlay-detail {
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: var(--space-xs);
}

.simon-waiting-overlay .next-player-name {
  font-size: 1.1rem;
  color: var(--color-cream);
}

.simon-waiting-overlay .you-are-next {
  font-family: var(--font-display);
  font-size: 1.8rem;
  color: var(--color-gold);
  text-shadow: 0 0 15px rgba(212, 175, 55, 0.4);
  animation: you-next-pulse 2s ease-in-out infinite;
}

@keyframes you-next-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.85; transform: scale(1.03); }
}
