@font-face {
  font-family: Fredoka;
  font-weight: 300 700;
  font-display: swap;
  src: url("../assets/fonts/fredoka.ttf");
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #071d29;
  color: #effeff;
  font-family: Fredoka, Arial;
  font-weight: 700;
}
button {
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}
button:focus-visible {
  outline: 4px solid #ffe472;
  outline-offset: 2px;
}
#app {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #103641;
}
#home {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: clamp(18px, 5vw, 70px);
  /* the full original picture: no dark overlay, no blur, no zoom effect */
  background: url("../assets/images/menu.jpg") center/cover no-repeat;
}
#home[hidden],
#game[hidden],
#overlay[hidden] {
  display: none;
}
.intro {
  align-self: flex-start;
  padding-top: 2vh;
  max-width: 64%;
  text-shadow:
    0 4px #102d36,
    0 7px #06131c;
}
.smallcap {
  color: #b8f6f5;
  letter-spacing: 0.22em;
  font-size: clamp(10px, 1.5vw, 15px);
  text-shadow: 0 2px 4px #0b3646;
}
.intro h1 {
  font-weight: 1000;
  font-size: clamp(47px, 6.9vw, 106px);
  letter-spacing: -0.055em;
  line-height: 0.85;
  margin: 12px 0;
  color: #f1e2bc;
  text-shadow:
    0 4px #946035,
    0 8px #542b1c,
    3px 11px #1b1b22;
}
.intro h1 em {
  font-style: normal;
  color: #51e1dc;
  text-shadow:
    0 4px #157c82,
    0 8px #094351,
    3px 11px #14252a;
}
.intro p {
  font-size: clamp(15px, 2vw, 23px);
  color: #fff3bd;
}
.menu-panel {
  width: min(390px, 38vw);
  background: linear-gradient(145deg, #513324f2, #241b1cf5);
  border: 4px solid #bd8448;
  border-radius: 22px;
  box-shadow:
    0 9px #15121b,
    0 15px 30px #0009,
    inset 0 0 0 3px #563321;
  padding: 16px;
}
.ticket {
  text-align: center;
  border-bottom: 2px dashed #a57348;
  padding: 0 0 12px;
  margin-bottom: 12px;
}
.ticket span {
  display: block;
  font-size: 10px;
  letter-spacing: 0.25em;
  color: #f4c884;
}
.ticket b {
  display: block;
  color: #fff5d5;
  font-size: 23px;
}
.ticket small {
  color: #bde6de;
}
.menu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}
.menu-grid button,
.action {
  min-height: 45px;
  border: 2px solid #ffe4a0;
  border-radius: 12px;
  background: linear-gradient(#4cc2b6, #13877f);
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  text-shadow: 0 2px #084d4a;
  box-shadow:
    inset 0 2px #b2fff588,
    0 4px #075951;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.menu-grid button img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}
.menu-grid .primary {
  grid-column: span 2;
  background: linear-gradient(#ffce62, #e77d19);
  border-color: #fff1b9;
  box-shadow:
    inset 0 2px #fff7c888,
    0 5px #a84913;
  text-shadow: 0 2px #914617;
  font-size: 20px;
  min-height: 55px;
}
.home-stats {
  display: flex;
  justify-content: space-between;
  color: #ffe9aa;
  font-size: 11px;
  margin: 16px 3px 0;
}
#game {
  height: 100%;
}
.game-layout {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  background:
    linear-gradient(#062a3bb8, #071721df),
    url("../assets/images/menu.jpg") center/cover no-repeat;
}
.track-wrap {
  width: min(100%, 650px);
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #10343b;
  box-shadow: 0 0 35px #000b;
}
.side {
  flex: 1;
  max-width: 370px;
  padding: clamp(15px, 3vw, 40px);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #ffe7aa;
}
.side-title {
  font-size: clamp(28px, 3vw, 48px);
  font-weight: 1000;
  line-height: 0.9;
  color: #ffe3a1;
  text-shadow: 0 4px #603b22;
}
.side-title em {
  font-style: normal;
  color: #51e3d3;
}
.side p {
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: 0.08em;
}
.side-crystal img {
  width: min(15vw, 170px);
  filter: drop-shadow(0 0 15px #48d6ff);
}
.side-tip {
  border: 2px solid #b37d44;
  background: #34271ee8;
  border-radius: 14px;
  padding: 13px;
  font-size: 12px;
  letter-spacing: 0.05em;
  color: #f9dea1;
}
.side-instructions p {
  background: #134452cc;
  border: 2px solid #66cfc7;
  border-radius: 12px;
  padding: 10px 18px;
  min-width: 170px;
  font-size: 12px;
}
.side-instructions b {
  font-size: 19px;
  color: #fff;
}
.hud {
  height: 76px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: linear-gradient(#184b52, #0a3038);
  border-bottom: 3px solid #a9783f;
  z-index: 1;
}
.hud-title {
  min-width: 64px;
}
.hud-title small {
  display: block;
  color: #a4f7e6;
  font-size: 10px;
}
.hud-title b {
  font-size: 20px;
}
.hud-goals {
  flex: 1;
  background: #082c34;
  border: 2px solid #448d8c;
  border-radius: 10px;
  padding: 6px;
  font-size: 10px;
  line-height: 1.2;
}
.progress {
  height: 8px;
  background: #092024;
  border-radius: 20px;
  margin-top: 5px;
  overflow: hidden;
}
.progress i {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(#fef382, #f5aa25);
  border-radius: 20px;
}
.hud-crystal {
  display: flex;
  align-items: center;
  background: #092d39;
  border-radius: 20px;
  padding: 2px 7px;
}
.hud-crystal img {
  width: 31px;
  height: 31px;
  object-fit: contain;
}
#pause {
  width: 42px;
  height: 42px;
  border: 2px solid #ffdc99;
  border-radius: 12px;
  background: linear-gradient(#eab365, #ae652d);
  padding: 4px;
}
#pause img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
#field {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: #0b3941;
}
canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}
#notice {
  position: absolute;
  top: 19%;
  width: 100%;
  text-align: center;
  color: #fff4a0;
  font-weight: 1000;
  font-size: clamp(20px, 4vh, 35px);
  text-shadow:
    0 3px #b3531c,
    2px 4px #4b3024;
  pointer-events: none;
}
#tutorial {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  background: #063f4ad9;
  border: 2px solid #76d8dc;
  border-radius: 10px;
  padding: 6px 12px;
  font-size: 11px;
  pointer-events: none;
}
.controls {
  display: flex;
  justify-content: center;
  gap: 10px;
  background: linear-gradient(#604632, #3b2a22);
  border-top: 3px solid #cb995a;
  padding: 7px 12px;
}
.controls button {
  width: min(30%, 150px);
  height: 58px;
  border: 2px solid #9be9e1;
  border-radius: 14px;
  background: linear-gradient(#45beb6, #08756f);
  box-shadow: 0 4px #074e49;
  color: white;
  font-size: 22px;
  text-shadow: 0 2px #00584c;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 22px;
}
.controls #jump {
  background: linear-gradient(#ffd168, #e9821c);
  border-color: #fff0bb;
  box-shadow: 0 4px #a85210;
}
.controls small {
  font-size: 10px;
}
.status {
  background: #271d19;
  color: #ffe0a0;
  display: flex;
  justify-content: space-between;
  padding: 5px 12px max(5px, env(safe-area-inset-bottom));
  font-size: 11px;
}
#overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 14px;
  background: #031119c9;
}
.dialog {
  position: relative;
  width: min(100%, 580px);
  max-height: 90%;
  overflow: auto;
  text-align: center;
  background: linear-gradient(#174d55, #0b303a);
  border: 4px solid #d6a361;
  border-radius: 22px;
  box-shadow:
    0 8px #1f1b1a,
    0 15px 30px #0008;
  padding: 22px;
  color: #e8fffa;
}
.dialog h2 {
  font-size: 29px;
  color: #ffe08a;
  margin: 0 30px 8px;
}
.dialog p {
  line-height: 1.4;
}
.dialog #close {
  position: absolute;
  right: 8px;
  top: 2px;
  background: none;
  color: #ffeab4;
  border: 0;
  font-size: 32px;
}
.action {
  display: inline-flex;
  padding: 9px 16px;
  margin: 5px;
  background: linear-gradient(#ffcc62, #dc7918);
  box-shadow: 0 4px #9a4c17;
  border-color: #ffedb4;
  text-shadow: 0 2px #a44717;
}
.action.alt {
  background: linear-gradient(#58cabb, #178c83);
  box-shadow: 0 4px #075951;
}
.grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.grid button {
  min-height: 49px;
  background: linear-gradient(#5bd5c2, #128b83);
  border: 2px solid #bffef0;
  border-radius: 10px;
  color: #fff;
  font-weight: 900;
}
.grid button:disabled {
  background: #365257;
  color: #79928e;
  border-color: #627e78;
}
.grid button small {
  display: block;
  font-size: 9px;
  color: #ffdf68;
}
.result-stars img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}
.shoprow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-align: left;
  padding: 9px;
  margin: 7px 0;
  background: #0b3036;
  border: 1px solid #4b8f87;
  border-radius: 12px;
}
.shoprow small {
  display: block;
  color: #b6e2d9;
}
.shoprow button {
  font-size: 12px;
}
.hintrow {
  background: #0d3740;
  border-radius: 10px;
  padding: 8px;
  margin: 6px 0;
  text-align: left;
  font-size: 14px;
}
#loader {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: radial-gradient(circle, #1b6972, #09232e);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  text-align: center;
}
#loader img {
  width: 120px;
  animation: bob 0.55s alternate infinite;
}
#loader b {
  font-size: 35px;
  line-height: 0.9;
  color: #ffe5aa;
  text-shadow: 0 3px #75401f;
}
#loader em {
  color: #5be4d9;
  font-style: normal;
}
#loader p {
  margin: 4px;
  font-size: 14px;
}
.load {
  width: 220px;
  height: 14px;
  padding: 2px;
  border-radius: 15px;
  background: #d8fbf1;
}
.load i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 15px;
  background: #ffc953;
  transition: width 0.2s ease;
}
#loader.hidden {
  display: none;
}
@keyframes bob {
  to {
    transform: translateY(-10px) rotate(4deg);
  }
}
@media (max-width: 850px) {
  .side {
    display: none;
  }
  .track-wrap {
    width: 100%;
    max-width: 650px;
  }
}
@media (max-width: 650px) and (orientation: portrait) {
  #home {
    padding: 14px;
    flex-direction: column;
    justify-content: space-between;
    background: url("../assets/images/menu.jpg") 37% center/cover no-repeat;
  }
  .intro {
    max-width: none;
    width: 100%;
    padding-top: 1vh;
    text-align: center;
  }
  .intro h1 {
    font-size: clamp(45px, 8vh, 68px);
  }
  .intro p {
    font-size: 14px;
  }
  .menu-panel {
    width: 100%;
    max-width: 420px;
    padding: 11px;
  }
  .ticket {
    padding-bottom: 5px;
    margin-bottom: 7px;
  }
  .ticket b {
    font-size: 18px;
  }
  .ticket span {
    font-size: 9px;
  }
  .menu-grid {
    gap: 6px;
  }
  .menu-grid button {
    min-height: 39px;
    font-size: 12px;
  }
  .menu-grid .primary {
    min-height: 47px;
  }
  .home-stats {
    margin: 10px 3px 0;
  }
  .hud {
    height: 68px;
  }
  .controls button {
    height: 51px;
  }
  .status {
    font-size: 10px;
  }
}
@media (max-height: 570px) {
  #home {
    padding: 12px 4vw;
  }
  .intro h1 {
    font-size: clamp(35px, 9vh, 55px);
  }
  .intro p {
    margin: 4px;
  }
  .menu-panel {
    padding: 9px;
    width: min(380px, 48vw);
  }
  .ticket {
    padding: 0 0 4px;
    margin-bottom: 5px;
  }
  .ticket b {
    font-size: 16px;
  }
  .ticket small {
    display: none;
  }
  .menu-grid {
    gap: 5px;
  }
  .menu-grid button {
    min-height: 30px;
    font-size: 11px;
  }
  .menu-grid button img {
    width: 21px;
    height: 21px;
  }
  .menu-grid .primary {
    min-height: 38px;
    font-size: 16px;
  }
  .home-stats {
    margin: 6px;
  }
  .track-wrap {
    max-width: none;
    position: relative;
  }
  .hud {
    height: 55px;
  }
  .controls {
    position: absolute;
    bottom: 16px;
    right: 8px;
    background: #3b2a22b9;
    border: 0;
    border-radius: 12px;
    z-index: 2;
    padding: 4px;
    width: 245px;
  }
  .controls button {
    height: 40px;
    flex: 1;
    font-size: 17px;
    line-height: 17px;
  }
  .controls small {
    font-size: 8px;
  }
  .status {
    height: 19px;
    padding: 3px 8px;
  }
  .status span:last-child {
    margin-right: 260px;
  }
  .hud-goals {
    font-size: 9px;
  }
  .side {
    display: none;
  }
  .dialog {
    padding: 14px;
  }
  .dialog h2 {
    font-size: 23px;
  }
  .grid button {
    min-height: 34px;
  }
}
@media (max-width: 360px) and (orientation: portrait) {
  .intro h1 {
    font-size: 42px;
  }
  .menu-grid button {
    min-height: 33px;
  }
  .menu-panel {
    padding: 8px;
  }
  .ticket {
    display: none;
  }
}
.controls button img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}
.controls button small {
  display: block;
}
@media (max-height: 570px) {
  .controls button img {
    width: 18px;
    height: 18px;
  }
}

