:root {
  --paper: #fffdf7;
  --paper-deep: #f7f1df;
  --ink: #174f49;
  --muted: #6e8480;
  --line: #ddd3b6;
  --green: #49a27d;
  --green-dark: #27735b;
  --gold: #efb43a;
  --coral: #ec765b;
  --teal: #4c9db1;
  --error: #dc6b61;
  --error-bg: #fff0ed;
  --success-bg: #ebf7ee;
  --shadow: 0 11px 0 rgba(109, 92, 49, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  overflow-y: scroll;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 10px 10px, rgba(72, 157, 130, 0.08) 1.5px, transparent 1.8px) 0 0 / 28px 28px,
    linear-gradient(135deg, #fff7e6 0%, #fbf9ee 48%, #eef8ef 100%);
}

button,
a {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
a:focus-visible {
  outline: 4px solid rgba(239, 180, 58, 0.7);
  outline-offset: 4px;
}

.app {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 56px;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 66px;
  margin-bottom: 18px;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 13px;
  color: var(--ink);
  text-decoration: none;
}

.brand-link strong,
.brand-link small {
  display: block;
}

.brand-link strong {
  font-size: 1.15rem;
  line-height: 1.1;
}

.brand-link small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand-icon {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border: 3px solid #b8ddd2;
  border-radius: 17px;
  color: var(--green-dark);
  background: #eff9f3;
  box-shadow: 0 5px 0 rgba(43, 113, 90, 0.14);
  font-family: Georgia, serif;
  font-size: 1.9rem;
  font-weight: 900;
}

.sound-button,
.small-button,
.primary-button,
.secondary-button {
  border: 0;
  cursor: pointer;
  font-weight: 900;
}

.sound-button {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  padding: 0 18px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 253, 247, 0.9);
}

.screen {
  display: none;
}

.screen--active {
  display: block;
}

.hero-card,
.task-card,
.complete-card {
  border: 3px solid var(--line);
  border-radius: 36px;
  background: var(--paper);
  box-shadow: 0 18px 40px rgba(59, 77, 55, 0.12);
}

.hero-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 0.82fr);
  min-height: 470px;
  overflow: hidden;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 60px;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 12px;
  color: #8e6b36;
  font-family: Georgia, serif;
  font-size: 0.9rem;
  font-weight: 900;
  letter-spacing: 0.16em;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 650px;
  margin-bottom: 22px;
  font-size: clamp(3rem, 6vw, 5.2rem);
  line-height: 0.98;
  letter-spacing: -0.055em;
}

.hero-text {
  max-width: 630px;
  margin-bottom: 30px;
  color: var(--muted);
  font-size: 1.22rem;
  font-weight: 700;
  line-height: 1.55;
}

.hero-actions,
.complete-actions,
.task-actions__right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.primary-button,
.secondary-button {
  min-height: 58px;
  padding: 0 25px;
  border-radius: 18px;
  font-size: 1.02rem;
}

.primary-button {
  color: #fff;
  background: var(--green);
  box-shadow: 0 8px 0 var(--green-dark);
}

.primary-button:hover {
  background: #55ad89;
  transform: translateY(-1px);
}

.primary-button:active {
  box-shadow: 0 4px 0 var(--green-dark);
  transform: translateY(4px);
}

.secondary-button {
  border: 2px solid var(--line);
  background: #fffdf8;
}

.secondary-button:hover {
  border-color: #c4b788;
  background: #fff9e9;
}

.progress-pill {
  display: inline-grid;
  min-height: 58px;
  place-items: center;
  padding: 0 22px;
  border: 2px solid var(--line);
  border-radius: 18px;
  background: #fffdf8;
  font-weight: 900;
}

