:root {
  --ink: #12302f;
  --muted: #5d736a;
  --panel: rgba(255, 255, 255, 0.78);
  --line: rgba(28, 67, 57, 0.16);
  --leaf: #3e9b62;
  --gold: #f4bc42;
  --danger: #d94d45;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
}

html {
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  position: fixed;
  inset: 0;
  margin: 0;
  min-height: 100vh;
  user-select: none;
  -webkit-user-select: none;
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 16% 12%, rgba(255, 229, 139, 0.42), transparent 24%),
    linear-gradient(180deg, #c9f0cf 0%, #93d7a9 46%, #497c54 100%);
}

.shell {
  width: min(1280px, calc(100vw - 28px));
  margin: 14px auto;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}

.hud {
  display: grid;
  grid-template-columns: 0.7fr 0.7fr 0.8fr 1.25fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.hud > div {
  min-height: 56px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  backdrop-filter: blur(12px);
  box-shadow: 0 9px 24px rgba(19, 57, 43, 0.08);
}

.hud span {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.hud strong {
  display: block;
  line-height: 1.3;
}

.stage {
  position: relative;
  overflow: hidden;
  border-radius: 10px;
  box-shadow: 0 18px 60px rgba(15, 47, 35, 0.22);
  touch-action: none;
  overscroll-behavior: none;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  max-height: min(72vh, calc(100vh - 180px));
  aspect-ratio: 16 / 9;
  border: 1px solid rgba(30, 71, 54, 0.22);
  border-radius: 10px;
  background: #9fe3c0;
  touch-action: none;
  image-rendering: auto;
}

.toast {
  position: absolute;
  right: 20px;
  bottom: 20px;
  max-width: 420px;
  min-height: 38px;
  padding: 10px 13px;
  border-radius: 8px;
  color: #0f2d29;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(18, 48, 47, 0.15);
  box-shadow: 0 12px 30px rgba(14, 45, 37, 0.18);
  backdrop-filter: blur(8px);
  font-weight: 800;
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.game-over-panel {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  background: rgba(7, 24, 20, 0.38);
  pointer-events: auto;
  touch-action: manipulation;
}

.game-over-panel.hidden {
  display: none;
}

.game-over-card {
  width: min(560px, 94%);
  padding: clamp(24px, 4vw, 42px);
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: clamp(26px, 4vw, 48px);
  background: rgba(241, 248, 242, 0.82);
  box-shadow: 0 22px 80px rgba(5, 24, 18, 0.22);
  backdrop-filter: blur(14px);
  text-align: center;
}

.game-over-card h2 {
  margin: 0 0 14px;
  color: #12302f;
  font-size: clamp(34px, 7vw, 64px);
  line-height: 1.05;
}

.game-over-card p {
  margin: 0 0 clamp(24px, 4vw, 40px);
  color: #12302f;
  font-size: clamp(18px, 4vw, 30px);
  font-weight: 900;
}

.game-over-actions {
  display: flex;
  justify-content: center;
  gap: clamp(14px, 3vw, 28px);
  direction: rtl;
}

.game-over-button {
  min-width: clamp(130px, 28vw, 210px);
  min-height: clamp(58px, 11vw, 78px);
  border-radius: clamp(18px, 4vw, 30px);
  border: 2px solid rgba(18, 48, 47, 0.22);
  color: #12302f;
  font: 950 clamp(24px, 5vw, 38px) system-ui;
  touch-action: manipulation;
}

.game-over-restart {
  border-color: rgba(244, 188, 66, 0.72);
  background: #f4bc42;
}

.game-over-exit {
  background: rgba(255, 255, 255, 0.26);
}

.game-over-button:active {
  transform: translateY(2px) scale(0.97);
}

.audio-toggle {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: max(10px, env(safe-area-inset-left));
  z-index: 10;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 999px;
  color: rgba(18, 48, 47, 0.86);
  background: rgba(255, 255, 255, 0.32);
  box-shadow: 0 10px 24px rgba(10, 41, 30, 0.12);
  backdrop-filter: blur(12px) saturate(1.18);
  font: 900 18px system-ui;
  line-height: 1;
  touch-action: manipulation;
}

.audio-toggle.muted {
  color: rgba(90, 55, 50, 0.82);
  background: rgba(255, 226, 210, 0.32);
}

.controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.controls span {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--panel);
  font-size: 14px;
  font-weight: 700;
}

.start-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: clamp(18px, 4vw, 38px);
  background:
    radial-gradient(circle at 28% 22%, rgba(255, 236, 150, 0.42), transparent 24%),
    radial-gradient(circle at 72% 64%, rgba(91, 190, 116, 0.34), transparent 28%),
    linear-gradient(180deg, rgba(37, 111, 79, 0.42), rgba(18, 48, 47, 0.5));
  backdrop-filter: blur(3px);
  z-index: 7;
}

.start-overlay.hidden {
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.start-panel {
  position: relative;
  width: min(720px, 94%);
  min-height: min(92%, 520px);
  display: grid;
  grid-template-rows: minmax(150px, 1fr) auto auto auto;
  justify-items: center;
  align-content: center;
  gap: clamp(8px, 1.8vw, 16px);
  padding: clamp(18px, 4vw, 34px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 18px;
  text-align: center;
  color: #fff9dc;
  background:
    linear-gradient(180deg, rgba(17, 64, 54, 0.78), rgba(12, 43, 38, 0.86)),
    radial-gradient(circle at 50% 24%, rgba(255, 244, 207, 0.18), transparent 36%);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

.start-panel h1 {
  position: relative;
  z-index: 1;
  margin: 0;
  font-size: clamp(34px, 6.8vw, 68px);
  line-height: 0.95;
  letter-spacing: 0;
  text-shadow: 0 4px 16px rgba(0, 0, 0, 0.24);
}

.start-panel p {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0;
  color: rgba(255, 255, 255, 0.86);
  font-size: clamp(15px, 2.4vw, 21px);
  font-weight: 700;
}

.start-panel button {
  position: relative;
  z-index: 1;
  min-width: clamp(176px, 28vw, 240px);
  min-height: clamp(56px, 8vw, 68px);
  border: 0;
  border-radius: 999px;
  color: #12302f;
  background: linear-gradient(180deg, #ffd86b, #f4af30);
  font: 900 clamp(18px, 3vw, 24px) system-ui;
  box-shadow:
    0 12px 28px rgba(0, 0, 0, 0.24),
    inset 0 2px 0 rgba(255, 255, 255, 0.45);
  touch-action: manipulation;
}

.start-panel button:active {
  transform: translateY(2px) scale(0.98);
}

.start-hero {
  position: relative;
  z-index: 1;
  width: min(360px, 70vw);
  height: clamp(135px, 24vw, 210px);
}

.start-leaf {
  position: absolute;
  border-radius: 60% 12% 60% 16%;
  background: linear-gradient(135deg, #90db72, #2f945a);
  box-shadow: 0 16px 22px rgba(0, 0, 0, 0.14);
  opacity: 0.9;
}

.start-leaf-a {
  width: 72%;
  height: 54%;
  left: 12%;
  bottom: 10%;
  transform: rotate(-6deg);
}

.start-leaf-b {
  width: 36%;
  height: 28%;
  right: 4%;
  top: 12%;
  transform: rotate(18deg);
  opacity: 0.62;
}

.start-ant {
  --start-ant-scale: 1;
  position: absolute;
  left: 50%;
  top: 50%;
  width: 210px;
  height: 116px;
  transform: translate(-50%, -46%) scale(var(--start-ant-scale));
  animation: startAntFloat 2.4s ease-in-out infinite;
}

.start-ant-shadow {
  position: absolute;
  left: 28px;
  right: 18px;
  bottom: 10px;
  height: 18px;
  border-radius: 50%;
  background: rgba(8, 35, 25, 0.24);
  filter: blur(2px);
}

.start-ant-body,
.start-ant-eye,
.start-ant-antenna,
.start-ant-leg {
  position: absolute;
  display: block;
}

.start-ant-body {
  background:
    radial-gradient(circle at 38% 30%, rgba(255, 255, 255, 0.18), transparent 22%),
    linear-gradient(180deg, #2f2118, #120d0a);
  border: 2px solid rgba(255, 221, 144, 0.16);
  box-shadow: inset -8px -10px 14px rgba(0, 0, 0, 0.22);
}

.start-ant-head {
  width: 58px;
  height: 54px;
  right: 20px;
  top: 30px;
  border-radius: 48% 58% 48% 52%;
}

.start-ant-thorax {
  width: 64px;
  height: 48px;
  right: 72px;
  top: 36px;
  border-radius: 50%;
}

.start-ant-abdomen {
  width: 82px;
  height: 62px;
  left: 22px;
  top: 28px;
  border-radius: 55% 45% 52% 48%;
}

.start-ant-eye {
  right: 31px;
  top: 42px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 34%, #fff, #aee7ff 32%, #12302f 36%);
}

.start-ant-antenna {
  right: 36px;
  top: 28px;
  width: 52px;
  height: 34px;
  border-top: 4px solid #1a130e;
  border-radius: 50%;
  transform-origin: right bottom;
  animation: startAntenna 1.9s ease-in-out infinite;
}

.start-ant-antenna-a {
  transform: rotate(-28deg);
}

.start-ant-antenna-b {
  right: 32px;
  top: 29px;
  transform: rotate(-52deg) scaleX(0.88);
  animation-delay: -0.5s;
}

.start-ant-leg {
  width: 48px;
  height: 24px;
  border-bottom: 5px solid #17100b;
  border-radius: 0 0 70% 70%;
  transform-origin: center top;
}

.start-ant-leg-1 { right: 56px; top: 70px; transform: rotate(-20deg); }
.start-ant-leg-2 { right: 78px; top: 74px; transform: rotate(12deg); }
.start-ant-leg-3 { right: 102px; top: 72px; transform: rotate(-16deg); }
.start-ant-leg-4 { left: 66px; top: 72px; transform: scaleX(-1) rotate(-20deg); }
.start-ant-leg-5 { left: 44px; top: 76px; transform: scaleX(-1) rotate(12deg); }
.start-ant-leg-6 { left: 24px; top: 72px; transform: scaleX(-1) rotate(-14deg); }

.start-portrait-card {
  display: none;
}

.rotate-icon {
  position: relative;
  width: 118px;
  height: 94px;
  margin: 0 auto 14px;
}

.rotate-phone {
  position: absolute;
  left: 34px;
  top: 8px;
  width: 48px;
  height: 76px;
  border: 5px solid #fff9dc;
  border-radius: 12px;
  transform: rotate(90deg);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.2);
}

.rotate-arrow {
  position: absolute;
  inset: 4px;
  border: 5px solid rgba(244, 188, 66, 0.95);
  border-left-color: transparent;
  border-bottom-color: transparent;
  border-radius: 50%;
}

.rotate-arrow::after {
  content: "";
  position: absolute;
  right: 3px;
  top: 14px;
  width: 0;
  height: 0;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  border-left: 14px solid rgba(244, 188, 66, 0.95);
  transform: rotate(34deg);
}

.portrait-ant {
  position: relative;
  width: 76px;
  height: 42px;
  margin: 0 auto 16px;
}

.portrait-ant::before,
.portrait-ant::after,
.portrait-ant span {
  content: "";
  position: absolute;
  top: 10px;
  display: block;
  border-radius: 50%;
  background: #1a130e;
}

.portrait-ant::before {
  right: 4px;
  width: 26px;
  height: 24px;
}

.portrait-ant span {
  right: 27px;
  width: 25px;
  height: 21px;
}

.portrait-ant::after {
  left: 4px;
  width: 34px;
  height: 27px;
}

@keyframes startAntFloat {
  0%, 100% {
    transform: translate(-50%, -46%) translateY(0) scale(var(--start-ant-scale));
  }

  50% {
    transform: translate(-50%, -46%) translateY(-5px) scale(var(--start-ant-scale));
  }
}

@keyframes startAntenna {
  0%, 100% {
    margin-top: 0;
  }

  50% {
    margin-top: -4px;
  }
}

.rotate-hint {
  position: absolute;
  left: 50%;
  top: 12px;
  transform: translateX(-50%);
  z-index: 6;
  display: none;
  padding: 9px 12px;
  border-radius: 999px;
  color: #12302f;
  background: rgba(255, 244, 207, 0.9);
  border: 1px solid rgba(18, 48, 47, 0.12);
  font-size: 13px;
  font-weight: 900;
}

.developer-panel {
  position: absolute;
  left: max(12px, env(safe-area-inset-left));
  top: max(12px, env(safe-area-inset-top));
  z-index: 20;
  width: min(310px, calc(100vw - 28px));
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 14px;
  color: #eaffdf;
  background: rgba(9, 30, 24, 0.78);
  box-shadow: 0 18px 42px rgba(8, 29, 23, 0.28);
  backdrop-filter: blur(14px);
  direction: ltr;
  pointer-events: auto;
}

.developer-panel.hidden {
  display: none;
}

.developer-panel header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 13px;
}

.developer-panel header span {
  color: rgba(234, 255, 223, 0.68);
  font-size: 11px;
}

.developer-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
}

.developer-actions button {
  min-height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 9px;
  color: #12302f;
  background: rgba(255, 244, 207, 0.92);
  font: 800 12px system-ui;
  cursor: pointer;
}

.developer-actions button[data-dev-reset] {
  color: #fff4cf;
  background: rgba(217, 77, 69, 0.78);
}

.developer-debug {
  min-height: 86px;
  margin: 10px 0 0;
  padding: 8px;
  border-radius: 9px;
  color: rgba(234, 255, 223, 0.86);
  background: rgba(0, 0, 0, 0.22);
  font: 11px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
}

.touch-controls {
  position: fixed;
  inset-inline: 0;
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 8;
  display: none;
  direction: ltr;
  justify-content: space-between;
  align-items: end;
  padding: 0 max(16px, env(safe-area-inset-left)) 0 max(16px, env(safe-area-inset-right));
  pointer-events: none;
}

.touch-cluster {
  display: flex;
  direction: ltr;
  flex-direction: row;
  gap: 12px;
  pointer-events: auto;
}

.touch-cluster-right {
  direction: rtl;
}

.touch-button {
  width: clamp(58px, 12vw, 78px);
  height: clamp(58px, 12vw, 78px);
  border: 2px solid rgba(255, 255, 255, 0.34);
  border-radius: 999px;
  color: #fff9dc;
  background: rgba(18, 48, 47, 0.62);
  box-shadow: 0 12px 30px rgba(11, 32, 26, 0.22);
  backdrop-filter: blur(10px);
  font: 900 clamp(22px, 5vw, 32px) system-ui;
  touch-action: none;
}

.touch-button.active {
  transform: translateY(2px) scale(0.96);
  background: rgba(244, 188, 66, 0.82);
  color: #12302f;
}

.touch-button-jump,
.touch-button-use {
  width: clamp(72px, 15vw, 96px);
  font-size: clamp(13px, 3vw, 17px);
}

body.pre-start {
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 232, 145, 0.5), transparent 22%),
    radial-gradient(circle at 82% 20%, rgba(179, 236, 146, 0.34), transparent 26%),
    linear-gradient(180deg, #bfeec8 0%, #79c98f 46%, #315f42 100%);
}

body.pre-start .shell {
  width: 100vw;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  margin: 0;
  padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}

body.pre-start .hud,
body.pre-start .controls,
body.pre-start .touch-controls,
body.pre-start .toast {
  display: none;
}

body.pre-start .audio-toggle {
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
}

body.pre-start .stage {
  width: min(1180px, calc(100vw - max(24px, env(safe-area-inset-left) + env(safe-area-inset-right))));
  height: min(680px, calc(100dvh - max(24px, env(safe-area-inset-top) + env(safe-area-inset-bottom))));
  min-height: 360px;
  border-radius: clamp(16px, 2.4vw, 26px);
  box-shadow: 0 26px 80px rgba(13, 49, 35, 0.28);
}

body.pre-start canvas {
  width: 100%;
  height: 100%;
  max-height: none;
  opacity: 0.24;
  filter: saturate(1.08) blur(0.2px);
}

body.pre-start .start-overlay {
  padding: clamp(18px, 3vw, 42px);
  background:
    radial-gradient(circle at 16% 22%, rgba(255, 231, 125, 0.46), transparent 18%),
    radial-gradient(circle at 82% 18%, rgba(207, 255, 181, 0.24), transparent 24%),
    linear-gradient(180deg, rgba(37, 115, 77, 0.42), rgba(10, 42, 34, 0.68));
}

body.pre-start .start-overlay::before,
body.pre-start .start-overlay::after {
  content: "";
  position: absolute;
  inset: auto;
  z-index: 0;
  pointer-events: none;
}

body.pre-start .start-overlay::before {
  left: -6%;
  bottom: -9%;
  width: 44%;
  height: 46%;
  border-radius: 55% 45% 0 0;
  background:
    radial-gradient(ellipse at 18% 100%, rgba(18, 76, 51, 0.84), transparent 62%),
    radial-gradient(ellipse at 56% 100%, rgba(47, 145, 76, 0.58), transparent 58%),
    radial-gradient(ellipse at 82% 100%, rgba(126, 201, 91, 0.42), transparent 54%);
}

body.pre-start .start-overlay::after {
  right: -4%;
  top: -8%;
  width: 34%;
  height: 54%;
  border-radius: 0 0 50% 50%;
  background:
    radial-gradient(ellipse at 60% 0%, rgba(41, 115, 73, 0.55), transparent 64%),
    radial-gradient(ellipse at 30% 0%, rgba(157, 224, 115, 0.28), transparent 52%);
}

body.pre-start .start-panel {
  width: min(820px, 94%);
  min-height: min(92%, 560px);
  grid-template-rows: minmax(156px, 1fr) auto auto auto auto;
  gap: clamp(8px, 1.5vw, 14px);
  padding: clamp(20px, 3vw, 38px);
  border-radius: clamp(18px, 2.2vw, 28px);
  background:
    linear-gradient(180deg, rgba(16, 72, 55, 0.66), rgba(10, 41, 35, 0.82)),
    radial-gradient(circle at 50% 20%, rgba(255, 239, 179, 0.18), transparent 38%);
  box-shadow:
    0 28px 80px rgba(4, 29, 22, 0.36),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

body.pre-start .start-panel h1 {
  display: grid;
  gap: 0;
  font-size: clamp(46px, 8vw, 92px);
  line-height: 0.88;
  text-transform: uppercase;
}

body.pre-start .start-panel h1 small {
  display: block;
  color: rgba(255, 249, 220, 0.9);
  font-size: clamp(22px, 3.4vw, 40px);
  font-weight: 900;
  text-transform: none;
}

body.pre-start .start-tagline {
  color: #ffdf77;
  font-size: clamp(16px, 2.1vw, 24px);
  font-weight: 900;
}

body.pre-start .start-panel p:not(.start-tagline) {
  width: min(560px, 92%);
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  font-size: clamp(13px, 1.8vw, 18px);
}

.start-route-title {
  position: relative;
  z-index: 1;
  color: rgba(255, 249, 220, 0.92);
  font-size: clamp(13px, 1.7vw, 16px);
  font-weight: 900;
}

.start-route-actions {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: clamp(8px, 1.4vw, 12px);
}

body.pre-start .start-panel .start-route-actions button {
  min-width: clamp(210px, 30vw, 292px);
  min-height: max(64px, clamp(64px, 8vw, 76px));
  margin-top: 2px;
  font-size: clamp(20px, 2.8vw, 28px);
  transition:
    transform 150ms ease,
    box-shadow 150ms ease,
    filter 150ms ease;
}

body.pre-start .start-panel button#startButton {
  animation: startButtonPulse 2.15s ease-in-out infinite;
}

body.pre-start .start-panel .start-route-actions button:hover {
  transform: translateY(-2px) scale(1.015);
  filter: brightness(1.04);
}

body.pre-start .start-panel .start-route-actions button:active {
  transform: translateY(2px) scale(0.97);
}

body.pre-start .start-panel button.start-route-test {
  color: #fff8dc;
  background:
    linear-gradient(180deg, rgba(127, 194, 91, 0.96), rgba(54, 124, 64, 0.96)),
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.38), transparent 38%);
  box-shadow:
    0 12px 26px rgba(6, 40, 24, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.42);
}

body.pre-start .start-panel button.start-route-units {
  display: grid;
  place-items: center;
  gap: 3px;
  color: #12302f;
  background:
    linear-gradient(180deg, rgba(255, 231, 141, 0.98), rgba(240, 181, 55, 0.98)),
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.42), transparent 38%);
  box-shadow:
    0 12px 26px rgba(87, 62, 6, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.48);
}

