@font-face {
  font-family: Fredoka;
  src: url("../assets/fonts/fredoka.ttf");
}
* {
  box-sizing: border-box;
}
html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}
body {
  font-family: Fredoka, system-ui, sans-serif;
  color: #653e20;
  background: #ddaa6c;
}
button {
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}
button:focus-visible {
  outline: 3px solid #106b96;
  outline-offset: 2px;
}
.screen {
  display: none;
  position: absolute;
  inset: 0;
  background: #eac18a url("../assets/images/workshop.jpg") center/cover no-repeat;
  overflow: auto;
}
.screen.active {
  display: block;
}
.top,
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 4%;
  max-width: 1400px;
  margin: auto;
}
header h2 {
  font-size: 26px;
  margin: 0;
  text-align: center;
}
.tag,
.progress-tag {
  background: #fff4d9;
  border: 2px solid #c58e56;
  border-radius: 22px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  color: #7b4d2d;
}
.eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.13em;
  color: #a65b29;
}
.btn,
.tiny,
.piece {
  border: 3px solid #ffefd0;
  color: #56331d;
  font-weight: 700;
  border-radius: 17px;
  box-shadow:
    0 5px 0 #80532e,
    inset 0 4px 0 #ffffff85,
    0 8px 14px #6b3c243a;
  transition:
    transform 0.12s,
    filter 0.12s;
}
.btn:active,
.tiny:active,
.piece:active {
  transform: translateY(3px);
  box-shadow:
    0 2px 0 #80532e,
    inset 0 2px 0 #ffffff85;
}
.btn:hover,
.tiny:hover,
.piece:hover {
  filter: brightness(1.06);
}
.btn {
  font-size: 18px;
  min-height: 54px;
  padding: 11px 15px;
}
.btn span {
  float: right;
}
.orange {
  background: linear-gradient(#ffca76, #f5913d);
}
.blue {
  background: linear-gradient(#92ddfb, #53acd7);
  color: #254e62;
}
.green {
  background: linear-gradient(#b3e597, #79bf70);
  color: #32522a;
}
.yellow {
  background: linear-gradient(#ffe589, #f2b950);
  color: #65441a;
}
.coral {
  background: linear-gradient(#ffb6a3, #e78371);
}
.tiny {
  min-width: 48px;
  min-height: 46px;
  padding: 7px 12px;
  background: linear-gradient(#fff9e7, #efc892);
  border-color: #b77e4f;
  font-size: 16px;
}
.home {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 32px;
  max-width: 1100px;
  width: 92%;
  margin: 3vh auto;
}
.home-copy {
  width: 510px;
  background: #fff3ddf2;
  border: 3px solid #bc8553;
  border-radius: 27px;
  padding: 27px;
  box-shadow: 0 8px 0 #88512e99;
}
.home h1 {
  font-size: clamp(52px, 6vw, 76px);
  line-height: 0.95;
  margin: 14px 0;
  color: #704124;
  letter-spacing: -0.035em;
}
.home h1 em {
  font-style: normal;
  color: #e58239;
}
.home p,
.panel p {
  font-size: 18px;
  color: #7b5236;
  line-height: 1.4;
}
.primary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.secondary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 13px;
}
.secondary .btn {
  font-size: 15px;
  padding: 8px 5px;
}
.foot {
  font-size: 12px;
  text-align: center;
  letter-spacing: 0.06em;
  color: #9a633b;
  margin-top: 17px;
}
.cover {
  width: min(40vw, 440px);
  aspect-ratio: 1;
  overflow: hidden;
  border: 6px solid #ffecd1;
  border-radius: 34px;
  box-shadow:
    0 9px 0 #9a613e,
    0 12px 28px #402b2555;
  transform: rotate(2deg);
}
.cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.panel,
.load-panel {
  background: #fff4e1f5;
  border: 3px solid #bd895a;
  border-radius: 24px;
  padding: 24px;
  box-shadow:
    0 7px 0 #88512e99,
    0 10px 30px #5b392c44;
}
.load-panel {
  width: min(350px, 90%);
  text-align: center;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}
.load-panel img {
  width: 130px;
}
.load-panel h1 {
  font-size: 36px;
  margin: 10px;
}
.load-panel p {
  font-size: 16px;
}
.loading-track {
  height: 18px;
  background: #dfbe91;
  border: 2px solid #b98758;
  border-radius: 22px;
  overflow: hidden;
}
.loading-track i {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #77c8e4, #a4d77e, #ffcb65);
}
.load-panel strong {
  display: block;
  margin-top: 7px;
}
.levels-panel,
.instructions,
.settings {
  width: min(840px, 94%);
  margin: 12px auto;
  text-align: center;
}
.panel h2 {
  font-size: 30px;
  margin: 6px;
}
.pager {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 17px;
  margin: 10px;
}
.pager b {
  min-width: 160px;
  font-size: 17px;
}
#grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}
.level {
  min-height: 78px;
  background: linear-gradient(#94ddf4, #60b5db);
  border: 3px solid #fff4d2;
  border-radius: 16px;
  color: #28536c;
  font-weight: 700;
  box-shadow: 0 4px 0 #6b9aa6;
}
.level b {
  display: block;
  font-size: 25px;
}
.level span {
  font-size: 13px;
}
.level:disabled {
  background: #c8bca9;
  color: #7b7061;
  box-shadow: 0 4px 0 #9d8c7b;
}
.cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 22px 0;
}
.cards article {
  text-align: left;
  background: #ffebc9;
  border: 2px solid #e0b483;
  border-radius: 15px;
  padding: 12px;
}
.cards article > b {
  font-size: 27px;
  color: #e28b42;
}
.cards h3 {
  margin: 6px 0;
}
.cards p {
  font-size: 15px;
  margin: 0;
}
.settings {
  max-width: 450px;
}
.settings > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fbe6c9;
  border-radius: 12px;
  padding: 12px;
  margin: 12px 0;
}
.settings .btn {
  min-height: 45px;
  font-size: 15px;
}
.game-head {
  height: 62px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  background: #fff2def2;
  border-bottom: 3px solid #c28a56;
  padding: 5px;
  position: relative;
  z-index: 3;
}
.game-title {
  min-width: 190px;
  text-align: center;
}
.game-title small {
  display: block;
  font-size: 12px;
  letter-spacing: 0.1em;
  color: #9b633e;
}
.game-title strong {
  font-size: 20px;
}
.progress-tag {
  font-size: 14px;
  min-width: 65px;
  text-align: center;
}
.game-head .tiny {
  min-width: 47px;
  min-height: 44px;
}
.screen#game {
  overflow: hidden;
}
#playfield {
  position: absolute;
  top: 62px;
  bottom: 160px;
  left: 0;
  right: 0;
  overflow: hidden;
  background: linear-gradient(#ffffff10, #fff4dd25);
}
#scene,
#markers {
  position: absolute;
  inset: 0;
}
#scene canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}
#markers {
  pointer-events: none;
}
.marker {
  position: absolute;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  width: 46px;
  height: 46px;
  border: 3px solid white;
  background: linear-gradient(#ffe387, #f6a932);
  color: #6d3b17;
  font-size: 21px;
  font-weight: 700;
  box-shadow:
    0 4px 0 #a45d27,
    0 0 18px #fff78b;
  pointer-events: auto;
}
.marker.done {
  background: linear-gradient(#a8eaa2, #62b875);
  color: #1f562c;
}
.marker:active {
  transform: translate(-50%, -47%);
}
.prompt {
  position: absolute;
  z-index: 2;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: #fff7e6f4;
  border: 2px solid #b9834f;
  border-radius: 25px;
  padding: 7px 17px;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  max-width: 95%;
  text-align: center;
  pointer-events: none;
}
.bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 160px;
  background: #fff2ddf5;
  border-top: 3px solid #bf8957;
  padding: 8px max(15px, calc((100vw - 900px) / 2));
  z-index: 4;
}
.tray-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.tray-title > div {
  display: flex;
  flex-direction: column;
}
.tray-title strong {
  font-size: 17px;
}
.tray-title .tiny {
  min-height: 38px;
  padding: 5px 12px;
  font-size: 15px;
}
.tray {
  display: flex;
  gap: 10px;
  align-items: stretch;
  margin-top: 7px;
}
.piece {
  height: 83px;
  width: 116px;
  background: linear-gradient(#fff8e8, #f5dcb5);
  border-color: #c69563;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  color: #78482a;
}
.piece img {
  width: 80px;
  height: 52px;
  object-fit: contain;
  pointer-events: none;
}
.piece span {
  font-size: 14px;
}
.piece.selected {
  border-color: #ffa132;
  background: linear-gradient(#fff2ae, #ffdc87);
  box-shadow:
    0 5px 0 #b27335,
    0 0 0 3px #fff6c9;
}
.piece:disabled,
.btn:disabled {
  opacity: 0.55;
  cursor: default;
}
.go {
  flex: 1;
  align-self: center;
  margin-left: 10px;
}
.mobile-go {
  display: none;
}
.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: #302013aa;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 15px;
}
.hidden {
  display: none;
}
.modal {
  text-align: center;
  width: min(430px, 100%);
}
.modal img {
  width: 86px;
}
.modal h2 {
  font-size: 30px;
}
.modal #modalButtons {
  display: grid;
  gap: 10px;
}
.modal .btn {
  width: 100%;
}
@media (max-width: 700px) and (orientation: portrait) {
  .top,
  header {
    padding: 9px 12px;
  }
  header h2 {
    font-size: 20px;
  }
  .top .tag {
    font-size: 10px;
  }
  .home {
    flex-direction: column-reverse;
    gap: 10px;
    margin: 0 auto;
  }
  .cover {
    width: min(49vw, 190px);
    height: 160px;
    transform: rotate(1deg);
  }
  .home-copy {
    width: min(450px, 100%);
    padding: 18px;
  }
  .home h1 {
    font-size: clamp(40px, 11vw, 55px);
    margin: 8px 0;
  }
  .home p {
    font-size: 15px;
    margin: 10px 0;
  }
  .primary .btn {
    font-size: 15px;
  }
  .secondary .btn {
    font-size: 14px;
  }
  .foot {
    font-size: 10px;
  }
  .levels-panel,
  .instructions,
  .settings {
    padding: 15px;
    margin: 8px auto;
  }
  .cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin: 12px 0;
  }
  .cards p {
    font-size: 14px;
  }
  #grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
  .level {
    min-height: 64px;
  }
  .game-head {
    height: 56px;
    gap: 6px;
  }
  .game-title {
    min-width: 145px;
  }
  .game-title small {
    font-size: 10px;
  }
  .game-title strong {
    font-size: 17px;
  }
  .progress-tag {
    font-size: 12px;
    padding: 7px;
    min-width: 50px;
  }
  #playfield {
    top: 56px;
    bottom: 204px;
  }
  .prompt {
    font-size: 13px;
    line-height: 1.1;
    white-space: normal;
    width: max-content;
    max-width: 95%;
    padding: 6px 10px;
  }
  .bottom {
    height: 204px;
    padding: 7px 10px;
  }
  .tray-title strong {
    font-size: 15px;
  }
  .tray-title .eyebrow {
    font-size: 10px;
  }
  .tray-title .tiny {
    min-height: 36px;
  }
  .tray {
    gap: 8px;
    margin-top: 5px;
  }
  .piece {
    height: 72px;
    flex: 1;
    width: auto;
  }
  .piece img {
    height: 43px;
    width: 70px;
  }
  .piece span {
    font-size: 12px;
  }
  .go {
    display: none;
  }
  .mobile-go {
    display: block;
    margin-top: 7px;
  }
  .mobile-go .btn {
    width: 100%;
    min-height: 47px;
    font-size: 17px;
    padding: 6px 14px;
  }
  .marker {
    width: 42px;
    height: 42px;
    font-size: 18px;
  }
}
@media (max-width: 350px) {
  .game-title {
    min-width: 120px;
  }
  .game-title strong {
    font-size: 15px;
  }
  .game-head .tiny {
    min-width: 40px;
  }
  .progress-tag {
    min-width: 45px;
    padding: 5px;
  }
  .bottom {
    padding: 6px;
  }
  .piece span {
    font-size: 11px;
  }
}
@media (max-height: 500px) and (orientation: landscape) {
  .game-head {
    height: 50px;
  }
  .game-title small {
    font-size: 10px;
  }
  .game-title strong {
    font-size: 16px;
  }
  #playfield {
    top: 50px;
    bottom: 0;
    right: 230px;
  }
  .prompt {
    font-size: 12px;
    padding: 4px;
  }
  .bottom {
    top: 50px;
    left: auto;
    width: 230px;
    height: auto;
    border-top: 0;
    border-left: 3px solid #bf8957;
    padding: 8px;
  }
  .tray {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
  }
  .piece {
    width: 100%;
    height: 65px;
  }
  .piece img {
    width: 55px;
    height: 38px;
  }
  .piece span {
    font-size: 10px;
  }
  .go {
    display: block;
    grid-column: 1 / -1;
    margin: 6px 0 0;
    min-height: 45px;
    font-size: 15px;
  }
  .mobile-go {
    display: none;
  }
  .tray-title strong {
    font-size: 14px;
  }
  .tray-title .eyebrow {
    font-size: 10px;
  }
}

