/* style.css - Modern Museum Aesthetic */

:root {
  /* Palette */
  --bg-body: #FDFBF7;
  /* Cream/Paper */
  --bg-card: #FFFFFF;
  /* White */
  --primary-navy: #1B2631;
  /* Midnight Blue */
  --secondary-navy: #2C3E50;
  /* Lighter Navy */
  --gold-accent: #D4AF37;
  /* Antique Gold */
  --text-main: #333333;
  /* Charcoal */
  --text-light: #666666;
  /* Grey */
  --text-white: #FFFFFF;
  --success: #27AE60;
  --error: #C0392B;
  --border-light: #E0E0E0;
  --parchment: #F5ECD9;
  /* Warm parchment for chips, tooltips, etc. */
  --ink: #1F2A37;
  /* Deep ink for text on parchment backgrounds */
  --burgundy: #7D2027;
  /* Alert accent */
  --burgundy-light: #A6453F;
  /* Hover state for alert accents */

  /* Shadows */
  --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.05);
  --shadow-hover: 0 8px 25px rgba(0, 0, 0, 0.1);

  /* Compatibility Variables for JS */
  --primary-blue: var(--primary-navy);
  --secondary-blue: var(--bg-body);
  --light-gray: var(--bg-card);
  --medium-gray: var(--border-light);
  --dark-gray: var(--text-main);
  --white: var(--bg-card);
  --cerise-red: var(--error);
  --hof-top3-gold: #FFD700;
  --hof-top3-silver: #C0C0C0;
  --hof-top3-bronze: #CD7F32;
  --parchment-dark: #f3e7d3;

  /* Timeline Colors */
  --timeline-red-line: #C0392B;
  --timeline-blue-line: #2980B9;
  --timeline-primary-marker: #D4AF37;
  --timeline-current-year-marker: #8E44AD;
}

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

body {
  font-family: 'Lato', sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  margin: 0;
  padding: 20px;
  line-height: 1.6;
}

/* Headers */
h1,
h2,
h3,
h4 {
  font-family: 'Playfair Display', serif;
  color: var(--primary-navy);
  font-weight: 700;
  margin-top: 0;
}

h1 {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

h2 {
  font-size: 1.8rem;
  margin-bottom: 1rem;
}

/* Containers */
.container {
  max-width: 900px;
  margin: 0 auto;
  background-color: var(--bg-card);
  border-radius: 12px;
  box-shadow: var(--shadow-soft);
  padding: 40px;
  position: relative;
  border: 1px solid rgba(0, 0, 0, 0.03);
  transition: all 0.3s ease;
}

/* Utility Classes */
.hidden {
  display: none !important;
}

/* Overlays & Modals */
.overlay {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 0;
}

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

.ai-overlay {
  top: 0;
  left: 0;
  transform: none;
  width: 100%;
  max-width: none;
  max-height: none;
  height: 100%;
  padding: 24px;
  display: none;
  align-items: center;
  justify-content: center;
  inset: 0;
  background: transparent;
}

.ai-overlay:not(.hidden) {
  display: flex;
}

.ai-overlay .modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 0;
}

.ai-overlay .modal-card {
  position: relative;
  z-index: 1;
  background: #0d172c;
  color: #fff;
  max-width: 520px;
  width: 90%;
  border-radius: 14px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.ai-card .modal-header {
  background: rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.ai-card .modal-body {
  padding: 24px 28px;
}

.ai-status-message {
  margin: 0 0 16px;
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.85);
}

.ai-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
}

.ai-stat {
  flex: 1;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ai-stat-label {
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.65);
}

.ai-stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
}

.ai-details {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin-top: 20px;
  padding-top: 16px;
}

.ai-details-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 10px 16px;
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
  appearance: none;
}

.ai-details-toggle:hover,
.ai-details-toggle:focus-visible {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
}

.ai-details-toggle .chevron {
  display: inline-block;
  transition: transform 0.2s ease;
  font-size: 1rem;
  line-height: 1;
}

.ai-details-toggle .chevron::before {
  content: '⌄';
}

.ai-details-toggle[aria-expanded="true"] .chevron {
  transform: rotate(180deg);
}

