@font-face {
  font-family: Fredoka;
  src: url("../assets/fonts/fredoka.ttf") format("truetype");
  font-weight: 300 700;
  font-display: swap;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family: Fredoka, system-ui, sans-serif;
  color: #70482f;
  background: #b0e9d7;
  user-select: none;
}
button {
  font: inherit;
  cursor: pointer;
}
.screen {
  display: none;
  position: fixed;
  inset: 0;
  overflow: auto;
  flex-direction: column;
  background:
    linear-gradient(#ffffff12, #c4f3c52b),
    url("../assets/images/world-1-meadow.jpg") center/cover no-repeat;
}
.screen.active {
  display: flex;
}
.btn,
.icon,
.level {
  border: 4px solid #80502f;
  border-radius: 18px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 2px #8c563a;
  box-shadow:
    inset 0 4px #ffffffa9,
    0 5px #885630,
    0 9px 15px #52674240;
  transition: transform 0.1s;
}
.btn {
  padding: 13px 20px;
  font-size: 19px;
  line-height: 1.1;
}
.btn:active,
.icon:active,
.level:active {
  transform: translateY(4px);
  box-shadow:
    inset 0 3px #fff9,
    0 1px #885630;
}
.btn:focus-visible,
.icon:focus-visible,
.level:focus-visible {
  outline: 4px solid #fff;
  outline-offset: 3px;
}
.orange {
  background: linear-gradient(#ffc18b, #ff8e51 55%, #eb632e);
}
.blue {
  background: linear-gradient(#a6edff, #57bde9 55%, #2c91cc);
}
.green {
  background: linear-gradient(#b2efa9, #6bcf7f 55%, #38ad5e);
}
.yellow {
  background: linear-gradient(#ffe996, #ffc456 55%, #ee9d30);
}
.purple {
  background: linear-gradient(#e6c9ff, #bc8ae9 55%, #9568c8);
}
.cream,
.icon {
  background: linear-gradient(#fff8da, #f0cf99);
  color: #754a30;
  text-shadow: none;
}
.small {
  padding: 9px 14px;
  font-size: 16px;
}
.big {
  font-size: 33px;
  min-width: 270px;
  padding: 15px 38px;
}
.big span {
  float: right;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #fff8df;
  border: 3px solid #8c5b36;
  border-radius: 30px;
  padding: 7px 14px;
  font-weight: 700;
  box-shadow: 0 4px #be8d59;
  white-space: nowrap;
}
.top {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  padding: 16px 22px;
}
.home {
  width: min(1100px, 96vw);
  margin: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 0 20px;
  padding: 0 20px 24px;
}
.brand {
  text-align: center;
}
.eyebrow {
  font-size: 12px;
  letter-spacing: 2px;
  font-weight: 700;
  color: #ba7950;
}
.brand h1 {
  font-size: clamp(60px, 7vw, 90px);
  line-height: 0.8;
  margin: 16px 0;
  color: #f48d68;
  -webkit-text-stroke: 2px #784a31;
  text-shadow:
    0 6px #9b653c,
    0 10px 14px #456a4355;
}
.brand h1 span {
  color: #82cbea;
}
.brand h2 {
  display: inline-block;
  border: 3px solid #a36b3f;
  border-radius: 30px;
  background: #ffe596;
  color: #a66335;
  font-size: 21px;
  letter-spacing: 4px;
  padding: 5px 22px;
  margin: 0;
}
.brand p {
  font-size: 20px;
  font-weight: 600;
  color: #765742;
}
.hero {
  height: 340px;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}
.hero img {
  height: 325px;
  max-width: 90%;
  object-fit: contain;
  position: relative;
  filter: drop-shadow(0 9px 5px #49664477);
}
.halo {
  position: absolute;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle at 35% 30%, #fff9, #ffe9a9aa, #a8e5c599);
  border: 6px solid #fff8;
  border-radius: 50%;
  box-shadow: 0 12px 25px #42724644;
}
.home-actions {
  grid-column: 1/-1;
  text-align: center;
}
.menu-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  max-width: 950px;
  margin: 20px auto 0;
}
.note {
  color: #8c6c50;
  font-size: 15px;
  font-weight: 600;
}
.load-card {
  margin: auto;
  text-align: center;
  background: #fff8e3ef;
  border: 4px solid #98633f;
  border-radius: 30px;
  padding: 24px 46px;
  box-shadow: 0 7px #c38d5a;
}
.load-card img {
  width: 110px;
  height: 145px;
  object-fit: contain;
}
.load-card h1 {
  font-size: 34px;
  margin: 6px;
  color: #e47854;
}
.load-card h1 span {
  color: #62b2d6;
}
.load-card p {
  color: #997454;
}
.track {
  height: 18px;
  width: 260px;
  max-width: 70vw;
  margin: 18px auto 5px;
  background: #e6d7b1;
  border: 3px solid #ac8054;
  border-radius: 20px;
  overflow: hidden;
}
.track i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #91d983, #f7c35d);
}
header {
  padding: 14px 24px;
  background: #fff6e2ed;
  border-bottom: 4px solid #a87446;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
header h2 {
  font-size: 27px;
  margin: 0;
  color: #754a30;
}
.panel {
  width: min(850px, 94vw);
  margin: 24px auto;
  padding: 24px 30px;
  background: #fff6dfea;
  border: 4px solid #92613b;
  border-radius: 27px;
  box-shadow:
    0 7px #c08d59,
    0 16px 35px #41684a44;
  text-align: center;
}
.panel h2 {
  font-size: 34px;
  color: #75472e;
  margin: 6px;
}
.panel p {
  color: #927158;
}
.level-panel {
  max-width: 650px;
}
.level {
  width: 110px;
  height: 110px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(#9ce9ff, #52bce8);
  margin: 24px auto;
  font-size: 38px;
}
.level span {
  font-size: 15px;
  color: #ffe47d;
}
.cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  text-align: left;
  margin: 22px 0;
}
.cards article {
  background: #fffdf2;
  border: 2px solid #eac89a;
  border-radius: 18px;
  padding: 15px;
}
.cards b {
  display: inline-grid;
  place-items: center;
  background: #f9a86b;
  border-radius: 50%;
  color: #fff;
  width: 38px;
  height: 38px;
}
.cards h3 {
  font-size: 20px;
  margin: 8px 0 3px;
}
.cards p {
  font-size: 17px;
  margin: 0;
  line-height: 1.35;
}
.setting-panel {
  max-width: 520px;
}
.setting {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid #ebd8b9;
  padding: 16px 0;
  font-weight: 600;
  font-size: 20px;
}
#game {
  overflow: hidden;
}
.game-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  min-height: 68px;
  background: #fff7e5ee;
  border-bottom: 4px solid #a87446;
  padding: 7px 16px;
}
.icon {
  width: 50px;
  height: 50px;
  flex: none;
  font-size: 26px;
  line-height: 1;
}
.game-title {
  text-align: center;
  display: flex;
  flex-direction: column;
  min-width: 160px;
}
.game-title small {
  font-size: 11px;
  letter-spacing: 1px;
  color: #b38259;
  font-weight: 700;
}
.game-title b {
  font-size: 21px;
}
.star-pill {
  color: #c68132;
}
.game-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  padding: 8px 12px;
}
.goal {
  position: absolute;
  top: 17px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1;
  background: #fff9e7ee;
  border: 2px solid #fff;
  border-radius: 30px;
  padding: 5px 18px;
  display: flex;
  gap: 10px;
  white-space: nowrap;
}
.goal b {
  color: #ca7750;
}
.goal span {
  font-size: 14px;
}
canvas {
  display: block;
  width: 100%;
  height: 100%;
  border: 4px solid #fff9;
  border-radius: 24px;
  background: #cfedff;
  box-shadow: 0 8px 20px #426d4a44;
}
.controls {
  min-height: 90px;
  background: #fff6e3ed;
  border-top: 4px solid #a87446;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 25px;
  padding: 10px 20px;
}
.power {
  width: min(330px, 40vw);
}
.power-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: #8c6848;
  font-size: 14px;
}
.power-track {
  height: 22px;
  background: #e7d9ba;
  border: 3px solid #b48458;
  border-radius: 20px;
  overflow: hidden;
  margin-top: 6px;
}
.power-track i {
  height: 100%;
  display: block;
  width: 0;
  background: linear-gradient(90deg, #7bd68e, #f5d05b, #fa8964);
}
.jump {
  min-width: 245px;
  font-size: 21px;
  touch-action: none;
}
.jump:disabled {
  filter: grayscale(0.45);
  opacity: 0.65;
}
.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 12px;
  background: #40372fb0;
}
.hidden {
  display: none;
}
.modal {
  width: min(450px, 96vw);
  max-height: 96dvh;
  overflow: auto;
  border: 4px solid #8c5735;
  border-radius: 27px;
  padding: 9px;
  background: #dca16c;
  box-shadow: 0 15px 30px #42352e55;
}
.modal-inner {
  text-align: center;
  background: #fff7e5;
  border: 3px solid #fff;
  border-radius: 18px;
  padding: 16px 24px;
}
.modal img {
  width: 80px;
  height: 105px;
  object-fit: contain;
}
.modal img.hide {
  display: none;
}
.modal h2 {
  font-size: 34px;
  color: #75432d;
  margin: 4px;
}
.modal p {
  font-size: 17px;
  color: #967357;
  margin: 5px 0;
}
#modalStars {
  color: #f4b52e;
  font-size: 32px;
  letter-spacing: 5px;
  text-shadow: 0 2px #a6652e;
}
#modalButtons {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-top: 12px;
}
#modalButtons .btn {
  font-size: 19px;
}
@media (max-width: 700px) {
  .top {
    padding: 9px;
  }
  .pill {
    font-size: 12px;
    padding: 5px 9px;
  }
  .home {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    flex-shrink: 0;
    padding: 10px 12px 24px;
  }
  .brand h1 {
    font-size: 52px;
    margin: 12px 0;
  }
  .brand h2 {
    font-size: 15px;
  }
  .brand p {
    font-size: 15px;
    margin: 8px;
  }
  .eyebrow {
    font-size: 10px;
  }
  .hero {
    height: 180px;
  }
  .hero img {
    height: 175px;
  }
  .halo {
    width: 170px;
    height: 170px;
  }
  .big {
    min-width: 220px;
    font-size: 27px;
  }
  .menu-grid {
    grid-template-columns: 1fr 1fr;
    width: min(360px, 94vw);
    gap: 10px;
    margin: 15px auto 0;
  }
  .menu-grid .btn {
    font-size: 16px;
    min-height: 50px;
    padding: 8px 4px;
  }
  header {
    padding: 10px;
  }
  header h2 {
    font-size: 20px;
  }
  .panel {
    padding: 18px 16px;
    margin: 16px auto;
  }
  .panel h2 {
    font-size: 26px;
  }
  .cards {
    grid-template-columns: 1fr;
  }
  .cards h3 {
    font-size: 18px;
  }
  .cards p {
    font-size: 16px;
  }
  .game-header {
    min-height: 60px;
    gap: 8px;
    padding: 5px;
  }
  .game-title {
    min-width: 100px;
  }
  .game-title b {
    font-size: 18px;
  }
  .game-title small {
    font-size: 9px;
  }
  .icon {
    height: 43px;
    width: 43px;
    font-size: 22px;
  }
  .game-stage {
    padding: 5px;
  }
  .goal {
    top: 12px;
    font-size: 14px;
    padding: 4px 10px;
  }
  .goal span {
    font-size: 12px;
  }
  .controls {
    min-height: 85px;
    padding: 8px 10px;
    gap: 10px;
  }
  .power {
    flex: 1;
    width: auto;
  }
  .power-label {
    font-size: 12px;
  }
  .jump {
    min-width: 155px;
    font-size: 16px;
    padding: 15px 7px;
  }
  .modal h2 {
    font-size: 27px;
  }
}
@media (max-height: 650px) and (max-width: 700px) {
  .brand h1 {
    font-size: 42px;
    margin: 5px 0;
  }
  .brand p {
    margin: 4px;
  }
  .hero {
    height: 125px;
  }
  .hero img {
    height: 120px;
  }
  .halo {
    height: 120px;
    width: 120px;
  }
  .home {
    padding-top: 0;
  }
  .menu-grid .btn {
    min-height: 43px;
  }
  .goal span {
    display: none;
  }
}
/* On phones, keep enough horizontal view to see the next landing platform. */
@media (max-width: 700px) {
  .game-stage {
    justify-content: center;
  }
  .game-stage canvas {
    height: min(100%, 500px);
    flex: none;
  }
}
.world-picker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.world-picker p {
  margin: 4px;
}
.world-arrow {
  border: 3px solid #80502f;
  border-radius: 50%;
  width: 52px;
  height: 52px;
  background: linear-gradient(#ffe8a0, #f2b24e);
  box-shadow: 0 4px #885630;
  font: 700 35px/1 Fredoka;
  color: #70482f;
  flex: none;
}
.world-arrow:disabled {
  opacity: 0.4;
  box-shadow: none;
}
.level-panel {
  max-width: 800px;
}
.level-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}
.level-grid .level {
  width: 100%;
  height: auto;
  min-width: 0;
  aspect-ratio: 1.15;
  margin: 0;
  font-size: 27px;
}
.level-grid .level span {
  font-size: 13px;
}
.level-grid .level.locked {
  background: linear-gradient(#e5d7bd, #c7b49b);
  color: #a38a72;
  box-shadow: 0 4px #a58a70;
  text-shadow: none;
}
.level-grid .level.locked span {
  color: #99846f;
}
.world-arrow:focus-visible {
  outline: 4px solid white;
  outline-offset: 2px;
}
@media (max-width: 700px) {
  .world-arrow {
    width: 41px;
    height: 41px;
    font-size: 28px;
  }
  .level-grid {
    gap: 7px;
  }
  .level-grid .level {
    border-width: 3px;
    font-size: 21px;
    border-radius: 12px;
  }
  .level-grid .level span {
    font-size: 10px;
  }
}
.primary-actions {
  display: flex;
  justify-content: center;
  gap: 14px;
}
.primary-actions .big {
  min-width: 0;
  width: 245px;
}
.endless-best {
  margin: 12px 0 0;
  font-size: 14px;
  font-weight: 700;
  color: #77543d;
}
.menu-grid {
  margin-top: 12px;
}
@media (max-width: 700px) {
  .primary-actions {
    width: min(360px, 94vw);
    gap: 9px;
  }
  .primary-actions .big {
    width: 50%;
    min-width: 0;
    font-size: 23px;
    padding: 12px 13px;
  }
  .endless-best {
    margin: 8px 0 0;
    font-size: 12px;
  }
}
@media (max-width: 360px) {
  .primary-actions .big {
    font-size: 20px;
  }
  .game-header {
    gap: 5px;
  }
  .game-title {
    min-width: 84px;
  }
}
@media (max-width: 700px) {
  .endless-best {
    font-size: 14px;
  }
}

/* ============================================================
   Polish: icons, hover and press states, motion
   ============================================================ */
.ic { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em; fill: currentColor; }
.ic.gold { color: #f4b52e; }
.btn, .icon, .level { transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.icon { display: inline-grid; place-items: center; }
.icon .ic { width: 22px; height: 22px; }
.world-arrow { display: inline-grid; place-items: center; }
.world-arrow .ic { width: 22px; height: 22px; }
@media (hover: hover) {
  .btn:hover:not(:disabled), .icon:hover:not(:disabled), .level:hover:not(:disabled), .world-arrow:hover:not(:disabled) {
    transform: translateY(-3px);
    filter: brightness(1.07) saturate(1.08);
  }
}
.btn:active:not(:disabled), .icon:active:not(:disabled), .level:active:not(:disabled) { transform: translateY(3px); filter: none; }
.btn:disabled, .world-arrow:disabled { filter: grayscale(0.5); opacity: 0.6; cursor: default; }
.level span { display: flex; gap: 1px; justify-content: center; align-items: center; }
.level span .ic { width: 14px; height: 14px; color: #f4b52e; }
.level.locked span .ic { color: #a38a72; width: 16px; height: 16px; }
.star-pill .ic { width: 20px; height: 20px; }
#modalStars { display: flex; justify-content: center; gap: 6px; letter-spacing: 0; }
#modalStars:empty { display: none; }
#modalStars .ic { width: 42px; height: 42px; color: #f4b52e; filter: drop-shadow(0 3px 0 #a6652e55); animation: starIn 0.5s cubic-bezier(0.2, 1.6, 0.4, 1) both; }
#modalStars .ic:nth-child(2) { animation-delay: 0.15s; }
#modalStars .ic:nth-child(3) { animation-delay: 0.3s; }
@keyframes starIn { from { opacity: 0; transform: scale(0.2) rotate(-40deg); } to { opacity: 1; transform: none; } }
.version { font-size: 12px; opacity: 0.75; margin: 4px 0 0; }

.screen.active { animation: screenIn 0.35s ease both; }
@keyframes screenIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.overlay { animation: fadeIn 0.2s ease both; }
.modal { animation: modalPop 0.32s cubic-bezier(0.2, 1.4, 0.4, 1) both; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalPop { from { opacity: 0; transform: scale(0.85) translateY(14px); } to { opacity: 1; transform: none; } }
#modalPanda { animation: float 2.4s ease-in-out infinite; }
@keyframes float { 0%, 100% { transform: translateY(4px) rotate(-1.5deg); } 50% { transform: translateY(-6px) rotate(1.5deg); } }
.hero img { animation: heroBounce 1.6s ease-in-out infinite; transform-origin: 50% 100%; }
.load-card img { animation: heroBounce 1.2s ease-in-out infinite; transform-origin: 50% 100%; }
@keyframes heroBounce { 0%, 100% { transform: translateY(0) scale(1.03, 0.96); } 45% { transform: translateY(-16px) scale(0.98, 1.03); } 80% { transform: translateY(0) scale(1.03, 0.96); } }
.halo { animation: haloPulse 3.2s ease-in-out infinite; }
@keyframes haloPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
.power-track i { transition: width 0.05s linear; }
.power-track i.full { animation: fullPulse 0.4s ease-in-out infinite; }
@keyframes fullPulse { 50% { filter: brightness(1.25); } }
canvas.shake { animation: boardShake 0.35s ease; }
@keyframes boardShake { 0%, 100% { transform: none; } 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }

/* ---------- menu always fits one screen, text sits on a card ---------- */
#menu { overflow: hidden; }
#menu .top { padding: clamp(6px, 1.6vh, 16px) 22px; }
#menu .home {
  flex: 1; min-height: 0; margin: 0 auto; padding: 0 20px clamp(8px, 2vh, 24px);
  grid-template-rows: minmax(0, 1fr) auto; gap: clamp(8px, 2vh, 22px) 20px;
}
#menu .brand { align-self: center; }
.brand-card {
  display: inline-block; padding: clamp(10px, 2.6vh, 22px) clamp(16px, 2.6vh, 28px); background: #fff8e8e6;
  border: 4px solid #92613b; border-radius: 27px; box-shadow: 0 7px #c08d59, 0 16px 35px #41684a44;
}
#menu .brand h1 { font-size: clamp(38px, min(7vw, 12vh), 90px); margin: clamp(4px, 1.4vh, 16px) 0; }
#menu .brand h2 { font-size: clamp(13px, 2.6vh, 21px); padding: 4px 20px; }
#menu .brand p { font-size: clamp(13px, 2.8vh, 20px); margin: clamp(6px, 1.4vh, 14px) 0 0; }
#menu .eyebrow { font-size: clamp(9px, 1.6vh, 12px); }
#menu .hero { height: 100%; min-height: 0; }
#menu .hero img { height: auto; max-height: min(325px, 92%); width: auto; max-width: 90%; }
#menu .halo { width: min(300px, 44vh); height: min(300px, 44vh); }
#menu .primary-actions .btn { font-size: clamp(18px, 3.8vh, 28px); padding: clamp(7px, 1.5vh, 12px) 20px; }
#menu .endless-best, #menu .note { margin: clamp(2px, 0.8vh, 8px) 0 0; font-size: clamp(11px, 1.8vh, 14px); }
#menu .note { display: inline-block; background: #fff8e8e6; border-radius: 20px; padding: 3px 14px; }
#menu .endless-best { display: inline-block; background: #fff8e8e6; border-radius: 20px; padding: 3px 14px; }
#menu .menu-grid { margin-top: clamp(8px, 1.6vh, 18px); gap: clamp(8px, 1.6vh, 14px) 14px; }
#menu .menu-grid .btn { font-size: clamp(14px, 2.6vh, 19px); padding: clamp(6px, 1.3vh, 12px) 12px; }
@media (max-width: 700px) {
  #menu .home { display: flex; flex-direction: column; padding: 0 12px 10px; gap: 8px; }
  #menu .brand { flex: none; }
  #menu .hero { flex: 1; min-height: 0; width: 100%; height: auto; padding-top: 18px; }
  #menu .halo { width: min(170px, 80%); height: min(170px, 80%); }
  #menu .home-actions { flex: none; width: 100%; }
  #menu .menu-grid { grid-template-columns: 1fr 1fr; width: min(360px, 94vw); }
}
@media (max-width: 700px) and (max-height: 460px) {
  #menu .home { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  #menu .hero { height: 100%; }
  #menu .hero img { max-height: 44vh; }
  #menu .halo { width: 40vh; height: 40vh; }
  #menu .brand-card { padding: 8px 12px; }
  #menu .brand h1 { font-size: 34px; }
  #menu .home-actions { grid-column: 1 / -1; }
  #menu .menu-grid { grid-template-columns: repeat(4, 1fr); width: auto; max-width: 600px; }
  #menu .menu-grid .btn { font-size: 13px; padding: 5px 4px; }
  #menu .note, #menu .endless-best { display: none; }
}
@media (max-height: 460px) and (min-width: 701px) {
  #menu .note { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