.marker-line {
  position: absolute;
  height: 3px;
  background: #fff7c9;
  box-shadow: 0 1px 3px #925e36;
  transform-origin: 0 50%;
  pointer-events: none;
}

.marker.wrong {
  background: linear-gradient(#ffb09c, #ed6151);
  color: #71291a;
  box-shadow:
    0 4px 0 #a84337,
    0 0 18px #ffac86;
}

.zoom-tools {
  position: absolute;
  z-index: 3;
  right: 12px;
  top: 54px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.zoom-tools .tiny {
  width: 48px;
  height: 46px;
  min-height: 46px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
}
.zoom-tools .tiny:disabled {
  opacity: 0.55;
}
.zoom-tools .tiny:active {
  transform: translateY(3px);
}
@media (max-width: 700px) and (orientation: portrait) {
  .zoom-tools {
    right: 7px;
    top: 48px;
    gap: 6px;
  }
  .zoom-tools .tiny {
    width: 42px;
    height: 42px;
    min-width: 42px;
    min-height: 42px;
    font-size: 22px;
  }
}
@media (max-height: 500px) and (orientation: landscape) {
  .zoom-tools {
    top: 38px;
    right: 7px;
    flex-direction: row;
  }
  .zoom-tools .tiny {
    width: 39px;
    height: 39px;
    min-width: 39px;
    min-height: 39px;
    font-size: 20px;
  }
}

.zoom-tools .fit-btn {
  width: 50px;
  font-size: 16px;
}
.zoom-tools .tiny:disabled {
  opacity: 0.55;
}
@media (max-width: 700px) and (orientation: portrait) {
  .zoom-tools .fit-btn {
    width: 46px;
    font-size: 15px;
  }
}
/* Side toolbox: the play scene now extends to the bottom of the screen. */
#game #playfield {
  top: 62px;
  bottom: 0;
  left: 0;
  right: 190px;
}
#game .bottom {
  top: 62px;
  bottom: 0;
  left: auto;
  right: 0;
  width: 190px;
  height: auto;
  padding: 16px 12px;
  background: #fff2ddf7;
  border-top: 0;
  border-left: 3px solid #bf8957;
  overflow-y: auto;
  box-shadow: -5px 0 16px #5c392b44;
}
#game .tray-title {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  text-align: center;
}
#game .tray-title > div {
  align-items: center;
}
#game .tray-title .tiny {
  width: 100%;
  min-height: 46px;
  font-size: 17px;
}
#game .tray {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 14px;
}
#game .piece {
  flex: none;
  width: 100%;
  height: 100px;
}
#game .piece img {
  width: 118px;
  max-width: 95%;
  height: 65px;
}
#game .piece span {
  font-size: 16px;
}
#game .go {
  display: block;
  flex: none;
  width: 100%;
  align-self: stretch;
  margin: 3px 0 0;
  min-height: 68px;
  font-size: 18px;
  white-space: normal;
}
#game .mobile-go {
  display: none;
}
#game .zoom-tools {
  left: 10px;
  right: auto;
  top: 54px;
}
@media (max-width: 700px) and (orientation: portrait) {
  #game #playfield {
    top: 56px;
    right: 90px;
    bottom: 0;
  }
  #game .bottom {
    top: 56px;
    right: 0;
    bottom: 0;
    width: 90px;
    padding: 9px 5px;
  }
  #game .tray-title {
    gap: 6px;
  }
  .tray-title > div .eyebrow {
    font-size: 10px;
    letter-spacing: 0.03em;
  }
  #game .tray-title strong {
    font-size: 11px;
    line-height: 1.15;
    min-height: 26px;
  }
  #game .tray-title .tiny {
    min-height: 42px;
    font-size: 14px;
    padding: 4px;
  }
  #game .tray {
    gap: 8px;
    margin-top: 9px;
  }
  #game .piece {
    height: 76px;
    border-radius: 13px;
  }
  #game .piece img {
    width: 65px;
    height: 45px;
  }
  #game .piece span {
    font-size: 11px;
    line-height: 1.05;
  }
  #game .go {
    min-height: 58px;
    font-size: 14px;
    line-height: 1.05;
    padding: 6px 2px;
  }
  #game .go span {
    float: none;
    display: block;
    font-size: 12px;
  }
  #game .prompt {
    white-space: normal;
    max-width: 96%;
    width: max-content;
    font-size: 12px;
    padding: 6px 9px;
  }
  #game .zoom-tools {
    top: auto;
    bottom: 10px;
    left: 7px;
    right: auto;
    flex-direction: row;
  }
}
@media (max-height: 500px) and (orientation: landscape) {
  #game #playfield {
    top: 50px;
    right: 170px;
    bottom: 0;
  }
  #game .bottom {
    top: 50px;
    width: 170px;
    padding: 5px 8px;
  }
  #game .tray-title {
    flex-direction: row;
    gap: 4px;
    text-align: left;
  }
  #game .tray-title > div {
    align-items: flex-start;
  }
  #game .tray-title strong {
    font-size: 12px;
  }
  #game .tray-title .eyebrow {
    font-size: 9px;
  }
  #game .tray-title .tiny {
    width: auto;
    min-height: 36px;
    font-size: 13px;
  }
  #game .tray {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    margin-top: 5px;
  }
  #game .piece {
    width: 100%;
    height: 60px;
    border-radius: 11px;
  }
  #game .piece img {
    height: 36px;
    width: 46px;
  }
  #game .piece span {
    font-size: 9px;
  }
  #game .go {
    grid-column: 1 / -1;
    min-height: 42px;
    font-size: 15px;
    margin: 5px 0;
  }
  #game .zoom-tools {
    left: 7px;
    right: auto;
    top: auto;
    bottom: 8px;
    flex-direction: row;
  }
}