.ai-details-panel {
  margin-top: 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  padding: 0 16px;
  transition: max-height 0.3s ease, opacity 0.25s ease, padding 0.25s ease;
  pointer-events: none;
}

.ai-details-panel.expanded {
  max-height: 480px;
  opacity: 1;
  padding: 16px;
  pointer-events: auto;
}

.ai-detail-summary {
  margin: 0 0 12px;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.65);
}

.ai-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.ai-detail-metric {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 10px 12px;
}

.ai-detail-label {
  text-transform: uppercase;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.55);
  display: block;
  margin-bottom: 4px;
}

.ai-detail-value {
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
}

.ai-details-panel .ai-status-log {
  margin-top: 12px;
}

.ai-status-log {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 220px;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.ai-status-log li {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.9);
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.ai-status-log li:last-child {
  border-bottom: none;
}

.ai-log-time {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.6);
  min-width: 70px;
  font-family: 'Lato', sans-serif;
}

.ai-log-message {
  flex: 1;
  line-height: 1.4;
}

.button.ghost {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.5);
  color: rgba(255, 255, 255, 0.85);
}

.button.ghost:hover {
  border-color: #fff;
  color: #fff;
}

.expedition-overlay {
  top: 0;
  left: 0;
  transform: none;
  width: 100%;
  max-width: none;
  max-height: none;
  height: 100%;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 2100;
  /* Ensure above full-screen start panel */
}

.expedition-overlay .modal-backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.expedition-overlay .modal-card {
  position: relative;
  z-index: 1;
}

.modal-header {
  background: var(--primary-navy);
  color: var(--text-white);
  padding: 20px 30px;
  border-radius: 12px 12px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h1,
.modal-header h2 {
  color: var(--text-white);
  margin: 0;
  font-size: 1.5rem;
}

.close-icon {
  background: none;
  border: none;
  color: var(--text-white);
  font-size: 1.5rem;
  cursor: pointer;
  opacity: 0.8;
}

.close-icon:hover {
  opacity: 1;
}

.modal-body {
  padding: 30px;
}

.selection-summary {
  list-style: none !important;
  padding: 0;
  margin: 0 0 24px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  width: 100%;
}

@media (min-width: 500px) {
  .selection-summary {
    grid-template-columns: 1fr 1fr;
  }
}

.selection-summary li {
  background: #fff;
  border: 1px solid var(--border-light);
  border-left: 4px solid var(--primary-navy);
  border-radius: 6px;
  padding: 12px 16px;
  font-size: 1rem;
  color: var(--ink);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.selection-summary li strong {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-light);
  margin-bottom: 6px;
  font-weight: 600;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 16px;
  padding: 20px 30px;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  background: #fafafa;
}

.modal-actions.ai-actions {
  gap: 12px;
  padding: 18px 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.15);
}

.expedition-card {
  background: var(--parchment, #fdfbf7);
  width: 90%;
  max-width: 600px;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.05);
  overflow: hidden;
  transform: translateY(20px);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.expedition-overlay:not(.hidden) .expedition-card {
  transform: translateY(0);
}

.expedition-card .modal-header {
  background: rgba(0, 0, 0, 0.03);
  border-bottom: 1px solid var(--border-light);
  padding: 16px 24px;
  color: var(--ink);
}

.expedition-card .header-content {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
}

.expedition-card .header-icon {
  color: var(--primary-navy);
}

.expedition-card .modal-header h2 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.expedition-card .close-icon {
  background: transparent;
  color: var(--text-light);
  padding: 4px;
}

.expedition-card .close-icon:hover {
  color: var(--ink);
  opacity: 1;
}

.expedition-card .modal-body {
  padding: 24px 30px;
}

.expedition-card .intro-text {
  margin-top: 0;
  margin-bottom: 20px;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.5;
}

.expedition-card .helper-wrapper {
  background: rgba(0, 0, 0, 0.02);
  border-radius: 6px;
  padding: 10px 14px;
}

.expedition-card .helper-text {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-light);
  display: flex;
  align-items: center;
  gap: 8px;
}

.expedition-card .info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-light);
  color: #fff;
  font-size: 10px;
  font-weight: bold;
  font-style: normal;
}

