@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, system-ui, sans-serif;
  color: #293d54;
  background: #94d8dc;
}
button {
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}
button:focus-visible {
  outline: 4px solid #fff5a3;
  outline-offset: 2px;
}
.screen {
  display: none;
  position: absolute;
  inset: 0;
  overflow: auto;
  background: #a7d5bd url("../assets/images/toy-town.jpg") center/cover no-repeat;
}
.screen.active {
  display: block;
}
.screen::before {
  content: "";
  position: fixed;
  inset: 0;
  background: linear-gradient(#79cbe83a, #4ba9a242);
  pointer-events: none;
}
.screen > * {
  position: relative;
}
.screen#loader {
  background: #91d6d2 url("../assets/images/toy-town.jpg") center/cover;
}
.load-card,
.panel,
.home-card {
  background: #fff8eaf5;
  border: 4px solid #fff3d1;
  border-radius: 30px;
  box-shadow:
    0 8px 0 #7f9e8a,
    0 16px 30px #174a5a55;
}
.load-card {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(360px, 90%);
  padding: 30px;
  text-align: center;
}
.load-card img {
  width: 130px;
  height: 95px;
  object-fit: contain;
}
.load-card h1 {
  font-size: 34px;
  color: #ea8842;
  margin: 10px 0;
}
.load-card p {
  font-size: 17px;
}
.loadbar {
  height: 22px;
  background: #d8e8d5;
  border: 3px solid #89b2a7;
  border-radius: 20px;
  overflow: hidden;
}
.loadbar i {
  display: block;
  background: linear-gradient(90deg, #69d3b9, #ffd275);
  height: 100%;
  width: 0;
}
.load-card b {
  display: block;
  margin-top: 8px;
}
.menu-top,
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 4%;
  gap: 10px;
  max-width: 1400px;
  margin: auto;
}
header h2 {
  font-size: 26px;
  margin: 0;
  text-align: center;
}
.badge {
  background: #fff8e9e8;
  color: #536979;
  border: 2px solid #fff;
  border-radius: 30px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 700;
}
.small {
  min-width: 51px;
  min-height: 46px;
  padding: 7px 12px;
  border: 3px solid #fff;
  border-radius: 15px;
  background: linear-gradient(#fffdf3, #d5e6dd);
  box-shadow: 0 5px 0 #84a99e;
  color: #3b6263;
  font-size: 16px;
  font-weight: 700;
}
.home {
  width: min(1050px, 92%);
  margin: 3vh auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 32px;
}
.cover {
  width: min(40vw, 400px);
  aspect-ratio: 1;
  border: 7px solid #fff4d4;
  border-radius: 32px;
  overflow: hidden;
  box-shadow:
    0 9px 0 #629895,
    0 15px 30px #22596566;
  transform: rotate(-2deg);
}
.cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.home-card {
  width: 510px;
  padding: 28px;
}
.eyebrow {
  color: #55a89d;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.13em;
}
.home h1 {
  font-size: clamp(50px, 6vw, 78px);
  line-height: 0.92;
  margin: 16px 0 7px;
  color: #ed8d43;
  text-shadow: 0 4px #fff;
}
.home h1 span {
  color: #5bb9a4;
}
.home h2 {
  font-size: 18px;
  letter-spacing: 0.32em;
  margin: 8px 0;
  color: #569bb4;
}
.home p,
.panel p {
  font-size: 18px;
  line-height: 1.35;
  color: #5a7580;
}
.btn {
  border: 3px solid #fff9e8;
  border-radius: 17px;
  min-height: 54px;
  padding: 9px 15px;
  box-shadow:
    0 6px 0 #769995,
    inset 0 4px 0 #ffffff82,
    0 9px 16px #39635d42;
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  text-shadow: 0 2px 1px #5b4a3b55;
}
.btn:active,
.small:active,
.tool:active {
  transform: translateY(4px);
  box-shadow:
    0 2px 0 #769995,
    inset 0 3px #ffffff80;
}
.btn span {
  float: right;
}
.orange {
  background: linear-gradient(#ffd07b, #ef9149);
  color: #684529;
  text-shadow: none;
}
.purple {
  background: linear-gradient(#d5a8f5, #a67ad8);
}
.blue {
  background: linear-gradient(#9ee6f1, #60b9d4);
  color: #315d72;
  text-shadow: none;
}
.green {
  background: linear-gradient(#b0eba0, #6fca88);
  color: #386747;
  text-shadow: none;
}
.pink {
  background: linear-gradient(#ffbfd0, #ee8cab);
  color: #7c4260;
  text-shadow: none;
}
.main-buttons {
  display: grid;
  grid-template-columns: 1fr;
  gap: 11px;
}
.menu-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin-top: 14px;
}
.menu-buttons .btn {
  font-size: 15px;
  padding: 8px 4px;
}
.footnote {
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.1em;
  margin-top: 17px;
  color: #83a39e;
}
.panel {
  padding: 24px;
}
.map,
.info,
.settings {
  width: min(840px, 94%);
  margin: 12px auto;
  text-align: center;
}
.panel h2 {
  margin: 5px;
  font-size: 29px;
}
.pager {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  margin: 12px;
}
.pager b {
  min-width: 135px;
}
#levelGrid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}
.level {
  background: linear-gradient(#9ce4e7, #5ebfc4);
  border: 3px solid white;
  border-radius: 16px;
  min-height: 76px;
  color: #275b67;
  font-weight: 700;
  box-shadow: 0 4px #74a7a2;
}
.level b {
  display: block;
  font-size: 24px;
}
.level small {
  font-size: 13px;
}
.level:disabled {
  background: #c3cbbf;
  color: #85958c;
  opacity: 0.8;
}
.map p {
  font-size: 14px;
}
.steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 22px 0;
}
.steps article {
  background: #e3f4e8;
  border: 2px solid #b9dfc9;
  border-radius: 16px;
  padding: 12px;
  text-align: left;
}
.steps b {
  color: #f49c53;
  font-size: 27px;
}
.steps h3 {
  margin: 5px 0;
}
.steps p {
  font-size: 14px;
  margin: 0;
}
.settings {
  max-width: 480px;
}
.settings > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #e3f4e8;
  padding: 12px;
  border-radius: 15px;
  margin: 12px 0;
}
.settings .btn {
  min-height: 42px;
  font-size: 15px;
}
.screen#game {
  overflow: hidden;
  background: #80cad8 url("../assets/images/toy-town.jpg") center/cover;
}
.screen#game::before {
  background: linear-gradient(#538f8a33, #23596b29);
}
.game-head {
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 25px;
  background: #fff8e9ed;
  border-bottom: 4px solid #fff0d5;
}
.game-title {
  text-align: center;
  min-width: 190px;
}
.game-title small {
  display: block;
  color: #76a99d;
  font-size: 10px;
  letter-spacing: 0.12em;
}
.game-title b {
  font-size: 22px;
  color: #496c6c;
}
.play-area {
  height: calc(100% - 62px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px;
}
.build-status {
  width: min(590px, 96vw);
  background: #fff9ebf2;
  border: 3px solid #fff4d4;
  border-radius: 17px;
  text-align: center;
  padding: 6px 12px;
  box-shadow: 0 4px #83b0a4;
}
.build-status b {
  display: block;
  font-size: 18px;
  color: #476a6b;
}
.build-status span {
  display: block;
  font-size: 13px;
  color: #79918a;
}
.board-wrap {
  position: relative;
  width: min(590px, 96vw, calc((100vh - 300px) * 1.2));
  aspect-ratio: 6/5;
  min-width: 0;
  max-height: calc(100vh - 290px);
}
.board {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(5, 1fr);
  border: 5px solid #dbac6e;
  border-radius: 19px;
  padding: 4px;
  gap: 3px;
  background: linear-gradient(140deg, #a8e9ea, #73c9d9);
  box-shadow:
    0 7px 0 #9b7654,
    0 14px 24px #28606d55;
}
.cell {
  position: relative;
  border: 2px solid #ddf8ed9c;
  border-radius: 12px;
  background: linear-gradient(145deg, #c8f4ebad, #7cd1dca8);
  overflow: hidden;
  padding: 0;
}
.cell:before {
  content: "";
  position: absolute;
  left: 18%;
  top: 22%;
  width: 28%;
  height: 4%;
  background: #e2fffa80;
  border-radius: 20px;
}
.cell img.tile {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.cell.blocked {
  background: linear-gradient(145deg, #80b7ad, #6aa9ae);
}
.cell.blocked img {
  width: 75%;
  height: 75%;
  object-fit: contain;
}
.cell.terminal {
  background: linear-gradient(145deg, #c5eda8, #8bcf86);
  border-color: #eaf8b1;
}
.cell.terminal img {
  width: 88%;
  height: 75%;
  object-fit: contain;
  position: relative;
}
.cell.goal img {
  height: 85%;
  width: 80%;
}
.cell.hint-cell {
  outline: 5px solid #ffdc65;
  outline-offset: -6px;
  animation: pulse 1s infinite;
}
@keyframes pulse {
  50% {
    filter: brightness(1.2);
  }
}
.driving-car {
  position: absolute;
  width: 13%;
  height: 13%;
  object-fit: contain;
  z-index: 3;
  pointer-events: none;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 3px 2px #17495588);
}
.hidden {
  display: none !important;
}
.toolbox {
  width: min(590px, 96vw);
  padding: 9px 12px 11px;
  background: #fff7e9f5;
  border: 3px solid #fff2d2;
  border-radius: 20px;
  box-shadow: 0 6px 0 #8bb2a5;
}
.tools-heading {
  display: flex;
  justify-content: space-between;
  color: #6b9189;
  font-size: 11px;
  letter-spacing: 0.07em;
}
.tools-heading span {
  letter-spacing: 0;
  font-size: 12px;
}
.tools {
  display: grid;
  grid-template-columns: 1fr 1fr 0.65fr;
  gap: 8px;
  margin-top: 6px;
}
.tool {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 55px;
  border: 3px solid #d8e9d6;
  border-radius: 14px;
  background: linear-gradient(#fffef9, #e7f1e4);
  box-shadow: 0 4px 0 #afc7b7;
  color: #4c6d69;
  font-weight: 700;
  font-size: 15px;
}
.tool.selected {
  border-color: #f7b74f;
  background: linear-gradient(#fff3c4, #ffe18d);
  box-shadow: 0 4px 0 #dca657;
}
.tool img {
  width: 42px;
  height: 42px;
  object-fit: contain;
}
.tool span {
  display: block;
}
.tool small {
  display: block;
  color: #7f9990;
  font-size: 11px;
}
.tool.erase b {
  font-size: 31px;
  color: #eb8d75;
  line-height: 1;
}
.actions {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 8px;
  margin-top: 9px;
}
.actions .btn {
  min-height: 47px;
  font-size: 17px;
}
.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: #174458aa;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 15px;
}
.modal {
  width: min(420px, 100%);
  text-align: center;
}
.modal h2 {
  font-size: 32px;
}
.modal p {
  font-size: 17px;
}
.modal #modalStars {
  font-size: 35px;
  color: #f5ad46;
}
.modal #modalButtons {
  display: grid;
  gap: 9px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}
@media (max-width: 700px) and (orientation: portrait) {
  .menu-top,
  header {
    padding: 8px 12px;
  }
  header h2 {
    font-size: 20px;
  }
  .badge {
    font-size: 10px;
  }
  .home {
    flex-direction: column;
    gap: 10px;
    margin: 0 auto;
  }
  .cover {
    width: min(42vw, 175px);
    height: 150px;
    transform: rotate(-1deg);
  }
  .home-card {
    width: min(440px, 100%);
    padding: 17px;
  }
  .home h1 {
    font-size: clamp(39px, 11vw, 53px);
    margin: 8px 0;
  }
  .home h2 {
    font-size: 13px;
  }
  .home p {
    font-size: 15px;
    margin: 8px 0;
  }
  .main-buttons .btn {
    font-size: 16px;
  }
  .menu-buttons .btn {
    font-size: 14px;
  }
  .footnote {
    font-size: 10px;
    margin-top: 12px;
  }
  .map,
  .info,
  .settings {
    padding: 14px;
    margin: 8px auto;
  }
  #levelGrid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
  .level {
    min-height: 60px;
  }
  .steps {
    grid-template-columns: repeat(2, 1fr);
    margin: 12px 0;
  }
  .steps p {
    font-size: 13px;
  }
  .game-head {
    height: 54px;
    gap: 14px;
  }
  .game-title b {
    font-size: 19px;
  }
  .game-title {
    min-width: 145px;
  }
  .small {
    min-height: 42px;
  }
  .play-area {
    height: calc(100% - 54px);
    gap: 7px;
    padding: 6px;
  }
  .build-status b {
    font-size: 15px;
  }
  .build-status span {
    font-size: 12px;
  }
  .board-wrap {
    width: min(96vw, calc((100vh - 280px) * 1.2));
    max-height: calc(100vh - 280px);
  }
  .board {
    border-width: 4px;
    gap: 2px;
    padding: 3px;
    border-radius: 15px;
  }
  .cell {
    border-radius: 8px;
  }
  .toolbox {
    padding: 7px 9px 9px;
  }
  .tool {
    min-height: 49px;
    font-size: 13px;
  }
  .tool img {
    width: 37px;
    height: 37px;
  }
  .actions .btn {
    min-height: 45px;
    font-size: 16px;
  }
}
@media (max-height: 520px) and (orientation: landscape) {
  .game-head {
    height: 46px;
  }
  .game-title b {
    font-size: 16px;
  }
  .game-title small {
    font-size: 9px;
  }
  .play-area {
    height: calc(100% - 46px);
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(220px, 320px);
    grid-template-rows: 1fr;
    gap: 12px;
    padding: 8px 4%;
  }
  .build-status {
    display: none;
  }
  .board-wrap {
    grid-column: 1;
    grid-row: 1;
    width: min(100%, calc((100vh - 70px) * 1.2));
    max-height: calc(100vh - 70px);
    justify-self: center;
  }
  .toolbox {
    grid-column: 2;
    grid-row: 1;
    width: 100%;
  }
  .tools-heading span {
    display: none;
  }
}
/* Deluxe toy-town bridge art */
.screen,
.screen#loader,
.screen#game {
  background-image: url("../assets/images/toy-town.jpg");
}
.screen#game::before {
  background: linear-gradient(#46898a16, #226e7029);
}
.board {
  background: #65c9d8 url("../assets/images/river-board.jpg") center/cover
    no-repeat;
  border: 4px solid #f5d197;
  gap: 1px;
  padding: 3px;
  box-shadow:
    0 6px 0 #bd966c,
    0 15px 28px #285c6c66;
}
.cell {
  background: #b0f1e833;
  border: 1px solid #d9fffda8;
  border-radius: 7px;
}
.cell:before {
  opacity: 0.5;
}
.cell.blocked {
  background: #76b6bb55;
}
.cell.terminal {
  background: linear-gradient(145deg, #d6f5a8e8, #80c67ee8);
  border: 2px solid #f2ffc4;
}
.cell img.tile {
  filter: drop-shadow(0 3px 2px #205a5988);
}
.tool img {
  width: 45px;
  height: 45px;
  filter: drop-shadow(0 2px 1px #875a3655);
}
.tool {
  background: linear-gradient(#fffef5, #e5f5e7);
}
.tool.selected {
  border-color: #ffbd4a;
  background: linear-gradient(#fff4cc, #ffe09a);
}
/* Side-mounted toolbox and larger desktop playing board. */
.screen#game .play-area {
  height: calc(100% - 62px);
  width: min(1200px, 100%);
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 230px;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  align-items: center;
  justify-items: center;
}
.screen#game .build-status {
  grid-column: 1 / -1;
  grid-row: 1;
  display: block;
  width: 100%;
  max-width: 920px;
  align-self: end;
}
.screen#game .board-wrap {
  grid-column: 1;
  grid-row: 2;
  width: min(100%, 900px, calc((100vh - 170px) * 1.2));
  max-height: calc(100vh - 170px);
  align-self: center;
  justify-self: center;
}
.screen#game .toolbox {
  grid-column: 2;
  grid-row: 2;
  width: 100%;
  padding: 15px;
  align-self: center;
  justify-self: stretch;
}
.screen#game .tools-heading {
  display: block;
  font-size: 12px;
}
.screen#game .tools-heading span {
  display: block;
  font-size: 12px;
  margin-top: 3px;
  line-height: 1.2;
}
.screen#game .tools {
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 10px;
}
.screen#game .tool {
  min-height: 62px;
  font-size: 16px;
  justify-content: flex-start;
  padding: 5px 12px;
}
.screen#game .tool img {
  width: 48px;
  height: 48px;
}
.screen#game .tool.erase b {
  width: 48px;
  text-align: center;
}
.screen#game .actions {
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 14px;
}
.screen#game .actions .btn {
  min-height: 50px;
  font-size: 17px;
}
@media (max-width: 700px) {
  .screen#game .play-area {
    height: calc(100% - 54px);
    grid-template-columns: minmax(0, 1fr) 98px;
    gap: 5px;
    padding: 6px;
  }
  .screen#game .build-status {
    padding: 6px 8px;
  }
  .screen#game .board-wrap {
    width: min(100%, calc((100vh - 155px) * 1.2));
    max-height: calc(100vh - 155px);
  }
  .screen#game .toolbox {
    padding: 7px 5px;
  }
  .screen#game .tools-heading {
    font-size: 10px;
    text-align: center;
  }
  .screen#game .tools-heading span {
    display: none;
  }
  .screen#game .tools {
    gap: 7px;
    margin-top: 7px;
  }
  .screen#game .tool {
    min-height: 65px;
    font-size: 12px;
    line-height: 1.02;
    flex-direction: column;
    justify-content: center;
    padding: 3px 1px;
    gap: 1px;
  }
  .screen#game .tool img {
    width: 32px;
    height: 32px;
  }
  .screen#game .tool small {
    font-size: 10px;
  }
  .screen#game .tool.erase b {
    font-size: 25px;
    line-height: 26px;
  }
  .screen#game .actions {
    gap: 7px;
    margin-top: 8px;
  }
  .screen#game .actions .btn {
    min-height: 46px;
    font-size: 13px;
    padding: 5px 2px;
  }
  .screen#game .actions .btn span {
    display: none;
  }
}
@media (max-height: 520px) and (orientation: landscape) {
  .screen#game .play-area {
    height: calc(100% - 46px);
    grid-template-columns: minmax(0, 1fr) 180px;
    gap: 5px;
    padding: 5px 3%;
    grid-template-rows: auto minmax(0, 1fr);
  }
  .screen#game .build-status {
    padding: 3px 8px;
  }
  .screen#game .build-status b {
    font-size: 13px;
  }
  .screen#game .build-status span {
    font-size: 11px;
  }
  .screen#game .board-wrap {
    width: min(100%, calc((100vh - 115px) * 1.2));
    max-height: calc(100vh - 115px);
  }
  .screen#game .toolbox {
    padding: 6px 8px;
  }
  .screen#game .tools-heading {
    font-size: 10px;
  }
  .screen#game .tools-heading span {
    display: none;
  }
  .screen#game .tools {
    gap: 4px;
    margin-top: 4px;
  }
  .screen#game .tool {
    flex-direction: row;
    min-height: 35px;
    padding: 1px 6px;
    font-size: 12px;
    justify-content: flex-start;
  }
  .screen#game .tool img {
    width: 28px;
    height: 28px;
  }
  .screen#game .tool.erase b {
    width: 28px;
    font-size: 23px;
  }
  .screen#game .actions {
    gap: 4px;
    margin-top: 5px;
  }
  .screen#game .actions .btn {
    min-height: 35px;
    font-size: 13px;
    padding: 3px 6px;
  }
}
@media (max-width: 700px) and (orientation: portrait) {
  .screen#game .play-area {
    grid-template-columns: minmax(0, 1fr) 86px;
  }
  .screen#game .actions .btn {
    font-size: 12px;
  }
}
@media (max-height: 520px) and (orientation: landscape) {
  .screen#game .play-area {
    grid-template-rows: auto minmax(0, 1fr);
    align-items: center;
  }
  .screen#game .build-status {
    grid-column: 2;
    grid-row: 1;
    align-self: end;
  }
  .screen#game .board-wrap {
    grid-column: 1;
    grid-row: 1 / 3;
    width: min(100%, calc((100vh - 62px) * 1.2));
    max-height: calc(100vh - 62px);
  }
  .screen#game .toolbox {
    grid-column: 2;
    grid-row: 2;
    align-self: start;
  }
}
/* Keep the tools next to the board rather than at the edge of a wide grid. */
@media (min-width: 701px) and (min-height: 521px) {
  .screen#game .play-area {
    grid-template-columns: minmax(
        0,
        min(900px, calc((100vh - 170px) * 1.2), calc(100% - 242px))
      ) 230px;
    justify-content: center;
  }
  .screen#game .board-wrap {
    width: 100%;
    justify-self: stretch;
  }
  .screen#game .build-status {
    max-width: none;
  }
}
@media (max-height: 520px) and (orientation: landscape) {
  .screen#game .play-area {
    grid-template-columns: minmax(
        0,
        min(calc((100vh - 62px) * 1.2), calc(100% - 185px))
      ) 180px;
    justify-content: center;
  }
  .screen#game .board-wrap {
    width: 100%;
    justify-self: stretch;
  }
}
/* Portrait phones: keep the board large and move all building controls below it. */
@media (max-width: 700px) and (orientation: portrait) {
  .screen#game .play-area {
    height: calc(100% - 54px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 7px;
    width: 100%;
  }
  .screen#game .build-status {
    width: min(590px, 96vw);
    max-width: none;
    align-self: center;
    padding: 6px 8px;
  }
  .screen#game .board-wrap {
    width: min(96vw, calc((100dvh - 280px) * 1.2));
    max-height: calc(100dvh - 280px);
    align-self: center;
  }
  .screen#game .toolbox {
    width: min(590px, 96vw);
    align-self: center;
    padding: 7px 9px 9px;
  }
  .screen#game .tools-heading {
    display: flex;
    justify-content: space-between;
    text-align: left;
    font-size: 10px;
  }
  .screen#game .tools-heading span {
    display: block;
    font-size: 11px;
    margin: 0;
    letter-spacing: 0;
  }
  .screen#game .tools {
    grid-template-columns: 1fr 1fr 0.68fr;
    gap: 6px;
    margin-top: 6px;
  }
  .screen#game .tool {
    min-height: 50px;
    flex-direction: row;
    justify-content: center;
    padding: 3px 2px;
    gap: 4px;
    font-size: 12px;
    line-height: 1.1;
  }
  .screen#game .tool img {
    width: 34px;
    height: 34px;
  }
  .screen#game .tool.erase b {
    width: auto;
    font-size: 25px;
    line-height: 1;
  }
  .screen#game .actions {
    grid-template-columns: 1fr 2fr;
    gap: 7px;
    margin-top: 8px;
  }
  .screen#game .actions .btn {
    min-height: 45px;
    font-size: 15px;
    padding: 5px 8px;
  }
  .screen#game .actions .btn span {
    display: inline;
  }
}
@media (max-width: 360px) and (orientation: portrait) {
  .screen#game .tools-heading span {
    font-size: 10px;
  }
  .screen#game .tool {
    font-size: 11px;
    gap: 2px;
  }
  .screen#game .tool img {
    width: 29px;
    height: 29px;
  }
  .screen#game .actions .btn {
    font-size: 14px;
  }
}
/* Touch phones in landscape also keep the toolbox beneath the board. */
@media (max-width: 950px) and (max-height: 520px) and (orientation: landscape) and (pointer: coarse) {
  .screen#game .play-area {
    height: calc(100% - 46px);
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 4px;
  }
  .screen#game .build-status {
    display: block;
    width: min(440px, 96vw);
    max-width: none;
    align-self: center;
    padding: 2px 6px;
  }
  .screen#game .build-status b {
    font-size: 12px;
  }
  .screen#game .build-status span {
    font-size: 10px;
    line-height: 1.1;
  }
  .screen#game .board-wrap {
    width: min(96vw, calc((100dvh - 190px) * 1.2));
    max-height: calc(100dvh - 190px);
    align-self: center;
  }
  .screen#game .toolbox {
    width: min(440px, 96vw);
    align-self: center;
    padding: 4px 7px 6px;
  }
  .screen#game .tools-heading {
    display: none;
  }
  .screen#game .tools {
    grid-template-columns: 1fr 1fr 0.68fr;
    gap: 5px;
    margin: 0;
  }
  .screen#game .tool {
    flex-direction: row;
    justify-content: center;
    min-height: 34px;
    font-size: 11px;
    padding: 1px 3px;
    gap: 3px;
  }
  .screen#game .tool img {
    width: 26px;
    height: 26px;
  }
  .screen#game .tool.erase b {
    width: auto;
    font-size: 20px;
  }
  .screen#game .actions {
    grid-template-columns: 1fr 2fr;
    gap: 5px;
    margin-top: 4px;
  }
  .screen#game .actions .btn {
    min-height: 32px;
    font-size: 12px;
    padding: 2px 6px;
  }
  .screen#game .actions .btn span {
    display: inline;
  }
}