.hero-art {
  position: relative;
  display: grid;
  place-items: center;
  padding: 44px;
  overflow: hidden;
  background:
    radial-gradient(circle at 80% 15%, rgba(255, 255, 255, 0.72) 0 48px, transparent 49px),
    linear-gradient(145deg, #d7f1e2, #f8e8b2);
}

.hero-art::before,
.hero-art::after {
  position: absolute;
  content: "";
  border: 30px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
}

.hero-art::before {
  width: 260px;
  height: 260px;
  top: -130px;
  right: -90px;
}

.hero-art::after {
  width: 180px;
  height: 180px;
  bottom: -100px;
  left: -70px;
}

.mini-board {
  position: relative;
  z-index: 1;
  display: grid;
  width: min(100%, 390px);
  aspect-ratio: 1;
  grid-template-columns: repeat(4, 1fr);
  overflow: hidden;
  border: 10px solid #fff;
  border-radius: 30px;
  background: #fff;
  box-shadow: var(--shadow), 0 18px 30px rgba(47, 80, 61, 0.2);
  transform: rotate(-3deg);
}

.mini-board span {
  display: grid;
  place-items: center;
  border: 1px solid #d7d0bb;
  background: rgba(255, 252, 240, 0.92);
  font-size: clamp(1.55rem, 3.5vw, 2.65rem);
}

.mini-board span:nth-child(1),
.mini-board span:nth-child(2),
.mini-board span:nth-child(5),
.mini-board span:nth-child(6),
.mini-board span:nth-child(11),
.mini-board span:nth-child(12),
.mini-board span:nth-child(15),
.mini-board span:nth-child(16) {
  background: #eff8ef;
}

.hero-pencil {
  position: absolute;
  z-index: 2;
  right: 9%;
  bottom: 8%;
  font-size: 4.6rem;
  filter: drop-shadow(0 8px 4px rgba(73, 60, 35, 0.2));
  transform: rotate(-22deg);
}

.how-card {
  display: flex;
  align-items: center;
  gap: 18px;
  margin: 22px 0 46px;
  padding: 20px 26px;
  border: 2px solid #e8cc72;
  border-radius: 24px;
  background: #fff5cf;
}

.how-card strong {
  display: block;
  margin-bottom: 5px;
  font-size: 1.05rem;
}

.how-card p {
  margin: 0;
  color: #746d59;
  font-weight: 700;
  line-height: 1.45;
}

.how-icon {
  display: grid;
  flex: 0 0 auto;
  width: 54px;
  height: 54px;
  place-items: center;
  border-radius: 16px;
  background: #fff;
  font-size: 1.7rem;
}

.routes-section {
  scroll-margin-top: 20px;
}

.section-heading,
.task-topline,
.panel-heading,
.task-actions {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.section-heading {
  margin-bottom: 22px;
}

.section-heading h2,
.task-topline h2 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.section-heading > p {
  max-width: 390px;
  margin: 0;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.4;
  text-align: right;
}

.route-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.route-card {
  display: flex;
  min-height: 330px;
  flex-direction: column;
  padding: 28px;
  border: 3px solid var(--line);
  border-radius: 28px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.route-card__icon {
  display: grid;
  width: 62px;
  height: 62px;
  place-items: center;
  margin-bottom: 30px;
  border: 4px solid color-mix(in srgb, var(--route-accent), white 64%);
  border-radius: 20px;
  background: color-mix(in srgb, var(--route-accent), white 86%);
  font-size: 1.75rem;
}

.route-card small {
  margin-bottom: 8px;
  color: #8e6b36;
  font-family: Georgia, serif;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.route-card h3 {
  margin-bottom: 12px;
  font-size: 1.65rem;
}

.route-card p {
  color: var(--muted);
  font-weight: 700;
  line-height: 1.45;
}

.route-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  padding-top: 22px;
  border-top: 1px dashed #d9ccb0;
}

.route-card__progress {
  font-weight: 900;
}

.route-button {
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 15px;
  color: #fff;
  background: var(--route-accent);
  box-shadow: 0 5px 0 color-mix(in srgb, var(--route-accent), black 28%);
  cursor: pointer;
  font-weight: 900;
}

.task-card {
  padding: 38px;
}

.task-topline {
  margin-bottom: 26px;
}

.task-topline > div:first-child {
  min-width: 0;
}

.task-topline #taskPrompt {
  max-width: 680px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
  font-weight: 700;
}

.task-progress {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 0 0 min(320px, 34vw);
}

.progress-track {
  width: 100%;
  height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: #e4e1d8;
}

.progress-track span {
  display: block;
  width: 10%;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
  transition: width 260ms ease;
}

.play-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 22px;
}

.board-panel,
.palette-panel {
  border: 3px solid var(--line);
  border-radius: 28px;
  background: #fffdf8;
}

.board-panel {
  padding: 24px;
}

.palette-panel {
  padding: 28px;
  background: #f1f7ef;
}

.panel-heading {
  align-items: center;
  margin-bottom: 20px;
}

.panel-kicker {
  display: block;
  margin-bottom: 6px;
  font-size: 0.75rem;
}

.panel-heading h3,
.palette-panel h3 {
  margin-bottom: 0;
  font-size: 1.45rem;
}

.small-button {
  min-height: 42px;
  padding: 0 14px;
  border: 2px solid #d7ccb1;
  border-radius: 13px;
  background: #fff;
}

.small-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.sudoku-board {
  --board-size: 4;
  --region-columns: 2;
  --region-rows: 2;
  display: grid;
  width: min(100%, 610px);
  aspect-ratio: 1;
  grid-template-columns: repeat(var(--board-size), minmax(0, 1fr));
  margin: 0 auto;
  overflow: hidden;
  border: 5px solid var(--ink);
  border-radius: 21px;
  background: var(--ink);
  box-shadow: 0 8px 0 rgba(27, 76, 67, 0.14);
}

.sudoku-cell {
  position: relative;
  display: grid;
  min-width: 0;
  place-items: center;
  border: 1px solid #aacbc0;
  background: #fffef9;
  cursor: pointer;
  font-size: clamp(1.65rem, 5.2vw, 3.8rem);
  line-height: 1;
  transition: background 130ms ease, box-shadow 130ms ease;
}

.sudoku-cell::after {
  position: absolute;
  inset: 8%;
  border: 3px dashed transparent;
  border-radius: 16px;
  content: "";
  pointer-events: none;
}

.sudoku-cell--region-right {
  border-right: 5px solid var(--ink);
}

.sudoku-cell--region-bottom {
  border-bottom: 5px solid var(--ink);
}

.sudoku-cell--fixed {
  cursor: default;
  background: #e5f1e8;
}

.sudoku-cell--selected {
  z-index: 2;
  background: #fff3bd;
  box-shadow: inset 0 0 0 5px var(--gold);
}

.sudoku-cell--selected::after {
  border-color: rgba(150, 104, 20, 0.3);
}

.sudoku-cell--same {
  background: #f0f8ed;
}

.sudoku-cell--wrong {
  color: #a93e37;
  background: var(--error-bg);
  animation: gentlePulse 550ms ease;
}

.sudoku-cell--hinted::before {
  position: absolute;
  top: 7px;
  right: 8px;
  color: #bd8120;
  content: "★";
  font-size: 0.76rem;
}

.sudoku-cell--empty::before {
  width: 30%;
  height: 30%;
  border: 3px dotted #cfcbba;
  border-radius: 50%;
  content: "";
}

.palette-panel > p {
  color: var(--muted);
  font-weight: 700;
  line-height: 1.45;
}

.symbol-palette {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 23px 0;
}

.symbol-button {
  position: relative;
  display: grid;
  min-height: 94px;
  place-items: center;
  border: 3px solid #cad9cd;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 5px 0 rgba(79, 112, 80, 0.13);
  cursor: pointer;
  font-size: 2.6rem;
}

.symbol-button:hover {
  border-color: var(--green);
  background: #f9fff9;
}

.symbol-button small {
  position: absolute;
  right: 8px;
  bottom: 6px;
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: #719184;
  font-size: 0.72rem;
}

.symbol-palette--six .symbol-button {
  min-height: 78px;
  font-size: 2.15rem;
}

.rule-note {
  display: flex;
  gap: 12px;
  padding: 16px;
  border: 2px solid #cfe1d2;
  border-radius: 18px;
  background: #fff;
}

.rule-note p {
  margin: 0;
  color: #667b73;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.45;
}

.feedback {
  display: none;
  align-items: center;
  gap: 18px;
  min-height: 92px;
  margin-top: 22px;
  padding: 18px 22px;
  border: 3px solid;
  border-radius: 24px;
  font-weight: 700;
  line-height: 1.45;
}

.feedback--visible {
  display: flex;
}

.feedback--success {
  border-color: #83bea0;
  background: var(--success-bg);
}

.feedback--error {
  border-color: #e49a93;
  background: var(--error-bg);
}

.feedback--hint {
  border-color: #e4c05e;
  background: #fff7d9;
}

.feedback__icon {
  display: grid;
  flex: 0 0 auto;
  width: 54px;
  height: 54px;
  place-items: center;
  border-radius: 16px;
  color: #fff;
  background: var(--green);
  font-size: 1.6rem;
  font-weight: 900;
}

.feedback--error .feedback__icon {
  background: var(--error);
}

.feedback--hint .feedback__icon {
  color: #624d18;
  background: var(--gold);
}

.feedback strong {
  display: block;
  margin-bottom: 4px;
  font-size: 1.08rem;
}

.feedback p {
  margin: 0;
  color: #5d716b;
}

.task-actions {
  align-items: center;
  margin-top: 24px;
}

.complete-card {
  min-height: 680px;
  padding: 64px;
  text-align: center;
}

.complete-badge {
  display: grid;
  width: 82px;
  height: 82px;
  place-items: center;
  margin: 0 auto 24px;
  border: 7px solid #d8f0e1;
  border-radius: 50%;
  color: #fff;
  background: var(--green);
  font-size: 2.8rem;
  font-weight: 900;
}

.complete-card h2 {
  margin-bottom: 16px;
  font-size: clamp(2.7rem, 6vw, 5.2rem);
  line-height: 1;
  letter-spacing: -0.05em;
}

.complete-card > p:not(.eyebrow) {
  color: var(--muted);
  font-size: 1.2rem;
  font-weight: 700;
}

.stars {
  margin: 34px 0;
  color: var(--gold);
  font-size: 3.2rem;
  letter-spacing: 0.1em;
}

.complete-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  max-width: 760px;
  margin: 0 auto 38px;
}

