/* ============================================================
   The Straits Crossword — Design System
   ============================================================
   Tokens: hibiscus red, pandan green, turmeric gold, deep navy
   Fonts: Young Serif (headings), Schibsted Grotesk (ui)
   ============================================================ */

/* --- Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Young+Serif&family=Schibsted+Grotesk:wght@400;500;600;700&display=swap');

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

:root {
  /* Colors */
  --hibiscus: #C73B3B;
  --hibiscus-dark: #9E2B2B;
  --hibiscus-light: #E86B6B;
  --pandan: #4A8C5C;
  --pandan-dark: #3A7050;
  --pandan-light: #6BBF7E;
  --turmeric: #D4A017;
  --turmeric-dark: #B8860B;
  --turmeric-light: #F0C75E;
  --navy: #1A2A3A;
  --navy-light: #2C4058;
  --cream: #FDF8F0;
  --cream-dark: #F5EDE0;
  --white: #FFFFFF;
  --ink: #1A1A2E;
  --ink-light: #4A4A5A;
  --gray-100: #F5F5F5;
  --gray-200: #E0E0E0;
  --gray-300: #C0C0C0;
  --gray-400: #909090;
  --gray-500: #606060;
  --gray-600: #404040;
  --success: #2E7D32;
  --error: #C62828;
  --warning: #F57F17;

  /* Typography */
  --font-display: 'Young Serif', Georgia, serif;
  --font-ui: 'Schibsted Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Sizing */
  --cell-size: 32px;
  --cell-size-mobile: clamp(24px, 4.5vw, 34px);

  /* Borders */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 20px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);

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

/* --- Dark Mode --- */
[data-theme="dark"] {
  --cream:            #1C1A17;
  --cream-dark:       #141210;
  --white:            #252220;
  --surface-hover:    #2E2B27;
  --surface-elevated: #363028;
  --ink:              #EDEBE6;
  --ink-light:        #9E9890;
  --gray-100:         #2E2B27;
  --gray-200:         #3D3830;
  --gray-300:         #524D47;
  --gray-400:         #6A6058;
  --gray-500:         #908880;
  --gray-600:         #B0A898;
  --navy:             #0D1B2A;
  --navy-light:       #1B2838;
  --hibiscus:         #E06060;
  --hibiscus-dark:    #C73B3B;
  --hibiscus-light:   #F08585;
  --pandan:           #5CA870;
  --pandan-dark:      #4A8C5C;
  --pandan-light:     #7ACC8E;
  --turmeric:         #E8B840;
  --turmeric-dark:    #D4A017;
  --turmeric-light:   #F5CE6A;
  --success:          #4CAF50;
  --error:            #EF5350;
  --warning:          #FFB300;
  --shadow-sm:        0 1px 3px rgba(0,0,0,0.35);
  --shadow-md:        0 4px 12px rgba(0,0,0,0.45);
  --shadow-lg:        0 8px 24px rgba(0,0,0,0.55);
}

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

body {
  font-family: var(--font-ui);
  background: var(--cream);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--pandan);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover { color: var(--pandan-dark); }

img { max-width: 100%; height: auto; }

/* --- Layout Container --- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-md);
}

/* --- Header --- */
.site-header {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  color: var(--white);
  padding: var(--space-md) 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}

.site-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}
.site-title .hibiscus-icon {
  display: inline-block;
  font-size: 1.4em;
  line-height: 1;
}

.site-title a {
  color: inherit;
}
.site-title a:hover {
  color: var(--turmeric-light);
}

/* --- Navigation --- */
.main-nav {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.main-nav a {
  color: rgba(255,255,255,0.75);
  font-size: 0.875rem;
  font-weight: 500;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  white-space: nowrap;
}
.main-nav a:hover,
.main-nav a.active {
  color: #FFFFFF;
  background: rgba(255,255,255,0.15);
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--white);
  font-size: 1.5rem;
  cursor: pointer;
  padding: var(--space-xs);
}

/* --- Theme Toggle --- */
.theme-toggle {
  background: none;
  border: 1px solid rgba(255,255,255,0.2);
  color: var(--white);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: all var(--transition-fast);
}
.theme-toggle:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.4);
}

/* --- Hero / Masthead --- */
.masthead {
  text-align: center;
  padding: var(--space-2xl) var(--space-md) var(--space-xl);
  background: linear-gradient(180deg, var(--cream-dark) 0%, var(--cream) 100%);
  border-bottom: 4px solid var(--turmeric);
}