.expedition-card .modal-actions {
  background: #fafafa;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  padding: 20px 30px;
  justify-content: flex-end;
  gap: 16px;
}

/* Buttons */
.button {
  display: inline-block;
  padding: 14px 28px;
  font-family: 'Lato', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  margin: 10px 5px;
}

.button.primary {
  background-color: var(--primary-navy);
  color: var(--text-white);
  box-shadow: 0 4px 10px rgba(27, 38, 49, 0.2);
}

.button.primary:hover {
  background-color: var(--gold-accent);
  color: var(--primary-navy);
  transform: translateY(-2px);
}

.button.secondary {
  background-color: transparent;
  border: 2px solid var(--primary-navy);
  color: var(--primary-navy);
}

.button.secondary:hover {
  background-color: rgba(27, 38, 49, 0.05);
}

.expedition-card .button {
  padding: 10px 20px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  display: inline-flex;
  align-items: center;
}

.expedition-card .button.secondary {
  background: transparent;
  color: var(--text-light);
  box-shadow: inset 0 0 0 1px var(--border-light);
}

.expedition-card .button.secondary:hover {
  background: rgba(0, 0, 0, 0.03);
  color: var(--ink);
}

.expedition-card .button.primary {
  background: var(--primary-navy);
  color: var(--text-white);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  gap: 8px;
}

.expedition-card .button.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.expedition-card .button.primary:active {
  transform: translateY(0);
}

/* Start Screen Layout */
.hero-section {
  text-align: center;
  margin-bottom: 40px;
  border-bottom: 2px solid var(--gold-accent);
  padding-bottom: 20px;
}

.subtitle {
  font-style: italic;
  color: var(--text-light);
  font-size: 1.1rem;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 30px;
}

.setting-group label {
  display: block;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--secondary-navy);
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 0.5px;
}

.select-wrapper select {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  font-family: 'Lato', sans-serif;
  font-size: 1rem;
  background: #fff;
  cursor: pointer;
}

.slider-group {
  background: rgba(0, 0, 0, 0.02);
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 30px;
}

.slider-row {
  margin-bottom: 15px;
}

.slider-row:last-child {
  margin-bottom: 0;
}

.slider-row label {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  margin-bottom: 10px;
}

.year-display {
  color: var(--primary-navy);
  font-family: 'Playfair Display', serif;
}

input[type=range] {
  width: 100%;
  cursor: pointer;
}

.action-area {
  text-align: center;
  margin-top: 30px;
}

/* Game Screen */
.game-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 30px;
  background: var(--primary-navy);
  padding: 15px;
  border-radius: 8px;
  color: white;
}

.stat-pill {
  font-weight: 700;
  font-size: 1.1rem;
}

.stat-pill.highlight {
  color: var(--gold-accent);
}

.section-title {
  text-align: center;
  position: relative;
  font-size: 1.4rem;
  margin: 30px 0 15px;
}

.section-title::after {
  content: '';
  display: block;
  width: 50px;
  height: 3px;
  background: var(--gold-accent);
  margin: 10px auto 0;
}

/* Event Cards */
.primary-events-container,
.cards-row {
  display: flex;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
}

.primary-event,
.choice {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 20px;
  box-shadow: var(--shadow-soft);
  transition: all 0.3s ease;
  flex: 1;
  min-width: 250px;
}

.primary-event {
  border-top: 4px solid var(--gold-accent);
}

.event-name {
  font-weight: 700;
  font-size: 1.1rem;
  display: block;
  margin-bottom: 5px;
}

.summary {
  font-size: 0.9rem;
  color: var(--text-light);
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-light);
}

/* Choices */
.choices-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 15px;
}

.choice {
  cursor: pointer;
  border-left: 4px solid transparent;
  text-align: left;
}

.choice:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
  border-left-color: var(--gold-accent);
}

/* Increased specificity to override mobile styles */
#choices .choice.selected,
.choice.selected {
  background-color: var(--primary-navy) !important;
  color: var(--parchment) !important;
  border: 2px solid var(--gold-accent) !important;
  transform: scale(1.02);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
  position: relative;
}