body.pre-start .start-panel button.start-route-units span {
  display: block;
  color: rgba(18, 48, 47, 0.74);
  font-size: clamp(11px, 1.5vw, 14px);
  font-weight: 900;
  line-height: 1.1;
}

body.pre-start .start-panel button.start-route-account {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #12382f;
  background:
    linear-gradient(180deg, #a9ffd1, #66d99b),
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.42), transparent 38%);
  box-shadow:
    0 12px 26px rgba(4, 40, 28, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
  text-align: right;
  touch-action: manipulation;
}

body.pre-start .start-panel button.start-route-account .start-account-copy {
  place-items: start;
}

.units-modal {
  position: absolute;
  inset: 0;
  z-index: 9;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  background: rgba(5, 28, 22, 0.48);
  backdrop-filter: blur(10px);
  pointer-events: auto;
  touch-action: manipulation;
}

.units-modal.hidden {
  display: none;
}

.units-card {
  position: relative;
  width: min(560px, 94vw);
  max-height: min(82dvh, 620px);
  overflow: auto;
  padding: clamp(20px, 4vw, 34px);
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: clamp(22px, 4vw, 34px);
  color: #f8ffe9;
  background:
    linear-gradient(180deg, rgba(20, 78, 57, 0.94), rgba(9, 42, 35, 0.96)),
    radial-gradient(circle at 45% 8%, rgba(255, 218, 100, 0.2), transparent 36%);
  box-shadow: 0 28px 80px rgba(4, 26, 20, 0.46);
  text-align: right;
}

