* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family:
    system-ui,
    -apple-system,
    Arial,
    sans-serif;
  color: #354266;
  background: #e7f8ff;
  user-select: none;
}
button {
  font: inherit;
  cursor: pointer;
}
.screen {
  display: none;
  position: fixed;
  inset: 0;
  overflow: auto;
  flex-direction: column;
  background: radial-gradient(circle at 8% 3%, #fff7c5, transparent 29%), linear-gradient(145deg, #c7f3f3, #e8e2ff);
}
.screen.active {
  display: flex;
}
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 24px;
  background: #ffffffc9;
  border-bottom: 3px solid #fff9;
  box-shadow: 0 5px 15px #3e617715;
}
.logo {
  font-weight: 1000;
  letter-spacing: 2px;
  color: #f56e65;
  font-size: 19px;
  white-space: nowrap;
}
.logo span {
  color: #458de5;
}
.logo em {
  font-style: normal;
  color: #34b995;
}
.stats {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 900;
}
.stats span {
  padding: 8px 13px;
  border: 2px solid #e2ebf4;
  border-radius: 30px;
  background: white;
}
.btn {
  border: 0;
  border-radius: 17px;
  padding: 15px 20px;
  font-weight: 900;
  letter-spacing: 1px;
  color: white;
  text-shadow: 0 2px #0003;
  box-shadow:
    inset 0 2px #fff9,
    0 5px #0003,
    0 10px 20px #33496b24;
  transition: transform 0.1s;
}
.btn:active {
  transform: translateY(4px);
  box-shadow:
    inset 0 2px #fff9,
    0 1px #0003;
}
.btn img {
  width: 20px;
  height: 20px;
  vertical-align: middle;
}
.btn.coral {
  background: linear-gradient(#ffa378, #f45b53);
}
.btn.blue {
  background: linear-gradient(#86d9ff, #338fe1);
}
.btn.green {
  background: linear-gradient(#86ebb9, #23b98b);
}
.btn.orange {
  background: linear-gradient(#ffcb74, #f39531);
}
.btn.purple {
  background: linear-gradient(#d3adff, #9265df);
}
.btn.red {
  background: linear-gradient(#ff9797, #e44f55);
}
.btn.light {
  background: linear-gradient(white, #dce7f2);
  color: #53647b;
  text-shadow: none;
}
.btn.small {
  padding: 9px 14px;
  border-radius: 12px;
  font-size: 12px;
}
.btn.big {
  font-size: 25px;
  padding: 18px 48px;
}
.home {
  width: min(1050px, 94vw);
  margin: auto;
  display: grid;
  grid-template-columns: 1.65fr 1fr;
  gap: 22px;
  padding: 25px 0;
}
.hero,
.info,
.mini {
  border: 3px solid white;
  border-radius: 28px;
  box-shadow: 0 18px 40px #566b9024;
  background: #fffdf2d9;
}
.hero {
  padding: 38px;
  min-height: 430px;
  overflow: hidden;
  background: linear-gradient(130deg, #fffbe8, #dcf8fd);
}
.eyebrow {
  color: #df9562;
  font-size: 11px;
  letter-spacing: 3px;
  font-weight: 900;
}
.hero h1 {
  color: #f66f62;
  font-size: clamp(40px, 5vw, 64px);
  line-height: 1;
  letter-spacing: -2px;
  margin: 15px 0;
}
.hero h1 span {
  color: #448fe5;
}
.hero p {
  max-width: 380px;
  line-height: 1.6;
  font-weight: 600;
  color: #8490a4;
}
.art {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: 22px;
}
.art img {
  width: 85px;
  filter: drop-shadow(0 10px 7px #46607a40);
}
.art .plus,
.art .equals {
  font-size: 32px;
  font-weight: 900;
  color: #a4b5c7;
}
.menuButtons {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.mini {
  text-align: center;
  padding: 20px;
  font-size: 12px;
  line-height: 1.8;
  letter-spacing: 1.5px;
  color: #8796a8;
}
.mini b {
  color: #32b79c;
}
.loading {
  width: min(400px, 90vw);
  margin: auto;
  text-align: center;
}
.loading img {
  width: 120px;
  animation: bob 1.5s infinite ease-in-out;
}
.large {
  font-size: 36px;
}
.loading p {
  font-size: 12px;
  letter-spacing: 3px;
  font-weight: 900;
  color: #83a4b5;
}
.loading small {
  display: block;
  margin-top: 14px;
  color: #8392a6;
}
.loadbar {
  height: 20px;
  background: white;
  border: 3px solid white;
  border-radius: 20px;
  margin: 26px 0 8px;
  overflow: hidden;
}
.loadbar i {
  display: block;
  background: linear-gradient(90deg, #ffbe6b, #fa6d76);
  height: 100%;
  width: 0;
}
@keyframes bob {
  50% {
    transform: translateY(-15px) rotate(8deg);
  }
}
.levelWrap {
  width: min(920px, 94vw);
  margin: 20px auto;
}
.levelWrap p,
.info p {
  color: #8292aa;
}
#levelGrid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 10px;
  padding-bottom: 30px;
}
.cell {
  aspect-ratio: 1;
  border: 3px solid white;
  border-radius: 15px;
  background: linear-gradient(#83daef, #3eabc7);
  color: white;
  font-size: 19px;
  font-weight: 900;
  box-shadow: 0 4px #2e89a8;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}
.cell small {
  font-size: 10px;
  color: #ffdf64;
}
.cell.locked {
  background: #dce7f1;
  color: #a4afc1;
  box-shadow: none;
}
.cell img {
  width: 16px;
}
.info {
  width: min(850px, 94vw);
  margin: 30px auto;
  padding: 28px;
}
.info h2 {
  font-size: 30px;
}
.cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-bottom: 25px;
}
.cards div {
  border: 2px solid white;
  border-radius: 18px;
  background: #eff8ff;
  padding: 18px;
}
.cards b {
  color: #f58d64;
}
.cards h3 {
  font-size: 15px;
  letter-spacing: 1px;
}
.cards p {
  line-height: 1.5;
}
.narrow {
  max-width: 500px;
}
.setting {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid #e3ebf4;
}
#game {
  overflow: hidden;
}
.gameHeader {
  padding: 8px 14px;
}
.objective {
  text-align: center;
  padding: 7px;
  background: #ffffffa8;
  font-weight: 900;
}
.swatch {
  display: inline-block;
  width: 19px;
  height: 19px;
  border: 2px solid #fff;
  border-radius: 50%;
  vertical-align: middle;
  box-shadow: 0 1px 4px #42546b66;
}
.goalText {
  font-size: 10px;
  color: #8a9bb0;
  letter-spacing: 1.2px;
  margin-left: 14px;
}
.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}
canvas {
  width: 100%;
  height: 100%;
  touch-action: none;
  display: block;
}
.toolbar {
  min-height: 68px;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 18px;
  background: #ffffffd9;
  border-top: 3px solid white;
}
.toolbar #hintText {
  margin-right: auto;
  color: #8293a8;
  letter-spacing: 1px;
  font-size: 11px;
  font-weight: 900;
}
.toolbar .btn {
  padding: 12px 20px;
}
.toolbar small {
  font-size: 10px;
}
.overlay {
  position: fixed;
  inset: 0;
  background: #252b49b0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
  padding: 15px;
  backdrop-filter: blur(4px);
}
.hidden {
  display: none;
}
.modal {
  width: min(420px, 95vw);
  background: #fffdf7;
  border: 4px solid white;
  border-radius: 25px;
  text-align: center;
  padding: 26px;
  box-shadow: 0 30px 60px #202f4b55;
}
.modal img {
  width: 70px;
}
.modal h2 {
  font-size: 27px;
  margin: 8px;
}
.modal p {
  color: #8291a7;
  line-height: 1.5;
}
#modalStars {
  font-size: 34px;
  color: #ffc43d;
  letter-spacing: 4px;
}
#modalButtons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 15px;
}
@media (max-width: 700px) {
  .home {
    grid-template-columns: 1fr;
    margin: 15px auto;
  }
  .hero {
    padding: 25px;
    min-height: 340px;
  }
  .art img {
    width: 60px;
  }
  .menuButtons {
    padding-bottom: 20px;
  }
  .logo {
    font-size: 14px;
  }
  .stats {
    font-size: 10px;
  }
  .stats span {
    padding: 6px;
  }
  .stats span:nth-child(2) {
    display: none;
  }
  #levelGrid {
    grid-template-columns: repeat(5, 1fr);
  }
  .cards {
    grid-template-columns: 1fr;
  }
  .toolbar {
    flex-wrap: wrap;
    gap: 8px;
  }
  .toolbar #hintText {
    width: 100%;
    text-align: center;
  }
  .toolbar .btn {
    flex: 1;
    padding: 11px;
  }
  .goalText {
    display: block;
    margin: 4px 0 0;
  }
  .large {
    font-size: 27px;
  }
}
/* Illustrated garden-laboratory redesign */
.screen {
  background: #9dddbe url("../assets/images/world-1-garden.jpg") center center / cover no-repeat;
}
#menu {
  overflow: auto;
  background-position: center center;
}
.world-header {
  position: absolute;
  top: 16px;
  right: 24px;
  display: flex;
  gap: 10px;
  z-index: 2;
}
.world-pill {
  padding: 8px 17px;
  border: 3px solid #79451f;
  background: linear-gradient(#fff8d2, #edc994);
  color: #663a27;
  border-radius: 40px;
  box-shadow:
    0 4px 0 #75451e,
    0 7px 12px #412b1c44;
  font-weight: 1000;
  font-size: 14px;
}
.world-pill img {
  height: 23px;
  vertical-align: middle;
}
.world-menu {
  min-height: 100%;
  width: min(900px, 100%);
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 20px 24px;
}
.game-logo {
  width: min(490px, 55vw);
  height: auto;
  filter: drop-shadow(0 6px 1px #6d381a66);
  margin-bottom: -10px;
}
.mascot-wrap {
  width: 245px;
  height: 225px;
  display: flex;
  justify-content: center;
  align-items: center;
  filter: drop-shadow(0 11px 7px #412b1c4a);
}
.mascot {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  animation: mascotFloat 2.7s ease-in-out infinite;
}
@keyframes mascotFloat {
  50% {
    transform: translateY(-7px) rotate(1deg);
  }
}
.world-tag {
  margin: 3px 0 12px;
  border: 2px solid #fff0c4;
  color: #6d4221;
  font-weight: 1000;
  letter-spacing: 2px;
  border-radius: 40px;
  padding: 6px 17px;
  background: #fff7d9d9;
  text-shadow: 0 1px white;
  font-size: 12px;
}
.btn {
  border: 3px solid #66391f;
  border-radius: 24px;
  text-shadow: 0 2px 0 #4d291c88;
  box-shadow:
    inset 0 3px 0 #ffffffac,
    inset 0 -5px 0 #00000024,
    0 5px 0 #784920,
    0 8px 12px #56361c55;
  font-weight: 1000;
  letter-spacing: 0.6px;
}
.btn.coral {
  background: linear-gradient(#9dff53 0%, #6fe713 50%, #47bf06 100%);
  color: white;
}
.btn.blue {
  background: linear-gradient(#9bdcff, #39a9ee);
}
.btn.green {
  background: linear-gradient(#a4f2ad, #45c67a);
}
.btn.orange {
  background: linear-gradient(#ffe48b, #ffac36);
}
.btn.purple {
  background: linear-gradient(#e0b9ff, #b777df);
}
.btn.light {
  background: linear-gradient(#fff9dc, #edc88f);
  color: #613b26;
  text-shadow: 0 1px #fff;
}
.btn.big {
  font-size: 31px;
  line-height: 1;
  padding: 15px 85px;
}
.main-play {
  min-width: 310px;
  border-radius: 40px;
}
.menuButtons {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  width: min(770px, 94vw);
}
.menuButtons .btn {
  padding: 10px 10px;
  white-space: nowrap;
  font-size: 12px;
}
.menuButtons img {
  width: 21px;
  height: 21px;
}
#loading {
  background: #c9f0c3 url("../assets/images/world-1-garden.jpg") center / cover no-repeat;
}
.loading {
  background: #fff8dfd9;
  border: 4px solid #8a542d;
  border-radius: 32px;
  padding: 25px;
  box-shadow: 0 7px 0 #86512a;
}
.loadbar {
  border: 3px solid #915429;
}
header {
  background: #fff2dce8;
  border-bottom: 4px solid #8c552c;
  box-shadow: 0 5px 0 #e2aa64;
}
.logo {
  color: #ac4f37;
  text-shadow: 0 1px #fff5d7;
}
.logo span {
  color: #388fc3;
}
.stats span {
  border: 2px solid #b47842;
  background: #fff5d9;
  color: #603a27;
}
.objective {
  background: #fff0d6ed;
  border-bottom: 3px solid #d09a59;
  color: #573923;
}
.goalText {
  color: #9b704f;
}
.stage {
  background: linear-gradient(#a6ead7aa, #d3f6a7aa);
}
.toolbar {
  background: #f8dcaeea;
  border-top: 4px solid #9a6435;
}
.toolbar #hintText {
  color: #704d32;
}
.info,
.modal {
  background: #fff5df;
  border: 4px solid #8b542c;
  box-shadow:
    0 6px #cc9356,
    0 20px 45px #4b331b55;
}
.cards div {
  background: #fff9e8;
  border: 2px solid #edc98c;
}
.info p,
.modal p {
  color: #846449;
}
.levelWrap {
  background: #fff7deed;
  border: 4px solid #89532d;
  border-radius: 26px;
  padding: 20px;
  box-shadow: 0 6px #d3a267;
}
.cell {
  border: 3px solid #90582e;
  box-shadow: 0 4px #976030;
}
.modal {
  color: #633e26;
}
.modal h2 {
  color: #693d27;
}
#modalStars {
  text-shadow: 0 3px #8b5720;
}
.overlay {
  background: #3e2e25b8;
}
@media (max-height: 740px) and (min-width: 701px) {
  .game-logo {
    width: min(420px, 48vw);
  }
  .mascot-wrap {
    height: 180px;
    width: 200px;
  }
  .world-menu {
    padding: 8px;
  }
  .menuButtons {
    margin-top: 10px;
  }
  .world-tag {
    margin: 0 0 8px;
  }
}
@media (max-width: 700px) {
  .world-header {
    top: 10px;
    right: 8px;
  }
  .world-pill {
    font-size: 10px;
    padding: 5px 9px;
  }
  .world-menu {
    min-height: 100%;
    justify-content: center;
    padding: 70px 12px 20px;
  }
  .game-logo {
    width: min(340px, 86vw);
  }
  .mascot-wrap {
    width: 190px;
    height: 200px;
  }
  .world-tag {
    font-size: 10px;
  }
  .main-play {
    min-width: 220px;
  }
  .menuButtons {
    grid-template-columns: repeat(2, 1fr);
    width: min(370px, 95vw);
    gap: 10px;
  }
  .menuButtons .btn {
    font-size: 11px;
  }
  .gameHeader .stats span:nth-child(2) {
    display: none;
  }
}

.stage {
  position: relative;
}
.game-guide {
  position: absolute;
  left: 3%;
  bottom: 5%;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}
.game-guide img {
  width: 160px;
  filter: drop-shadow(0 8px 5px #70432260);
}
.guide-bubble {
  background: #fff7dd;
  border: 3px solid #784825;
  border-radius: 18px;
  color: #6d4029;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 900;
  box-shadow: 0 4px 0 #bd8b51;
}
.game-guide:after {
  content: "";
  width: 50px;
  height: 8px;
  background: #4a733333;
  filter: blur(4px);
  border-radius: 50%;
}
@media (max-width: 950px) {
  .game-guide {
    display: none;
  }
}
/* Readability and generous, toy-like controls */
.world-menu {
  width: min(1080px, 100%);
}
.world-tag {
  font-size: 16px;
  padding: 8px 20px;
  letter-spacing: 1px;
}
.main-play {
  font-size: 38px;
  min-width: 350px;
  padding: 20px 100px;
  border-width: 4px;
}
.menuButtons {
  width: min(1000px, 94vw);
  gap: 16px;
  margin-top: 20px;
}
.menuButtons .btn {
  font-size: 17px;
  padding: 15px 12px;
  min-height: 64px;
  border-width: 4px;
}
.menuButtons img {
  width: 27px;
  height: 27px;
  margin-right: 4px;
}
.world-pill {
  font-size: 17px;
}
.gameHeader .stats {
  font-size: 16px;
}
.gameHeader .stats span {
  padding: 9px 18px;
  border-width: 3px;
}
.gameHeader .btn.small {
  font-size: 24px;
  min-width: 56px;
  min-height: 52px;
  padding: 6px 14px;
}
.objective {
  font-size: 20px;
  padding: 9px;
}
.goalText {
  font-size: 14px;
  letter-spacing: 0.5px;
}
.swatch {
  width: 24px;
  height: 24px;
}
.toolbar {
  min-height: 76px;
  gap: 16px;
}
.toolbar #hintText {
  font-size: 17px;
  letter-spacing: 0.4px;
}
.toolbar .btn {
  font-size: 20px;
  min-height: 55px;
  min-width: 155px;
  padding: 10px 24px;
  border-width: 4px;
}
.toolbar small {
  font-size: 14px;
}
.modal h2 {
  font-size: 34px;
}
.modal p {
  font-size: 19px;
}
.modal .btn {
  font-size: 20px;
  min-height: 57px;
}
@media (max-height: 740px) and (min-width: 701px) {
  .world-tag {
    font-size: 13px;
    padding: 4px 14px;
  }
  .main-play {
    min-width: 300px;
    padding: 13px 80px;
    font-size: 30px;
  }
  .menuButtons .btn {
    font-size: 15px;
    min-height: 53px;
    padding: 10px;
  }
}
@media (max-width: 700px) {
  .world-menu {
    padding-top: 65px;
  }
  .world-pill {
    font-size: 13px;
  }
  .world-tag {
    font-size: 12px;
    padding: 5px 12px;
  }
  .main-play {
    min-width: 245px;
    font-size: 30px;
    padding: 13px 55px;
  }
  .menuButtons {
    gap: 12px;
    width: min(390px, 96vw);
  }
  .menuButtons .btn {
    font-size: 15px;
    min-height: 58px;
    padding: 9px 7px;
  }
  .menuButtons img {
    width: 24px;
    height: 24px;
  }
  .gameHeader {
    padding: 6px 10px;
  }
  .gameHeader .stats {
    font-size: 13px;
  }
  .gameHeader .stats span {
    padding: 7px 10px;
  }
  .gameHeader .btn.small {
    font-size: 20px;
    min-width: 48px;
    min-height: 46px;
  }
  .objective {
    font-size: 16px;
    padding: 7px 4px;
  }
  .goalText {
    font-size: 12px;
  }
  .swatch {
    width: 19px;
    height: 19px;
  }
  .toolbar {
    min-height: 90px;
    gap: 8px;
  }
  .toolbar #hintText {
    font-size: 13px;
  }
  .toolbar .btn {
    font-size: 18px;
    min-height: 54px;
    min-width: 0;
  }
  .toolbar small {
    font-size: 12px;
  }
}
/* Rounded, readable type system across every screen. Fredoka is bundled locally. */
@font-face {
  font-family: Fredoka;
  src: url("../assets/fonts/fredoka.ttf") format("truetype");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}
body,
button {
  font-family: Fredoka, system-ui, sans-serif;
}
.btn,
.world-pill,
.stats,
.objective,
.toolbar,
#levelGrid,
.guide-bubble {
  font-weight: 700;
  letter-spacing: 0;
}
.btn {
  text-transform: none;
  line-height: 1.05;
}
.btn.big,
.main-play {
  font-size: 42px;
  text-shadow:
    0 3px #63391d,
    2px 2px #63391d,
    -2px -1px #63391d;
  -webkit-text-stroke: 0.7px #63391d;
}
.menuButtons .btn {
  font-size: 20px;
}
.world-tag {
  font-size: 15px;
  letter-spacing: 1px;
}
.logo {
  font-size: 24px;
  letter-spacing: 0;
  font-weight: 700;
}
.logo.large {
  font-size: 38px;
}
.gameHeader .stats {
  font-size: 19px;
}
.objective {
  font-size: 23px;
}
.goalText {
  font-size: 16px;
  font-weight: 600;
}
.toolbar #hintText {
  font-size: 19px;
}
.toolbar .btn {
  font-size: 23px;
}
.toolbar small {
  font-size: 15px;
}
.info {
  max-width: 980px;
  padding: 28px 36px;
  background: #fff6e4f5;
}
.info h2 {
  font-size: 38px;
  color: #673d29;
  margin: 5px 0 20px;
  text-align: center;
}
.cards {
  gap: 14px;
}
.cards div {
  background: #fffdf2;
  border: 3px solid #dfbb87;
  box-shadow: 0 4px #e0bc89;
  border-radius: 22px;
  padding: 18px 22px;
}
.cards b {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 21px;
  color: white;
  background: #ff9c61;
  border: 3px solid #a85a32;
  border-radius: 50%;
  width: 42px;
  height: 42px;
}
.cards h3 {
  font-size: 22px;
  color: #71452f;
  letter-spacing: 0;
  margin: 10px 0 4px;
}
.cards p {
  font-size: 19px;
  color: #795d4a;
  margin: 0;
  line-height: 1.38;
}
.info > .btn {
  display: block;
  margin: 10px auto;
  min-width: 220px;
  font-size: 22px;
}
.narrow {
  max-width: 560px;
}
.narrow .setting {
  font-size: 21px;
  padding: 19px 0;
}
.narrow .setting .btn {
  font-size: 18px;
}
.narrow p {
  font-size: 17px;
  text-align: center;
}
.levelWrap {
  width: min(830px, 94vw);
  padding: 22px 35px 30px;
  margin: 20px auto;
  background: #fff3d9f7;
}
.world-select {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: center;
}
.world-select h2 {
  font-size: 37px;
  line-height: 1.1;
  margin: 3px;
  color: #6a3d25;
}
.world-select p {
  font-size: 17px;
  color: #976847;
  margin: 6px;
}
.world-kicker {
  color: #dc8450;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
}
.world-arrow {
  width: 57px;
  height: 57px;
  border: 3px solid #774322;
  border-radius: 50%;
  background: linear-gradient(#ffe59c, #f7a83e);
  box-shadow:
    0 4px #8e5127,
    inset 0 3px #fff8;
  color: #613923;
  font:
    700 40px/1 Fredoka,
    sans-serif;
}
.world-arrow:disabled {
  opacity: 0.38;
  box-shadow: none;
}
.levelWrap #levelGrid {
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  padding: 20px 0 8px;
}
.levelWrap .cell {
  font-size: 29px;
  border: 4px solid #784522;
  border-radius: 20px;
  background: linear-gradient(#b5efff, #4fb4dd);
  box-shadow:
    0 5px #794c2b,
    inset 0 3px #fff9;
  text-shadow: 0 2px #4b7996;
  aspect-ratio: 1.15;
}
.levelWrap .cell small {
  font-size: 15px;
  color: #ffd450;
  line-height: 1.2;
}
.levelWrap .cell.locked {
  background: linear-gradient(#eadcc2, #d5c5a8);
  color: #aa967c;
  box-shadow: 0 4px #ad987c;
  text-shadow: none;
}
.levelWrap .cell img {
  width: 20px;
}
.level-footnote {
  text-align: center;
  font-size: 17px;
  color: #9a714f;
  margin: 14px 0 0;
}
.modal {
  width: min(540px, 94vw);
  padding: 12px;
  background: #db9c5e;
  border: 4px solid #703f25;
  max-height: 95dvh;
  overflow: auto;
}
.modal-inner {
  border: 3px solid #fff3d1;
  border-radius: 17px;
  background: #fff4df;
  padding: 20px 26px;
}
.modal img#modalIcon {
  width: 66px;
  height: 66px;
  object-fit: contain;
}
.modal h2 {
  font-size: 38px;
  line-height: 1.1;
  margin: 8px 0;
  color: #6a3d29;
}
.modal p {
  font-size: 21px;
  margin: 10px 0;
  color: #846249;
}
.modal #modalStars {
  font-size: 44px;
  line-height: 1;
  color: #ffbd19;
  -webkit-text-stroke: 1px #874b18;
}
.modal-mascot {
  display: none;
}
.modal.celebrate .modal-inner {
  background: radial-gradient(circle at 50% 60%, #fff4a9 0, #ffe3b9 38%, #ffc5d5 100%);
}
.modal.celebrate .modal-mascot {
  display: block;
  width: 120px;
  height: 128px;
  object-fit: contain;
  margin: 5px auto;
}
.modal.celebrate #modalIcon {
  display: none;
}
#modalButtons {
  gap: 10px;
  margin-top: 16px;
}
#modalButtons .btn {
  font-size: 22px;
  min-height: 54px;
}
.tiny-icon {
  width: 22px;
  vertical-align: middle;
}
@media (max-width: 700px) {
  .logo {
    font-size: 18px;
  }
  .logo.large {
    font-size: 27px;
  }
  .btn.big,
  .main-play {
    font-size: 34px;
  }
  .menuButtons .btn {
    font-size: 18px;
  }
  .gameHeader .stats {
    font-size: 15px;
  }
  .objective {
    font-size: 18px;
  }
  .goalText {
    font-size: 13px;
  }
  .toolbar #hintText {
    font-size: 15px;
  }
  .toolbar .btn {
    font-size: 20px;
  }
  .levelWrap {
    padding: 16px 16px 20px;
  }
  .world-select h2 {
    font-size: 26px;
  }
  .world-select p {
    font-size: 14px;
  }
  .world-kicker {
    font-size: 11px;
  }
  .world-arrow {
    width: 42px;
    height: 42px;
    font-size: 31px;
    flex-shrink: 0;
  }
  .levelWrap #levelGrid {
    grid-template-columns: repeat(5, 1fr);
    gap: 7px;
  }
  .levelWrap .cell {
    font-size: 22px;
    border-radius: 13px;
    border-width: 3px;
  }
  .levelWrap .cell small {
    font-size: 11px;
  }
  .level-footnote {
    font-size: 15px;
  }
  .info {
    padding: 20px;
  }
  .info h2 {
    font-size: 29px;
  }
  .cards h3 {
    font-size: 19px;
  }
  .cards p {
    font-size: 17px;
  }
  .modal h2 {
    font-size: 29px;
  }
  .modal p {
    font-size: 18px;
  }
  .modal.celebrate .modal-mascot {
    width: 95px;
    height: 96px;
  }
  #modalButtons .btn {
    font-size: 19px;
    min-height: 48px;
  }
}
.modal.celebrate .modal-inner {
  background:
    radial-gradient(ellipse at 50% 60%, #fff5b0bb, #ffd5b9aa 55%, #ffb9cbaa),
    repeating-conic-gradient(from -12deg at 50% 57%, #fff5bd 0deg 12deg, #ffd2a9 12deg 24deg);
}
#modalStars {
  display: flex;
  justify-content: center;
  gap: 8px;
  min-height: 0;
}
#modalStars .result-star {
  width: 59px;
  height: 59px;
  object-fit: contain;
  filter: drop-shadow(0 3px 1px #8b4e2e55);
}
#modalStars .result-star.dim {
  filter: grayscale(1);
  opacity: 0.4;
}
@media (max-width: 700px) {
  #modalStars .result-star {
    width: 46px;
    height: 46px;
  }
}

/* Keep the illustration clear of the interactive puzzle board. */
#game .game-guide {
  display: none;
}
/* Improved game controls: clear disabled feedback and compact mobile layout. */
#undo:disabled {
  filter: grayscale(0.8);
  opacity: 0.48;
  cursor: not-allowed;
  box-shadow:
    inset 0 2px #fff6,
    0 3px #865f45;
}
#undo:focus-visible,
#hint:focus-visible,
#flow:focus-visible,
.cell:focus-visible,
.btn:focus-visible {
  outline: 4px solid #fff;
  outline-offset: 3px;
}
@media (max-width: 700px) {
  .toolbar {
    padding: 8px 10px;
  }
  .toolbar .btn {
    font-size: clamp(14px, 4vw, 19px);
    padding: 10px 5px;
  }
  .toolbar small {
    font-size: 11px;
  }
}
/* Desktop: a full-width lab panel around a proportionate, playable pipe grid. */
.lab-side {
  display: none;
}
.wide-board .lab-side {
  display: block;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: min(23%, 285px, var(--side-width));
  pointer-events: none;
  color: #70472e;
}
.wide-board .left-side {
  left: 4.2%;
}
.wide-board .right-side {
  right: 4.2%;
}
.lab-side .side-kicker {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #c4804d;
}
.lab-side h2 {
  font-size: clamp(24px, 2.8vw, 39px);
  line-height: 1.06;
  margin: 12px 0;
  color: #734126;
}
.lab-side p {
  font-size: clamp(15px, 1.5vw, 20px);
  line-height: 1.35;
  margin: 0 0 18px;
  color: #8b6549;
}
.side-chip,
.side-tip {
  background: #fffaf0;
  border: 2px solid #e7c494;
  border-radius: 17px;
  padding: 14px 16px;
  font-size: 16px;
  line-height: 1.35;
  box-shadow: 0 4px #e4c597;
}
.side-tip b {
  color: #ca8550;
}
.side-rule {
  height: 2px;
  background: #e3c598;
  margin-bottom: 18px;
}
/* Keep level tiles inside narrow mobile screens. */
.levelWrap #levelGrid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}
.levelWrap .cell {
  min-width: 0;
  padding: 2px;
}
@media (max-width: 360px) {
  .levelWrap .cell small {
    font-size: 9px;
    letter-spacing: -0.5px;
  }
  .levelWrap .cell img {
    width: 16px;
  }
}
/* Prevent the menu logo and top counters from colliding on small screens. */
@media (max-width: 700px) {
  .world-menu {
    flex-shrink: 0;
    justify-content: flex-start;
  }
}
@media (max-width: 700px) and (max-height: 650px) {
  .world-menu {
    padding: 54px 12px 14px;
  }
  .game-logo {
    width: min(220px, 70vw);
    margin-bottom: -6px;
  }
  .mascot-wrap {
    width: 140px;
    height: 125px;
  }
  .world-tag {
    margin: 2px 0 8px;
    padding: 4px 10px;
    font-size: 11px;
  }
  .btn.big.main-play {
    font-size: 27px;
    min-width: 220px;
    padding: 10px 40px;
  }
  .menuButtons {
    margin-top: 12px;
    gap: 8px;
    padding-bottom: 8px;
  }
  .menuButtons .btn {
    font-size: 15px;
    min-height: 45px;
    padding: 7px 4px;
  }
  .menuButtons img {
    width: 20px;
    height: 20px;
  }
}