.choice.selected .event-name {
  font-weight: 800;
}

.choice.selected::after {
  content: '✓';
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--gold-accent);
  color: var(--primary-navy);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 14px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

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

/* Feedback */
.feedback {
  text-align: center;
  font-size: 1.2rem;
  font-weight: 700;
  min-height: 1.6em;
  margin: 20px 0;
}

.feedback span.correct {
  color: var(--success);
}

.feedback span.wrong {
  color: var(--error);
}

.mode-note {
  text-align: center;
  margin: 15px auto 5px;
  color: var(--text-light);
  max-width: 420px;
}

/* Timeline */
.canvas-wrapper {
  width: 100%;
  overflow-x: auto;
  background: #fff;
  border-top: 1px solid var(--border-light);
  padding: 20px 0;
}

#timelineCanvas {
  display: block;
  margin: 0 auto;
  /* Removed max-width to allow horizontal scrolling */
}

/* Hall of Fame List Style */
#hallOfFameList ol,
.mini-hof ol {
  list-style: none;
  padding: 0;
  margin: 0;
}

#hallOfFameList li,
.mini-hof li {
  display: flex;
  justify-content: space-between;
  padding: 12px;
  border-bottom: 1px solid var(--border-light);
  align-items: center;
}

.rank-1,
.rank-2,
.rank-3 {
  font-weight: bold;
  border-radius: 6px;
  margin-bottom: 5px;
  padding: 15px !important;
}

.rank-1 {
  background: rgba(255, 215, 0, 0.15);
  border: 1px solid var(--hof-top3-gold) !important;
}

.rank-2 {
  background: rgba(192, 192, 192, 0.15);
  border: 1px solid var(--hof-top3-silver) !important;
}

.rank-3 {
  background: rgba(205, 127, 50, 0.15);
  border: 1px solid var(--hof-top3-bronze) !important;
}

.hof-score {
  font-weight: 700;
  color: var(--primary-navy);
}

/* Hint Button */
.hint-area {
  text-align: right;
  margin-bottom: 10px;
}

.hint-icon-button {
  background: #fff;
  border: 1px solid var(--gold-accent);
  color: var(--primary-navy);
  padding: 5px 10px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  transition: background 0.2s ease, color 0.2s ease;
}

.hint-icon-button .hint-text {
  margin-left: 4px;
}

.hint-icon-button:hover:not(:disabled) {
  background: var(--gold-accent);
  color: white;
}

.hint-icon-button:disabled,
.hint-icon-button.used {
  background-color: var(--medium-gray);
  color: var(--dark-gray);
  opacity: 0.6;
  cursor: not-allowed;
  border-color: var(--medium-gray);
  box-shadow: none;
}

.choice.hint-removed {
  opacity: 0.4;
  pointer-events: none;
  text-decoration: line-through;
  transition: opacity 0.3s ease, background-color 0.3s ease;
  background-color: var(--parchment-dark);
  border-style: dashed;
  box-shadow: none;
}

.choice.hint-removed:hover {
  background-color: var(--parchment-dark);
  transform: none;
}

.hint-penalty {
  font-size: 0.9em;
  color: var(--text-light);
  font-style: italic;
  margin-left: 4px;
}

/* Auth Page Specifics (Shared Classes) */
#auth-container,
#login-container,
#register-container,
#reset-container {
  max-width: 450px;
  margin: 60px auto;
  background: var(--bg-card);
  padding: 40px;
  border-radius: 12px;
  box-shadow: var(--shadow-soft);
  text-align: center;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 12px;
  margin-bottom: 15px;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  font-size: 1rem;
  box-sizing: border-box;
}

input:focus {
  border-color: var(--primary-navy);
  outline: none;
}