/* ==========================================================================
   Version 3 additions: icon row, goal chips, hearts, level/world list,
   upgrades, trails, confetti and the menu locked state.
   ========================================================================== */
.ic { width: 1em; height: 1em; fill: currentColor; vertical-align: -0.12em; }
.icon-row { display: flex; justify-content: center; gap: 12px; margin-top: 10px; }
.round { width: 46px; height: 46px; border-radius: 50%; border: 2px solid #ffe4a0; padding: 6px;
  background: linear-gradient(#4cc2b6, #13877f); box-shadow: inset 0 2px #b2fff588, 0 4px #075951; }
.round img { width: 100%; height: 100%; object-fit: contain; }
.menu-grid button.locked { filter: saturate(0.5); opacity: 0.85; }
.home-stats { gap: 6px; }

.goals { display: flex; gap: 5px; }
.chip { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-width: 0;
  background: #0b3a45; border: 2px solid #3f8f90; border-radius: 9px; padding: 2px 5px; font-size: 12px; white-space: nowrap; }
.chip img { width: 17px; height: 17px; object-fit: contain; }
.chip b { font-weight: 700; }
.chip.done { background: #1c6a4a; border-color: #8cf0b4; color: #eafff2; }
.chip.bad { background: #5a2a2a; border-color: #d87a6a; color: #ffd8d0; }
.hud-goals { font-size: 12px; }

.status { align-items: center; font-size: 13px; }
.hearts { display: flex; gap: 3px; }
.heart { width: 19px; height: 19px; color: #ff5a6a; filter: drop-shadow(0 1px 0 #50121c); }
.heart.lost { color: #4d3a3f; filter: none; }
.stat { display: inline-flex; align-items: center; gap: 4px; }
.stat .ic { width: 18px; height: 18px; color: #ffe47b; }
.stat.off { opacity: 0.45; }
#magnet-state .ic { color: #7ff6ff; }
.status [hidden] { display: none; }
.controls button.wait { filter: saturate(0.5) brightness(0.85); }

.dialog h3 { color: #ffe08a; margin: 14px 0 6px; font-size: 19px; }
.dialog h2.new { color: #7ff6ff; }
.notetext { font-size: 18px; }
.hint { color: #b6e2d9; font-size: 13px; }
.hint.gate { color: #ffd27a; }
.reward { color: #ffe08a; font-size: 20px; margin: 8px 0; }
.reward img, .bank img, .shoprow img { width: 22px; height: 22px; object-fit: contain; vertical-align: middle; }
.reward small { font-size: 12px; color: #b6e2d9; }
.ok { color: #8cf0b4; } .no { color: #ffb08a; }
.notes { margin: 6px 0 0; padding-left: 18px; font-weight: 400; font-size: 13px; line-height: 1.5; }

.world-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 12px 2px 6px;
  color: #ffe08a; font-size: 15px; text-align: left; }
.world-head span { font-size: 12px; color: #9fe6d8; }
.world-head.locked span { color: #ffb08a; }
.grid button { position: relative; }
.grid button .lockic { width: 18px; height: 18px; opacity: 0.8; }
.grid button .crown { position: absolute; right: 3px; top: 3px; width: 13px; height: 13px; color: #ffd45a; }
.grid button.boss:not(:disabled) { background: linear-gradient(#ffcc62, #dc7918); border-color: #fff0b0; }
.grid button.boss:not(:disabled) small { color: #5c2f08; }

.pip { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-left: 4px; background: #284c52; border: 1px solid #66a6a2; }
.pip.on { background: #ffd45a; border-color: #fff0b0; }
.shoprow .action { margin: 0 0 0 8px; white-space: nowrap; }
.shoprow .action:disabled { opacity: 0.5; }
.bank { font-size: 18px; }
.trails { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.trail { background: #0b3036; border: 2px solid #4b8f87; border-radius: 12px; color: #e8fffa; padding: 8px; }
.trail.sel { border-color: #ffd45a; background: #14464c; }
.trail b { display: block; font-size: 13px; } .trail small { color: #b6e2d9; }
.trail .dots i { display: inline-block; width: 14px; height: 14px; border-radius: 50%; margin: 0 2px; }

#confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 7; }
#confetti i { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }
#loader.hidden { display: none; }
@media (prefers-reduced-motion: reduce) { #confetti i, #loader img { animation: none; } }
@media (max-width: 650px) and (orientation: portrait) { .chip { font-size: 11px; padding: 2px 3px; } .chip img { width: 14px; height: 14px; } }
@media (max-height: 570px) {
  .icon-row { margin-top: 5px; gap: 8px; }
  .round { width: 32px; height: 32px; padding: 4px; }
  .chip { font-size: 10px; } .heart { width: 14px; height: 14px; }
  .status { font-size: 11px; }
}
@media (min-width: 521px) {
  .grid { grid-template-columns: repeat(10, 1fr); gap: 5px; }
  .grid button { min-height: 44px; font-size: 15px; }
}
@media (max-width: 360px) {
  .hud { gap: 5px; padding: 6px; }
  .hud-title { min-width: 50px; }
  .hud-title b { font-size: 17px; }
  .chip { padding: 2px; gap: 2px; font-size: 10px; }
  .chip img { width: 12px; height: 12px; }
  .hud-crystal { padding: 2px 5px; }
  .hud-crystal img { width: 24px; height: 24px; }
  #pause { width: 36px; height: 36px; flex: none; }
}
.chip .ic { width: 15px; height: 15px; flex: none; }
.status { gap: 8px; white-space: nowrap; }
.status #score { margin-left: auto; }
@media (max-width: 360px) { .status { font-size: 11px; padding-left: 8px; padding-right: 8px; } .heart { width: 15px; height: 15px; } }
