:root {
  --bg: #f6f8fc;
  --bg-accent: #eef4ff;
  --surface: #ffffff;
  --surface-2: #f9fbff;
  --text: #1f2937;
  --muted: #667085;
  --heading: #101828;
  --border: #dbe4f0;
  --border-strong: #93a2ba;
  --shadow: 0 10px 30px rgba(16, 24, 40, 0.08);
  --shadow-soft: 0 4px 14px rgba(16, 24, 40, 0.05);
  --shadow-hover: 0 18px 40px rgba(16, 24, 40, 0.12);
  --accent: #4f46e5;
  --accent-2: #44b454;
  --accent-soft: #eef2ff;
  --success-bg: #f1fbf2;
  --success-border: #44b454;
  --info-bg: #f4f8ff;
  --info-border: #7aa7ff;
  --danger: #d9534f;
  --danger-bg: #ffe7e7;
  --warning-bg: #ffe9b0;
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, #ffffff 0%, var(--bg-accent) 28%, var(--bg) 70%);
  line-height: 1.5;
}

.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 40px 20px 72px;
}


/* ===== Home page ===== */

.hero,
.page > h1,
.page > .subtitle,
.page > .intro {
  text-align: center;
}

.hero {
  text-align: center;
  padding: 56px 24px;
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(244, 247, 255, 0.82));
  border: 1px solid rgba(219, 228, 240, 0.9);
  box-shadow: 0 10px 30px rgba(16, 24, 40, 0.06);
  margin-bottom: 36px;
}

.eyebrow {
  display: inline-block;
  margin: 0 0 14px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.page > h1,
.hero h1 {
  margin: 0;
  font-size: clamp(2.6rem, 5vw, 4rem);
  line-height: 1.08;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--heading);
}

.page > .subtitle,
.subtitle {
  margin: 14px auto 0;
  max-width: 760px;
  font-size: 1.12rem;
  color: var(--muted);
  line-height: 1.6;
}

.intro {
  margin: 20px auto 0;
  max-width: 820px;
  font-size: 1rem;
  color: #475467;
  line-height: 1.7;
}

.hero-actions {
  margin-top: 22px;
}

.hero-btn {
  display: inline-block;
  background: #4f46e5;
  color: #fff;
  padding: 14px 22px;
  border-radius: 12px;
  font-weight: 700;
  text-decoration: none;
  transition: all 0.2s ease;
}

.hero-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(79, 70, 229, 0.25);
}

.games-section {
  margin-top: 12px;
}

.section-head {
  margin-bottom: 18px;
  padding: 0 4px;
}

.section-head h2 {
  margin: 0;
  font-size: 1.5rem;
  color: var(--heading);
}

.section-head p {
  margin: 6px 0 0;
  color: var(--muted);
}



.menu {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
  align-items: stretch;
}

.game-card {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-soft);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.game-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
  border-color: #c8d7ee;
}

.game-card.disabled {
  opacity: 0.7;
  cursor: default;
  pointer-events: none;
}

.icon-wrap {
  flex-shrink: 0;
}

.icon {
  width: 64px;
  height: 64px;
  min-width: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.9rem;
  border-radius: 18px;
  background: linear-gradient(180deg, #eef4ff, #e7f7ec);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.9);
}

.game-text h2,
.game-text h3 {
  margin: 0 0 8px;
  font-size: 1.15rem;
  line-height: 1.25;
  color: var(--heading);
}

.game-text p {
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.55;
}

.play-link {
  display: inline-block;
  margin-top: 12px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent);
}

/* ===== Shared puzzle page styles ===== */

.back-link {
  display: inline-block;
  margin-bottom: 24px;
  color: var(--accent-2);
  text-decoration: none;
  font-weight: 700;
  font-size: 1rem;
}

.back-link:hover {
  text-decoration: underline;
}

.legend-card,
.mode-section,
.game-section,
.word-search-sidebar,
.maze-card,
.sudoku-card,
.fallen-board,
.word-search-grid {
  box-shadow: var(--shadow-soft);
}