.cell.locked {
  box-shadow:
    inset 0 0 0 3px #ffb74dcc,
    0 0 0 1px #fff3;
}
.cell .lockbadge {
  position: absolute;
  right: 3%;
  top: 3%;
  font-size: clamp(10px, 2.4vw, 17px);
  line-height: 1;
  font-style: normal;
  background: #fff8e9;
  border-radius: 50%;
  padding: 2px;
  box-shadow: 0 2px 3px #0003;
}
.cell img.pop {
  animation: popin 0.22s ease-out;
}
@keyframes popin {
  0% {
    scale: 0.6;
    opacity: 0.4;
  }
  70% {
    scale: 1.1;
  }
  100% {
    scale: 1;
    opacity: 1;
  }
}
#undo b {
  font-size: 20px;
  line-height: 1;
}
.confetti {
  position: fixed;
  top: -20px;
  width: 10px;
  height: 14px;
  z-index: 60;
  pointer-events: none;
  animation: fall 1.8s ease-in forwards;
}
@keyframes fall {
  to {
    transform: translateY(110vh) rotate(540deg);
    opacity: 0.9;
  }
}
@media (max-width: 380px) {
  .game-head {
    gap: 8px;
  }
  .game-title {
    min-width: 104px;
  }
  .game-title b {
    font-size: 17px;
  }
  .game-head .small {
    min-width: 44px;
    padding: 6px 8px;
  }
}

