:root {
  color-scheme: dark;
  --ink: #eafcff;
  --muted: #86a7b9;
  --panel: rgba(10, 29, 49, .82);
  --line: rgba(108, 228, 255, .2);
  --cyan: #3ef2ff;
  --cyan-bright: #b9fbff;
  --violet: #9b6cff;
  --pink: #ff5cd6;
  --lime: #baff70;
  --navy: #071426;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: #030b17; }

body {
  margin: 0;
  min-width: 300px;
  min-height: 100dvh;
  overflow-x: hidden;
  color: var(--ink);
  font-family: "Segoe UI", "Yu Gothic UI", "Hiragino Kaku Gothic ProN", sans-serif;
  background:
    radial-gradient(circle at 8% 8%, rgba(40, 145, 202, .23), transparent 34rem),
    radial-gradient(circle at 92% 82%, rgba(139, 75, 219, .18), transparent 32rem),
    linear-gradient(145deg, #061323 0%, #020713 78%);
  overscroll-behavior: none;
}

button { color: inherit; font: inherit; -webkit-tap-highlight-color: transparent; }
button:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.hidden { display: none !important; }

.app {
  position: relative;
  isolation: isolate;
  width: min(100%, 1220px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 0 28px 24px;
}

.app::before {
  position: fixed;
  z-index: -3;
  inset: 0;
  content: "";
  opacity: .28;
  background-image:
    linear-gradient(rgba(80, 194, 255, .06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(80, 194, 255, .06) 1px, transparent 1px);
  background-size: 52px 52px;
  mask-image: linear-gradient(to bottom, black, transparent 85%);
}

.ambient {
  position: fixed;
  z-index: -2;
  width: 460px;
  height: 460px;
  border-radius: 50%;
  filter: blur(110px);
  opacity: .12;
  pointer-events: none;
}

.ambient-one { top: -250px; left: -170px; background: var(--cyan); }
.ambient-two { right: -210px; bottom: -230px; background: var(--violet); }

.topbar {
  position: relative;
  z-index: 10;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(112, 222, 255, .16);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 5px;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}

.brand-icon {
  position: relative;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(62, 242, 255, .7);
  clip-path: polygon(0 0, 76% 0, 100% 24%, 100% 100%, 24% 100%, 0 76%);
  box-shadow: inset 0 0 18px rgba(62, 242, 255, .18);
}

.brand-icon::before,
.brand-icon::after,
.brand-icon i {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  content: "";
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
}

.brand-icon::before { top: 8px; left: 8px; }
.brand-icon::after { right: 7px; bottom: 7px; }
.brand-icon i:nth-child(1) { top: 16px; left: 16px; }
.brand-icon i:nth-child(2) { top: 8px; right: 8px; }
.brand-icon i:nth-child(3) { bottom: 7px; left: 8px; }

.brand b {
  display: block;
  color: #e9fdff;
  font-size: 15px;
  line-height: 1.05;
  letter-spacing: .17em;
}

.brand small {
  display: block;
  margin-top: 3px;
  color: #638ca2;
  font-size: 8px;
  letter-spacing: .28em;
}

.top-actions { display: flex; align-items: center; gap: 12px; }

.best-chip {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 7px 14px;
  border: 1px solid rgba(132, 209, 237, .14);
  border-radius: 4px;
  background: rgba(5, 18, 33, .5);
}

.best-chip small { color: #6c91a5; font-size: 9px; letter-spacing: .17em; }
.best-chip b { color: var(--cyan-bright); font-size: 15px; font-variant-numeric: tabular-nums; }

.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(62, 242, 255, .32);
  border-radius: 50%;
  background: rgba(9, 30, 49, .72);
  cursor: pointer;
  transition: .2s ease;
}

.icon-button:hover { color: var(--cyan); border-color: var(--cyan); box-shadow: 0 0 18px rgba(62, 242, 255, .18); }
.icon-button[aria-pressed="false"] { color: #527084; opacity: .7; }

.screen { min-height: calc(100dvh - 94px); }

.start-screen {
  position: relative;
  display: grid;
  grid-template-columns: minmax(350px, .88fr) minmax(440px, 1.12fr);
  align-items: center;
  gap: 28px;
  padding: 28px 20px 66px;
}

.start-copy { position: relative; z-index: 3; max-width: 500px; }

.eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
  color: #75b7ce;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .28em;
}

.eyebrow > span {
  width: 29px;
  height: 1px;
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
}

.centered { justify-content: center; }

h1 {
  margin: 0;
  font-size: clamp(46px, 5.6vw, 78px);
  font-weight: 900;
  line-height: .94;
  letter-spacing: -.06em;
  text-shadow: 0 4px 36px rgba(0, 0, 0, .6);
}

h1 em {
  color: transparent;
  font-size: 1.04em;
  font-style: normal;
  letter-spacing: -.08em;
  background: linear-gradient(94deg, var(--cyan) 6%, #8affff 48%, #c7acff 92%);
  -webkit-background-clip: text;
  background-clip: text;
  filter: drop-shadow(0 0 17px rgba(62, 242, 255, .24));
}

.lead {
  margin: 22px 0 26px;
  color: #8eacbc;
  font-size: 16px;
  line-height: 1.8;
}

.lead b { color: #dceef2; font-size: 18px; }

.primary-button,
.secondary-button {
  position: relative;
  overflow: hidden;
  border: 0;
  border-radius: 5px;
  cursor: pointer;
  transition: transform .18s ease, filter .18s ease, box-shadow .18s ease;
}

.primary-button {
  min-width: 262px;
  padding: 13px 52px 12px 24px;
  color: #03121a;
  text-align: left;
  background: linear-gradient(105deg, #48f4ff 0%, #8dfcf4 58%, #bbffdf 100%);
  box-shadow: 0 0 30px rgba(62, 242, 255, .22), inset 0 -2px 0 rgba(0, 87, 101, .25);
}

.primary-button::after {
  position: absolute;
  top: 0;
  right: 0;
  width: 44px;
  height: 100%;
  content: "";
  background: rgba(255, 255, 255, .2);
  clip-path: polygon(38% 0, 100% 0, 100% 100%, 0 100%);
}

.primary-button b { position: relative; z-index: 1; display: block; font-size: 17px; letter-spacing: .05em; }
.primary-button small { position: relative; z-index: 1; display: block; margin-top: 2px; font-size: 8px; font-weight: 800; letter-spacing: .24em; opacity: .6; }
.primary-button small i { margin-left: 8px; font-size: 12px; font-style: normal; }
.primary-button:hover { transform: translateY(-2px); filter: brightness(1.08); box-shadow: 0 8px 38px rgba(62, 242, 255, .3); }
.primary-button:active { transform: translateY(1px); }

.button-glow {
  position: absolute;
  inset: -100% 40%;
  transform: rotate(18deg);
  background: rgba(255, 255, 255, .42);
  animation: buttonShine 3.6s ease-in-out infinite;
}

@keyframes buttonShine { 0%, 68% { left: -130%; } 100% { left: 130%; } }

.feature-row { display: flex; gap: 24px; margin-top: 24px; color: #60879b; font-size: 8px; letter-spacing: .16em; }
.feature-row span { display: flex; align-items: center; gap: 6px; }
.feature-row i { color: var(--cyan); font-size: 15px; font-style: normal; font-weight: 800; }

.hero-maze { position: relative; height: min(510px, 66vh); min-height: 390px; perspective: 1000px; }

.maze-card {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  width: min(400px, 78%);
  aspect-ratio: .96;
  padding: 18px 18px 38px;
  transform: translate(-50%, -50%) rotateX(6deg) rotateY(-9deg) rotateZ(2deg);
  border: 1px solid rgba(87, 230, 255, .34);
  border-radius: 7px;
  background: linear-gradient(145deg, rgba(12, 39, 63, .92), rgba(4, 14, 29, .97));
  box-shadow: 28px 32px 80px rgba(0, 0, 0, .47), inset 0 0 40px rgba(35, 193, 225, .06), 0 0 40px rgba(62, 242, 255, .09);
}

.maze-card::before,
.maze-card::after { position: absolute; width: 28px; height: 28px; content: ""; border-color: var(--cyan); opacity: .6; }
.maze-card::before { top: -5px; left: -5px; border-top: 2px solid; border-left: 2px solid; }
.maze-card::after { right: -5px; bottom: -5px; border-right: 2px solid; border-bottom: 2px solid; }

.maze-grid {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border: 2px solid rgba(107, 230, 255, .65);
  background:
    linear-gradient(rgba(37, 111, 148, .16) 1px, transparent 1px),
    linear-gradient(90deg, rgba(37, 111, 148, .16) 1px, transparent 1px),
    radial-gradient(circle at 50% 50%, rgba(28, 109, 144, .16), transparent 70%),
    #050f21;
  background-size: 14.285% 14.285%, 14.285% 14.285%, auto, auto;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, .58), 0 0 22px rgba(62, 242, 255, .12);
}

.wall { position: absolute; display: block; background: #7ef7ff; box-shadow: 0 0 7px rgba(62, 242, 255, .86); }
.w1 { top: 14%; left: 14%; width: 2px; height: 43%; }
.w2 { top: 28%; left: 28%; width: 43%; height: 2px; }
.w3 { top: 28%; right: 14%; width: 2px; height: 43%; }
.w4 { top: 56%; left: 14%; width: 43%; height: 2px; }
.w5 { top: 42%; left: 42%; width: 2px; height: 44%; }
.w6 { top: 71%; left: 42%; width: 43%; height: 2px; }
.w7 { top: 0; left: 71%; width: 2px; height: 29%; }
.w8 { top: 85%; left: 14%; width: 29%; height: 2px; }

.route { position: absolute; display: block; height: 5px; border-radius: 9px; background: rgba(173, 255, 242, .56); box-shadow: 0 0 13px var(--cyan); transform-origin: left center; }
.r1 { top: 7%; left: 6%; width: 52%; }
.r2 { top: 7%; left: 57%; width: 24%; transform: rotate(90deg); }
.r3 { top: 31%; left: 58%; width: 27%; }
.r4 { top: 31%; left: 85%; width: 52%; transform: rotate(90deg); }
.r5 { top: 83%; left: 85%; width: 10%; }

.hero-runner {
  position: absolute;
  z-index: 4;
  top: 3.6%;
  left: 3.6%;
  width: 24px;
  height: 24px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 10px #fff, 0 0 28px var(--cyan), 0 0 55px rgba(62, 242, 255, .8);
  animation: runnerPulse 1.6s ease-in-out infinite;
}

.hero-runner b { position: absolute; inset: 5px; border: 2px solid #063c4f; border-radius: 50%; }

@keyframes runnerPulse { 50% { transform: scale(1.12); box-shadow: 0 0 14px #fff, 0 0 40px var(--cyan), 0 0 70px rgba(62, 242, 255, .9); } }

.hero-gem,
.mini-gem,
.legend-energy {
  display: block;
  width: 15px;
  height: 15px;
  transform: rotate(45deg);
  border: 2px solid #fff6bc;
  background: #fff06d;
  box-shadow: 0 0 13px #ffe852;
}

.hero-gem { position: absolute; z-index: 3; animation: gemFloat 1.8s ease-in-out infinite; }
.gem-one { top: 27%; left: 54%; }
.gem-two { top: 78%; right: 10%; animation-delay: -.7s; }
@keyframes gemFloat { 50% { transform: rotate(45deg) scale(.78); filter: brightness(1.4); } }

.hero-exit {
  position: absolute;
  right: 3%;
  bottom: 3%;
  width: 28px;
  height: 28px;
  border: 4px solid var(--pink);
  border-radius: 50%;
  box-shadow: 0 0 16px var(--pink), inset 0 0 12px var(--pink);
  animation: exitPulse 1.3s ease-in-out infinite;
}

@keyframes exitPulse { 50% { opacity: .55; transform: scale(.82); } }

.card-label { display: flex; justify-content: space-between; padding: 11px 1px 0; color: #5d8498; font-size: 8px; letter-spacing: .2em; }
.card-label b { color: #9bdce7; }

.hero-orbit { position: absolute; top: 50%; left: 50%; border: 1px solid rgba(74, 214, 255, .12); border-radius: 50%; transform: translate(-50%, -50%); }
.orbit-one { width: 94%; aspect-ratio: 1; animation: spin 40s linear infinite; }
.orbit-two { width: 70%; aspect-ratio: 1; border-style: dashed; animation: spinReverse 25s linear infinite; }
.hero-orbit::before { position: absolute; top: 50%; left: -3px; width: 6px; height: 6px; border-radius: 50%; content: ""; background: var(--cyan); box-shadow: 0 0 10px var(--cyan); }
@keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } }
@keyframes spinReverse { to { transform: translate(-50%, -50%) rotate(-360deg); } }

.floating-tag {
  position: absolute;
  z-index: 4;
  min-width: 92px;
  padding: 10px 13px;
  border: 1px solid rgba(91, 228, 255, .3);
  border-radius: 4px;
  background: rgba(7, 24, 42, .84);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .35);
  backdrop-filter: blur(8px);
}

.floating-tag small { display: block; color: #4f879e; font-size: 7px; letter-spacing: .2em; }
.floating-tag b { display: block; margin-top: 3px; color: var(--cyan); font-size: 11px; letter-spacing: .08em; }
.tag-a { top: 18%; left: 3%; }
.tag-b { right: 3%; bottom: 17%; }

.how-strip {
  position: absolute;
  right: 20px;
  bottom: 17px;
  left: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(18px, 4vw, 54px);
  padding-top: 16px;
  border-top: 1px solid rgba(112, 222, 255, .13);
}

.how-strip span { display: flex; align-items: center; gap: 10px; color: #92aebb; font-size: 11px; }
.how-strip i { display: grid; width: 25px; height: 25px; place-items: center; border: 1px solid rgba(62, 242, 255, .28); border-radius: 50%; color: var(--cyan); font-size: 8px; font-style: normal; }
.how-strip em { color: #386279; font-style: normal; }

/* Game */
.game-screen { padding: 18px 0 8px; }

.hud {
  display: grid;
  grid-template-columns: repeat(5, minmax(78px, 1fr));
  margin-bottom: 14px;
  border: 1px solid rgba(105, 224, 255, .16);
  border-radius: 6px;
  background: rgba(6, 22, 39, .66);
  box-shadow: inset 0 0 25px rgba(39, 171, 208, .025);
}

.hud > div { position: relative; padding: 9px 15px 8px; border-right: 1px solid rgba(105, 224, 255, .11); }
.hud > div:last-child { border-right: 0; }
.hud > div::before { position: absolute; top: 0; left: 14px; width: 22px; height: 1px; content: ""; background: var(--cyan); opacity: .58; }
.hud small { display: block; color: #577f94; font-size: 7px; font-weight: 800; letter-spacing: .23em; }
.hud strong { display: block; margin-top: 2px; font-size: 19px; font-variant-numeric: tabular-nums; letter-spacing: .03em; }
.hud strong i { color: #527083; font-size: 10px; font-style: normal; }
.hud-score strong { color: var(--cyan); }

.game-layout {
  display: grid;
  grid-template-columns: minmax(360px, 1.65fr) minmax(285px, .76fr);
  gap: 18px;
  align-items: stretch;
}

.maze-shell {
  position: relative;
  min-height: min(68vh, 610px);
  overflow: hidden;
  border: 1px solid rgba(72, 224, 255, .27);
  border-radius: 7px;
  background: rgba(2, 11, 24, .8);
  box-shadow: inset 0 0 55px rgba(2, 7, 18, .95), 0 18px 60px rgba(0, 0, 0, .28);
}

.maze-shell::before {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
  background: linear-gradient(rgba(48, 192, 232, .035) 1px, transparent 1px), linear-gradient(90deg, rgba(48, 192, 232, .035) 1px, transparent 1px);
  background-size: 28px 28px;
}

#mazeCanvas {
  position: absolute;
  top: 50%;
  left: 50%;
  display: block;
  width: min(calc(100% - 38px), calc(100% - 38px));
  height: calc(100% - 42px);
  max-width: calc(100% - 38px);
  max-height: calc(100% - 42px);
  transform: translate(-50%, -50%);
  touch-action: none;
}

.corner { position: absolute; z-index: 2; width: 24px; height: 24px; border-color: var(--cyan); opacity: .72; pointer-events: none; }
.corner-tl { top: 8px; left: 8px; border-top: 2px solid; border-left: 2px solid; }
.corner-tr { top: 8px; right: 8px; border-top: 2px solid; border-right: 2px solid; }
.corner-bl { bottom: 8px; left: 8px; border-bottom: 2px solid; border-left: 2px solid; }
.corner-br { right: 8px; bottom: 8px; border-right: 2px solid; border-bottom: 2px solid; }

.canvas-badge { position: absolute; z-index: 3; top: 10px; left: 50%; display: flex; align-items: center; gap: 7px; padding: 4px 10px; transform: translateX(-50%); border: 1px solid rgba(95, 222, 255, .14); border-radius: 10px; color: #578095; font-size: 7px; letter-spacing: .18em; background: rgba(3, 16, 29, .78); }
.canvas-badge span { width: 4px; height: 4px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 7px var(--lime); }

.toast {
  position: absolute;
  z-index: 6;
  bottom: 20px;
  left: 50%;
  min-width: 160px;
  margin: 0;
  padding: 9px 15px;
  transform: translate(-50%, 14px);
  border: 1px solid rgba(93, 230, 255, .35);
  border-radius: 4px;
  color: var(--cyan-bright);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  background: rgba(3, 18, 33, .93);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .36), 0 0 16px rgba(62, 242, 255, .1);
  opacity: 0;
  pointer-events: none;
  transition: .25s ease;
}

.toast.show { transform: translate(-50%, 0); opacity: 1; }

.pause-overlay { position: absolute; z-index: 5; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: rgba(2, 10, 23, .84); backdrop-filter: blur(7px); }
.pause-overlay span { display: grid; width: 68px; height: 68px; margin-bottom: 15px; place-items: center; border: 1px solid var(--cyan); border-radius: 50%; color: var(--cyan); font-size: 29px; box-shadow: 0 0 30px rgba(62, 242, 255, .14); }
.pause-overlay b { font-size: 21px; letter-spacing: .2em; }
.pause-overlay small { margin-top: 6px; color: var(--muted); }

.control-panel { display: flex; min-height: 0; flex-direction: column; gap: 12px; }

.mission-card {
  position: relative;
  padding: 17px 18px 15px;
  border: 1px solid rgba(102, 221, 255, .16);
  border-radius: 6px;
  background: linear-gradient(145deg, rgba(13, 38, 59, .84), rgba(6, 20, 36, .85));
}

.mission-card::after { position: absolute; top: -1px; right: 17px; width: 50px; height: 2px; content: ""; background: linear-gradient(90deg, transparent, var(--cyan)); }
.mission-card > p { display: flex; align-items: center; gap: 7px; margin: 0; color: #5d899d; font-size: 7px; font-weight: 800; letter-spacing: .22em; }
.mission-card > p span { width: 5px; height: 5px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }
.mission-card h2 { margin: 7px 0 10px; font-size: 22px; letter-spacing: .02em; }
.mission-target { display: flex; align-items: center; gap: 9px; color: #a7c1cc; font-size: 11px; }
.mini-gem { width: 10px; height: 10px; flex: 0 0 auto; border-width: 1px; }

.route-meter { margin-top: 15px; }
.route-meter > span { color: #52798c; font-size: 6px; font-weight: 800; letter-spacing: .16em; }
.route-meter > b { float: right; color: var(--cyan); font-size: 9px; }
.route-meter > i { display: block; height: 3px; margin-top: 6px; overflow: hidden; border-radius: 3px; background: #102b3c; }
.route-meter > i em { display: block; width: 100%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--violet), var(--cyan)); box-shadow: 0 0 8px var(--cyan); transition: width .3s ease; }

.dpad {
  display: grid;
  width: min(214px, 80%);
  aspect-ratio: 1.15;
  margin: 0 auto;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 5px;
  grid-template-areas: ". up ." "left core right" ". down .";
}

.move-button {
  position: relative;
  border: 1px solid rgba(83, 216, 249, .26);
  border-radius: 7px;
  color: #b8e9f1;
  font-size: 22px;
  background: linear-gradient(145deg, rgba(18, 51, 72, .96), rgba(7, 25, 42, .96));
  box-shadow: inset 0 0 18px rgba(44, 177, 210, .05), 0 4px 10px rgba(0, 0, 0, .18);
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  transition: .12s ease;
}

.move-button:hover { color: #fff; border-color: var(--cyan); box-shadow: inset 0 0 18px rgba(62, 242, 255, .14), 0 0 15px rgba(62, 242, 255, .1); }
.move-button:active { transform: scale(.92); color: var(--cyan); background: rgba(25, 75, 94, .95); }
.move-button small { position: absolute; right: 6px; bottom: 3px; color: #456d7f; font-size: 7px; }
.move-button.up { grid-area: up; }
.move-button.left { grid-area: left; }
.move-button.right { grid-area: right; }
.move-button.down { grid-area: down; }

.dpad-core { grid-area: core; display: grid; place-items: center; border: 1px solid rgba(72, 199, 234, .12); border-radius: 50%; }
.dpad-core i { width: 17px; height: 17px; border: 1px solid rgba(62, 242, 255, .45); border-radius: 50%; box-shadow: 0 0 15px rgba(62, 242, 255, .12); }

.tool-row { display: grid; grid-template-columns: 1.45fr .8fr; gap: 8px; }
.scan-button,
.pause-button { min-height: 54px; border: 1px solid rgba(116, 202, 248, .18); border-radius: 5px; background: rgba(8, 27, 45, .9); cursor: pointer; transition: .17s ease; }
.scan-button:hover,
.pause-button:hover { border-color: var(--violet); box-shadow: 0 0 18px rgba(155, 108, 255, .12); }
.scan-button:disabled { opacity: .42; cursor: not-allowed; }
.scan-button span { float: left; margin: 1px 10px 0 5px; color: #ba95ff; font-size: 23px; }
.scan-button b,
.scan-button small,
.pause-button b { display: block; text-align: left; }
.scan-button b { color: #cfc6f6; font-size: 11px; }
.scan-button small { margin-top: 2px; color: #657a91; font-size: 8px; }
.scan-button small i { color: #b99bfa; font-style: normal; }
.pause-button span { display: block; color: #7fabbd; font-size: 15px; }
.pause-button b { margin-top: 2px; color: #83a0ad; font-size: 9px; text-align: center; }
.control-help { margin: -3px 0 0; color: #4e7285; font-size: 8px; text-align: center; }
.legend { display: flex; justify-content: center; gap: 16px; margin-top: auto; padding: 8px 5px; border-top: 1px solid rgba(91, 210, 244, .1); color: #638393; font-size: 8px; }
.legend span { display: flex; align-items: center; gap: 5px; }
.legend i { display: inline-block; width: 8px; height: 8px; flex: 0 0 auto; }
.legend-runner { border: 2px solid white; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 6px var(--cyan); }
.legend-energy { border-width: 1px; }
.legend-exit { border: 2px solid var(--pink); border-radius: 50%; box-shadow: 0 0 6px var(--pink); }

/* Results */
.result-screen,
.fail-screen,
.final-screen {
  position: relative;
  display: flex;
  min-height: calc(100dvh - 80px);
  max-width: 760px;
  margin: 0 auto;
  padding: 34px 20px 28px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.result-icon,
.fail-symbol {
  position: relative;
  z-index: 2;
  display: grid;
  width: 74px;
  height: 74px;
  margin-bottom: 20px;
  place-items: center;
  transform: rotate(45deg);
  border: 2px solid var(--cyan);
  background: rgba(10, 45, 60, .82);
  box-shadow: 0 0 32px rgba(62, 242, 255, .25), inset 0 0 24px rgba(62, 242, 255, .13);
}

.result-icon span,
.fail-symbol span { transform: rotate(-45deg); color: var(--cyan); font-size: 35px; font-weight: 300; }
.fail-symbol { border-color: var(--pink); box-shadow: 0 0 32px rgba(255, 92, 214, .2); }
.fail-symbol span { color: var(--pink); }
.result-rings { position: absolute; top: 50%; left: 50%; width: 430px; height: 430px; transform: translate(-50%, -58%); pointer-events: none; }
.result-rings i { position: absolute; inset: 0; border: 1px solid rgba(65, 227, 255, .08); border-radius: 50%; }
.result-rings i:nth-child(2) { inset: 55px; border-style: dashed; animation: spin 30s linear infinite; }
.result-rings i:nth-child(3) { inset: 120px; border-color: rgba(155, 108, 255, .14); }

.result-screen h2,
.fail-screen h2,
.final-screen h2 { position: relative; z-index: 1; margin: 0; font-size: clamp(32px, 5vw, 48px); letter-spacing: -.04em; }
.result-lead { position: relative; z-index: 1; margin: 9px 0 18px; color: #86a5b4; font-size: 13px; }

.rank {
  position: absolute;
  z-index: 0;
  top: 49%;
  right: 5%;
  transform: translateY(-50%) rotate(8deg);
  color: rgba(62, 242, 255, .075);
  font-size: 230px;
  font-weight: 900;
  line-height: 1;
}

.result-stats {
  position: relative;
  z-index: 1;
  display: grid;
  width: min(100%, 600px);
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 15px;
  border: 1px solid rgba(97, 220, 255, .18);
  border-radius: 6px;
  background: rgba(7, 25, 43, .74);
}

.result-stats div { padding: 13px 12px; border-right: 1px solid rgba(97, 220, 255, .12); }
.result-stats div:last-child { border-right: 0; }
.result-stats small { display: block; color: #587e90; font-size: 7px; letter-spacing: .16em; }
.result-stats b { display: block; margin-top: 3px; color: var(--cyan-bright); font-size: 22px; }

.brain-tip {
  position: relative;
  z-index: 1;
  width: min(100%, 600px);
  margin-bottom: 18px;
  padding: 12px 16px;
  border-left: 2px solid var(--violet);
  color: #91a8b5;
  text-align: left;
  background: rgba(18, 24, 51, .55);
}

.brain-tip span { color: #ac8fff; font-size: 7px; font-weight: 800; letter-spacing: .2em; }
.brain-tip p { margin: 4px 0 0; font-size: 11px; line-height: 1.55; }

.result-actions { position: relative; z-index: 2; display: flex; align-items: stretch; justify-content: center; gap: 10px; width: min(100%, 600px); }
.secondary-button { padding: 11px 20px; border: 1px solid rgba(110, 211, 239, .22); color: #92acb8; font-size: 11px; background: rgba(8, 24, 41, .9); }
.secondary-button:hover { color: #fff; border-color: var(--cyan); }
.primary-button.compact { min-width: 210px; padding-top: 10px; padding-bottom: 9px; }

.final-burst { position: relative; width: 100px; height: 85px; margin-bottom: 6px; }
.final-burst::before { position: absolute; top: 18px; left: 21px; width: 58px; height: 58px; transform: rotate(45deg); border: 2px solid var(--cyan); content: ""; box-shadow: 0 0 30px rgba(62, 242, 255, .3); }
.final-burst::after { position: absolute; top: 34px; left: 37px; width: 26px; height: 26px; transform: rotate(45deg); content: "✓"; color: #071426; font-size: 20px; font-weight: 900; line-height: 26px; background: var(--cyan); box-shadow: 0 0 20px var(--cyan); }
.final-burst i { position: absolute; width: 5px; height: 5px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 9px var(--cyan); }
.final-burst i:nth-child(1) { top: 4px; left: 48px; }
.final-burst i:nth-child(2) { top: 39px; left: 3px; }
.final-burst i:nth-child(3) { top: 39px; right: 3px; }
.final-burst i:nth-child(4) { bottom: 0; left: 48px; }

.final-score { position: relative; z-index: 1; width: min(100%, 430px); margin: 4px 0 15px; padding: 15px; border: 1px solid rgba(65, 230, 255, .25); border-radius: 6px; background: radial-gradient(circle, rgba(31, 102, 125, .2), rgba(7, 23, 39, .78)); box-shadow: 0 0 35px rgba(62, 242, 255, .07); }
.final-score small { display: block; color: #608697; font-size: 8px; letter-spacing: .24em; }
.final-score strong { display: block; margin: 2px 0; color: var(--cyan); font-size: 46px; line-height: 1.05; font-variant-numeric: tabular-nums; text-shadow: 0 0 25px rgba(62, 242, 255, .38); }
.final-score span { color: #c3a7ff; font-size: 10px; font-weight: 800; letter-spacing: .18em; }
.mastery-row { position: relative; z-index: 1; display: flex; gap: 10px; margin-bottom: 16px; }
.mastery-row span { padding: 7px 11px; border: 1px solid rgba(133, 197, 219, .14); border-radius: 20px; color: #91aab5; font-size: 9px; background: rgba(7, 22, 38, .72); }
.mastery-row i { margin-right: 5px; color: var(--lime); font-style: normal; }
.new-best { position: relative; z-index: 2; margin: -4px 0 12px; color: #ffe979; font-size: 11px; font-weight: 900; letter-spacing: .19em; text-shadow: 0 0 15px #ffde54; animation: newBestPulse 1s ease-in-out infinite alternate; }
@keyframes newBestPulse { to { transform: scale(1.05); filter: brightness(1.3); } }

@media (max-width: 840px) {
  .app { padding-right: 18px; padding-left: 18px; }
  .start-screen { grid-template-columns: 1fr 1fr; padding-right: 0; padding-left: 0; }
  .hero-maze { min-height: 350px; }
  .floating-tag { display: none; }
  .game-layout { grid-template-columns: minmax(330px, 1.4fr) minmax(235px, .72fr); }
  .mission-card { padding: 13px; }
  .mission-card h2 { font-size: 18px; }
  .dpad { width: min(185px, 85%); }
  .control-help { display: none; }
}

@media (max-width: 660px) {
  .app { padding: 0 12px max(18px, env(safe-area-inset-bottom)); }
  .topbar { height: 58px; }
  .best-chip { padding: 6px 9px; }
  .start-screen { display: flex; min-height: calc(100dvh - 58px); padding: 34px 8px 74px; flex-direction: column; justify-content: center; }
  .start-copy { width: 100%; text-align: center; }
  .eyebrow { justify-content: center; }
  h1 { font-size: clamp(46px, 15vw, 66px); }
  .lead { margin: 16px 0 20px; font-size: 14px; }
  .lead b { font-size: 15px; }
  .primary-button { min-width: min(270px, 100%); }
  .feature-row { justify-content: center; gap: 17px; }
  .hero-maze { order: -1; width: 100%; height: 205px; min-height: 205px; margin-bottom: 15px; }
  .maze-card { width: 190px; padding: 9px 9px 25px; }
  .card-label { padding-top: 6px; font-size: 5px; }
  .hero-runner { width: 14px; height: 14px; border-width: 2px; }
  .hero-runner b { inset: 3px; border-width: 1px; }
  .hero-gem { width: 9px; height: 9px; border-width: 1px; }
  .hero-exit { width: 16px; height: 16px; border-width: 2px; }
  .how-strip { right: 0; left: 0; gap: 11px; }
  .how-strip span { gap: 5px; font-size: 9px; }
  .how-strip i { width: 21px; height: 21px; }
  .game-screen { padding-top: 10px; }
  .hud { grid-template-columns: repeat(4, 1fr); margin-bottom: 9px; }
  .hud > div { padding: 7px 7px; text-align: center; }
  .hud > div:nth-child(4) { border-right: 0; }
  .hud-score { grid-column: 1 / -1; border-top: 1px solid rgba(105, 224, 255, .11); }
  .hud > .hud-score { padding: 4px 8px; }
  .hud-score small,
  .hud-score strong { display: inline; margin-right: 7px; font-size: 13px; }
  .hud-score small { font-size: 7px; }
  .hud strong { font-size: 15px; }
  .game-layout { display: flex; flex-direction: column; gap: 9px; }
  .maze-shell { min-height: 0; aspect-ratio: 1; }
  #mazeCanvas { width: calc(100% - 28px); height: calc(100% - 28px); max-width: calc(100% - 28px); max-height: calc(100% - 28px); }
  .canvas-badge { top: 5px; }
  .control-panel { gap: 8px; }
  .mission-card { padding: 9px 12px; }
  .mission-card h2 { display: inline-block; margin: 5px 10px 5px 0; font-size: 16px; }
  .mission-target { display: inline-flex; font-size: 9px; }
  .route-meter { margin-top: 6px; }
  .dpad { width: 190px; height: 164px; }
  .move-button { font-size: 20px; }
  .tool-row { width: min(100%, 360px); margin: 0 auto; }
  .legend { display: none; }
  .result-screen,
  .fail-screen,
  .final-screen { min-height: calc(100dvh - 58px); padding-right: 6px; padding-left: 6px; }
  .result-icon,
  .fail-symbol { width: 58px; height: 58px; margin-bottom: 17px; }
  .result-icon span,
  .fail-symbol span { font-size: 28px; }
  .result-screen h2,
  .fail-screen h2,
  .final-screen h2 { font-size: 31px; }
  .result-stats div { padding: 10px 4px; }
  .result-stats b { font-size: 17px; }
  .result-actions { flex-direction: column-reverse; }
  .result-actions button { width: 100%; }
  .primary-button.compact { min-width: 0; text-align: center; }
  .mastery-row { gap: 5px; }
  .mastery-row span { padding: 6px 8px; font-size: 8px; }
}

@media (max-width: 360px), (max-height: 700px) and (max-width: 660px) {
  .brand small { display: none; }
  .start-screen { padding-top: 18px; }
  .hero-maze { height: 170px; min-height: 170px; }
  .maze-card { width: 155px; }
  h1 { font-size: 43px; }
  .feature-row { margin-top: 14px; }
  .how-strip { display: none; }
  .game-screen { padding-top: 6px; }
  .dpad { width: 160px; height: 138px; }
  .mission-card { display: none; }
}

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