.complete-stats div {
  padding: 22px;
  border: 2px solid #d5dfce;
  border-radius: 22px;
  background: #f1f7ef;
}

.complete-stats strong,
.complete-stats span {
  display: block;
}

.complete-stats strong {
  margin-bottom: 5px;
  font-size: 1.8rem;
}

.complete-stats span {
  color: var(--muted);
  font-weight: 800;
}

.complete-actions {
  justify-content: center;
}

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}

@media (max-width: 960px) {
  .hero-card {
    grid-template-columns: 1fr;
  }

  .hero-copy {
    padding: 46px;
  }

  .hero-art {
    min-height: 390px;
  }

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

  .route-card {
    min-height: 260px;
  }

  .play-layout {
    grid-template-columns: 1fr;
  }

  .palette-panel {
    display: grid;
    grid-template-columns: minmax(160px, 0.5fr) minmax(0, 1fr);
    gap: 18px;
  }

  .palette-panel > .panel-kicker,
  .palette-panel > h3,
  .palette-panel > p {
    grid-column: 1;
  }

  .symbol-palette {
    grid-column: 2;
    grid-row: 1 / span 4;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin: 0;
  }

  .rule-note {
    grid-column: 1;
  }
}

@media (max-width: 720px) {
  .app {
    width: min(100% - 20px, 1120px);
    padding-top: 10px;
  }

  .game-header {
    align-items: flex-start;
  }

  .sound-button span:last-child {
    display: none;
  }

  .sound-button {
    width: 48px;
    padding: 0;
    justify-content: center;
  }

  .hero-copy {
    padding: 32px 24px;
  }

  h1 {
    font-size: clamp(2.8rem, 14vw, 4.2rem);
  }

  .hero-art {
    min-height: 320px;
    padding: 28px;
  }

  .mini-board {
    width: min(100%, 310px);
  }

  .section-heading,
  .task-topline,
  .task-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .section-heading > p {
    text-align: left;
  }

  .route-card {
    padding: 23px;
  }

  .task-card {
    padding: 22px 16px;
    border-radius: 26px;
  }

  .task-progress {
    width: 100%;
    flex-basis: auto;
  }

  .board-panel {
    padding: 14px;
  }

  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .sudoku-board {
    border-width: 4px;
    border-radius: 14px;
  }

  .sudoku-cell {
    font-size: clamp(1.4rem, 10vw, 2.7rem);
  }

  .sudoku-cell--region-right {
    border-right-width: 4px;
  }

  .sudoku-cell--region-bottom {
    border-bottom-width: 4px;
  }

  .palette-panel {
    display: block;
    padding: 22px 16px;
  }

  .symbol-palette {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin: 18px 0;
  }

  .symbol-button,
  .symbol-palette--six .symbol-button {
    min-height: 70px;
    font-size: 2rem;
  }

  .feedback {
    align-items: flex-start;
  }

  .task-actions__right,
  .task-actions > button {
    width: 100%;
  }

  .task-actions__right > button,
  .task-actions > button {
    flex: 1 1 180px;
  }

  .complete-card {
    min-height: 0;
    padding: 44px 18px;
  }

  .complete-stats {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 430px) {
  .brand-icon {
    width: 46px;
    height: 46px;
  }

  .brand-link strong {
    font-size: 0.98rem;
  }

  .brand-link small {
    font-size: 0.64rem;
  }

  .hero-actions > * {
    width: 100%;
  }

  .hero-art {
    min-height: 280px;
  }

  .how-card {
    align-items: flex-start;
    padding: 18px;
  }

  .route-card__footer {
    align-items: stretch;
    flex-direction: column;
  }

  .route-button {
    width: 100%;
  }

  .task-card {
    padding-inline: 10px;
  }

  .board-panel {
    padding: 9px;
  }

  .sudoku-cell {
    font-size: clamp(1.25rem, 9.5vw, 2.15rem);
  }

  .sudoku-cell--hinted::before {
    top: 3px;
    right: 4px;
    font-size: 0.58rem;
  }
}