/* ---------- Art direction v2: icons, illustration, feedback ---------- */
.ic {
  width: 1.1em;
  height: 1.1em;
  fill: currentColor;
  vertical-align: -0.2em;
  flex: none;
}
.ic.inline {
  width: 1em;
  height: 1em;
}
.btn .ic,
.tile .ic,
.level .ic,
#modalStars .ic,
.modal-art .ic,
.world-badge .ic {
  filter: drop-shadow(0 2px 0 #3b53583a);
}
.small .ic {
  width: 24px;
  height: 24px;
  color: #3b6263;
}
.small.back .ic {
  width: 18px;
  height: 18px;
  vertical-align: -3px;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.badge .ic {
  width: 18px;
  height: 18px;
}
.btn {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.btn em {
  font-style: normal;
  flex: 1;
  text-align: center;
}
.btn .ic.lead {
  width: 28px;
  height: 28px;
}
.btn .ic.tail {
  width: 18px;
  height: 18px;
  opacity: 0.75;
}
.btn::after {
  content: "";
  position: absolute;
  top: 0;
  left: -60%;
  width: 40%;
  height: 100%;
  background: linear-gradient(100deg, transparent, #ffffff77, transparent);
  transform: skewX(-20deg);
  transition: left 0.5s;
  pointer-events: none;
}
.btn:hover::after {
  left: 130%;
}
.btn:hover:not(:disabled),
.small:hover:not(:disabled) {
  transform: translateY(-2px);
}
.btn:disabled,
.small:disabled {
  filter: saturate(0.5) brightness(0.9);
  cursor: default;
}
.btn.stack {
  flex-direction: column;
  gap: 2px;
}
.btn.stack .ic.big {
  width: 34px;
  height: 34px;
}
.btn.stack em {
  flex: none;
}
.top-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand .ic {
  width: 22px;
  height: 22px;
}
/* menu scenery */
.deco {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.cloud {
  position: absolute;
  width: 120px;
  height: 38px;
  border-radius: 40px;
  background: #ffffffd9;
  box-shadow:
    30px -16px 0 -4px #ffffffd9,
    62px -8px 0 -2px #ffffffd9;
  animation: float-cloud 38s linear infinite;
}
.cloud.c1 {
  top: 12%;
  left: -160px;
}
.cloud.c2 {
  top: 28%;
  left: -160px;
  transform: scale(0.7);
  animation-duration: 52s;
  animation-delay: -20s;
}
.cloud.c3 {
  top: 6%;
  left: -160px;
  transform: scale(0.5);
  animation-duration: 64s;
  animation-delay: -42s;
}
@keyframes float-cloud {
  to {
    translate: calc(100vw + 340px) 0;
  }
}
.menu-top,
.home {
  position: relative;
  z-index: 1;
}
.cover {
  animation: bob 5s ease-in-out infinite;
  position: relative;
}
.cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 40%, #ffffff40 50%, transparent 60%);
  background-size: 250% 100%;
  animation: sheen 5s ease-in-out infinite;
}
@keyframes bob {
  50% {
    transform: rotate(-2deg) translateY(-8px);
  }
}
@keyframes sheen {
  from {
    background-position: 130% 0;
  }
  to {
    background-position: -60% 0;
  }
}
/* level map */
.world-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.world-head h2 {
  margin: 0;
}
.world-badge .ic {
  width: 56px;
  height: 56px;
  animation: bob 6s ease-in-out infinite;
}
.level {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition:
    transform 0.15s,
    filter 0.15s;
}
.level:not(:disabled):hover {
  transform: translateY(-3px);
  filter: brightness(1.08);
}
.level small {
  display: flex;
  min-height: 20px;
  align-items: center;
}
.level small .ic {
  width: 20px;
  height: 20px;
  margin: 0 -1px;
  filter: none;
}
.level:disabled {
  opacity: 1;
}
.level:disabled small .ic {
  color: #8d9c93;
  width: 22px;
  height: 22px;
}
.level.current {
  background: linear-gradient(#ffe29a, #ffa94d);
  color: #6a3d10;
  animation: pulse-ring 1.6s ease-in-out infinite;
}
@keyframes pulse-ring {
  0%,
  100% {
    box-shadow:
      0 4px #c9852f,
      0 0 0 0 #ffd27a99;
  }
  50% {
    box-shadow:
      0 4px #c9852f,
      0 0 0 9px #ffd27a00;
  }
}
#levels[data-world="2"] .level:not(:disabled):not(.current) {
  background: linear-gradient(#bfeea0, #6cc46f);
  color: #2b5a2a;
}
#levels[data-world="3"] .level:not(:disabled):not(.current) {
  background: linear-gradient(#ffc6d6, #ec86a8);
  color: #6a2c47;
}
#levels[data-world="4"] .level:not(:disabled):not(.current) {
  background: linear-gradient(#d8f1ff, #8fc6ee);
  color: #1f4a6e;
}
#levels[data-world="5"] .level:not(:disabled):not(.current) {
  background: linear-gradient(#e2c8ff, #a77be0);
  color: #442a72;
}
/* how to play + settings */
.steps article {
  text-align: center;
  transition:
    transform 0.2s,
    border-color 0.2s;
}
.steps article:hover {
  transform: translateY(-4px);
  border-color: #f4b36f;
}
.tile {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  margin: 0 auto 6px;
  border-radius: 20px;
  border: 3px solid #fff;
  box-shadow:
    0 5px 0 #7f9e8a,
    inset 0 3px 0 #ffffff80;
}
.tile .ic {
  width: 36px;
  height: 36px;
}
.tile.t1 {
  background: linear-gradient(#ffd07b, #ef9149);
}
.tile.t2 {
  background: linear-gradient(#d5a8f5, #a67ad8);
}
.tile.t3 {
  background: linear-gradient(#ffbfd0, #ee8cab);
}
.tile.t4 {
  background: linear-gradient(#b0eba0, #6fca88);
}
.steps article:hover .tile .ic {
  animation: wiggle 0.5s;
}
@keyframes wiggle {
  25% {
    transform: rotate(-10deg) scale(1.1);
  }
  75% {
    transform: rotate(10deg) scale(1.1);
  }
}
.settings > div strong {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ic.row {
  width: 28px;
  height: 28px;
}
.settings .btn .ic {
  width: 20px;
  height: 20px;
}
/* game */
.screen.active {
  animation: screen-in 0.28s ease-out;
}
@keyframes screen-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.tool .tool-ic {
  width: 44px;
  height: 44px;
}
.tool {
  transition:
    transform 0.15s,
    box-shadow 0.15s;
}
.tool:hover {
  transform: translateY(-2px);
}
.tool.selected {
  animation: tool-glow 1.8s ease-in-out infinite;
}
@keyframes tool-glow {
  50% {
    filter: brightness(1.07);
  }
}
.btn .ic.lead {
  filter: drop-shadow(0 2px 0 #3b53583a);
}
.cell:not(:disabled):hover {
  background: #fff8c866;
  transform: scale(1.04);
  z-index: 2;
}
.cell {
  transition:
    transform 0.12s,
    background 0.12s;
}
.lockbadge .ic {
  width: 18px;
  height: 18px;
}
.lockbadge {
  display: grid;
  place-items: center;
}
.modal {
  position: relative;
}
.overlay:not(.hidden) .modal {
  animation: modal-pop 0.3s cubic-bezier(0.3, 1.4, 0.5, 1);
}
@keyframes modal-pop {
  from {
    opacity: 0;
    transform: scale(0.86);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.modal-art img {
  width: 86px;
  height: 60px;
  object-fit: contain;
}
.modal-art.big .ic {
  width: 80px;
  height: 80px;
  animation: medal-in 0.7s cubic-bezier(0.3, 1.5, 0.5, 1) both;
}
@keyframes medal-in {
  from {
    transform: scale(0) rotate(-90deg);
  }
  to {
    transform: none;
  }
}
#modalStars {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 8px 0 12px;
}
#modalStars .ic {
  width: 44px;
  height: 44px;
  animation: pop 0.45s cubic-bezier(0.3, 1.6, 0.5, 1) both;
}
#modalStars .ic:nth-child(2) {
  animation-delay: 0.15s;
}
#modalStars .ic:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes pop {
  from {
    transform: scale(0) rotate(-40deg);
  }
  to {
    transform: none;
  }
}
.load-card img {
  animation: bob 1.8s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ---------- Fit every screen without scrolling (short windows and phones) ---------- */
#menu.active {
  display: flex;
  flex-direction: column;
}
#menu .home {
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 0;
  margin-bottom: 0;
}
@media (max-height: 760px) {
  .menu-top,
  header {
    padding: 8px 4%;
  }
  header h2 {
    font-size: 22px;
  }
  .home .cover {
    width: min(40vw, 46vh);
    border-width: 5px;
  }
  .home-card {
    padding: 18px 22px;
  }
  .home h1 {
    font-size: clamp(36px, 8.5vh, 64px);
    margin: 8px 0 4px;
  }
  .home h2 {
    margin: 4px 0;
    font-size: 15px;
  }
  .home p {
    font-size: 16px;
    margin: 6px 0 10px;
  }
  .home .btn {
    min-height: 46px;
  }
  .footnote {
    margin-top: 10px;
  }
  .panel {
    padding: 16px 20px;
  }
  .map,
  .info,
  .settings {
    margin: 6px auto;
  }
  .panel h2 {
    font-size: 24px;
  }
  .steps {
    margin: 12px 0;
  }
}
@media (max-height: 640px) {
  .home .cover {
    width: min(36vw, 40vh);
  }
  .home-card {
    padding: 12px 18px;
  }
  .home h1 {
    font-size: clamp(30px, 9vh, 46px);
  }
  .home h2,
  .home p,
  .eyebrow,
  .footnote,
  .map p {
    display: none;
  }
  .world-head .eyebrow {
    display: none;
  }
  .home .btn {
    min-height: 40px;
    padding: 5px 8px;
    font-size: 16px;
  }
  .menu-buttons {
    margin-top: 9px;
  }
  .btn.stack {
    flex-direction: row;
    gap: 6px;
  }
  .btn.stack .ic.big {
    width: 22px;
    height: 22px;
  }
  .btn .ic.lead {
    width: 22px;
    height: 22px;
  }
  .world-badge .ic {
    width: 34px;
    height: 34px;
  }
  .panel h2 {
    font-size: 20px;
  }
  .pager {
    margin: 6px;
  }
  #levelGrid {
    gap: 7px;
  }
  .level {
    min-height: 48px;
  }
  .level b {
    font-size: 18px;
  }
  .level small {
    min-height: 14px;
  }
  .level small .ic {
    width: 15px;
    height: 15px;
  }
  .level:disabled small .ic {
    width: 15px;
    height: 15px;
  }
  .tile {
    width: 40px;
    height: 40px;
    margin-bottom: 2px;
    border-radius: 14px;
  }
  .tile .ic {
    width: 26px;
    height: 26px;
  }
  .steps {
    gap: 8px;
    margin: 8px 0;
  }
  .steps article {
    padding: 8px;
  }
  .steps h3 {
    margin: 2px 0;
    font-size: 15px;
  }
  .steps p {
    font-size: 12px;
    line-height: 1.2;
  }
  .settings > div {
    padding: 8px 10px;
    margin: 8px 0;
  }
  .deco .cloud {
    display: none;
  }
}
@media (max-height: 460px) {
  .small {
    min-height: 38px;
  }
  .panel {
    padding: 8px 12px;
  }
  .steps p {
    display: none;
  }
  .level {
    min-height: 40px;
  }
  .btn {
    min-height: 36px;
  }
  .home .cover {
    width: min(30vw, 36vh);
  }
}
@media (max-width: 620px) {
  .brand {
    display: none;
  }
  .menu-top {
    justify-content: flex-end;
  }
}
@media (max-width: 700px) and (max-height: 560px) {
  .steps {
    grid-template-columns: repeat(2, 1fr);
  }
  .steps p {
    display: none;
  }
}
@media (max-height: 360px) {
  .info > h2,
  .settings > h2 {
    display: none;
  }
  .steps {
    grid-template-columns: repeat(4, 1fr);
    margin: 4px 0;
  }
  .steps article {
    padding: 4px;
  }
  .tile {
    width: 32px;
    height: 32px;
    margin-bottom: 0;
  }
  .tile .ic {
    width: 22px;
    height: 22px;
  }
  .panel {
    padding: 6px 10px;
  }
  .settings > div {
    margin: 5px 0;
    padding: 5px 10px;
  }
  .map p,
  .pager {
    display: none;
  }
  .level {
    min-height: 38px;
  }
}
/* Phones held sideways (about 320px tall): every building tool stays on screen. */
@media (max-height: 360px) and (orientation: landscape) {
  #game .build-status {
    padding: 3px 6px;
  }
  #game .build-status b {
    font-size: 13px;
  }
  #game .build-status span,
  #game .tools-heading {
    display: none;
  }
  #game .toolbox {
    padding: 5px 6px 8px;
  }
  #game .tools {
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    margin-top: 0;
  }
  #game .tool {
    flex-direction: column;
    gap: 0;
    min-height: 50px;
    padding: 2px;
    font-size: 11px;
    border-width: 2px;
  }
  #game .tool img,
  #game .tool .tool-ic {
    width: 24px;
    height: 24px;
  }
  #game .tool span {
    text-align: center;
    line-height: 1.05;
  }
  #game .tool small {
    font-size: 10px;
  }
  #game .actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    margin-top: 6px;
  }
  #game .actions .btn {
    min-height: 34px;
    padding: 2px 4px;
    font-size: 12px;
    gap: 4px;
  }
  #game .actions .btn .ic.lead {
    width: 18px;
    height: 18px;
  }
}
/* End of style.css */