.masthead h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3rem);
  color: var(--navy);
  margin-bottom: var(--space-sm);
}

.masthead .batik-band {
  height: 8px;
  background: repeating-linear-gradient(
    90deg,
    var(--hibiscus) 0px,
    var(--hibiscus) 12px,
    var(--turmeric) 12px,
    var(--turmeric) 24px,
    var(--pandan) 24px,
    var(--pandan) 36px
  );
  width: 100%;
  max-width: 400px;
  margin: var(--space-md) auto;
  border-radius: 4px;
}

.masthead p {
  font-size: 1.1rem;
  color: var(--ink-light);
  max-width: 600px;
  margin: 0 auto;
}

/* --- Page Content --- */
.page-content {
  padding: var(--space-xl) 0;
}

.page-title {
  font-family: var(--font-display);
  font-size: 1.75rem;
  margin-bottom: var(--space-lg);
  color: var(--navy);
}

/* --- Puzzle Cards Grid --- */
.puzzle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-lg);
  margin: var(--space-xl) 0;
}

.puzzle-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  transition: all var(--transition-normal);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.puzzle-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
}

.puzzle-card[data-theme="peninsula"]::before { background: var(--navy); }
.puzzle-card[data-theme="makan"]::before { background: var(--turmeric); }
.puzzle-card[data-theme="island"]::before { background: var(--pandan); }
.puzzle-card[data-theme="heritage"]::before { background: var(--hibiscus); }
.puzzle-card[data-theme="daily"]::before { background: var(--turmeric-light); }

.puzzle-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.puzzle-card h3 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  margin-bottom: var(--space-xs);
  color: var(--navy);
}

.puzzle-card .card-meta {
  font-size: 0.8rem;
  color: var(--gray-400);
  margin-bottom: var(--space-sm);
}

.puzzle-card p {
  font-size: 0.9rem;
  color: var(--ink-light);
  margin-bottom: var(--space-md);
}

.puzzle-card .play-btn {
  display: inline-block;
  background: var(--pandan);
  color: var(--white);
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  transition: background var(--transition-fast);
}
.puzzle-card .play-btn:hover {
  background: var(--pandan-dark);
}

.daily-badge {
  display: inline-block;
  background: var(--turmeric);
  color: var(--navy);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-xs);
}

/* --- Daily Highlight --- */
.daily-highlight {
  background: var(--white);
  border: 2px solid var(--turmeric);
  border-radius: var(--radius-lg);
  padding: var(--space-lg) var(--space-xl);
  text-align: center;
  margin-bottom: var(--space-xl);
  max-width: 680px;
  margin-left: auto;
  margin-right: auto;
}

.daily-highlight h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  margin-bottom: var(--space-xs);
}

.daily-highlight .daily-date {
  color: var(--gray-400);
  margin-bottom: var(--space-xs);
  font-size: 0.85rem;
}

.daily-highlight .daily-desc {
  color: var(--ink-light);
  margin-bottom: var(--space-sm);
  font-size: 0.95rem;
}

.daily-highlight .meta-chips {
  display: flex;
  justify-content: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
}

.daily-highlight .meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--gray-100);
  color: var(--ink-light);
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 500;
}

[data-theme="dark"] .daily-highlight .meta-chip {
  background: var(--gray-200);
}

.daily-highlight .cta-btn {
  display: inline-block;
  background: var(--hibiscus);
  color: var(--white);
  padding: var(--space-sm) var(--space-xl);
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 600;
  transition: background var(--transition-fast);
}
.daily-highlight .cta-btn:hover {
  background: var(--hibiscus-dark);
}

/* --- Leaderboard Teaser --- */
.leaderboard-teaser {
  margin: var(--space-xl) 0;
  padding: var(--space-lg);
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.leaderboard-teaser h3 {
  font-family: var(--font-display);
  margin-bottom: var(--space-md);
}

.leaderboard-teaser table {
  width: 100%;
  border-collapse: collapse;
}

.leaderboard-teaser th,
.leaderboard-teaser td {
  padding: var(--space-xs) var(--space-sm);
  text-align: left;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--gray-200);
}

.leaderboard-teaser th {
  font-weight: 600;
  color: var(--gray-500);
  font-size: 0.75rem;
  text-transform: uppercase;
}