.units-close {
  position: absolute;
  top: 14px;
  left: 14px;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  color: #fff8dc;
  background: rgba(255, 255, 255, 0.12);
  font: 900 28px/1 system-ui;
  touch-action: manipulation;
}

.units-eyebrow {
  display: inline-flex;
  padding: 6px 12px;
  border-radius: 999px;
  color: #12302f;
  background: #ffdf77;
  font-size: 13px;
  font-weight: 950;
}

.units-card h2 {
  margin: 12px 0 8px;
  font-size: clamp(28px, 5vw, 44px);
  line-height: 1.1;
}

.units-card p {
  margin: 0 0 18px;
  color: rgba(248, 255, 233, 0.82);
  font-size: clamp(14px, 2vw, 18px);
  font-weight: 800;
  line-height: 1.7;
}

.units-list {
  display: grid;
  gap: 14px;
}

.unit-group {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.07);
}

.unit-group h3,
.unit-group p {
  margin: 0;
}

.unit-group h3 {
  color: #fff5bd;
  font-size: clamp(17px, 2.4vw, 22px);
  line-height: 1.25;
}

.unit-group p {
  color: rgba(248, 255, 233, 0.72);
  font-size: clamp(12px, 1.6vw, 15px);
  font-weight: 800;
  line-height: 1.5;
}