/* Mobile Responsive Overrides (Iteration 2) */
@media (max-width: 768px) {
  body {
    padding: 0;
    /* Remove body padding for full width feel */
    background-color: var(--parchment-dark);
    /* Ensure background covers all */
  }

  .container {
    padding: 15px;
    width: 100%;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
    /* Remove container shadow for cleaner look */
  }

  h1 {
    font-size: 1.6rem;
    margin-bottom: 0.2rem;
  }

  h2 {
    font-size: 1.3rem;
    margin-bottom: 0.6rem;
  }

  .subtitle {
    font-size: 0.9rem;
  }

  /* Compact Toolbar */
  .toolbar {
    flex-direction: row;
    /* Keep row but wrap if needed */
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px;
    justify-content: space-between;
    position: relative;
    /* For absolute nav menu */
    z-index: 2001;
    /* Ensure above overlays */
  }

  .toolbar-left {
    width: auto;
    justify-content: flex-start;
  }

  .toolbar h2 {
    font-size: 1rem;
    /* Smaller logo text */
  }

  .toolbar-right {
    width: auto;
    gap: 5px;
  }

  /* Mobile Menu */
  .mobile-menu-btn {
    display: block;
    /* Show on mobile */
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    font-size: 1.2rem;
    padding: 4px 10px;
    color: white;
    /* Ensure visible */
  }

  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    width: 200px;
    background: var(--primary-navy);
    flex-direction: column;
    padding: 10px;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 1000;
  }

  .nav-links.active {
    display: flex;
  }

  .nav-links .nav-btn {
    width: 100%;
    text-align: left;
    margin-bottom: 5px;
    display: block;
    /* Ensure they show */
  }

  /* Start Screen - Full Screen Setup Overhaul */
  #startScreen .start-panel:not(.collapsed) {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-body);
    z-index: 2000;
    overflow-y: auto;
    padding: 60px 20px 20px;
    /* Top padding for close button */
    display: flex;
    flex-direction: column;
  }

  .mobile-close-panel-btn {
    display: block;
    position: absolute;
    top: 15px;
    right: 15px;
    background: var(--primary-navy);
    color: white;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    z-index: 2001;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  }

  .settings-grid {
    grid-template-columns: 1fr;
    gap: 20px;
    margin-bottom: 25px;
  }

  .select-wrapper select {
    padding: 16px;
    /* Larger touch target */
    font-size: 18px;
    /* Readable */
  }

  .slider-group {
    padding: 20px;
    background: rgba(255, 255, 255, 0.5);
  }

  /* Larger Era Scrollers */
  input[type=range] {
    height: 30px;
    /* Taller track area */
  }

  /* Larger Categories */
  .choices-grid {
    grid-template-columns: 1fr 1fr;
    /* 2 columns for categories */
    gap: 12px;
  }

  .choice,
  .category-chip {
    padding: 15px;
    min-height: 60px;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
  }

  /* Compact Game Header */
  .game-header {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px;
    align-items: center;
    justify-content: space-between;
    background: var(--primary-navy);
    color: white;
    border-radius: 8px;
    margin-bottom: 15px;
  }

  .stat-pill {
    font-size: 0.9rem;
    width: auto;
    /* Auto width */
    border-bottom: none;
    padding: 4px 8px;
    margin: 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    flex: 1 1 auto;
    /* Allow flex grow/shrink */
    text-align: center;
    display: block;
    /* Reset flex display from desktop */
  }

  .stat-pill span {
    font-weight: bold;
    display: inline-block;
    margin-left: 4px;
  }

  .section-title {
    font-size: 1.1rem;
    margin: 15px 0 8px;
    padding-left: 5px;
    border-left: 4px solid var(--gold-accent);
  }

  /* Horizontal Scroll for Primary Events */
  .primary-events-container {
    flex-direction: row;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: 12px;
    padding-bottom: 10px;
    /* Space for scrollbar */
    margin: 0 -15px;
    /* Negative margin to touch edges */
    padding-left: 15px;
    /* Restore padding */
    padding-right: 15px;
  }

  .primary-event {
    min-width: 85vw;
    /* Show mostly one card */
    width: 85vw;
    scroll-snap-align: center;
    padding: 15px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border-light);
    background: white;
  }

  /* Vertical Stack for Choices (In Game) */
  #choices.choices-grid {
    grid-template-columns: 1fr;
    /* Stack choices in game */
    gap: 10px;
    padding-bottom: 80px;
    /* Space for sticky footer */
  }

  #choices .choice {
    padding: 14px;
    min-height: 50px;
    font-size: 0.95rem;
    background: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border-light);
    justify-content: flex-start;
    /* Align text left for game choices */
    text-align: left;
  }

  .choice:active {
    background-color: var(--parchment);
    transform: scale(0.98);
  }

  /* Sticky Action Footer */
  .game-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: white;
    padding: 12px 15px;
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.1);
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
  }

  .game-footer .feedback {
    font-size: 0.9rem;
    margin-bottom: 0;
    flex: 1;
    text-align: left;
  }

  .game-footer .button {
    margin: 0;
    width: auto;
    min-width: 120px;
    padding: 12px 20px;
  }

  /* Modals - Scroll Fix & Action Wrap */
  .overlay {
    padding: 0;
    align-items: flex-end;
    /* Sheet-like appearance */
    display: flex;
  }

  .modal-card {
    height: 90vh;
    /* Almost full height */
    max-height: 90vh;
    border-radius: 16px 16px 0 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    /* Stack children */
  }

  .modal-header {
    border-radius: 16px 16px 0 0;
    flex: 0 0 auto;
    /* Don't shrink */
  }

  .modal-body {
    flex: 1 1 auto;
    /* Grow and shrink */
    overflow-y: auto;
    /* Scrollable */
    min-height: 0;
    /* Flexbox fix for scrolling */
    padding-bottom: 20px;
  }

  .modal-actions {
    flex: 0 0 auto;
    /* Don't shrink */
    background: white;
    border-top: 1px solid var(--border-light);
    padding: 15px;
    position: sticky;
    bottom: 0;
    display: flex;
    flex-wrap: wrap;
    /* Allow wrapping */
    justify-content: center;
    /* Center buttons */
    gap: 10px;
  }

  .modal-actions .button {
    flex: 1 1 auto;
    /* Grow to fill space */
    min-width: 140px;
    /* Minimum width */
    margin: 0;
  }

  /* Timeline */
  .canvas-wrapper {
    margin: 0 -15px;
    padding: 10px 15px;
    background: rgba(255, 255, 255, 0.5);
  }

  /* Auth Pages */
  #auth-container,
  #login-container,
  #register-container,
  #reset-container {
    margin: 10px auto;
    padding: 20px;
    width: 100%;
    box-shadow: none;
    background: transparent;
  }

  #auth-container .card,
  #login-container .card {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
  }
}