.leaderboard-teaser .rank {
  font-weight: 700;
  color: var(--gray-400);
  width: 30px;
}

.leaderboard-teaser .rank-1 { color: var(--turmeric); }
.leaderboard-teaser .rank-2 { color: var(--gray-400); }
.leaderboard-teaser .rank-3 { color: var(--hibiscus); }

.view-all-link {
  display: block;
  text-align: center;
  margin-top: var(--space-sm);
  font-size: 0.85rem;
  font-weight: 600;
}

/* --- Grid Game Area --- */
.game-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: var(--space-lg);
  align-items: start;
  max-width: 900px;
  margin: 0 auto;
}

@media (max-width: 768px) {
  .game-layout {
    grid-template-columns: 1fr;
  }
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.game-header .puzzle-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
}

.game-controls {
  display: flex;
  gap: var(--space-xs);
  flex-wrap: wrap;
}

.game-btn {
  background: var(--white);
  border: 1px solid var(--gray-200);
  color: var(--ink);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  cursor: pointer;
  font-family: var(--font-ui);
  font-weight: 500;
  transition: all var(--transition-fast);
  white-space: nowrap;
}
.game-btn:hover {
  background: var(--gray-100);
  border-color: var(--gray-300);
}
.game-btn:active {
  transform: scale(0.96);
}
.game-btn.primary {
  background: var(--pandan);
  color: var(--white);
  border-color: var(--pandan);
}
.game-btn.primary:hover {
  background: var(--pandan-dark);
  border-color: var(--pandan-dark);
}
.game-btn.danger {
  color: var(--error);
  border-color: var(--error);
}
.game-btn.danger:hover {
  background: var(--error);
  color: var(--white);
}

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

/* --- Clue Bar --- */
.clue-bar {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-height: 48px;
}

.clue-bar .clue-direction {
  font-weight: 700;
  color: var(--pandan);
  font-size: 0.75rem;
  text-transform: uppercase;
  min-width: 50px;
}

.clue-bar .clue-text {
  flex: 1;
  font-size: 0.9rem;
  line-height: 1.4;
}

.clue-bar .clue-number {
  font-weight: 700;
  color: var(--navy);
  margin-right: var(--space-xs);
}

.clue-bar .clue-nav {
  display: flex;
  gap: var(--space-xs);
}

.clue-bar .clue-nav button {
  background: none;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  width: 30px;
  height: 30px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  color: var(--ink);
  transition: all var(--transition-fast);
}
.clue-bar .clue-nav button:hover {
  background: var(--gray-100);
}

/* --- Crossword Grid --- */
.grid-container {
  position: relative;
  aspect-ratio: 1;
  max-width: 500px;
  width: 100%;
  margin: 0 auto;
}

.crossword-grid {
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  grid-template-rows: repeat(15, 1fr);
  gap: 1px;
  background: var(--ink);
  border: 2px solid var(--ink);
  border-radius: var(--radius-sm);
  overflow: hidden;
  width: 100%;
  height: 100%;
}

.cell {
  background: var(--white);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(0.7rem, 2vw, 1.1rem);
  font-weight: 600;
  font-family: var(--font-ui);
  text-transform: uppercase;
  cursor: pointer;
  transition: background var(--transition-fast);
  user-select: none;
  -webkit-user-select: none;
  aspect-ratio: 1;
}

.cell.block {
  background: var(--ink);
  cursor: default;
}

.cell .cell-number {
  position: absolute;
  top: 1px;
  left: 2px;
  font-size: 0.5rem;
  font-weight: 500;
  color: var(--gray-400);
  line-height: 1;
  pointer-events: none;
}

.cell.selected {
  background: var(--turmeric-light);
}

.cell.highlighted {
  background: #E8F5E9;
}

.cell.correct {
  color: var(--ink);
}

.cell.wrong {
  color: var(--error);
  text-decoration: line-through;
  text-decoration-color: var(--error);
}

.cell.revealed {
  color: var(--navy);
  font-weight: 700;
}

.cell.focused {
  outline: 2px solid var(--pandan);
  outline-offset: -2px;
  z-index: 2;
}

.cell.completed {
  color: var(--success);
}

.cell.inactive {
  color: var(--gray-300);
}