.lesson-buttons {
  display: grid;
  gap: 8px;
}

.units-list button {
  min-height: 68px;
  padding: 12px 16px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 18px;
  color: #f8ffe9;
  background: rgba(255, 255, 255, 0.1);
  text-align: right;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
  touch-action: manipulation;
}

.units-list button:hover {
  background: rgba(255, 255, 255, 0.16);
}

.units-list button.selected {
  border-color: rgba(255, 220, 114, 0.82);
  background:
    linear-gradient(180deg, rgba(255, 220, 114, 0.2), rgba(154, 255, 205, 0.1)),
    rgba(255, 255, 255, 0.12);
  box-shadow:
    0 0 0 3px rgba(255, 220, 114, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.units-list button:active {
  transform: scale(0.98);
}

.units-list strong,
.units-list span {
  display: block;
}

.units-list strong {
  font-size: clamp(17px, 2.4vw, 22px);
}

.units-list span {
  margin-top: 3px;
  color: rgba(255, 249, 220, 0.82);
  font-size: clamp(13px, 1.8vw, 16px);
  font-weight: 800;
}

.lesson-route-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(154, 255, 205, 0.24);
  border-radius: 18px;
  background: rgba(5, 28, 22, 0.24);
}

.lesson-route-title {
  color: #ffdf77;
  font-size: clamp(13px, 1.8vw, 16px);
  font-weight: 950;
}

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

.units-list .lesson-route-actions button {
  min-height: 58px;
  padding: 10px;
  border-radius: 16px;
  text-align: center;
  color: #12302f;
  background: rgba(255, 248, 220, 0.92);
  font-size: clamp(12px, 1.7vw, 15px);
  font-weight: 950;
}

.units-list .lesson-route-actions button[data-lesson-action="adventure"] {
  background: linear-gradient(180deg, #ffdf77, #efb83e);
}

.units-list .lesson-route-actions button[data-lesson-action="lesson_map"] {
  background: linear-gradient(180deg, #9affcd, #5ebf8a);
}

.units-list .lesson-route-actions button[data-lesson-action="tree_test"] {
  color: #fff8dc;
  background: linear-gradient(180deg, #78b95f, #316f42);
}

.units-status {
  margin: 14px 0 0;
  color: rgba(255, 249, 220, 0.72);
  font-size: 13px;
  font-weight: 850;
}

@media (max-width: 680px), (pointer: coarse) {
  .lesson-route-actions {
    grid-template-columns: 1fr;
  }

  .units-list .lesson-route-actions button {
    min-height: 54px;
  }
}

.branch-learning-visual {
  position: absolute;
  z-index: 8;
  top: max(74px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  width: min(340px, calc(100vw - 32px));
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid rgba(167, 255, 207, 0.42);
  border-radius: 24px;
  color: #f7ffe9;
  background:
    linear-gradient(145deg, rgba(8, 52, 42, 0.88), rgba(13, 73, 54, 0.74)),
    radial-gradient(circle at 15% 10%, rgba(255, 229, 116, 0.2), transparent 42%);
  box-shadow: 0 20px 55px rgba(3, 25, 20, 0.32), 0 0 28px rgba(132, 255, 190, 0.18);
  backdrop-filter: blur(12px);
  pointer-events: none;
}

.branch-learning-visual.hidden {
  display: none;
}

.branch-learning-visual.success {
  border-color: rgba(154, 255, 205, 0.8);
}

.branch-learning-visual.fail {
  border-color: rgba(255, 151, 124, 0.7);
  animation: branchLearningShake 240ms ease;
}

.branch-learning-close {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 30px;
  height: 30px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  color: #fff8dc;
  background: rgba(255, 255, 255, 0.12);
  font: 900 20px/1 system-ui;
  pointer-events: auto;
}

.branch-learning-image {
  min-height: 94px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.11);
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.branch-learning-image svg {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 94px;
}

.branch-learning-copy {
  min-width: 0;
  padding-left: 18px;
}

.branch-learning-skill {
  display: inline-flex;
  max-width: 100%;
  padding: 4px 8px;
  border-radius: 999px;
  color: #17362d;
  background: #ffdc72;
  font-size: 11px;
  font-weight: 950;
  white-space: nowrap;
}

.branch-learning-copy strong,
.branch-learning-copy p {
  display: block;
  margin: 0;
}

.branch-learning-copy strong {
  margin-top: 7px;
  font-size: clamp(14px, 2vw, 18px);
  line-height: 1.25;
}

.branch-learning-copy p {
  margin-top: 5px;
  color: rgba(247, 255, 233, 0.82);
  font-size: clamp(12px, 1.7vw, 14px);
  font-weight: 800;
  line-height: 1.45;
}

@keyframes branchLearningShake {
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

@media (max-width: 760px) {
  .branch-learning-visual {
    top: max(54px, env(safe-area-inset-top));
    right: max(10px, env(safe-area-inset-right));
    width: min(330px, calc(100vw - 20px));
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 9px;
    padding: 9px;
    border-radius: 20px;
  }

  .branch-learning-image,
  .branch-learning-image svg {
    min-height: 82px;
  }
}

.start-secondary {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.start-secondary button {
  min-width: auto;
  min-height: 34px;
  height: 34px;
  padding: 7px 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  color: rgba(255, 249, 220, 0.86);
  background: rgba(255, 255, 255, 0.1);
  font: 800 13px system-ui;
  box-shadow: none;
}

body.pre-start .start-panel .start-account-button {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  z-index: 4;
  width: auto;
  min-width: 174px;
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 0;
  padding: 9px 15px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 18px;
  color: #12382f;
  background: linear-gradient(180deg, #a9ffd1, #66d99b);
  box-shadow:
    0 10px 26px rgba(4, 40, 28, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
  text-align: right;
  touch-action: manipulation;
}

body.pre-start .start-panel .start-account-button:hover {
  transform: translateY(-2px);
  filter: brightness(1.04);
}

.start-account-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  flex: 0 0 34px;
  border-radius: 50%;
  color: #f8ffe9;
  background: #176649;
  font-size: 21px;
  line-height: 1;
}

.start-account-copy {
  display: grid;
  gap: 1px;
}

.start-account-copy strong,
.start-account-copy small {
  display: block;
  white-space: nowrap;
}

.start-account-copy strong {
  font-size: 16px;
  line-height: 1.1;
}

.start-account-copy small {
  color: rgba(18, 56, 47, 0.72);
  font-size: 11px;
  font-weight: 900;
}

.student-account-modal {
  position: absolute;
  inset: 0;
  z-index: 44;
  display: grid;
  place-items: center;
  padding:
    max(16px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  direction: rtl;
  background: rgba(6, 28, 23, 0.72);
  backdrop-filter: blur(10px);
}

.student-account-modal.hidden {
  display: none;
}

.student-account-card {
  position: relative;
  width: min(460px, 94vw);
  display: grid;
  gap: 12px;
  padding: 26px;
  border: 1px solid rgba(205, 255, 218, 0.3);
  border-radius: 24px;
  color: #fff8dc;
  background: rgba(13, 57, 45, 0.96);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
}

.student-account-card h2,
.student-account-card p {
  margin: 0;
}

.student-account-card p {
  color: rgba(255, 248, 220, 0.78);
  font-weight: 750;
  line-height: 1.5;
}

.student-account-card label {
  display: grid;
  gap: 6px;
  font-weight: 900;
}

.student-account-card .hidden {
  display: none;
}

.student-account-card input,
.student-account-card select {
  width: 100%;
  min-height: 52px;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 14px;
  color: #14342c;
  background: #fffbea;
  font: 800 18px system-ui;
  text-align: right;
}

.student-account-card select {
  appearance: none;
  cursor: pointer;
}

.student-consent-row {
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  color: rgba(255, 248, 220, 0.86);
  font-size: 12px;
  line-height: 1.5;
}

.student-consent-row input {
  width: 22px;
  min-height: 22px;
  height: 22px;
  margin-top: 1px;
  padding: 0;
  accent-color: #66d99b;
}

.student-recaptcha {
  min-height: 1px;
}

.student-account-close {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: #fff8dc;
  background: rgba(255, 255, 255, 0.12);
  font: 900 24px/1 system-ui;
}

.student-account-submit {
  min-height: 54px;
  border-radius: 14px;
  color: #17362d;
  background: #ffdc72;
  font: 950 17px system-ui;
}

.student-account-submit:disabled {
  opacity: 0.58;
}

.student-resend-code {
  min-height: 38px;
  color: #fff2bd;
  background: transparent;
  text-decoration: underline;
  font: 850 13px system-ui;
}

.student-account-status {
  min-height: 24px;
}

.student-account-status[data-status="success"] {
  color: #9affcd;
}

.student-account-status[data-status="warning"] {
  color: #ffe49a;
}

.student-account-status[data-status="error"] {
  color: #ffb3a8;
}

body.pre-start .start-hero {
  width: min(420px, 68vw);
  height: clamp(168px, 24vw, 250px);
}

body.pre-start .start-ant {
  --start-ant-scale: 1.16;
}

@keyframes startButtonPulse {
  0%, 100% {
    box-shadow:
      0 12px 28px rgba(0, 0, 0, 0.24),
      0 0 0 0 rgba(255, 216, 107, 0.28),
      inset 0 2px 0 rgba(255, 255, 255, 0.45);
  }

  50% {
    box-shadow:
      0 16px 34px rgba(0, 0, 0, 0.28),
      0 0 0 8px rgba(255, 216, 107, 0.08),
      inset 0 2px 0 rgba(255, 255, 255, 0.45);
  }
}

@media (max-width: 840px) {
  body {
    min-height: 100svh;
  }

  .shell {
    width: 100vw;
    min-height: 100svh;
    margin: 0;
    padding: max(6px, env(safe-area-inset-top)) 8px max(104px, env(safe-area-inset-bottom));
  }

  .hud {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 5px;
    margin-bottom: 6px;
    direction: rtl;
  }

  .hud > div {
    min-height: 44px;
    padding: 6px;
    border-radius: 7px;
  }

  .hud span {
    margin-bottom: 0;
    font-size: 10px;
  }

  .hud strong {
    font-size: 13px;
  }

  .stage {
    border-radius: 8px;
  }

  canvas {
    height: min(56.25vw, calc(100dvh - 168px));
    max-height: calc(100svh - 168px);
    border-radius: 8px;
  }

  .controls {
    display: none;
  }

  .touch-controls {
    display: flex;
  }

  body.pre-start .touch-controls {
    display: none;
  }

  .toast {
    right: 10px;
    bottom: 10px;
    max-width: min(320px, calc(100vw - 20px));
    font-size: 13px;
  }
}

@media (orientation: portrait) and (max-width: 840px) {
  body.pre-start .stage {
    width: calc(100vw - max(24px, env(safe-area-inset-left) + env(safe-area-inset-right)));
    height: calc(100dvh - max(24px, env(safe-area-inset-top) + env(safe-area-inset-bottom)));
    min-height: 0;
  }

  body.pre-start .stage:has(.start-overlay:not(.hidden)) {
    min-height: 0;
  }

  body.pre-start .stage:has(.start-overlay:not(.hidden)) canvas {
    opacity: 0.14;
  }

  body.pre-start .start-overlay {
    padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
  }

  body.pre-start .start-panel {
    display: none;
  }

  body.pre-start .start-portrait-card {
    width: min(360px, 92vw);
    min-height: min(420px, 64dvh);
    display: grid;
    place-content: center;
    gap: 12px;
    padding: 30px 22px;
    border: 1px solid rgba(255, 255, 255, 0.32);
    border-radius: 26px;
    text-align: center;
    color: #fff9dc;
    background:
      radial-gradient(circle at 50% 12%, rgba(255, 224, 119, 0.18), transparent 28%),
      linear-gradient(180deg, rgba(17, 64, 54, 0.88), rgba(12, 43, 38, 0.94));
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
  }

  body.pre-start .start-portrait-card strong {
    display: block;
    font-size: clamp(24px, 7vw, 34px);
    line-height: 1.2;
  }

  .rotate-hint {
    display: none;
  }

  body:not(.pre-start) .shell {
    padding-bottom: max(118px, env(safe-area-inset-bottom));
  }

  body:not(.pre-start) canvas {
    max-height: min(56svh, calc(100svh - 210px));
  }
}

@media (orientation: landscape) {
  .rotate-hint {
    display: none;
  }
}

@media (max-height: 480px) {
  .shell {
    padding: max(4px, env(safe-area-inset-top)) 8px max(86px, env(safe-area-inset-bottom));
  }

  .hud {
    gap: 4px;
    margin-bottom: 4px;
  }

  .hud > div {
    min-height: 36px;
    padding: 4px 6px;
  }

  .hud span {
    font-size: 9px;
  }

  .hud strong {
    font-size: 12px;
  }

  canvas {
    height: min(56.25vw, calc(100dvh - 126px));
    max-height: calc(100dvh - 126px);
  }

  .start-panel {
    width: min(760px, 96%);
    min-height: min(96%, 318px);
    grid-template-columns: minmax(180px, 0.85fr) minmax(260px, 1fr);
    grid-template-rows: auto auto auto;
    column-gap: 18px;
    padding: 14px 18px;
    text-align: right;
  }

  body.pre-start .start-panel {
    height: min(318px, calc(100% - 28px));
    min-height: 0;
    row-gap: 6px;
    align-content: center;
    overflow: hidden;
  }

  body.pre-start .start-panel .start-account-button {
    top: 8px;
    right: 8px;
    min-width: 146px;
    min-height: 42px;
    padding: 6px 10px;
    border-radius: 14px;
  }

  .start-account-icon {
    width: 28px;
    height: 28px;
    flex-basis: 28px;
    font-size: 17px;
  }

  .start-account-copy strong {
    font-size: 13px;
  }

  .start-hero {
    grid-row: 1 / span 3;
    width: min(260px, 34vw);
    height: min(190px, 44dvh);
    align-self: center;
  }

  body.pre-start .start-hero {
    width: min(236px, 29vw);
    height: min(150px, 38dvh);
  }

  .start-ant {
    --start-ant-scale: 0.84;
  }

  body.pre-start .start-ant {
    --start-ant-scale: 0.72;
  }

  .start-panel h1 {
    font-size: clamp(26px, 4.4vw, 40px);
    align-self: end;
  }

  body.pre-start .start-panel h1 small {
    font-size: clamp(16px, 2.4vw, 24px);
  }

  body.pre-start .start-tagline {
    font-size: clamp(12px, 1.8vw, 15px);
  }

  .start-panel p {
    font-size: clamp(12px, 1.75vw, 14px);
    margin-bottom: 0;
  }

  body.pre-start .start-panel p:not(.start-tagline) {
    width: min(360px, 100%);
    padding: 7px 10px;
  }

  .start-route-title {
    justify-self: start;
    font-size: 12px;
  }

  .start-route-actions {
    justify-self: start;
    justify-content: flex-start;
    gap: 8px;
  }

  .start-panel .start-route-actions button,
  .start-panel button#startButton {
    justify-self: start;
    align-self: center;
    min-width: 168px;
    min-height: 64px;
    font-size: clamp(15px, 2vw, 18px);
  }

  .start-secondary {
    grid-column: 2;
    justify-content: flex-start;
    align-items: center;
    gap: 6px;
  }

  .start-secondary button {
    min-width: auto;
    min-height: 30px;
    height: 30px;
    padding: 6px 9px;
    font-size: 12px;
  }

  .touch-controls {
    display: flex;
  }

  body.pre-start .touch-controls {
    display: none;
  }

  .rotate-hint {
    display: none;
  }
}

@media (pointer: coarse) {
  .touch-controls {
    display: flex;
  }

  body.pre-start .touch-controls {
    display: none;
  }
}

/* Mobile game UX pass: the world should read before the interface. */
body:not(.pre-start) .shell {
  width: 100vw;
  min-height: 100dvh;
  margin: 0;
  padding: max(6px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
}

body:not(.pre-start) .stage {
  width: min(100%, 1280px);
  margin: 0 auto;
  border-radius: clamp(10px, 1.6vw, 18px);
  box-shadow: 0 18px 54px rgba(13, 49, 35, 0.18);
}

body:not(.pre-start) canvas {
  height: min(85dvh, 56.25vw);
  max-height: calc(100dvh - max(18px, env(safe-area-inset-top) + env(safe-area-inset-bottom)));
  border: 0;
}

body:not(.pre-start) .hud {
  position: fixed;
  top: max(8px, env(safe-area-inset-top));
  left: 50%;
  z-index: 9;
  width: auto;
  min-width: 210px;
  display: flex;
  grid-template-columns: none;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin: 0;
  padding: 3px 6px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  box-shadow: 0 10px 28px rgba(10, 41, 30, 0.12);
  backdrop-filter: blur(14px) saturate(1.2);
  transform: translateX(-50%) scale(0.9);
  pointer-events: none;
  direction: ltr;
}

body:not(.pre-start) .hud-item {
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

body:not(.pre-start) .hud-hearts,
body:not(.pre-start) .hud-food,
body:not(.pre-start) .hud-energy {
  min-width: 54px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 8px;
  border-inline-start: 1px solid rgba(18, 48, 47, 0.12);
  color: rgba(18, 48, 47, 0.88);
}

body:not(.pre-start) .hud-hearts {
  border-inline-start: 0;
  color: rgba(40, 42, 36, 0.9);
}

body:not(.pre-start) .hud-food::before {
  content: "●";
  color: #f4bc42;
  font-size: 10px;
}

body:not(.pre-start) .hud-energy::before {
  content: "⚡";
  color: #328a57;
  font-size: 11px;
}

body:not(.pre-start) .hud span {
  display: none;
}

body:not(.pre-start) .hud strong {
  display: block;
  font-size: 11px;
  line-height: 1;
  font-weight: 900;
  white-space: nowrap;
}

body:not(.pre-start) .hud-skill,
body:not(.pre-start) .hud-zone {
  position: fixed;
  left: 50%;
  min-width: min(300px, calc(100vw - 40px));
  max-width: calc(100vw - 40px);
  display: block;
  padding: 8px 13px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  text-align: center;
  color: #12302f;
  background: rgba(255, 244, 207, 0.62);
  box-shadow: 0 12px 28px rgba(10, 41, 30, 0.12);
  backdrop-filter: blur(12px);
  opacity: 0;
  transform: translate(-50%, 8px);
  transition:
    opacity 220ms ease,
    transform 220ms ease;
  pointer-events: none;
}

body:not(.pre-start) .hud-zone {
  top: max(44px, calc(env(safe-area-inset-top) + 40px));
}

body:not(.pre-start) .hud-skill {
  top: max(82px, calc(env(safe-area-inset-top) + 76px));
  background: rgba(255, 255, 255, 0.54);
}

body:not(.pre-start) .hud-skill.visible,
body:not(.pre-start) .hud-zone.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

body:not(.pre-start) .hud-skill span,
body:not(.pre-start) .hud-zone span {
  display: block;
  margin-bottom: 1px;
  color: rgba(18, 48, 47, 0.52);
  font-size: 9px;
}

body:not(.pre-start) .hud-skill strong,
body:not(.pre-start) .hud-zone strong {
  font-size: 13px;
  line-height: 1.25;
}

@media (max-height: 500px) and (orientation: landscape) {
  body:not(.pre-start) .hud {
    transform: translateX(-50%) scale(0.78);
    opacity: 0.82;
  }

  body:not(.pre-start) .hud-skill,
  body:not(.pre-start) .hud-zone {
    display: none;
  }
}

body:not(.pre-start) .touch-controls {
  opacity: 0.34;
  transition: opacity 240ms ease;
}

body:not(.pre-start).controls-active .touch-controls {
  opacity: 0.88;
}

body.stage-lesson-map:not(.pre-start) .touch-controls {
  opacity: 0.46;
  pointer-events: auto;
  transform: translateY(10px);
}

body.stage-lesson-map:not(.pre-start) .touch-button[data-control="left"],
body.stage-lesson-map:not(.pre-start) .touch-button[data-control="right"],
body.stage-lesson-map:not(.pre-start) .touch-button[data-control="jump"] {
  opacity: 0.12;
  pointer-events: none;
}

body.stage-lesson-map:not(.pre-start) .touch-button[data-control="use"] {
  opacity: 0.96;
  pointer-events: auto;
  transform: scale(1.04);
  box-shadow: 0 0 0 4px rgba(154, 255, 205, 0.12), 0 14px 34px rgba(0, 0, 0, 0.22);
}

body:not(.pre-start) .touch-button {
  width: clamp(58px, 9vw, 72px);
  height: clamp(58px, 9vw, 72px);
  border: 1px solid rgba(255, 255, 255, 0.24);
  color: rgba(255, 249, 220, 0.86);
  background: rgba(18, 48, 47, 0.24);
  box-shadow: 0 8px 22px rgba(11, 32, 26, 0.12);
  font-size: clamp(16px, 3vw, 22px);
}

body:not(.pre-start) .touch-button-jump,
body:not(.pre-start) .touch-button-use {
  width: clamp(68px, 11vw, 88px);
  font-size: clamp(12px, 2.4vw, 15px);
}

body:not(.pre-start) .touch-button.active {
  background: rgba(244, 188, 66, 0.72);
}

.stage1_5-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  pointer-events: none;
}

.stage1_5-overlay.hidden {
  display: none;
}

.stage1_5-card {
  pointer-events: auto;
  width: min(1120px, 94vw);
  max-height: min(82dvh, 760px);
  display: grid;
  grid-template-columns: minmax(280px, 34%) minmax(0, 1fr);
  gap: 20px;
  padding: 20px;
  border: 1px solid rgba(154, 255, 205, 0.42);
  border-radius: 24px;
  color: #f4ffe9;
  background:
    linear-gradient(145deg, rgba(16, 55, 38, 0.94), rgba(8, 27, 21, 0.9)),
    radial-gradient(circle at 14% 10%, rgba(255, 220, 114, 0.18), transparent 48%);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.42), 0 0 30px rgba(154, 255, 205, 0.12);
  backdrop-filter: blur(12px);
  overflow: auto;
}

.stage1_5-image {
  position: relative;
  align-self: start;
  min-height: 280px;
  aspect-ratio: 4 / 3;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 12px 28px rgba(0, 0, 0, 0.24);
}

.stage1_5-image img,
.stage1_5-image svg {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 280px;
  object-fit: contain;
  object-position: center;
}

.stage1_5-image-markers {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.stage1_5-image-marker {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 7px;
  transform: translate(-50%, -50%);
  color: #fff8dc;
  filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.72));
}

.stage1_5-image-marker strong {
  max-width: 190px;
  padding: 7px 10px;
  border: 2px solid #ffdc72;
  border-radius: 12px;
  background: rgba(36, 29, 10, 0.92);
  font-size: clamp(11px, 1.5vw, 14px);
  line-height: 1.25;
}

.stage1_5-marker-dot {
  position: relative;
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  place-items: center;
  border-radius: 50%;
  color: #173126;
  background: #ffdc72;
  box-shadow: 0 0 0 7px rgba(255, 220, 114, 0.2), 0 0 24px #ffdc72;
  font-weight: 950;
  animation: stage15MarkerPulse 1.25s ease-in-out infinite;
}

.stage1_5-image-marker.cyan strong {
  border-color: #9eefff;
  background: rgba(10, 44, 52, 0.94);
}

.stage1_5-image-marker.cyan .stage1_5-marker-dot {
  background: #9eefff;
  box-shadow: 0 0 0 7px rgba(158, 239, 255, 0.2), 0 0 24px #9eefff;
  animation-delay: 0.28s;
}

@keyframes stage15MarkerPulse {
  0%, 100% { transform: scale(0.92); }
  50% { transform: scale(1.12); }
}

.stage1_5-copy {
  min-width: 0;
}

.stage1_5-step {
  display: inline-flex;
  padding: 5px 10px;
  border-radius: 999px;
  color: #073126;
  background: #9affcd;
  font-size: 12px;
  font-weight: 950;
}

.stage1_5-card h2,
.stage1_5-card h3,
.stage1_5-card p {
  margin: 0;
}

.stage1_5-card h2 {
  margin-top: 8px;
  color: #ffd76d;
  font-size: clamp(20px, 3vw, 30px);
  line-height: 1.2;
}

.stage1_5-card p {
  margin-top: 8px;
  color: rgba(244, 255, 233, 0.86);
  font-size: clamp(13px, 2vw, 16px);
  font-weight: 800;
  line-height: 1.55;
}

.stage1_5-visual-detail {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid rgba(154, 255, 205, 0.28);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
}

.stage1_5-visual-detail.hidden {
  display: none;
}

.stage1_5-detail-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}

.stage1_5-detail-row span {
  color: #9affcd;
  font-size: 12px;
  font-weight: 950;
}

.stage1_5-detail-row strong {
  color: rgba(255, 248, 220, 0.94);
  font-size: clamp(12px, 1.8vw, 14px);
  line-height: 1.45;
}

.stage1_5-card h3 {
  margin-top: 11px;
  color: #fff8dc;
  font-size: clamp(15px, 2.3vw, 20px);
  line-height: 1.35;
}

.stage1_5-options {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.stage1_5-options button,
.stage1_5-continue {
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 14px;
  color: #12302f;
  background: rgba(255, 248, 220, 0.92);
  font: 900 14px/1.2 system-ui;
  cursor: pointer;
}

.stage1_5-options button:disabled {
  opacity: 0.58;
  cursor: default;
}

.stage1_5-continue {
  margin-top: 10px;
  color: #073126;
  background: #9affcd;
}

.stage1_5-continue:disabled {
  opacity: 0.42;
  cursor: default;
}

.stage1_5-feedback.success {
  color: #9affcd;
  font-weight: 950;
}

.stage1_5-feedback.fail {
  color: #ffb3a8;
  font-weight: 950;
}

@media (max-width: 840px), (pointer: coarse) {
  body:not(.pre-start) .shell {
    padding-top: max(6px, env(safe-area-inset-top));
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }

  body:not(.pre-start) .stage {
    width: calc(100vw - max(12px, env(safe-area-inset-left) + env(safe-area-inset-right)));
  }

  body:not(.pre-start) canvas {
    height: min(85dvh, 56.25vw);
    max-height: calc(100dvh - max(18px, env(safe-area-inset-top) + env(safe-area-inset-bottom)));
  }

  body:not(.pre-start) .hud {
    top: max(7px, env(safe-area-inset-top));
    min-width: 184px;
    padding: 3px 6px;
  }

  body:not(.pre-start) .hud-hearts,
  body:not(.pre-start) .hud-food,
  body:not(.pre-start) .hud-energy {
    min-width: 50px;
    height: 22px;
    padding: 0 6px;
  }

  body:not(.pre-start) .hud strong {
    font-size: 11px;
  }
}

@media (max-width: 760px), (max-height: 560px) {
  .stage1_5-card {
    width: min(960px, 96vw);
    grid-template-columns: minmax(190px, 32%) minmax(0, 1fr);
    gap: 12px;
    padding: 12px;
    border-radius: 20px;
    max-height: 84dvh;
  }

  .stage1_5-image {
    min-height: 170px;
  }

  .stage1_5-image img,
  .stage1_5-image svg {
    min-height: 170px;
  }

  .stage1_5-options {
    gap: 6px;
  }

  .stage1_5-options button,
  .stage1_5-continue {
    min-height: 40px;
    font-size: 12px;
  }
}

@media (max-width: 540px) and (orientation: portrait) {
  .stage1_5-card {
    grid-template-columns: 1fr;
    width: min(94vw, 520px);
    max-height: 88dvh;
  }

  .stage1_5-image {
    width: 100%;
    min-height: 190px;
    aspect-ratio: 16 / 9;
  }

  .stage1_5-image img,
  .stage1_5-image svg {
    min-height: 190px;
  }
}

@media (max-width: 920px), (max-height: 520px), (pointer: coarse) {
  body:not(.pre-start) .controls {
    display: none;
  }
}
