* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #e8f6ef;
  --ink: #23433a;
  --accent: #2ca36a;
  --accent-dark: #1f7c50;
  --fwd: #2ca36a;
  --fwd-dark: #1f7c50;
  --back: #e08a3c;
  --back-dark: #b96b23;
  --card: #fff;
  --bad: #d4564f;
  --line: #6b7f78;
}

html, body {
  height: 100%;
  font-family: ui-rounded, "Trebuchet MS", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
}

#app { height: 100%; display: flex; flex-direction: column; }
.screen { display: none; flex: 1; min-height: 0; flex-direction: column; }
.screen.active { display: flex; }
.hidden { display: none !important; }

/* ---------- menus ---------- */

.menu-screen { align-items: center; padding: 20px 16px; overflow-y: auto; }
.logo { font-size: clamp(28px, 7vw, 46px); margin-top: 5vh; text-align: center; }
.tagline { font-size: clamp(14px, 3vw, 18px); margin: 12px 0 26px; text-align: center; line-height: 1.6; }
.menu-buttons { display: flex; flex-direction: column; gap: 14px; width: min(340px, 92vw); }

.big-btn {
  min-height: 54px; border: 0; border-radius: 14px;
  background: var(--accent); color: #fff;
  font-family: inherit; font-size: 18px; font-weight: 700;
  cursor: pointer; padding: 10px 18px; box-shadow: 0 4px 0 var(--accent-dark);
}
.big-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--accent-dark); }
.big-btn.ghost { background: #fff; color: var(--ink); box-shadow: 0 4px 0 #c3d8ce; }
.big-btn.danger { background: var(--bad); box-shadow: 0 4px 0 #a53b36; }

.portal-link {
  margin-top: 22px; padding: 12px 20px; min-height: 44px;
  display: inline-flex; align-items: center;
  font-size: 14px; color: var(--ink); text-decoration: none;
  background: #fff; border-radius: 999px; box-shadow: 0 2px 0 #c3d8ce;
}
.build { margin-top: 14px; font-size: 12px; color: #6d857b; }

.menu-header {
  display: flex; align-items: center; gap: 12px;
  width: min(760px, 100%); margin-bottom: 10px;
}
.menu-header h2 { font-size: clamp(18px, 4vw, 24px); }
.back-btn, .hud-btn {
  min-width: 44px; min-height: 44px; border: 0; border-radius: 12px;
  background: #fff; color: var(--ink); font-size: 18px; cursor: pointer;
  box-shadow: 0 2px 0 #c3d8ce;
}
.map-progress { width: min(760px, 100%); font-size: 14px; margin-bottom: 12px; color: #557067; }

.level-grid { width: min(760px, 100%); display: flex; flex-direction: column; gap: 6px; }
.world-row {
  display: flex; align-items: center; gap: 10px;
  margin-top: 12px; font-weight: 700; font-size: 15px;
}
.world-emoji { font-size: 22px; }
.world-range { margin-left: auto; font-size: 12px; color: #6d857b; font-weight: 400; }
.level-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }

.tile {
  border: 0; border-radius: 12px; background: var(--card);
  font-family: inherit; color: var(--ink); cursor: pointer;
  padding: 10px 4px; min-height: 60px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  box-shadow: 0 3px 0 #c3d8ce;
}
.tile:active { transform: translateY(2px); box-shadow: 0 1px 0 #c3d8ce; }
.tile.locked { opacity: 0.5; cursor: default; }
.tile-num { font-size: 20px; font-weight: 700; }
.tile-stars { font-size: 12px; color: #e0a020; }
.dim { color: #d6e2dc; }

/* ---------- game ---------- */

#game-header {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; background: rgba(255,255,255,0.8);
  font-weight: 700; font-size: clamp(13px, 2.6vw, 16px);
}
#level-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.teach {
  padding: 8px 16px; text-align: center;
  font-size: clamp(13px, 2.8vw, 16px); line-height: 1.5; background: #f4fbf7;
}
.equation {
  text-align: center; font-size: clamp(20px, 5vw, 30px); font-weight: 700;
  padding: 10px 8px 2px; letter-spacing: 0.5px;
}
.equation.solved { color: var(--accent); }

.nl-wrap {
  flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 6px 8px;
}
#numberline { width: 100%; max-width: 720px; }

.nl-line { stroke: var(--line); stroke-width: 3; stroke-linecap: round; }
.nl-tick { stroke: var(--line); stroke-width: 1.5; }
.nl-tick.major { stroke-width: 2.5; }
.nl-label { fill: #45645b; font-size: 15px; font-family: inherit; font-weight: 700; }
.nl-frog { font-size: 34px; }
.nl-flag { font-size: 26px; }
.nl-arc { fill: none; stroke-width: 3; opacity: 0.85; }
.nl-arc.fwd { stroke: var(--fwd); }
.nl-arc.back { stroke: var(--back); }
.nl-arclabel { font-size: 15px; font-weight: 700; font-family: inherit; }
.nl-arclabel.fwd { fill: var(--fwd-dark); }
.nl-arclabel.back { fill: var(--back-dark); }
.nl-frog.shake { animation: shake 0.35s ease; }
@keyframes shake {
  0%,100% { transform: translateX(0); } 25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

.jump-buttons {
  display: flex; gap: 12px; justify-content: center; flex-wrap: wrap;
  padding: 6px 10px;
}
.jump-group { display: flex; gap: 8px; }
.jump-btn {
  min-width: 60px; min-height: 52px; border: 0; border-radius: 14px;
  font-family: inherit; font-weight: 800; cursor: pointer; color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px; padding: 4px 10px;
}
.jump-btn .arrow { font-size: 12px; opacity: 0.9; }
.jump-btn .mag { font-size: 20px; }
.jump-btn.fwd { background: var(--fwd); box-shadow: 0 4px 0 var(--fwd-dark); }
.jump-btn.back { background: var(--back); box-shadow: 0 4px 0 var(--back-dark); }
.jump-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,0.3); }
.jump-btn:disabled { opacity: 0.35; cursor: default; box-shadow: none; }
.jump-btn.hintflash { animation: hintflash 0.9s ease 2; }
@keyframes hintflash {
  0%,100% { transform: translateY(0); filter: brightness(1); }
  50% { transform: translateY(-4px); filter: brightness(1.25); }
}

.game-footer {
  padding: 6px 14px 14px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.status { font-size: clamp(13px, 2.8vw, 16px); font-weight: 700; }
.jump-count { font-size: 13px; color: #557067; }
.jump-count.warn { color: var(--back-dark); font-weight: 700; }
.check-btn {
  min-height: 48px; width: min(280px, 80vw); margin-bottom: 4px;
  font-size: 17px;
}
.world-tag {
  font-size: 11px; font-weight: 700; color: #fff; background: var(--accent);
  border-radius: 999px; padding: 2px 9px; margin-left: 2px;
}
.footer-btns { display: flex; gap: 10px; }
.tool-btn {
  min-height: 44px; padding: 8px 18px; border: 0; border-radius: 999px;
  background: #fff; font-family: inherit; font-size: 14px; cursor: pointer;
  box-shadow: 0 2px 0 #c3d8ce;
}
.tool-btn:active { transform: translateY(2px); box-shadow: 0 0 0 #c3d8ce; }

/* ---------- overlays ---------- */

.overlay {
  position: fixed; inset: 0; z-index: 30; padding: 16px;
  background: rgba(35, 67, 58, 0.55);
  display: flex; align-items: center; justify-content: center;
}
.card {
  background: #fff; border-radius: 18px; padding: 24px;
  width: min(420px, 94vw); max-height: 90vh; overflow-y: auto; text-align: center;
}
.card h2 { font-size: clamp(19px, 4vw, 25px); margin-bottom: 10px; }
.card p { font-size: 15px; line-height: 1.6; }
.stars { font-size: 38px; color: #e0a020; margin: 8px 0; }
.card-buttons { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.setting-row {
  display: flex; align-items: center; gap: 12px;
  font-size: 16px; font-weight: 700; padding: 12px 6px; cursor: pointer;
}
.setting-row input { width: 22px; height: 22px; }

@media (orientation: landscape) and (max-height: 560px) {
  .teach { font-size: 12px; padding: 5px 12px; }
  .equation { font-size: 22px; padding: 4px; }
  .jump-btn { min-height: 46px; }
}

@media (prefers-reduced-motion: reduce) {
  .nl-frog.shake { animation: none; }
}