[data-theme="dark"] .crossword-grid {
  background: #3D3830;
  border-color: #524D47;
}
[data-theme="dark"] .cell {
  background: #2A2720;
  color: #EDEBE6;
}
[data-theme="dark"] .cell.block {
  background: #0A0908;
  color: #1C1A17;
}
[data-theme="dark"] .cell.selected {
  background: #E8B840;
  color: #1C1A17;
  border-color: #E8B840;
}
[data-theme="dark"] .cell.highlighted {
  background: #1E3325;
  border-color: #2D5A3A;
}
[data-theme="dark"] .cell.correct {
  color: #5CA870;
}
[data-theme="dark"] .cell.wrong {
  color: #EF5350;
}
[data-theme="dark"] .cell.completed {
  color: #5CA870;
  background: #1E3325;
  border-color: #2D5A3A;
}
[data-theme="dark"] .cell.revealed {
  color: #908880;
  font-weight: 700;
}
[data-theme="dark"] .cell.focused {
  outline: 2px solid var(--pandan-light);
  outline-offset: -2px;
}
[data-theme="dark"] .cell .cell-number {
  color: #6A6058;
}

/* --- Clue Lists --- */
.clue-panel {
  background: var(--white);
  border-radius: var(--radius-md);
  border: 1px solid var(--gray-200);
  overflow: hidden;
}

.clue-panel-header {
  display: flex;
  border-bottom: 1px solid var(--gray-200);
}

.clue-panel-header button {
  flex: 1;
  padding: var(--space-sm);
  border: none;
  background: none;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--gray-400);
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
}
.clue-panel-header button.active {
  color: var(--navy);
  border-bottom-color: var(--pandan);
}
.clue-panel-header button:hover {
  color: var(--ink);
}

.clue-list {
  max-height: 400px;
  overflow-y: auto;
  padding: var(--space-xs) 0;
}

.clue-item {
  padding: var(--space-xs) var(--space-md);
  font-size: 0.8rem;
  cursor: pointer;
  transition: background var(--transition-fast);
  display: flex;
  align-items: baseline;
  gap: var(--space-sm);
  border-left: 3px solid transparent;
}
.clue-item:hover {
  background: var(--gray-100);
}
.clue-item.active {
  background: #FFF8E1;
  border-left-color: var(--turmeric);
}
.clue-item.done {
  text-decoration: line-through;
  color: var(--gray-400);
}
.clue-item .ci-number {
  font-weight: 700;
  color: var(--navy);
  min-width: 24px;
}
.clue-item .ci-text {
  flex: 1;
}
.clue-item .ci-length {
  color: var(--gray-400);
  font-size: 0.7rem;
}

/* --- Timer --- */
.timer {
  font-family: var(--font-ui);
  font-size: 1rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--navy);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.timer .timer-icon {
  font-size: 1.1rem;
}

.timer.paused {
  color: var(--gray-400);
}

/* --- Completion Screen --- */
.completion-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--space-md);
  animation: fadeIn 300ms ease;
}

.completion-panel {
  background: var(--white);
  border-radius: var(--radius-xl);
  max-width: 420px;
  width: 100%;
  padding: var(--space-2xl);
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: slideUp 300ms ease;
}

.completion-panel .hibiscus-bloom {
  font-size: 3rem;
  margin-bottom: var(--space-md);
  display: block;
}

.completion-panel h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  margin-bottom: var(--space-sm);
}

.completion-panel .completion-time {
  font-size: 2rem;
  font-weight: 700;
  color: var(--pandan);
  margin: var(--space-md) 0;
  font-variant-numeric: tabular-nums;
}

.completion-panel .star-rating {
  font-size: 1.5rem;
  margin-bottom: var(--space-md);
  color: var(--turmeric);
}

.completion-panel p {
  color: var(--ink-light);
  margin-bottom: var(--space-md);
  font-size: 0.9rem;
}

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

.completion-panel .completion-actions .game-btn {
  padding: var(--space-sm) var(--space-lg);
  font-size: 0.9rem;
}