.legend-card,
.word-search-sidebar,
.maze-card,
.sudoku-card,
.fallen-board,
.word-search-grid {
  background: #fff;
  border: 1px solid var(--border);
}

.hero h1 {
  margin-bottom: 10px;
}

.legend-card,
.mode-section,
.game-section {
  margin-bottom: 28px;
}

.legend-card {
  max-width: 950px;
  margin-left: auto;
  margin-right: auto;
  border-radius: var(--radius-md);
  padding: 18px 22px;
  text-align: center;
  line-height: 1.7;
}

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

.mode-section h2 {
  margin: 0 0 18px;
  font-size: 1.5rem;
}

.mode-tabs {
  display: inline-flex;
  gap: 10px;
  background: #edf4eb;
  padding: 8px;
  border-radius: 999px;
  margin-bottom: 18px;
}

.mode-tab {
  border: none;
  background: transparent;
  color: #4d4d4d;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-tab.active {
  background: var(--accent-2);
  color: #fff;
  box-shadow: 0 8px 20px rgba(68, 180, 84, 0.2);
}

.mode-panel {
  display: none;
}

.mode-panel.active {
  display: block;
}

.mode-description {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 1rem;
}

.custom-form {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.phrase-input,
.word-input,
.maze-select {
  border: 1px solid #cfd7e3;
  border-radius: var(--radius-sm);
  font-family: inherit;
}

.phrase-input {
  width: 320px;
  max-width: 100%;
  height: 50px;
  padding: 0 16px;
  font-size: 1rem;
  outline: none;
}

.phrase-input:focus,
.word-input:focus,
.maze-select:focus,
.letter-box:focus,
.cryptogram-input:focus,
.fallen-slot.active,
.sudoku-cell:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(68, 180, 84, 0.12);
}

.primary-btn,
.secondary-btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 20px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.primary-btn {
  background: var(--accent-2);
  color: #fff;
}

.secondary-btn {
  background: #fff;
  color: var(--accent-2);
  border: 1px solid var(--accent-2);
}

.primary-btn:hover,
.secondary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(16, 24, 40, 0.08);
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.section-heading h3 {
  margin: 0;
  font-size: 1.3rem;
}

.hidden {
  display: none !important;
}

/* ===== Math puzzle page ===== */

.puzzle-board {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px;
  min-height: 140px;
  margin-bottom: 26px;
}

.puzzle-card {
  width: 150px;
  min-height: 150px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px 14px;
  text-align: center;
  box-shadow: var(--shadow-soft);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.puzzle-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 24px rgba(16, 24, 40, 0.08);
}

.math-problem {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 16px;
  color: var(--heading);
}

.letter-box {
  width: 52px;
  height: 52px;
  margin: 0 auto;
  border: 2px solid #cdd7e4;
  border-radius: 12px;
  text-align: center;
  font-size: 1.4rem;
  font-weight: 700;
  text-transform: uppercase;
}

.puzzle-card.correct {
  border-color: var(--success-border);
  background: var(--success-bg);
}

.puzzle-card.revealed {
  border-color: var(--info-border);
  background: var(--info-bg);
}

