@font-face {
  font-family: Fredoka;
  src: url("../assets/fonts/fredoka.ttf");
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
body {
  font-family: Fredoka, "Trebuchet MS", sans-serif;
  background: #12313a;
  color: #fff;
}
button {
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}
button:focus-visible {
  outline: 3px solid #fff2ac;
  outline-offset: 3px;
}
.hidden {
  display: none !important;
}
#world,
#canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
#canvas {
  touch-action: none;
}
.screen {
  display: none;
  position: absolute;
  inset: 0;
}
.screen.active {
  display: block;
}
#loader {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle, #245a58, #102d37);
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
#loader img {
  width: 100px;
  filter: drop-shadow(0 0 22px #ffcd50);
  animation: float 1.2s ease-in-out infinite alternate;
}
#loader h1 {
  font-size: 45px;
  margin: 12px 0;
  color: #fff0bd;
  text-shadow: 0 4px #995023;
}
#loader em,
.menuPanel em {
  font-style: normal;
  color: #ffc15a;
}
.loading {
  width: 220px;
  height: 14px;
  background: #0b252ce6;
  border: 2px solid #d7b870;
  border-radius: 20px;
  padding: 2px;
}
.loading i {
  display: block;
  background: linear-gradient(90deg, #f1a23a, #ffe38d);
  height: 100%;
  width: 0;
  border-radius: 20px;
  transition: width 0.25s ease-out;
}
@keyframes float {
  to {
    transform: translateY(-14px);
  }
}
.menuBackground {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, #0b273be8 0%, #0b273b91 33%, transparent 70%),
    url("../assets/images/menu.jpg") center 48% / cover no-repeat;
}
.menuPanel {
  position: absolute;
  left: 5%;
  top: 50%;
  transform: translateY(-50%);
  width: min(480px, 43vw);
  border: 3px solid #f6d58e;
  background: linear-gradient(160deg, #193e44f2, #102c38ee);
  border-radius: 34px;
  box-shadow:
    inset 0 0 0 4px #b3824938,
    0 18px 55px #061c2c99;
  padding: 22px 24px;
  text-align: center;
}
.eyebrow {
  color: #ffdd9e;
  font-size: 12px;
  letter-spacing: 2px;
  font-weight: bold;
}
.menuPanel h1 {
  font-size: clamp(52px, 5.5vw, 75px);
  line-height: 0.78;
  margin: 18px 0;
  color: #fff4cd;
  letter-spacing: -1.5px;
  -webkit-text-stroke: 1px #643b23;
  text-shadow:
    0 4px #a25c28,
    0 7px #543023;
}
.menuPanel h1 em {
  font-size: 1.1em;
}
.subtitle {
  margin: 19px 0 12px;
  color: #e7f3da;
  font-size: 19px;
}
.record {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: #ffe6a7;
  font-size: 14px;
  font-weight: bold;
  margin: 0 auto 12px;
}
.record img {
  width: 26px;
}
.primary,
.levelButton,
.icon,
.action {
  border: 3px solid #f7db9f;
  color: #fff4d1;
  font-weight: bold;
  text-shadow: 0 2px 2px #5d360e;
  box-shadow:
    inset 0 4px #ffe8ab77,
    0 5px 0 #75441e,
    0 9px 17px #071b2877;
  transition: filter 0.12s;
}
.primary:active,
.levelButton:active,
.icon:active,
.action:active {
  filter: brightness(0.83);
}
.primary {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border-radius: 50px;
  background: linear-gradient(#ffc45c, #e98224);
  font-size: 26px;
  height: 65px;
  margin-bottom: 11px;
}
.primary img {
  width: 31px;
  height: 31px;
}
.primary small {
  display: block;
  font-size: 10px;
  letter-spacing: 1px;
  line-height: 1;
}
.secondary {
  background: linear-gradient(#69ccc1, #218d85);
  height: 54px;
  font-size: 21px;
}
.menuRow {
  display: flex;
  gap: 8px;
}
.levelButton {
  flex: 1;
  border-radius: 35px;
  background: linear-gradient(#79c1ce, #398795);
  font-size: 21px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.levelButton img {
  width: 26px;
}
.icon {
  width: 54px;
  height: 54px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(#6089a3, #315469);
}
.icon img {
  width: 26px;
  height: 26px;
}
.muted {
  filter: grayscale(1);
  opacity: 0.6;
}
header {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 820px;
  padding: 14px;
  margin: 0 auto;
  text-shadow: 0 2px 5px #0b1e22;
}
.progressBox {
  flex: 1;
  text-align: center;
}
.progressBox strong {
  font-size: 20px;
  letter-spacing: 0.8px;
}
.bar {
  height: 15px;
  border: 2px solid #fbe1a5;
  background: #153341b0;
  border-radius: 20px;
  overflow: hidden;
  margin-top: 5px;
}
.bar i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #fb9a39, #ffe27e);
}
.progressBox small {
  display: block;
  color: #ffeab6;
  font-weight: bold;
}
.count {
  background: #17373deb;
  border: 2px solid #ecd295;
  border-radius: 30px;
  display: flex;
  align-items: center;
  padding: 5px 12px;
  gap: 5px;
  font-weight: bold;
  font-size: 17px;
  white-space: nowrap;
  box-shadow: 0 4px 12px #092d3980;
}
.count img {
  width: 31px;
  height: 36px;
  object-fit: contain;
}
.guide,
.bottomHint {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  text-align: center;
  border-radius: 30px;
  color: #ffeac1;
  background: #102e38d9;
  border: 2px solid #eac98c;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: bold;
  letter-spacing: 0.4px;
  pointer-events: none;
}
.guide {
  top: 17%;
}
.bottomHint {
  bottom: 4%;
}
#feedback {
  position: absolute;
  top: 25%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 22px;
  color: #fff0a4;
  font-weight: bold;
  text-shadow: 0 3px 5px #573c21;
  pointer-events: none;
  opacity: 0;
}
#feedback.pop {
  animation: pop 0.9s forwards;
}
@keyframes pop {
  0% {
    opacity: 0;
    transform: translate(-50%, 10px);
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -25px);
  }
}
.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: #061d26bd;
  display: grid;
  place-items: center;
  padding: 12px;
}
.dialog {
  width: min(470px, 96vw);
  max-height: 90dvh;
  overflow: auto;
  position: relative;
  background: linear-gradient(#245252, #17393e);
  border: 3px solid #f9d58b;
  border-radius: 30px;
  padding: 25px;
  color: #fff2d5;
  text-align: center;
  box-shadow:
    inset 0 0 0 4px #cb9b5b35,
    0 18px 45px #06151bc0;
}
.dialog h2 {
  font-size: 32px;
  margin: 2px 0 14px;
  color: #ffe09a;
  line-height: 1.05;
}
.dialog p {
  font-size: 17px;
  line-height: 1.4;
}
.close {
  position: absolute;
  top: 9px;
  right: 10px;
  width: 35px;
  height: 35px;
  border-radius: 50%;
  border: 2px solid #e2c98c;
  background: #3a6c6a;
  color: white;
  font-size: 23px;
}
.actions {
  display: flex;
  justify-content: center;
  gap: 9px;
  flex-wrap: wrap;
}
.action {
  border-radius: 30px;
  padding: 10px 19px;
  background: linear-gradient(#ffc35d, #df7d22);
  font-size: 18px;
}
.action.alt {
  background: linear-gradient(#73c5bf, #2b8a83);
}
.levelGrid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
  max-height: 48dvh;
  overflow: auto;
  padding: 5px;
}
.levelGrid button {
  aspect-ratio: 1;
  border: 2px solid #f1d396;
  border-radius: 14px;
  background: linear-gradient(#6ebeb6, #267c78);
  font-size: 19px;
  color: white;
  font-weight: bold;
}
.levelGrid button:disabled {
  background: #3e5555;
  color: #a0a5a1;
  border-color: #6e7771;
}
.levelGrid small {
  display: block;
  font-size: 9px;
}
.award img {
  width: 55px;
  height: 55px;
  object-fit: contain;
}
@media (max-width: 600px) {
  .menuBackground {
    background:
      linear-gradient(#102c3844 0%, #102c3810 40%, #0c253b99 100%),
      url("../assets/images/menu.jpg") center center/cover no-repeat;
  }
  .menuPanel {
    left: 50%;
    top: auto;
    bottom: 3%;
    transform: translateX(-50%);
    width: min(92vw, 410px);
    padding: 14px 14px 15px;
    border-radius: 28px;
  }
  .menuPanel h1 {
    font-size: 52px;
    margin: 12px 0;
  }
  .eyebrow {
    font-size: 10px;
  }
  .subtitle {
    font-size: 15px;
    margin: 12px 0 8px;
  }
  .record {
    margin-bottom: 8px;
  }
  .primary {
    height: 54px;
    font-size: 23px;
    margin-bottom: 8px;
  }
  .secondary {
    height: 47px;
    font-size: 19px;
  }
  .menuRow .icon {
    width: 46px;
    height: 46px;
  }
  .levelButton {
    font-size: 18px;
  }
  header {
    padding: 9px;
    gap: 7px;
  }
  .icon {
    width: 47px;
    height: 47px;
  }
  .icon img {
    width: 23px;
  }
  .progressBox strong {
    font-size: 16px;
  }
  .count {
    font-size: 13px;
    padding: 4px 8px;
  }
  .count img {
    width: 24px;
    height: 29px;
  }
  .guide,
  .bottomHint {
    font-size: 11px;
    padding: 8px 12px;
  }
  .bottomHint {
    bottom: 3%;
  }
}
@media (max-height: 520px) {
  .menuPanel {
    left: 3%;
    top: 50%;
    bottom: auto;
    transform: translateY(-50%);
    width: min(410px, 55vw);
    padding: 8px 12px;
  }
  .menuPanel h1 {
    font-size: 34px;
    margin: 7px 0;
  }
  .eyebrow {
    font-size: 9px;
  }
  .subtitle {
    font-size: 12px;
    margin: 8px 0 5px;
  }
  .record {
    margin-bottom: 5px;
    font-size: 11px;
  }
  .record img {
    width: 20px;
  }
  .primary {
    height: 42px;
    font-size: 18px;
    margin-bottom: 6px;
  }
  .secondary {
    height: 38px;
    font-size: 16px;
  }
  .primary img {
    width: 23px;
    height: 23px;
  }
  .menuRow .icon {
    width: 38px;
    height: 38px;
  }
  .levelButton {
    font-size: 16px;
  }
  .menuRow .levelButton img {
    width: 20px;
  }
  header {
    padding: 6px;
  }
  .guide {
    top: 24%;
    padding: 5px 12px;
  }
  .bottomHint {
    bottom: 3%;
    padding: 5px 12px;
  }
  .dialog {
    padding: 14px;
  }
  .dialog p {
    font-size: 14px;
    margin: 8px;
  }
  .dialog h2 {
    font-size: 26px;
  }
}
#world {
  background: #163641 url("../assets/images/world.jpg") center / cover no-repeat;
}
#game {
  touch-action: none;
  overscroll-behavior: none;
}

/* dialogs fit one screen: no scrolling */
.dialog {
  overflow: hidden;
  max-height: 96dvh;
}
.levelGrid {
  max-height: none;
  overflow: visible;
}
.levelGrid button {
  aspect-ratio: auto;
  height: clamp(34px, calc((100dvh - 270px) / 5), 66px);
  padding: 0;
}
.tabs {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 0 0 8px;
}
.tabs button {
  border: 2px solid #f1d396;
  border-radius: 20px;
  background: #3a6c6a;
  color: #fff2d5;
  font-weight: bold;
  font-size: 15px;
  padding: 7px 14px;
}
.tabs button.on {
  background: linear-gradient(#ffc35d, #df7d22);
}
button:focus-visible {
  outline: 3px solid #ffe38d;
  outline-offset: 2px;
}
@media (max-height: 700px) {
  .dialog {
    padding: 16px 20px;
  }
  .dialog h2 {
    font-size: 26px;
    margin: 2px 0 8px;
  }
  .dialog p {
    font-size: 15px;
    margin: 6px 0;
  }
  .action {
    padding: 8px 18px;
    font-size: 17px;
  }
}
@media (max-height: 500px) {
  .dialog {
    width: min(560px, 96vw);
    padding: 10px 16px;
    border-radius: 22px;
  }
  .dialog h2 {
    font-size: 21px;
    margin: 0 0 4px;
  }
  .dialog p {
    font-size: 13px;
    line-height: 1.3;
    margin: 4px 0;
  }
  .action {
    padding: 6px 15px;
    font-size: 15px;
  }
  .tabs {
    margin-bottom: 4px;
  }
  .tabs button {
    font-size: 12px;
    padding: 4px 12px;
  }
  .levelGrid {
    gap: 5px;
    padding: 2px;
  }
  .levelGrid button {
    height: clamp(28px, calc((100dvh - 150px) / 5), 50px);
    font-size: 16px;
    border-radius: 11px;
    line-height: 1;
  }
  .levelGrid small {
    font-size: 8px;
  }
  .close {
    width: 28px;
    height: 28px;
    font-size: 20px;
    top: 6px;
    right: 8px;
  }
}
@media (max-height: 380px) {
  .levelGrid small {
    display: none;
  }
  .dialog p {
    font-size: 12px;
  }
}

/* ---------- v2: worlds, gems, goals, shop ---------- */
#world {
  transition: filter 0.4s;
}
#world[data-w="2"] {
  filter: hue-rotate(35deg) saturate(1.05);
}
#world[data-w="3"] {
  filter: hue-rotate(150deg) brightness(1.08);
}
#world[data-w="4"] {
  filter: hue-rotate(290deg) saturate(1.1);
}
#world[data-w="5"] {
  filter: hue-rotate(205deg) brightness(0.85) saturate(1.2);
}
.gem {
  width: 18px;
  height: 22px;
  vertical-align: -4px;
  flex: none;
}
.record .sep {
  width: 2px;
  height: 16px;
  background: #ffe6a755;
  margin: 0 6px;
}
.record .gem {
  width: 15px;
  height: 18px;
}
.shopButton .gem {
  width: 22px;
  height: 26px;
}
.chips {
  position: absolute;
  left: 12px;
  right: 12px;
  top: calc(78px + env(safe-area-inset-top));
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  pointer-events: none;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #17373deb;
  border: 2px solid #ecd295;
  border-radius: 20px;
  padding: 3px 10px;
  font-weight: bold;
  font-size: 14px;
  color: #fff4d1;
  white-space: nowrap;
}
.pill.wind {
  border-color: #9ff2ff;
  color: #d7f8ff;
}
.pill.super {
  border-color: #ff8fb0;
  color: #ffd6e2;
}
.goals {
  position: absolute;
  right: 12px;
  top: calc(112px + env(safe-area-inset-top));
  list-style: none;
  margin: 0;
  padding: 6px 10px;
  background: #102e38cc;
  border: 2px solid #eac98c;
  border-radius: 14px;
  font-size: 12px;
  font-weight: bold;
  color: #ffeac1;
  max-width: 46vw;
  text-align: left;
  pointer-events: none;
}
.goals li {
  padding: 2px 0;
}
.goals li.ok {
  color: #aef5b2;
}
.goals li.fail {
  color: #ff9aa8;
  text-decoration: line-through;
}
.brief {
  position: absolute;
  left: 50%;
  top: 19%;
  transform: translateX(-50%);
  width: min(340px, 90vw);
  background: #102e38ee;
  border: 3px solid #eac98c;
  border-radius: 20px;
  padding: 12px 16px;
  color: #ffeac1;
  font-size: 15px;
  line-height: 1.35;
  text-align: left;
  pointer-events: none;
  box-shadow: 0 8px 24px #06151b99;
}
.brief b {
  color: #ffe09a;
  font-size: 17px;
}
.brief ol {
  margin: 4px 0 0;
  padding-left: 0;
  list-style: none;
}
.brief li {
  padding: 2px 0;
}
.brief p {
  margin: 6px 0 0;
  font-size: 14px;
}
.brief .news {
  color: #9ff2ff;
  font-weight: bold;
}
.mini {
  width: 16px;
  height: 15px;
  vertical-align: -2px;
}
.award {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 8px;
}
.award img {
  width: 52px;
  height: 49px;
}
.goalList {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
  font-size: 16px;
  text-align: left;
  display: inline-block;
}
.goalList li.ok {
  color: #aef5b2;
}
.goalList li.no {
  color: #ffb0ba;
}
.goalList em {
  font-style: normal;
  background: #ffc35d;
  color: #5d360e;
  border-radius: 8px;
  padding: 0 6px;
  font-size: 11px;
  margin-left: 4px;
}
.reward {
  color: #9ff2ff;
  font-weight: bold;
  margin: 6px 0 10px;
}
.reward small {
  display: block;
  color: #cfe9e3;
  font-weight: normal;
  font-size: 12px;
}
.levelGrid button.cup {
  background: linear-gradient(#ffc45c, #d9741b);
}
.worldTag {
  align-self: center;
  font-weight: bold;
  color: #ffe09a;
  font-size: 14px;
  min-width: 90px;
}
.gate {
  font-size: 13px !important;
  margin: 8px 0 0 !important;
  color: #cfe9e3;
}
.gate.locked {
  color: #ffd0a0;
}
.wallet {
  margin-left: auto;
  align-self: center;
  font-weight: bold;
  color: #9ff2ff;
  font-size: 16px;
}
.foxes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.fox {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  border: 2px solid #f1d396;
  border-radius: 16px;
  background: #2b6663;
  color: #fff2d5;
  padding: 8px 5px;
  font-family: inherit;
}
.fox.sel {
  background: linear-gradient(#ffc35d55, #df7d2255);
  border-color: #ffe38d;
}
.fox img {
  height: clamp(40px, 11dvh, 72px);
  width: auto;
}
.fox small {
  font-size: 11px;
  line-height: 1.2;
  min-height: 3.6em;
}
.fox i {
  font-style: normal;
  font-weight: bold;
  background: #153341;
  border-radius: 12px;
  padding: 2px 10px;
  font-size: 13px;
}
.ups {
  display: grid;
  gap: 7px;
}
.up {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 8px;
  text-align: left;
  background: #2b666355;
  border: 2px solid #f1d39688;
  border-radius: 14px;
  padding: 6px 10px;
}
.up b {
  display: block;
  font-size: 15px;
  color: #ffe09a;
}
.up small {
  font-size: 11px;
  color: #cfe9e3;
}
.up .action {
  padding: 5px 12px;
  font-size: 14px;
}
.action.dim {
  filter: grayscale(0.7) brightness(0.8);
}
.pips {
  display: flex;
  gap: 3px;
}
.pips i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid #f1d396;
}
.pips i.on {
  background: #ffd75a;
}
@media (max-height: 560px) {
  .brief {
    top: 15%;
    font-size: 12px;
    padding: 6px 12px;
    width: min(300px, 60vw);
  }
  .brief b {
    font-size: 14px;
  }
  .brief p {
    font-size: 12px;
    margin-top: 3px;
  }
  .goals {
    font-size: 10px;
    top: 80px;
  }
  .chips {
    top: 66px;
  }
  .pill {
    font-size: 12px;
    padding: 1px 8px;
  }
  .award img {
    width: 34px;
    height: 32px;
  }
  .goalList {
    font-size: 12px;
  }
  .goalList li {
    line-height: 1.25;
  }
  .fox img {
    height: 34px;
  }
  .fox small {
    font-size: 9px;
    min-height: 0;
  }
  .fox {
    padding: 4px;
    gap: 1px;
  }
  .up {
    padding: 3px 8px;
  }
  .up b {
    font-size: 12px;
  }
  .up small {
    font-size: 9px;
  }
  .ups {
    gap: 4px;
  }
  .wallet {
    font-size: 13px;
  }
  .reward small {
    display: none;
  }
  .gate {
    font-size: 11px !important;
    margin-top: 4px !important;
  }
}
@media (max-width: 380px) {
  .foxes {
    gap: 4px;
  }
  .fox small {
    font-size: 9px;
  }
  .up {
    gap: 5px;
  }
  .goalList {
    font-size: 14px;
  }
}
.menuRow {
  flex-wrap: wrap;
  justify-content: center;
}
.menuRow .levelButton {
  flex: 1 1 40%;
  min-width: 0;
}
@media (max-width: 480px) {
  .menuRow .levelButton {
    font-size: 18px;
    height: 50px;
  }
  .menuRow .icon {
    width: 46px;
    height: 46px;
  }
  .menuRow .icon img {
    width: 22px;
    height: 22px;
  }
  .menuRow {
    gap: 6px;
  }
}
@media (max-height: 420px) and (min-width: 481px) {
  .menuRow {
    flex-wrap: nowrap;
  }
  .menuRow .levelButton {
    flex: 1 1 0;
    font-size: 15px;
    height: 40px;
    gap: 4px;
    padding: 0 6px;
  }
  .menuRow .levelButton img,
  .menuRow .levelButton .gem {
    width: 17px;
    height: 20px;
  }
  .menuRow .icon {
    width: 40px;
    height: 40px;
  }
  .menuRow .icon img {
    width: 18px;
    height: 18px;
  }
}