.completion-panel .leaderboard-form {
  margin-top: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.completion-panel .leaderboard-form input {
  padding: var(--space-sm);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  text-align: center;
}

.completion-panel .leaderboard-form .submit-status {
  font-size: 0.8rem;
  color: var(--gray-400);
}

/* --- Leaderboard Page --- */
.leaderboard-tabs {
  display: flex;
  gap: var(--space-xs);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}

.leaderboard-tabs button {
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--gray-200);
  background: var(--white);
  border-radius: var(--radius-md);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  cursor: pointer;
  font-weight: 500;
  transition: all var(--transition-fast);
  color: var(--ink-light);
}
.leaderboard-tabs button.active {
  background: var(--pandan);
  color: var(--white);
  border-color: var(--pandan);
}
.leaderboard-tabs button:hover:not(.active) {
  background: var(--gray-100);
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.leaderboard-table th {
  background: var(--navy);
  color: var(--white);
  padding: var(--space-sm) var(--space-md);
  text-align: left;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
}

.leaderboard-table td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--gray-200);
  font-size: 0.9rem;
}

.leaderboard-table tr:hover td {
  background: var(--gray-100);
}

.leaderboard-table .highlight-row td {
  background: #FFF8E1;
  font-weight: 600;
}

[data-theme="dark"] .leaderboard-table .highlight-row td {
  background: #2A3A1A;
}

.leaderboard-table .rank-num {
  font-weight: 700;
  color: var(--gray-400);
}

.leaderboard-table .medal {
  font-size: 1.2rem;
}

.leaderboard-empty {
  text-align: center;
  padding: var(--space-2xl);
  color: var(--gray-400);
}

/* --- Content Pages --- */
.content-page {
  max-width: 700px;
  margin: 0 auto;
  padding: var(--space-xl) var(--space-md);
}

.content-page h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  margin-bottom: var(--space-lg);
}

.content-page h2 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  margin-top: var(--space-xl);
  margin-bottom: var(--space-md);
}

.content-page h3 {
  font-size: 1rem;
  margin-top: var(--space-lg);
  margin-bottom: var(--space-sm);
}

.content-page p {
  margin-bottom: var(--space-md);
  line-height: 1.7;
  color: var(--ink-light);
}

.content-page ul, .content-page ol {
  margin-bottom: var(--space-md);
  padding-left: var(--space-lg);
}

.content-page li {
  margin-bottom: var(--space-xs);
  line-height: 1.7;
  color: var(--ink-light);
}

.content-page .illustration {
  margin: var(--space-lg) 0;
  text-align: center;
}

.content-page .illustration .emoji-big {
  font-size: 3rem;
  display: block;
  margin-bottom: var(--space-sm);
}

/* --- Footer --- */
.site-footer {
  background: var(--navy);
  color: var(--gray-400);
  padding: var(--space-xl) 0;
  margin-top: var(--space-2xl);
  font-size: 0.85rem;
}

.footer-inner {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-lg);
}

.footer-inner h4 {
  color: var(--white);
  margin-bottom: var(--space-sm);
  font-size: 0.9rem;
}

.footer-inner a {
  display: block;
  color: var(--gray-400);
  margin-bottom: var(--space-xs);
  font-size: 0.8rem;
}
.footer-inner a:hover {
  color: var(--white);
}

.footer-bottom {
  text-align: center;
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 0.75rem;
}

/* --- Consent Banner --- */
.consent-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--navy);
  color: var(--white);
  padding: var(--space-md);
  z-index: 9999;
  display: none;
  box-shadow: 0 -4px 12px rgba(0,0,0,0.2);
}

.consent-banner.visible {
  display: block;
}

.consent-inner {
  max-width: 700px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.consent-inner p {
  flex: 1;
  font-size: 0.8rem;
  line-height: 1.5;
  min-width: 200px;
}

.consent-inner a {
  color: var(--turmeric-light);
}

.consent-inner .game-btn {
  font-size: 0.8rem;
}

/* --- Keyboard Shortcuts Panel --- */
.shortcuts-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-lg);
  z-index: 1001;
  max-width: 360px;
  width: 90%;
  display: none;
}

.shortcuts-panel.visible {
  display: block;
}

.shortcuts-panel h3 {
  font-family: var(--font-display);
  margin-bottom: var(--space-md);
}

.shortcuts-panel .shortcut-row {
  display: flex;
  justify-content: space-between;
  padding: var(--space-xs) 0;
  border-bottom: 1px solid var(--gray-200);
  font-size: 0.85rem;
}

.shortcuts-panel .shortcut-row:last-child {
  border-bottom: none;
}

.shortcuts-panel kbd {
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: 3px;
  padding: 1px 6px;
  font-size: 0.75rem;
  font-family: monospace;
}

.shortcuts-panel .close-shortcuts {
  display: block;
  margin-top: var(--space-md);
  width: 100%;
  padding: var(--space-sm);
  background: var(--navy);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-ui);
  font-weight: 600;
}