/* Desktop Menu Button & Close Button Hidden */
.mobile-menu-btn,
.mobile-close-panel-btn {
  display: none;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.container {
  animation: fadeIn 0.5s ease-out;
}

/* Flag styling */
.event-flag {
  height: 16px;
  width: auto;
  margin-right: 8px;
  border-radius: 2px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.custom-category-section {
  margin: 20px 0;
  padding: 15px;
  border: 1px dashed var(--gold-accent);
  background: rgba(253, 251, 247, 0.5);
  border-radius: 8px;
}

.start-panel {
  transition: max-height 0.3s ease-out;
  overflow: hidden;
}

.start-panel.collapsed {
  max-height: 0;
}

.start-card-toggle {
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  padding: 15px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-light);
}

.start-card {
  border: 1px solid var(--border-light);
  border-radius: 8px;
  margin-bottom: 20px;
  background: #fff;
}

/* Mobile Timeline Styles */
#timelineModal {
  z-index: 2000;
  /* High z-index to cover everything */
  background: rgba(0, 0, 0, 0.95);
}

#timelinePopup {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  padding: 20px;
  border-radius: 12px;
  max-width: 90%;
  max-height: 80%;
  overflow-y: auto;
  z-index: 2100;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  text-align: center;
  color: #333;
}

#timelinePopup h3 {
  margin-top: 0;
  color: #1a237e;
}

#timelinePopup img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 10px 0;
}

#viewTimelineBtn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1500;
  padding: 12px 24px;
  background: linear-gradient(135deg, #ff6f00, #bf360c);
  color: white;
  border: none;
  border-radius: 50px;
  font-weight: bold;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  display: none;
  /* Hidden by default */
  cursor: pointer;
}