.action-row {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.result-message {
  min-height: 32px;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 700;
}

.result-message.success {
  color: #2d9c42;
}

.result-message.error {
  color: var(--danger);
}

.result-message.info {
  color: #4477cc;
}

.decoded-section {
  margin-top: 30px;
  text-align: center;
}

.decoded-phrase {
  margin-top: 10px;
  font-size: 28px;
  letter-spacing: 10px;
  font-weight: bold;
  color: var(--heading);
}

.puzzle-space {
  width: 40px;
}

/* ===== Word search page ===== */

.word-search-layout {
  display: grid;
  grid-template-columns: minmax(320px, 540px) minmax(250px, 1fr);
  gap: 24px;
  align-items: start;
}

.word-search-grid {
  display: grid;
  grid-template-columns: repeat(11, minmax(30px, 48px));
  gap: 8px;
  border-radius: var(--radius-md);
  padding: 16px;
  user-select: none;
}

.word-cell {
  border: 1px solid #d1d9e5;
  background: #f6f9ff;
  color: var(--text);
  border-radius: 8px;
  min-height: 42px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

.word-cell.selected {
  background: var(--warning-bg);
  border-color: #f0b936;
}

.word-cell.found {
  background: var(--accent-2);
  border-color: #389b45;
  color: #fff;
}

.word-search-sidebar {
  border-radius: var(--radius-md);
  padding: 18px;
}

.word-search-sidebar h2 {
  margin-top: 0;
}

.word-input-panel {
  margin-bottom: 14px;
  display: grid;
  gap: 8px;
}

.word-input-label {
  font-size: 0.92rem;
  color: #555;
  font-weight: 700;
}

.word-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 0.95rem;
  resize: vertical;
}

.word-list {
  margin: 0 0 18px;
  padding-left: 18px;
  display: grid;
  gap: 8px;
}

.word-list li {
  font-weight: 700;
  letter-spacing: 0.04em;
}

.word-list li.found {
  color: var(--accent-2);
  text-decoration: line-through;
}

/* ===== Maze page ===== */

.maze-controls {
  display: flex;
  justify-content: center;
  align-items: end;
  gap: 14px;
  flex-wrap: wrap;
}

.maze-controls label {
  display: grid;
  gap: 6px;
  font-weight: 700;
  color: #444;
  text-align: left;
}

.maze-select {
  min-width: 180px;
  height: 48px;
  padding: 0 14px;
  font-size: 1rem;
  background: #fff;
}

.maze-card {
  max-width: 860px;
  margin: 0 auto;
  border-radius: 20px;
  padding: 24px;
  text-align: center;
}

.maze-legend {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.maze-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 90px;
  height: 40px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: 0.03em;
}

.start-badge {
  background: #e8f8ea;
  color: #2d9c42;
  border: 1px solid #b9e6c0;
}

.finish-badge {
  background: #fff1f0;
  color: var(--danger);
  border: 1px solid #f0c2bf;
}

#mazeCanvas {
  width: 100%;
  max-width: 700px;
  height: auto;
  display: block;
  margin: 0 auto;
  background: #fcfdff;
  border: 2px solid #cfd7e3;
  border-radius: 18px;
}

.maze-help-text {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 1rem;
}

/* ===== Cryptogram page ===== */

.cryptogram-hint {
  margin-bottom: 20px;
  font-weight: 700;
  color: #4a5a77;
}

.cryptogram-board {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-bottom: 24px;
}

.cryptogram-cell {
  width: 58px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-soft);
}

.cryptogram-cipher {
  font-size: 0.95rem;
  font-weight: 800;
  color: #5a6682;
}

.cryptogram-input {
  width: 40px;
  height: 40px;
  border: 2px solid #cfd7e3;
  border-radius: 10px;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 800;
  text-transform: uppercase;
}

.cryptogram-space {
  width: 22px;
}

.cryptogram-board.solved .cryptogram-cell {
  border-color: var(--success-border);
  background: var(--success-bg);
}

/* ===== Sudoku page ===== */

.sudoku-controls {
  display: flex;
  justify-content: center;
  align-items: end;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.sudoku-controls label {
  display: grid;
  gap: 6px;
  font-weight: 700;
  color: #444;
}

.sudoku-card {
  max-width: 700px;
  margin: 0 auto;
  border-radius: 20px;
  padding: 22px;
}

.sudoku-board {
  display: grid;
  grid-template-columns: repeat(9, minmax(34px, 58px));
  justify-content: center;
  border: 3px solid var(--border-strong);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 16px;
}

.sudoku-cell {
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 1px solid #cdd7e4;
  text-align: center;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
}

.sudoku-cell.fixed {
  background: #edf2f8;
  color: #2c3f5b;
}

.sudoku-cell.invalid {
  background: var(--danger-bg);
  color: #8d1f1f;
}

.sudoku-cell.box-right {
  border-right: 3px solid var(--border-strong);
}

.sudoku-cell.box-bottom {
  border-bottom: 3px solid var(--border-strong);
}

/* ===== Fallen phrase page ===== */

.fallen-hint {
  margin-bottom: 16px;
  font-weight: 700;
  color: #4a5a77;
}

.fallen-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 10px;
  margin-bottom: 22px;
}

