:root {
  color: #244f48;
  font-family: "Trebuchet MS", "Arial Rounded MT Bold", Arial, sans-serif;
  font-synthesis: none;
  --ink: #244f48;
  --muted: #6f837e;
  --paper: #fffdf8;
  --line: #dfd6b9;
  --green: #4da27d;
  --green-dark: #34775c;
  --gold: #efb13c;
  --coral: #e77964;
}

* { box-sizing: border-box; }
html { min-width: 0; background: #f7f3e7; }
body {
  min-width: 0;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 7% 12%, #dcefdc 0 145px, transparent 146px),
    radial-gradient(circle at 94% 18%, #fae8b8 0 165px, transparent 166px),
    radial-gradient(#d8cfb230 1.4px, transparent 1.5px),
    linear-gradient(145deg, #fff8e9, #eef6ea);
  background-size: auto, auto, 22px 22px, auto;
}
button { color: inherit; font: inherit; }
button:not(:disabled) { cursor: pointer; }
button:focus-visible { outline: 4px solid #f2bd49; outline-offset: 3px; }

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

.page { padding: 24px 0 56px; }
.loading-card {
  margin-top: 16vh;
  padding: 42px;
  border: 2px solid var(--line);
  border-radius: 30px;
  background: var(--paper);
  box-shadow: 0 18px 44px #31544b19;
  text-align: center;
  font-size: 22px;
  font-weight: 900;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
}
.brand-icon {
  position: relative;
  width: 56px;
  height: 52px;
  overflow: hidden;
  border: 3px solid #6aa68e;
  border-radius: 17px;
  background: #fdf4ce;
  box-shadow: 0 6px 0 #d4c8a7;
}
.brand-icon::before,
.brand-icon::after {
  position: absolute;
  border: solid #3d8569;
  content: "";
}
.brand-icon::before {
  width: 32px;
  height: 16px;
  left: 0;
  top: 7px;
  border-width: 5px 5px 0 0;
}
.brand-icon::after {
  width: 27px;
  height: 17px;
  right: 0;
  bottom: 6px;
  border-width: 5px 0 0 5px;
}
.brand-icon i {
  position: absolute;
  right: 6px;
  top: 5px;
  z-index: 2;
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 50%;
  background: #ee9d48;
  color: white;
  font-style: normal;
  font-weight: 900;
}
.brand strong,
.brand small { display: block; }
.brand strong { font-size: 22px; letter-spacing: -.5px; }
.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .7px;
  text-transform: uppercase;
}
.top-note {
  padding: 11px 15px;
  border: 2px solid #ded6bd;
  border-radius: 15px;
  background: #fffdf8dd;
  color: #60766f;
  font-size: 13px;
  font-weight: 900;
}

.eyebrow {
  display: block;
  color: #568f70;
  font: 900 12px Georgia, serif;
  letter-spacing: 1.55px;
  text-transform: uppercase;
}
.hero {
  position: relative;
  display: grid;
  min-height: 410px;
  grid-template-columns: 1.05fr .95fr;
  gap: 34px;
  align-items: center;
  overflow: hidden;
  padding: 46px 54px;
  border: 2px solid var(--line);
  border-radius: 40px;
  background: linear-gradient(125deg, #fffdf7 0 51%, #eff7e8 51% 100%);
  box-shadow: 0 20px 54px #31544b17;
}
.hero::after {
  position: absolute;
  width: 170px;
  height: 170px;
  right: -65px;
  bottom: -75px;
  border: 24px solid #f4c95b44;
  border-radius: 50%;
  content: "";
}
.hero h1 {
  max-width: 620px;
  margin: 10px 0 16px;
  font-size: clamp(42px, 5.2vw, 62px);
  line-height: 1.01;
  letter-spacing: -2px;
}
.hero p {
  max-width: 600px;
  margin: 0;
  color: #687e78;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.52;
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 27px;
}
.primary-button,
.secondary-button,
.route-button,
.control-button {
  min-height: 52px;
  border-radius: 16px;
  font-weight: 900;
}
.primary-button,
.route-button {
  padding: 13px 21px;
  border: 0;
  background: linear-gradient(145deg, #57aa82, #439571);
  color: #fff;
  box-shadow: 0 7px 0 #2f7457, 0 13px 24px #387e6030;
  transition: transform .15s ease, box-shadow .15s ease;
}
.primary-button:hover,
.route-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 9px 0 #2f7457, 0 16px 26px #387e6035;
}
.primary-button:active,
.route-button:active {
  transform: translateY(5px);
  box-shadow: 0 2px 0 #2f7457;
}
.secondary-button {
  padding: 12px 18px;
  border: 2px solid #d9d1b7;
  background: #fffdf8;
  color: var(--ink);
  box-shadow: 0 5px 0 #e3dcc7;
}
.secondary-button:hover { border-color: #8ebaa2; background: #f5fbf4; }

.hero-visual {
  position: relative;
  height: 308px;
  overflow: hidden;
  border: 8px solid #fff;
  border-radius: 31px;
  background: linear-gradient(#bfe3ec 0 38%, #8fbd72 39% 100%);
  box-shadow: 0 18px 34px #31544b20;
}
.hero-sun {
  position: absolute;
  width: 64px;
  height: 64px;
  right: 28px;
  top: 26px;
  border: 8px solid #fff3bc;
  border-radius: 50%;
  background: #f6c957;
}
.hero-cloud {
  position: absolute;
  width: 72px;
  height: 28px;
  left: 35px;
  top: 38px;
  border-radius: 30px;
  background: #fff;
  box-shadow: 26px -10px 0 -3px #fff, 47px 2px 0 -8px #fff;
}
.hero-maze {
  position: absolute;
  inset: 103px 34px 27px;
  border: 12px solid #4e966a;
  border-radius: 20px;
}
.hero-maze::before,
.hero-maze::after {
  position: absolute;
  background: #4e966a;
  content: "";
}
.hero-maze::before {
  width: 12px;
  height: 72%;
  left: 34%;
  top: 0;
  box-shadow: 82px 48px 0 #4e966a;
}
.hero-maze::after {
  width: 40%;
  height: 12px;
  left: 34%;
  top: 48%;
  box-shadow: -88px 55px 0 #4e966a;
}
.hero-friend,
.hero-goal {
  position: absolute;
  z-index: 2;
  display: grid;
  width: 50px;
  height: 50px;
  place-items: center;
  border: 5px solid #fff;
  border-radius: 50%;
  background: #fff7dc;
  font-size: 27px;
  box-shadow: 0 7px 12px #31544b24;
}
.hero-friend { left: 48px; bottom: 38px; }
.hero-goal { right: 48px; top: 116px; }

.routes-section { margin-top: 46px; scroll-margin-top: 20px; }
.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 25px;
  margin-bottom: 20px;
}
.section-head h2 {
  margin: 7px 0 0;
  font-size: clamp(32px, 4vw, 45px);
  letter-spacing: -1.2px;
}
.section-head p {
  max-width: 370px;
  margin: 0 0 5px;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.45;
  text-align: right;
}
.route-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}
.route-card {
  position: relative;
  min-height: 325px;
  overflow: hidden;
  padding: 25px;
  border: 2px solid var(--line);
  border-radius: 30px;
  background: var(--paper);
  box-shadow: 0 10px 0 #d9d1b8, 0 18px 34px #31544b12;
}
.route-card::after {
  position: absolute;
  width: 120px;
  height: 120px;
  right: -50px;
  top: -48px;
  border: 18px solid color-mix(in srgb, var(--route-color), transparent 72%);
  border-radius: 50%;
  content: "";
}
.route-number {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border-radius: 17px;
  background: var(--route-color);
  color: #fff;
  font: 900 25px Georgia, serif;
  box-shadow: 0 5px 0 color-mix(in srgb, var(--route-color), #183b32 28%);
}
.route-card h3 {
  margin: 26px 0 9px;
  font-size: 28px;
  line-height: 1.08;
}
.route-card p {
  min-height: 66px;
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.42;
}
.route-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 18px 0 16px;
  color: #647972;
  font-size: 13px;
  font-weight: 900;
}
.route-progress-track {
  flex: 1;
  height: 10px;
  overflow: hidden;
  border-radius: 10px;
  background: #e7e2d4;
}
.route-progress-track i {
  display: block;
  width: var(--route-progress);
  height: 100%;
  border-radius: inherit;
  background: var(--route-color);
}

.game-shell {
  padding: 28px;
  border: 2px solid var(--line);
  border-radius: 34px;
  background: var(--paper);
  box-shadow: 0 20px 52px #31544b17;
}
.game-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: end;
  margin-bottom: 22px;
}
.game-head h1 {
  margin: 7px 0 5px;
  font-size: clamp(34px, 4.5vw, 52px);
  letter-spacing: -1.4px;
}
.game-head p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}
.step-progress {
  display: flex;
  min-width: 260px;
  align-items: center;
  gap: 12px;
  font-weight: 900;
}
.step-progress-track {
  flex: 1;
  height: 14px;
  overflow: hidden;
  border-radius: 12px;
  background: #e5e1d6;
}
.step-progress-track i {
  display: block;
  width: var(--step-progress);
  height: 100%;
  border-radius: inherit;
  background: var(--route-color);
}
.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.48fr) minmax(270px, .72fr);
  gap: 22px;
}
.maze-panel,
.guide-panel {
  border: 2px solid var(--line);
  border-radius: 28px;
}
.maze-panel { padding: 18px; background: #fbf7e9; }
.maze-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  color: #5f7770;
  font-size: 14px;
  font-weight: 900;
}
.maze-board {
  --cell-size: min(56px, calc((100vw - 150px) / var(--maze-size)));
  display: grid;
  width: min(100%, 650px);
  aspect-ratio: 1;
  grid-template-columns: repeat(var(--maze-size), 1fr);
  overflow: hidden;
  margin: 0 auto;
  border: 8px solid #fff;
  border-radius: 24px;
  background: #e9ddad;
  box-shadow: 0 12px 0 #d2c49a, 0 17px 26px #31544b17;
  touch-action: none;
  user-select: none;
}
.maze-cell {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  place-items: center;
}
.maze-cell.wall {
  background:
    radial-gradient(circle at 30% 26%, #8abc6d 0 22%, transparent 23%),
    radial-gradient(circle at 68% 66%, #6ca65d 0 26%, transparent 27%),
    linear-gradient(145deg, #78ad61, #4f8d53);
  box-shadow: inset 0 0 0 1px #3e764b24;
}
.maze-cell.floor {
  background:
    radial-gradient(#c59f5d42 1px, transparent 1.5px),
    #f8e7b2;
  background-size: 9px 9px;
}
.maze-cell.trail { background: #f7cf70; }
.maze-cell.hint {
  z-index: 1;
  background: #fff0a6;
  box-shadow: inset 0 0 0 4px #efb13c;
}
.maze-cell.hint::after {
  color: #c78016;
  content: "•";
  font-size: clamp(18px, 3vw, 32px);
}
.player,
.goal {
  position: absolute;
  z-index: 4;
  display: grid;
  width: 82%;
  height: 82%;
  place-items: center;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 4px 8px #31544b32;
  font-size: clamp(15px, 3vw, 32px);
  line-height: 1;
  pointer-events: none;
}
.player { background: #fff6d8; }
.goal { background: #eef9ed; }
.maze-board.wall-notice { box-shadow: 0 12px 0 #d2c49a, 0 17px 26px #31544b17, 0 0 0 6px #e9867248; }

.guide-panel {
  display: flex;
  min-width: 0;
  flex-direction: column;
  padding: 24px;
  background: linear-gradient(160deg, #f1f8ef, #fffaf0);
}
.guide-panel h2 {
  margin: 8px 0 10px;
  font-size: 29px;
  line-height: 1.1;
}
.guide-panel > p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.5;
}
.status-card {
  min-height: 86px;
  margin-top: 19px;
  padding: 15px 16px;
  border: 2px solid #d8dfcf;
  border-radius: 18px;
  background: #fff;
  color: #60766f;
  font-weight: 800;
  line-height: 1.4;
}
.status-card.is-error {
  border-color: #e59c91;
  background: #fff1ee;
  color: #91483e;
}
.status-card.is-hint {
  border-color: #e6bf5d;
  background: #fff7d9;
  color: #815c16;
}
.status-card.is-success {
  border-color: #7fbc99;
  background: #eaf7ed;
  color: #2f6f55;
}
.guide-actions {
  display: grid;
  gap: 11px;
  margin-top: 18px;
}
.guide-actions .primary-button,
.guide-actions .secondary-button { width: 100%; }
.dpad {
  display: grid;
  width: 178px;
  grid-template-columns: repeat(3, 54px);
  grid-template-rows: repeat(3, 54px);
  gap: 7px;
  margin: 21px auto 0;
}
.control-button {
  display: grid;
  padding: 0;
  place-items: center;
  border: 2px solid #bcd0bf;
  background: #fff;
  color: #34775c;
  font-size: 24px;
  box-shadow: 0 4px 0 #cdd8c9;
}
.control-button:hover { background: #eff8ed; border-color: #72a987; }
.control-button:active { transform: translateY(3px); box-shadow: 0 1px 0 #cdd8c9; }
.control-up { grid-column: 2; grid-row: 1; }
.control-left { grid-column: 1; grid-row: 2; }
.control-right { grid-column: 3; grid-row: 2; }
.control-down { grid-column: 2; grid-row: 3; }
.keyboard-note {
  margin-top: auto;
  padding-top: 18px;
  color: #7a8d88;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.4;
}

.result {
  display: grid;
  min-height: 610px;
  place-items: center;
  padding: 45px;
  border: 2px solid var(--line);
  border-radius: 36px;
  background: linear-gradient(145deg, #fffdf7, #ecf7e9);
  box-shadow: 0 20px 52px #31544b17;
  text-align: center;
}
.result-inner { max-width: 680px; }
.result-icon {
  display: grid;
  width: 112px;
  height: 112px;
  margin: 0 auto 24px;
  place-items: center;
  border: 8px solid #fff;
  border-radius: 50%;
  background: #f4c957;
  box-shadow: 0 9px 0 #d7a63a, 0 15px 28px #31544b20;
  font-size: 57px;
}
.result h1 {
  margin: 10px 0 13px;
  font-size: clamp(40px, 5vw, 62px);
  line-height: 1.02;
  letter-spacing: -1.8px;
}
.result p {
  margin: 0 auto;
  color: var(--muted);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.5;
}
.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 28px 0;
}
.result-stat {
  padding: 17px 10px;
  border: 2px solid #d9dfd0;
  border-radius: 18px;
  background: #fff;
}
.result-stat b { display: block; font-size: 28px; }
.result-stat span { color: #748680; font-size: 12px; font-weight: 900; }
.result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

@media (max-width: 900px) {
  .hero { min-height: 0; grid-template-columns: 1fr; padding: 38px; }
  .hero-visual { height: 270px; }
  .route-grid { grid-template-columns: 1fr; }
  .route-card { min-height: 0; }
  .route-card p { min-height: 0; }
  .game-layout { grid-template-columns: 1fr; }
  .guide-panel { min-height: 0; }
  .keyboard-note { margin-top: 12px; }
}

@media (max-width: 700px) {
  .page { padding-top: 14px; }
  .top-note { display: none; }
  .hero { padding: 30px 24px; border-radius: 30px; }
  .hero h1 { font-size: clamp(38px, 12vw, 52px); }
  .hero p { font-size: 16px; }
  .hero-visual { height: 235px; }
  .section-head { display: block; }
  .section-head p { margin-top: 10px; text-align: left; }
  .game-shell { padding: 18px; border-radius: 27px; }
  .game-head { grid-template-columns: 1fr; }
  .step-progress { min-width: 0; }
  .maze-panel { padding: 10px; }
  .maze-board { border-width: 5px; border-radius: 18px; }
  .guide-panel { padding: 19px; }
  .result { min-height: 540px; padding: 28px 20px; }
}

@media (max-width: 440px) {
  .app { width: min(100% - 18px, 1120px); }
  .brand strong { font-size: 19px; }
  .brand-icon { width: 50px; height: 47px; }
  .hero { padding: 25px 18px; }
  .hero h1 { font-size: 38px; letter-spacing: -1.2px; }
  .hero-visual { height: 210px; }
  .hero-maze { inset: 78px 19px 20px; }
  .hero-friend { left: 27px; bottom: 27px; }
  .hero-goal { right: 27px; top: 88px; }
  .route-card { padding: 21px; }
  .game-shell { padding: 12px; }
  .game-head h1 { font-size: 34px; }
  .maze-panel-head { align-items: flex-start; flex-direction: column; }
  .maze-board { width: 100%; }
  .player, .goal { border-width: 2px; font-size: clamp(13px, 6vw, 24px); }
  .result-stats { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}