@media (max-width: 768px) and (orientation: landscape) {

  /* Hide non-timeline elements in landscape */
  .game-container,
  header,
  footer {
    display: none !important;
  }

  #timelineModal {
    display: flex !important;
    /* Force show */
  }
}

/* Mobile Timeline Controls - Moved to Footer */
#viewTimelineBtn {
  padding: 8px 15px;
  font-size: 0.9rem;
  border-radius: 20px;
  white-space: nowrap;
  min-width: auto;
  /* Override footer button min-width */
  flex: 0 0 auto;
  /* Don't grow */
  box-shadow: none;
  border: 1px solid var(--gold-accent);
}

#viewTimelineBtn.hidden {
  display: none;
}

/* Reset View Button (Landscape) */
#resetViewBtn {
  position: absolute;
  bottom: 15px;
  right: 15px;
  z-index: 3003;
  background: rgba(255, 255, 255, 0.8);
  color: var(--primary-navy);
  border: 1px solid var(--primary-navy);
  padding: 8px 12px;
  font-size: 0.8rem;
  border-radius: 4px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

#resetViewBtn.hidden {
  display: none;
}

/* Timeline Modal - Fullscreen Overlay */
#timelineModal.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 3000;
  /* Very high z-index */
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

#timelineModal.modal:not(.hidden) {
  opacity: 1;
  pointer-events: auto;
}

#timelineModal .modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
}

.timeline-modal-card {
  position: relative;
  z-index: 3001;
  width: 95%;
  max-width: 100%;
  height: 85vh;
  background: var(--bg-card);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.timeline-modal-card .modal-body {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  background: var(--parchment);
  padding: 0;
  -webkit-overflow-scrolling: touch;
  /* Smooth scrolling on iOS */
}

.timeline-modal-card .canvas-wrapper {
  min-width: 100%;
  padding: 20px;
}

#mobileTimelineCanvas {
  display: block;
}

@media (max-width: 768px) {

  /* Hide inline timeline on mobile */
  .game-screen .canvas-wrapper {
    display: none;
  }

  /* Show mobile controls */
  #mobileTimelineControls {
    display: block;
  }

  /* Ensure modal canvas scrolls */
  #mobileTimelineCanvas {
    width: 900px;
    /* Force width */
  }
}

@media (orientation: landscape) and (max-width: 900px) {
  .timeline-modal-card {
    height: 100vh;
    width: 100%;
    border-radius: 0;
    max-width: none;
  }

  /* Clean Landscape View */
  .landscape-mode .modal-header h2,
  .landscape-mode .modal-actions {
    display: none !important;
  }

  .landscape-mode .modal-header {
    position: absolute;
    top: 10px;
    right: 10px;
    background: transparent;
    padding: 0;
    z-index: 3002;
    width: auto;
    border-radius: 0;
  }

  .landscape-mode .close-modal-btn {
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    cursor: pointer;
  }

  .landscape-mode .modal-body {
    padding: 0;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    /* No scrolling needed if fitToScreen works */
  }

  .landscape-mode .canvas-wrapper {
    padding: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Landscape Popup */
  #timelinePopup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3005;
    /* Above modal content */
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    /* Dim background */
    backdrop-filter: blur(2px);
  }

  #timelinePopup.hidden {
    display: none;
  }

  #timelinePopup .popup-content {
    background: white;
    padding: 25px;
    border-radius: 12px;
    width: 70%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    border: 2px solid var(--gold-accent);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  }

  @keyframes popIn {
    from {
      transform: scale(0.8);
      opacity: 0;
    }

    to {
      transform: scale(1);
      opacity: 1;
    }
  }

  #timelinePopup h3 {
    color: var(--primary-navy);
    margin-bottom: 5px;
    font-size: 1.2rem;
  }

  #timelinePopup #popupYear {
    font-weight: bold;
    color: var(--gold-accent);
    font-size: 1.1rem;
    margin-bottom: 15px;
  }

  #timelinePopup #popupDescription {
    font-size: 0.95rem;
    line-height: 1.4;
    margin-bottom: 20px;
    color: #444;
  }

  #timelinePopup .tap-to-close {
    font-size: 0.8rem;
    color: #888;
    margin-top: 10px;
    font-style: italic;
  }
}