/* --- Resume Banner --- */
.resume-banner {
  background: #FFF8E1;
  border: 1px solid var(--turmeric);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-md);
  display: none;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.85rem;
}
.resume-banner.visible {
  display: flex;
}
.resume-banner .resume-btn {
  margin-left: auto;
  background: var(--turmeric);
  color: var(--navy);
  border: none;
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 0.8rem;
}
.resume-banner .resume-btn:hover {
  background: var(--turmeric-dark);
}

[data-theme="dark"] .resume-banner {
  background: #2A3A1A;
  border-color: var(--pandan);
}

/* --- Mobile On-screen Keyboard --- */
.mobile-keyboard {
  display: none;
  gap: 2px;
  padding: var(--space-sm);
  max-width: 500px;
  margin: var(--space-sm) auto;
}

.mobile-keyboard .kb-row {
  display: flex;
  gap: 2px;
  justify-content: center;
}

.mobile-keyboard .kb-key {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  width: 30px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--font-ui);
  text-transform: uppercase;
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--ink);
}
.mobile-keyboard .kb-key:active {
  background: var(--gray-200);
  transform: scale(0.92);
}
.mobile-keyboard .kb-key.special {
  flex: 1;
  font-size: 0.7rem;
  width: auto;
  min-width: 40px;
}
.mobile-keyboard .kb-key.space {
  flex: 2;
}

@media (pointer: coarse) {
  .mobile-keyboard {
    display: block;
  }
}

/* --- Streak Badge --- */
.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  background: linear-gradient(135deg, var(--turmeric), var(--turmeric-dark));
  color: var(--navy);
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
}

/* --- Animations --- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

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

@keyframes hibiscusSpin {
  0% { transform: rotate(0deg) scale(0); }
  50% { transform: rotate(180deg) scale(1.2); }
  100% { transform: rotate(360deg) scale(1); }
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .main-nav {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    background: var(--navy);
    flex-direction: column;
    padding: var(--space-md);
    display: none;
    box-shadow: var(--shadow-lg);
    z-index: 99;
  }
  .main-nav.open {
    display: flex;
  }
  .main-nav a {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
  }
  .nav-toggle {
    display: block;
  }
  .puzzle-grid {
    grid-template-columns: 1fr;
  }
  .site-title {
    font-size: 1rem;
  }
  .completion-panel {
    padding: var(--space-lg);
  }
  .game-layout {
    grid-template-columns: 1fr;
    gap: var(--space-md);
    padding-bottom: 45vh; /* make room for sticky clue panel */
  }

  /* Sticky clue panel at bottom on mobile */
  .clue-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 40vh;
    z-index: 50;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.12);
  }
  .clue-panel .clue-list {
    max-height: calc(40vh - 40px);
  }

  /* Dark mode border for sticky panel */
  [data-theme="dark"] .clue-panel {
    border: 1px solid var(--gray-200);
    border-bottom: none;
  }
}

@media (max-width: 480px) {
  .clue-bar {
    flex-wrap: wrap;
  }
  .clue-bar .clue-text {
    font-size: 0.8rem;
  }
  .timer {
    font-size: 0.85rem;
  }
}