/* ============================================================
   Polish: icons, hover and press states, motion
   ============================================================ */
.ic { width: 1.1em; height: 1.1em; flex: none; vertical-align: -0.18em; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease; }
.world-arrow { display: inline-grid; place-items: center; }
.world-arrow .ic { width: 22px; height: 22px; }
.main-play .ic { width: 30px; height: 30px; }
@media (hover: hover) {
  .btn:hover:not(:disabled),
  .world-arrow:hover:not(:disabled),
  .cell:hover:not(:disabled) {
    transform: translateY(-3px);
    filter: brightness(1.07) saturate(1.08);
  }
}
.btn:active:not(:disabled),
.cell:active:not(:disabled) { transform: translateY(3px); filter: none; }
.btn:focus-visible,
.cell:focus-visible,
.world-arrow:focus-visible { outline: 4px solid #fff; outline-offset: 3px; }
.btn:disabled { opacity: 0.6; filter: grayscale(0.5); cursor: default; }
.cell { transition: transform 0.12s ease, filter 0.12s ease; }
.cell small { display: flex; gap: 1px; align-items: center; justify-content: center; }
.cell .mini-star { width: 14px; height: 14px; }
.cell .mini-star.dim { opacity: 0.3; filter: grayscale(1); }
.version { font-size: 12px; opacity: 0.75; margin-top: 4px; }

.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; } }
.result-star { animation: starIn 0.5s cubic-bezier(0.2, 1.6, 0.4, 1) both; }
.result-star:nth-child(2) { animation-delay: 0.15s; }
.result-star:nth-child(3) { animation-delay: 0.3s; }
@keyframes starIn { from { opacity: 0; transform: scale(0.2) rotate(-40deg); } to { opacity: 1; transform: none; } }
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); } }

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

/* phones held sideways: keep the whole menu on one screen */
@media (max-height: 460px) {
  #menu .world-menu { padding: 6px 12px; min-height: 100%; }
  #menu .game-logo { width: min(250px, 34vw); margin-bottom: -4px; }
  #menu .mascot-wrap { width: 120px; height: 110px; }
  #menu .world-tag { margin: 0 0 6px; padding: 3px 12px; font-size: 10px; }
  #menu .main-play { font-size: 20px; padding: 8px 50px; min-width: 0; }
  #menu .menuButtons { margin-top: 8px; gap: 8px; }
  #menu .menuButtons .btn { padding: 6px 6px; font-size: 11px; }
}

/* short windows: the How to Play and Settings cards fit without scrolling */
@media (min-width: 701px) and (max-height: 780px) {
  .info { margin: 12px auto; padding: 16px 26px; }
  .info h2 { font-size: 26px; margin: 4px 0 10px; }
  .cards { gap: 10px; margin-bottom: 14px; }
  .cards div { padding: 12px 16px; }
  .cards p { font-size: 14px; line-height: 1.4; }
}