/* v3: piece stock badges */
#game .piece {
  position: relative;
}
#game .piece .cnt {
  position: absolute;
  top: 5px;
  right: 7px;
  min-width: 28px;
  padding: 1px 7px;
  border-radius: 14px;
  background: #fff7d6;
  border: 2px solid #b8742f;
  color: #7a4217;
  font-size: 14px;
  line-height: 1.25;
  text-align: center;
  box-shadow: 0 2px 0 #b8742f;
}
#game .piece.empty {
  opacity: 0.55;
}
#game .piece.empty .cnt {
  background: #ffc5b8;
  border-color: #c9503b;
  color: #8a2a1a;
}
@media (max-width: 700px) {
  #game .piece .cnt {
    top: 3px;
    right: 3px;
    font-size: 11px;
    padding: 0 5px;
    min-width: 22px;
  }
}

/* ============================================================
   Polish: icons, readable menu text, hover and press states,
   gentle animation, celebration
   ============================================================ */
.ic {
  width: 1.1em;
  height: 1.1em;
  fill: currentColor;
  vertical-align: -0.17em;
  flex: none;
}
.tiny .ic {
  width: 1.15em;
  height: 1.15em;
}
.btn .ic {
  margin-left: 0.15em;
}
.tag .ic,
.level span .ic {
  color: #f0a51a;
}
.marker .ic {
  width: 1.25em;
  height: 1.25em;
  vertical-align: middle;
}
.screen.active {
  animation: screen-in 0.28s ease-out;
}
@keyframes screen-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}
.btn,
.tiny,
.level,
.piece {
  transition:
    transform 0.12s ease,
    filter 0.12s ease,
    box-shadow 0.12s ease;
}
@media (hover: hover) {
  .btn:not(:disabled):hover,
  .tiny:not(:disabled):hover,
  .level:not(:disabled):hover,
  .piece:not(:disabled):hover {
    transform: translateY(-2px);
    filter: brightness(1.07);
  }
}
.btn:not(:disabled):active,
.tiny:not(:disabled):active,
.level:not(:disabled):active,
.piece:not(:disabled):active {
  transform: translateY(2px) scale(0.98);
  filter: brightness(0.96);
}
.level.done {
  box-shadow: inset 0 0 0 3px rgba(84, 198, 78, 0.55);
}
.piece.selected {
  animation: piece-pop 0.3s ease-out;
}
@keyframes piece-pop {
  50% {
    transform: translateY(-4px) scale(1.04);
  }
}
.marker:not(.done):not(.wrong) {
  animation: marker-pulse 1.8s ease-in-out infinite;
}
@keyframes marker-pulse {
  50% {
    box-shadow: 0 0 0 7px rgba(255, 213, 114, 0.5);
  }
}
.panel.modal,
.overlay:not(.hidden) .panel {
  animation: modal-pop 0.26s ease-out;
}
@keyframes modal-pop {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
}
.load-panel img {
  animation: marble-bob 1.4s ease-in-out infinite;
}
@keyframes marble-bob {
  50% {
    transform: translateY(-8px) rotate(8deg);
  }
}
.confetti {
  position: absolute;
  top: -12px;
  width: 10px;
  height: 16px;
  border-radius: 3px;
  pointer-events: none;
  z-index: 30;
  animation: confetti-fall 1.8s ease-in forwards;
}
@keyframes confetti-fall {
  to {
    transform: translate(var(--drift, 0), 110vh) rotate(540deg);
    opacity: 0.2;
  }
}
#playfield.shake {
  animation: field-shake 0.4s ease;
}
@keyframes field-shake {
  20% {
    transform: translateX(-8px);
  }
  40% {
    transform: translateX(7px);
  }
  60% {
    transform: translateX(-4px);
  }
  80% {
    transform: translateX(3px);
  }
}
.no-webgl {
  padding: 30px;
  background: #fff2dd;
  color: #653e20;
  border-radius: 15px;
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ============================================================
   Fit every menu on one screen (small phones, landscape phones)
   ============================================================ */
.screen {
  overflow-x: hidden;
}
.panel,
.cards article {
  min-width: 0;
}
.cards {
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
}
@media (max-width: 700px) and (orientation: portrait) {
  .cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .instructions h2,
  .panel h2 {
    font-size: 24px;
  }
}
@media (max-height: 640px) and (orientation: portrait) {
  .cover {
    width: min(44vw, 26vh);
    border-width: 4px;
  }
  .home {
    flex-direction: column;
    gap: 14px;
    margin: 1vh auto;
  }
  .home-copy {
    padding: 14px;
  }
  .home h1 {
    font-size: 34px;
    margin: 6px 0;
  }
  .home p {
    font-size: 13px;
    margin: 4px 0 8px;
  }
  .btn {
    min-height: 42px;
    font-size: 15px;
    padding: 6px 10px;
  }
  .secondary .btn {
    font-size: 13px;
    min-height: 38px;
  }
  .foot {
    margin-top: 8px;
    font-size: 10px;
  }
  .panel {
    padding: 14px;
  }
  .panel p {
    font-size: 13px;
    margin: 4px 0;
  }
  #grid {
    gap: 6px;
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
  .level {
    min-height: 54px;
  }
  .level b {
    font-size: 20px;
  }
  .level span {
    font-size: 9px;
  }
  .cards {
    gap: 8px;
    margin: 10px 0;
  }
  .cards article {
    padding: 8px;
  }
  .cards h3 {
    font-size: 13px;
    margin: 2px 0;
  }
  .cards p {
    font-size: 11.5px;
    line-height: 1.3;
  }
  .cards article > b {
    font-size: 20px;
  }
}
@media (max-height: 520px) and (orientation: landscape) {
  .top {
    padding: 6px 3%;
  }
  .tag,
  .progress-tag {
    padding: 4px 10px;
    font-size: 11px;
  }
  .home {
    gap: 18px;
    margin: 0 auto;
    width: 94%;
  }
  .home-copy {
    width: min(58%, 520px);
    padding: 10px 16px;
    border-radius: 20px;
  }
  .home h1 {
    font-size: 32px;
    margin: 2px 0 4px;
  }
  .home p {
    font-size: 12px;
    margin: 2px 0 6px;
    line-height: 1.25;
  }
  .eyebrow {
    font-size: 10px;
  }
  .btn {
    min-height: 36px;
    font-size: 14px;
    padding: 4px 10px;
  }
  .secondary {
    margin-top: 8px;
    gap: 8px;
  }
  .primary {
    gap: 8px;
  }
  .secondary .btn {
    font-size: 12px;
    min-height: 34px;
  }
  .foot {
    margin-top: 6px;
    font-size: 9px;
  }
  .cover {
    width: min(30vw, 60vh);
    border-width: 4px;
    border-radius: 22px;
  }
  header {
    padding: 6px 3%;
  }
  header h2 {
    font-size: 18px;
  }
  .tiny {
    min-height: 34px;
    min-width: 40px;
    font-size: 13px;
    padding: 4px 10px;
  }
  .panel {
    padding: 8px 14px;
    border-radius: 18px;
  }
  .levels-panel,
  .instructions,
  .settings {
    margin: 4px auto;
  }
  .panel h2 {
    font-size: 19px;
    margin: 2px;
  }
  .panel p {
    font-size: 12px;
    margin: 2px 0;
  }
  .pager {
    margin: 4px;
    gap: 10px;
  }
  #grid {
    gap: 6px;
  }
  .level {
    min-height: 44px;
    border-width: 2px;
  }
  .level b {
    font-size: 17px;
  }
  .level span {
    font-size: 9px;
  }
  .cards {
    gap: 8px;
    margin: 6px 0;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .cards article {
    padding: 6px 8px;
  }
  .cards article > b {
    font-size: 17px;
  }
  .cards h3 {
    font-size: 12px;
    margin: 2px 0;
  }
  .cards p {
    font-size: 10.5px;
    line-height: 1.25;
  }
  #how > .btn.back {
    margin: 4px auto;
    display: block;
    min-width: 160px;
  }
}
@media (max-height: 600px) and (orientation: portrait) {
  .cover {
    width: min(40vw, 22vh);
  }
  .home-copy {
    padding: 10px 12px;
  }
  .home h1 {
    font-size: 30px;
  }
}
header h2 {
  background: #fff4d9;
  border: 2px solid #c58e56;
  border-radius: 22px;
  padding: 5px 22px;
  box-shadow: 0 4px 0 #88512e66;
}
@media (max-height: 520px) and (orientation: landscape) {
  header h2 {
    padding: 2px 16px;
  }
}
#how > .btn.back {
  display: block;
  margin: 14px auto;
  min-width: 180px;
}

/* End of style.css */