/* --- Dark Mode Component Overrides --- */
[data-theme="dark"] .masthead {
  background: linear-gradient(180deg, #141210, #1C1A17);
}
[data-theme="dark"] .masthead h1,
[data-theme="dark"] .page-title,
[data-theme="dark"] .puzzle-card h3,
[data-theme="dark"] .daily-highlight h2,
[data-theme="dark"] .clue-bar .clue-number,
[data-theme="dark"] .clue-item .ci-number,
[data-theme="dark"] .clue-panel-header button.active,
[data-theme="dark"] .timer {
  color: var(--ink);
}
[data-theme="dark"] .puzzle-card,
[data-theme="dark"] .clue-bar,
[data-theme="dark"] .clue-panel {
  border-color: #3D3830;
}
[data-theme="dark"] .clue-bar {
  background: #2E2B27;
  border-color: #524D47;
}
[data-theme="dark"] .clue-bar .clue-direction {
  color: var(--turmeric);
}
[data-theme="dark"] .clue-bar .clue-text,
[data-theme="dark"] .clue-bar .clue-number {
  color: #EDEBE6;
}
[data-theme="dark"] .clue-bar .clue-nav button {
  border-color: #524D47;
  color: #EDEBE6;
}
[data-theme="dark"] .clue-bar .clue-nav button:hover {
  background: #363028;
}

[data-theme="dark"] .game-btn {
  background: #2E2B27;
  border: 1px solid #524D47;
  color: #EDEBE6;
}
[data-theme="dark"] .game-btn:hover {
  background: #363028;
  border-color: #6A6058;
}
[data-theme="dark"] .game-btn.primary {
  background: var(--pandan);
  color: #FFFFFF;
  border-color: var(--pandan);
}
[data-theme="dark"] .game-btn.danger {
  color: #EF5350;
  border-color: #EF5350;
}
[data-theme="dark"] .game-btn.danger:hover {
  background: #EF5350;
  color: #FFFFFF;
}

[data-theme="dark"] .completion-panel {
  background: #363028;
}
[data-theme="dark"] .shortcuts-panel {
  background: #252220;
  border-color: #3D3830;
}

[data-theme="dark"] .clue-panel-header {
  border-bottom-color: #3D3830;
}
[data-theme="dark"] .clue-panel-header button {
  color: #6A6058;
  border-bottom: 3px solid transparent;
}
[data-theme="dark"] .clue-panel-header button.active {
  color: #EDEBE6;
  border-bottom-color: var(--turmeric);
}
[data-theme="dark"] .clue-panel-header button:hover {
  color: #EDEBE6;
}

[data-theme="dark"] .clue-item {
  color: #EDEBE6;
  opacity: 0.85;
}
[data-theme="dark"] .clue-item:hover {
  background: #2E2B27;
}
[data-theme="dark"] .clue-item.active {
  background: #2E2B27;
  border-left: 3px solid var(--turmeric);
  opacity: 1;
}
[data-theme="dark"] .clue-item .ci-number {
  color: var(--turmeric);
  font-weight: 700;
}
[data-theme="dark"] .clue-item .ci-length {
  color: #6A6058;
}
[data-theme="dark"] .clue-item.done {
  opacity: 0.5;
}

[data-theme="dark"] .game-layout > .clue-panel {
  border-left: 1px solid #3D3830;
}

[data-theme="dark"] .leaderboard-tabs button {
  background: #252220;
  border-color: #3D3830;
}
[data-theme="dark"] .leaderboard-tabs button.active {
  background: var(--pandan);
  border-color: var(--pandan);
}

/* Dark mode content page fixes */
[data-theme="dark"] .feedback-card h1,
[data-theme="dark"] .feedback-card .subtitle {
  color: var(--ink);
}
[data-theme="dark"] .content-page h1,
[data-theme="dark"] .content-page h2,
[data-theme="dark"] .content-page h3 {
  color: var(--ink);
}
[data-theme="dark"] .site-footer a {
  color: var(--gray-500);
}
[data-theme="dark"] .footer-inner h4 {
  color: #B0A898;
}
[data-theme="dark"] .consent-banner p,
[data-theme="dark"] .consent-banner a,
[data-theme="dark"] .consent-inner p {
  color: #B0A898;
}
[data-theme="dark"] .consent-banner .game-btn {
  background: #252220;
  border-color: #524D47;
  color: #EDEBE6;
}

/* --- Theme Toggle Button --- */
.theme-toggle-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 1rem;
  color: var(--white);
  transition: background 0.15s ease, border-color 0.15s ease;
  line-height: 1;
}
.theme-toggle-btn:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.4);
}

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

:focus-visible {
  outline: 2px solid var(--pandan);
  outline-offset: 2px;
}

/* --- Loading --- */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl);
  color: var(--gray-400);
  font-size: 0.9rem;
}

.loading::after {
  content: '';
  width: 20px;
  height: 20px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--pandan);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-left: var(--space-sm);
}

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

/* --- Status Messages --- */
.status-message {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: var(--space-md);
}
.status-message.success {
  background: #E8F5E9;
  color: var(--success);
  border: 1px solid #A5D6A7;
}
.status-message.error {
  background: #FFEBEE;
  color: var(--error);
  border: 1px solid #EF9A9A;
}

/* --- Print Styles --- */
@media print {
  .site-header, .site-footer, .consent-banner, .game-controls,
  .mobile-keyboard, .clue-nav { display: none !important; }
  .crossword-grid { border-color: #000; }
  .cell.block { background: #000; }
}