.fallen-column {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  box-shadow: var(--shadow-soft);
}

.fallen-column-title {
  font-size: 0.82rem;
  font-weight: 800;
  color: #5a6682;
  text-align: center;
  margin-bottom: 8px;
}

.fallen-stack {
  min-height: 44px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.fallen-letter {
  width: 34px;
  height: 34px;
  border: 1px solid #b8c5d8;
  border-radius: 8px;
  background: #f7faff;
  font-weight: 800;
  cursor: pointer;
}

.fallen-letter:hover {
  background: #eaf4ff;
}

.fallen-empty {
  color: #98a6bc;
  font-weight: 700;
}

.fallen-subheading {
  margin: 0 0 10px;
  font-size: 1.15rem;
}

.fallen-board {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 20px;
}

.fallen-slot {
  width: 38px;
  height: 44px;
  border: 2px solid #cfd7e3;
  border-radius: 10px;
  background: #f8fbff;
  font-size: 1.2rem;
  font-weight: 800;
  cursor: pointer;
}

.fallen-space {
  width: 20px;
}

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

@media (max-width: 900px) {
  .word-search-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .page {
    padding: 28px 16px 52px;
  }

  .page > h1,
  .hero h1 {
    font-size: 2.4rem;
  }

  .subtitle {
    font-size: 1rem;
  }

  .intro {
    font-size: 0.98rem;
  }

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

  .game-card {
    padding: 18px;
  }

  .icon {
    width: 58px;
    height: 58px;
    min-width: 58px;
    font-size: 1.7rem;
  }

  .puzzle-card {
    width: 130px;
    min-height: 138px;
  }

  .math-problem {
    font-size: 1.6rem;
  }

  .letter-box {
    width: 46px;
    height: 46px;
    font-size: 1.2rem;
  }

  .section-heading {
    justify-content: center;
    text-align: center;
  }

  .maze-card,
  .sudoku-card {
    padding: 16px;
  }

  .maze-select {
    min-width: 150px;
  }

  .sudoku-board {
    grid-template-columns: repeat(9, minmax(28px, 1fr));
  }
}



/* ===== PRINT PDF ===== */


.print-actions {
  margin-top: 1rem;
}

@media print {
  @page {
    size: letter portrait;
    margin: 0.5in;
  }

  body {
    background: #fff;
    color: #000;
    margin: 0;
    padding: 0;
  }

  .no-print {
    display: none !important;
  }

  .page.printable-page {
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 0;
  }

  .hero {
    margin-bottom: 0.25in;
  }

  .hero h1 {
    font-size: 22pt;
    margin-bottom: 0.1in;
  }

  .subtitle {
    font-size: 11pt;
    margin-bottom: 0.2in;
  }

  .print-layout {
    display: grid;
    grid-template-columns: 1fr 2.2in;
    gap: 0.35in;
    align-items: start;
  }

  .print-grid-wrap,
  .print-sidebar {
    break-inside: avoid;
  }

  .word-search-grid {
    width: 100%;
  }

  .word-search-sidebar h2 {
    margin-top: 0;
    font-size: 14pt;
  }

  .word-list {
    padding-left: 1.1rem;
    margin: 0;
  }

  .word-list li {
    font-size: 11pt;
    margin-bottom: 0.08in;
  }
}


@media print {
  @page {
    size: letter portrait;
    margin: 0.5in;
  }

  body * {
    visibility: hidden;
  }

  .print-area,
  .print-area * {
    visibility: visible;
  }

  .print-area {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
  }

  body {
    margin: 0;
    background: white;
  }

  .print-layout {
    display: grid;
    grid-template-columns: 1fr 2.2in;
    gap: 0.35in;
    align-items: start;
  }

  .word-list {
    margin: 0;
    padding-left: 1rem;
  }
}
