@font-face {
  font-family: Fredoka;
  src: url("../assets/fonts/fredoka.ttf");
  font-display: swap;
}
* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}
body {
  font-family: Fredoka, system-ui, sans-serif;
  color: #563923;
  background: #dcaa6e;
}
button {
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}
button:focus-visible {
  outline: 3px solid #186c9b;
  outline-offset: 3px;
}
.screen {
  display: none;
  position: absolute;
  inset: 0;
  background: #f5d6a2 url("../assets/images/workshop.jpg") center/cover
    no-repeat;
  overflow: auto;
}
.screen.active {
  display: block;
}
.topline,
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 16px 5%;
  margin: auto;
  max-width: 1400px;
}
header h2 {
  font-size: 24px;
  margin: 0;
  text-align: center;
}
.badge {
  display: inline-block;
  border-radius: 18px;
  background: #fff3d5;
  border: 2px solid #c99559;
  padding: 7px 12px;
  color: #91643d;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.eyebrow {
  font-size: 11px;
  letter-spacing: 0.16em;
  font-weight: 700;
  color: #ba7045;
}
.btn,
.smallbtn {
  border: 2px solid #fff6d7;
  border-radius: 15px;
  color: white;
  font-weight: 700;
  box-shadow:
    0 5px 0 #8a5f3b,
    inset 0 3px 0 #ffffff74,
    0 8px 15px #5c3c2633;
  transition:
    transform 0.1s,
    filter 0.1s;
}
.btn:hover,
.smallbtn:hover {
  filter: brightness(1.08);
}
.btn:active,
.smallbtn:active {
  transform: translateY(3px);
  box-shadow:
    0 2px 0 #8a5f3b,
    inset 0 3px 0 #ffffff74;
}
.btn {
  font-size: 17px;
  padding: 13px 18px;
}
.btn span {
  float: right;
}
.smallbtn {
  font-size: 16px;
  background: linear-gradient(#fff9df, #ecc48e);
  color: #7a4f30;
  padding: 8px 13px;
  border-color: #a97548;
  box-shadow:
    0 4px 0 #92643d,
    inset 0 2px 0 #fff;
}
.orange {
  background: linear-gradient(#ffc278, #ed8b4c);
}
.blue {
  background: linear-gradient(#8bd8ee, #52a5cd);
}
.green {
  background: linear-gradient(#aad994, #72b66f);
}
.yellow {
  background: linear-gradient(#ffdd80, #e7b14f);
}
.red {
  background: linear-gradient(#ffa69a, #df7770);
}
.compact {
  font-size: 14px;
  padding: 9px 14px;
}
.home {
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 35px;
  width: min(1080px, 92%);
  margin: 5vh auto;
}
.home-copy {
  width: 500px;
  background: #fff4dfed;
  padding: 26px;
  border: 3px solid #b98756;
  border-radius: 27px;
  box-shadow: 0 8px 0 #90603999;
}
.home h1 {
  font-size: clamp(52px, 6vw, 80px);
  line-height: 0.95;
  letter-spacing: -0.04em;
  margin: 15px 0;
  color: #71472d;
}
.home h1 em {
  font-style: normal;
  color: #df834c;
}
.home p {
  font-size: 18px;
  line-height: 1.4;
  color: #916646;
}
.primary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.home-links {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 13px;
}
.home-links .btn {
  font-size: 14px;
  padding: 12px 5px;
}
.demo-label {
  font-size: 10px;
  letter-spacing: 0.13em;
  text-align: center;
  margin-top: 18px;
  color: #af7d51;
}
.hero {
  width: min(42vw, 440px);
  height: 370px;
  position: relative;
}
.hero .marble {
  position: absolute;
  width: 50%;
  top: 0;
  left: 18%;
  filter: drop-shadow(0 12px 8px #5d3f374a);
  animation: bob 3s ease-in-out infinite;
}
.hero .ramp {
  position: absolute;
  width: 100%;
  top: 58%;
  left: 0;
  transform: rotate(12deg);
  filter: drop-shadow(0 8px 4px #5d3f374a);
}
.hero .cup {
  position: absolute;
  width: 27%;
  right: 0;
  bottom: 0;
  filter: drop-shadow(0 8px 5px #5d3f374a);
}
@keyframes bob {
  50% {
    transform: translateY(-12px);
  }
}
.panel,
.load-card {
  background: #fff4dfed;
  border: 3px solid #b98756;
  border-radius: 25px;
  box-shadow:
    0 7px 0 #90603999,
    0 12px 30px #5d3e2d55;
  padding: 24px;
}
.panel h2 {
  margin: 5px 0 10px;
}
.level-panel,
.info,
.settings {
  width: min(850px, 92%);
  margin: 25px auto;
  text-align: center;
}
.panel p {
  color: #916646;
  line-height: 1.45;
}
.level-panel #level-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 24px 0;
}
.level {
  border: 3px solid #fff4d6;
  border-radius: 20px;
  background: linear-gradient(#8bd8ee, #52a5cd);
  box-shadow: 0 5px 0 #628e9d;
  color: white;
  padding: 18px;
  font-weight: 700;
}
.level:disabled {
  background: #b1ada4;
  box-shadow: 0 5px 0 #8a8177;
}
.level b {
  display: block;
  font-size: 28px;
}
.level span {
  font-size: 13px;
}
.instructions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 22px 0;
}
.instructions article {
  text-align: left;
  background: #fbe4c3;
  border: 2px solid #dfb986;
  border-radius: 15px;
  padding: 12px;
}
.instructions article > b {
  font-size: 25px;
  color: #e3975a;
}
.instructions h3 {
  margin: 4px 0;
}
.instructions p {
  font-size: 13px;
  margin: 0;
}
.settings {
  max-width: 440px;
}
.settings > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  margin: 10px 0;
  background: #f8e3c4;
  border-radius: 12px;
}
.load-card {
  position: absolute;
  width: min(340px, 90%);
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}
.load-card img {
  width: 130px;
}
.load-card h1 {
  margin: 8px;
  font-size: 35px;
}
.load-track {
  height: 17px;
  background: #dab990;
  border: 2px solid #b28456;
  border-radius: 20px;
  overflow: hidden;
}
.load-track i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #71bcd2, #a9d894, #f7bf72);
}
.load-card b {
  display: block;
  margin-top: 8px;
}
.game-head {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background: #fff4e4ed;
  border-bottom: 3px solid #bd8755;
  padding: 5px;
}
.game-head > div {
  text-align: center;
  min-width: 180px;
}
.game-head small {
  display: block;
  font-size: 10px;
  letter-spacing: 0.15em;
  color: #ae7347;
}
.game-head strong {
  font-size: 17px;
}
.game-layout {
  height: calc(100% - 60px);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  padding: 12px;
}
.work-area {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.hint {
  background: #fff6e7ef;
  border: 2px solid #ba895d;
  border-radius: 20px;
  padding: 7px 15px;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}
.work-area canvas {
  display: block;
  max-width: 100%;
  max-height: calc(100% - 38px);
  aspect-ratio: 5/6;
  background: #f7d8a9;
  border: 5px solid #936039;
  border-radius: 16px;
  box-shadow:
    0 6px 0 #724928,
    0 9px 18px #57371c55;
  touch-action: none;
}
.control-panel {
  width: 300px;
  max-width: 100%;
  background: #fff3dfed;
  border: 3px solid #bc8b5b;
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 6px 0 #90603999;
}
.control-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.control-title > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.control-title strong {
  font-size: 16px;
}
.rotate,
.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 14px;
}
.rotate .btn,
.action-row .btn {
  font-size: 14px;
  padding: 12px 8px;
}
.learning {
  font-size: 10px;
  letter-spacing: 0.08em;
  color: #bd7c49;
  margin-top: 15px;
}
.learning b {
  font-size: 12px;
  letter-spacing: 0;
  color: #8d664b;
}
.btn:disabled {
  opacity: 0.5;
  filter: grayscale(0.3);
  cursor: default;
}
.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: #302012aa;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 15px;
}
.hide {
  display: none;
}
.modal {
  text-align: center;
  width: min(390px, 100%);
}
.modal img {
  width: 82px;
}
.modal h2 {
  font-size: 28px;
}
.modal #modal-buttons {
  display: grid;
  gap: 10px;
}
.modal .btn {
  width: 100%;
}
@media (max-width: 700px) {
  .topline,
  header {
    padding: 8px 3%;
  }
  header h2 {
    font-size: 19px;
  }
  .home {
    flex-direction: column-reverse;
    gap: 0;
    margin: 0 auto;
  }
  .home-copy {
    width: min(450px, 100%);
    padding: 16px;
  }
  .home h1 {
    font-size: 43px;
    margin: 8px 0;
  }
  .home p {
    font-size: 14px;
    margin: 8px 0;
  }
  .hero {
    width: 200px;
    height: 150px;
  }
  .hero .marble {
    width: 40%;
  }
  .hero .ramp {
    top: 65%;
  }
  .home-links .btn {
    font-size: 12px;
  }
  .demo-label {
    margin-top: 12px;
    font-size: 9px;
  }
  .level-panel,
  .info,
  .settings {
    margin: 10px auto;
    padding: 15px;
  }
  .instructions {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .instructions article {
    padding: 8px;
  }
  .game-head {
    height: 53px;
  }
  .game-layout {
    height: calc(100% - 53px);
    flex-direction: column;
    gap: 6px;
    padding: 6px;
  }
  .work-area {
    flex: 1;
    width: 100%;
    gap: 4px;
    min-height: 0;
  }
  .work-area canvas {
    max-height: calc(100% - 33px);
    max-width: 100%;
    width: auto;
    height: auto;
  }
  .hint {
    font-size: 10px;
    padding: 5px 10px;
  }
  .control-panel {
    width: min(100%, 500px);
    padding: 8px 10px;
  }
  .control-title strong {
    font-size: 13px;
  }
  .control-title .eyebrow {
    font-size: 9px;
  }
  .rotate,
  .action-row {
    margin-top: 6px;
    gap: 6px;
  }
  .rotate .btn,
  .action-row .btn {
    font-size: 12px;
    padding: 7px;
  }
  .learning {
    margin-top: 6px;
    font-size: 9px;
  }
  .learning b {
    font-size: 10px;
  }
}
@media (max-height: 620px) and (min-width: 701px) {
  .home {
    margin: 0 auto;
  }
  .hero {
    height: 270px;
  }
  .home-copy {
    padding: 15px;
  }
  .home h1 {
    font-size: 50px;
  }
}
.work-area canvas {
  width: min(600px, calc((100vh - 120px) * 0.8333));
  height: auto;
  flex: none;
}
@media (max-width: 700px) {
  .work-area canvas {
    width: min(calc(100vw - 20px), calc((100vh - 255px) * 0.8333));
    height: auto;
  }
}

.pager {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  margin: 12px;
}
.pager b {
  min-width: 155px;
}
.pager button:disabled {
  opacity: 0.5;
}
.level-panel #level-grid {
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}
.level {
  padding: 10px 6px;
}
.level b {
  font-size: 23px;
}
.type-button {
  width: 100%;
  padding: 9px;
  font-size: 13px;
  margin-top: 10px;
}
.level-panel {
  margin: 10px auto;
}
.level-panel #level-grid {
  margin: 10px 0;
}
@media (max-width: 700px) {
  .level-panel #level-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
  }
  .level {
    padding: 8px 3px;
  }
  .level b {
    font-size: 18px;
  }
  .level span {
    font-size: 10px;
  }
  .type-button {
    margin-top: 5px;
    padding: 5px;
    font-size: 11px;
  }
  .work-area canvas {
    width: min(calc(100vw - 20px), calc((100vh - 285px) * 0.8333));
  }
}
/* Readability and touch-friendly controls */
.btn {
  font-size: 19px;
  min-height: 52px;
  border-radius: 17px;
  border-width: 3px;
  text-shadow: 0 2px 1px #6d4a3670;
  box-shadow:
    0 6px 0 #835633,
    inset 0 4px 0 #ffffff8a,
    0 9px 18px #5c3c2638;
}
.smallbtn {
  min-height: 48px;
  min-width: 48px;
  font-size: 18px;
  border-width: 3px;
}
.badge {
  font-size: 14px;
  letter-spacing: 0.03em;
  color: #76502e;
  padding: 9px 14px;
}
.eyebrow {
  font-size: 13px;
  letter-spacing: 0.09em;
  color: #9d552b;
}
.home {
  margin: 2vh auto;
}
.home-copy {
  width: 540px;
  padding: 30px;
  background: #fff4e5f5;
}
.home h1 {
  font-size: clamp(58px, 6vw, 86px);
  text-shadow: 0 3px 0 #fff6e5;
}
.home p {
  font-size: 20px;
  color: #704a30;
}
.home-links .btn {
  font-size: 17px;
  min-height: 55px;
}
.demo-label {
  font-size: 13px;
  color: #855b3d;
  letter-spacing: 0.04em;
}
.panel p {
  font-size: 17px;
  color: #714e36;
}
.instructions p {
  font-size: 16px;
}
.instructions h3 {
  font-size: 18px;
}
.level b {
  font-size: 26px;
}
.level span {
  font-size: 13px;
}
.level {
  min-height: 80px;
}
.pager b {
  font-size: 18px;
}
.game-head {
  height: 66px;
  gap: 18px;
}
.game-head small {
  font-size: 13px;
  letter-spacing: 0.08em;
  color: #89522e;
}
.game-head strong {
  font-size: 21px;
}
.game-head > div {
  min-width: 215px;
}
.game-layout {
  height: calc(100% - 66px);
  gap: 22px;
  padding: 10px;
}
.hint {
  font-size: 16px;
  line-height: 1.2;
  padding: 8px 17px;
  color: #674329;
}
.work-area canvas {
  width: min(600px, calc((100vh - 138px) * 0.8333));
  height: auto;
}
.control-panel {
  width: 360px;
  padding: 20px;
  background: #fff5e6fa;
}
.control-title strong {
  font-size: 20px;
  color: #533922;
}
.control-title .eyebrow {
  font-size: 13px;
}
.rotate,
.action-row {
  gap: 10px;
  margin-top: 12px;
}
.rotate .btn,
.action-row .btn {
  font-size: 17px;
  min-height: 54px;
  padding: 10px 8px;
}
.type-button {
  font-size: 16px;
  min-height: 48px;
  margin-top: 10px;
}
.learning {
  font-size: 13px;
  letter-spacing: 0.03em;
  margin-top: 12px;
  color: #9d552b;
}
.learning b {
  font-size: 15px;
  color: #704c35;
}
.modal {
  width: min(450px, 100%);
}
.modal h2 {
  font-size: 32px;
}
.modal p {
  font-size: 18px;
}
.modal .btn {
  min-height: 55px;
}
@media (max-width: 700px) and (orientation: portrait) {
  .topline,
  header {
    padding: 10px 12px;
  }
  .topline .badge {
    font-size: 11px;
  }
  .home {
    margin: 0 auto;
    gap: 3px;
  }
  .hero {
    width: 210px;
    height: 155px;
  }
  .home-copy {
    width: min(480px, 100%);
    padding: 18px;
  }
  .home h1 {
    font-size: clamp(42px, 11vw, 58px);
    line-height: 0.94;
    margin: 9px 0;
  }
  .home p {
    font-size: 16px;
    line-height: 1.3;
    margin: 9px 0 12px;
  }
  .home-links .btn {
    font-size: 15px;
    min-height: 49px;
  }
  .primary .btn {
    font-size: 16px;
    min-height: 53px;
    padding: 9px;
  }
  .demo-label {
    font-size: 11px;
    margin-top: 14px;
  }
  .level-panel,
  .info,
  .settings {
    padding: 16px;
    margin: 8px auto;
  }
  .level-panel #level-grid {
    gap: 7px;
  }
  .level {
    min-height: 64px;
    padding: 6px 2px;
  }
  .level b {
    font-size: 21px;
  }
  .level span {
    font-size: 11px;
  }
  .instructions p {
    font-size: 14px;
  }
  .instructions h3 {
    font-size: 16px;
  }
  .game-head {
    height: 58px;
    gap: 8px;
  }
  .game-head > div {
    min-width: 175px;
  }
  .game-head small {
    font-size: 12px;
  }
  .game-head strong {
    font-size: 19px;
  }
  .game-head .smallbtn {
    min-height: 44px;
    height: 44px;
    min-width: 48px;
  }
  .game-layout {
    height: calc(100% - 58px);
    gap: 6px;
    padding: 5px;
    justify-content: space-between;
  }
  .work-area {
    width: 100%;
    flex: 1;
    min-height: 0;
    gap: 5px;
  }
  .hint {
    font-size: 14px;
    line-height: 1.1;
    padding: 6px 10px;
    max-width: 98%;
  }
  .work-area canvas {
    width: min(calc(100vw - 18px), calc((100vh - 335px) * 0.8333));
    height: auto;
    max-height: calc(100% - 35px);
  }
  .control-panel {
    width: min(100%, 480px);
    padding: 10px 12px;
    border-radius: 18px;
  }
  .control-title strong {
    font-size: 16px;
  }
  .control-title .eyebrow {
    font-size: 11px;
  }
  .control-title .badge {
    font-size: 12px;
    padding: 5px 9px;
  }
  .rotate,
  .action-row {
    margin-top: 7px;
    gap: 8px;
  }
  .rotate .btn,
  .action-row .btn {
    font-size: 16px;
    min-height: 46px;
    padding: 7px;
  }
  .type-button {
    font-size: 15px;
    min-height: 40px;
    margin-top: 7px;
    padding: 5px;
  }
  .learning {
    margin-top: 7px;
    font-size: 11px;
    line-height: 1.25;
  }
  .learning b {
    font-size: 13px;
  }
}
@media (max-width: 700px) and (orientation: landscape) {
  .game-layout {
    flex-direction: row;
    gap: 8px;
    padding: 4px;
  }
  .work-area {
    width: auto;
    flex: 1;
    height: 100%;
    gap: 3px;
  }
  .work-area canvas {
    width: min(calc((100vh - 115px) * 0.8333), calc(100vw - 330px));
    height: auto;
  }
  .control-panel {
    width: 300px;
    padding: 8px;
  }
  .control-title strong {
    font-size: 15px;
  }
  .control-title .eyebrow {
    font-size: 11px;
  }
  .rotate,
  .action-row {
    margin-top: 5px;
  }
  .rotate .btn,
  .action-row .btn {
    min-height: 39px;
    font-size: 14px;
    padding: 5px;
  }
  .type-button {
    min-height: 36px;
    margin-top: 5px;
  }
  .learning {
    margin-top: 6px;
    font-size: 10px;
  }
  .learning b {
    font-size: 12px;
  }
  .hint {
    font-size: 12px;
    padding: 4px;
  }
  .game-head {
    height: 52px;
  }
  .game-layout {
    height: calc(100% - 52px);
  }
}
.btn {
  color: #553521;
  text-shadow: 0 1px 0 #ffffff9c;
}
.orange {
  color: #542d1b;
}
.blue {
  color: #204c62;
}
.green {
  color: #315a2c;
}
.yellow {
  color: #65471b;
}
.red {
  color: #5b3030;
}
@media (max-width: 700px) and (orientation: portrait) {
  .work-area canvas {
    width: min(calc(100vw - 18px), calc((100vh - 375px) * 0.8333));
    max-height: none;
  }
}
@media (max-height: 500px) and (orientation: landscape) {
  .game-head {
    height: 48px;
    gap: 9px;
  }
  .game-head .smallbtn {
    min-height: 39px;
    height: 39px;
  }
  .game-head small {
    font-size: 11px;
  }
  .game-head strong {
    font-size: 17px;
  }
  .game-layout {
    height: calc(100% - 48px);
    flex-direction: row;
    gap: 8px;
    padding: 4px;
  }
  .work-area {
    width: auto;
    flex: 1;
    height: 100%;
    gap: 3px;
  }
  .work-area canvas {
    width: min(calc((100vh - 105px) * 0.8333), calc(100vw - 315px));
    max-height: none;
    height: auto;
  }
  .control-panel {
    width: 300px;
    padding: 8px;
  }
  .control-title strong {
    font-size: 15px;
  }
  .control-title .eyebrow {
    font-size: 11px;
  }
  .rotate,
  .action-row {
    margin-top: 5px;
  }
  .rotate .btn,
  .action-row .btn {
    min-height: 39px;
    font-size: 14px;
    padding: 5px;
  }
  .type-button {
    min-height: 36px;
    font-size: 13px;
    margin-top: 5px;
  }
  .learning {
    margin-top: 5px;
    font-size: 10px;
  }
  .learning b {
    font-size: 12px;
  }
  .hint {
    font-size: 12px;
    padding: 4px;
  }
}
@media (max-width: 700px) and (orientation: portrait) {
  .level-panel #level-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 9px;
  }
  .level {
    min-height: 66px;
  }
  .level b {
    font-size: 24px;
  }
  .level span {
    font-size: 13px;
  }
}
@media (max-width: 700px) and (max-height: 700px) and (orientation: portrait) {
  .control-panel .learning,
  .control-title .eyebrow {
    display: none;
  }
  .control-panel {
    padding: 8px 10px;
  }
  .work-area canvas {
    width: min(calc(100vw - 18px), calc((100vh - 335px) * 0.8333));
    max-height: none;
  }
}

/* Optional per-level help, kept separate from the star counter. */
.hint-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  min-width: 64px;
  padding: 5px 10px;
  font-size: 15px;
  flex: none;
}
.hint-button:disabled {
  opacity: 0.55;
}
.control-title > div {
  flex: 1;
  min-width: 0;
}
@media (max-width: 700px) and (orientation: portrait) {
  .hint-button {
    min-height: 38px;
    min-width: 58px;
    padding: 4px 8px;
    font-size: 14px;
  }
  .control-title .badge {
    flex: none;
  }
  .control-title strong {
    font-size: 15px;
  }
}
@media (max-width: 350px) {
  .control-title {
    gap: 4px;
  }
  .control-title .badge {
    font-size: 11px;
    padding: 5px 6px;
  }
  .hint-button {
    min-width: 52px;
  }
}

/* ---- Icons, stars and feedback ---- */
.ic {
  width: 18px;
  height: 18px;
  vertical-align: -3px;
  margin-right: 6px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ic.r {
  margin: 0 0 0 8px;
  float: right;
  margin-top: 1px;
}
.smallbtn .ic {
  margin-right: 5px;
}
.smallbtn[aria-label] .ic,
#pause .ic,
#reset .ic,
#prevPage .ic,
#nextPage .ic {
  margin: 0;
}
.badge .ic {
  width: 13px;
  height: 13px;
  margin-right: 4px;
  vertical-align: -2px;
  color: #e3a21a;
}
.level {
  display: block;
  text-align: center;
  transition:
    transform 0.15s,
    filter 0.15s;
}
.level:not(:disabled):hover {
  transform: translateY(-3px);
  filter: brightness(1.06);
}
.level:not(:disabled):active {
  transform: translateY(2px);
}
.level.current:not(:disabled) {
  outline: 3px solid #fff4a8;
  outline-offset: 2px;
  animation: pulse 1.8s ease-in-out infinite;
}
.level span {
  display: flex;
  justify-content: center;
  gap: 2px;
  min-height: 18px;
}
.level span .ic {
  width: 16px;
  height: 16px;
  margin: 0;
}
.level span img {
  width: 18px;
  height: 18px;
  object-fit: contain;
}
.level span img.off,
.modal-stars img.off {
  filter: grayscale(1) brightness(0.6);
  opacity: 0.65;
}
.modal-stars {
  display: flex;
  justify-content: center;
  gap: 6px;
  min-height: 0;
}
.modal-stars img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  animation: pop 0.45s both;
}
.modal-stars img:nth-child(2) {
  animation-delay: 0.12s;
}
.modal-stars img:nth-child(3) {
  animation-delay: 0.24s;
}
.btn,
.smallbtn {
  transition:
    transform 0.12s,
    filter 0.12s;
}
.btn:not(:disabled):hover,
.smallbtn:not(:disabled):hover {
  filter: brightness(1.07);
}
.screen.active {
  animation: screen-in 0.35s ease both;
}
.modal {
  animation: modal-pop 0.3s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
@keyframes screen-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes modal-pop {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.3) rotate(-20deg);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes pulse {
  50% {
    outline-color: #fff;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
/* Short screens (landscape phones, small laptops): every menu fits without scrolling. */
@media (max-height: 560px) {
  .topline,
  header {
    padding: 6px 3%;
  }
  header h2 {
    font-size: 20px;
  }
  .smallbtn {
    padding: 5px 11px;
    font-size: 14px;
  }
  .badge {
    font-size: 10px;
    padding: 5px 9px;
  }
  .home {
    margin: 0 auto;
    gap: 18px;
  }
  .home-copy {
    width: min(520px, 60vw);
    padding: 14px 18px;
  }
  .home h1 {
    font-size: clamp(30px, 9vh, 48px);
    margin: 6px 0;
    text-shadow: none;
  }
  .home p {
    font-size: 14px;
    margin: 4px 0 10px;
  }
  .home .btn {
    padding: 9px 12px;
    font-size: 15px;
  }
  .home-links {
    margin-top: 8px;
  }
  .home-links .btn {
    padding: 8px 4px;
    font-size: 13px;
  }
  .demo-label {
    margin-top: 8px;
  }
  .hero {
    width: min(34vw, 330px);
    height: min(55vh, 300px);
  }
  .level-panel,
  .info,
  .settings {
    margin: 4px auto;
    padding: 10px 14px;
  }
  .level-panel > p {
    font-size: 12px;
    margin: 2px 0;
  }
  .panel h2 {
    font-size: 20px;
    margin: 2px 0;
  }
  .pager {
    margin: 4px;
  }
  .level-panel #level-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin: 8px 0;
  }
  .level {
    padding: 8px 4px;
  }
  .level b {
    font-size: 20px;
  }
  .instructions {
    gap: 8px;
    margin: 8px 0;
  }
  .instructions article {
    padding: 8px;
  }
  .instructions h3 {
    font-size: 14px;
    margin: 2px 0;
  }
  .instructions p {
    font-size: 12px;
    margin: 2px 0;
  }
  .info .btn {
    padding: 8px 18px;
  }
  .settings > div {
    padding: 8px 12px;
    margin: 6px 0;
  }
}
@media (max-height: 400px) {
  .home p,
  .hero,
  .level-panel > p,
  .instructions article > b {
    display: none;
  }
  .home-copy {
    width: min(520px, 92vw);
    padding: 10px 16px;
  }
  .home h1 {
    font-size: 26px;
    margin: 2px 0 6px;
  }
  .home h1 br {
    display: none;
  }
  .home .btn {
    padding: 7px 10px;
  }
  .home-links .btn {
    padding: 6px 4px;
  }
  .eyebrow {
    font-size: 9px;
  }
  .level-panel > h2,
  .info > h2 {
    display: none;
  }
  .level {
    padding: 4px;
  }
  .level b {
    font-size: 16px;
  }
  .level span img {
    width: 13px;
    height: 13px;
  }
  .instructions p {
    font-size: 11px;
  }
  .instructions article {
    padding: 5px 7px;
  }
}
@media (max-width: 360px) and (min-height: 401px) {
  .home {
    margin: 0 auto;
  }
  .home-copy {
    padding: 14px;
  }
  .home h1 {
    font-size: 40px;
  }
  .home p {
    font-size: 14px;
  }
  .hero {
    display: none;
  }
  .instructions {
    gap: 6px;
  }
  .instructions article {
    padding: 6px 8px;
  }
  .instructions p {
    font-size: 12px;
  }
  .instructions article > b {
    display: none;
  }
}
@media (max-height: 340px) {
  .topline,
  header {
    padding: 3px 3%;
  }
  .smallbtn {
    padding: 3px 9px;
  }
  .level-panel,
  .info,
  .settings {
    margin: 2px auto;
    padding: 6px 10px;
  }
  .level-panel #level-grid {
    gap: 5px;
    margin: 5px 0;
  }
  .pager {
    margin: 2px;
  }
  .instructions {
    margin: 5px 0;
  }
  .info .btn {
    padding: 5px 16px;
  }
  .settings > div {
    padding: 5px 10px;
    margin: 4px 0;
  }
  .settings > p {
    margin: 4px 0;
  }
}
@media (max-width: 360px) and (max-height: 620px) and (min-height: 401px) {
  .level {
    padding: 5px 2px;
  }
  .level b {
    font-size: 22px;
  }
  .level-panel #level-grid {
    gap: 6px;
    margin: 8px 0;
  }
  .level-panel > p {
    margin: 4px 0;
    font-size: 12px;
  }
  .instructions p {
    font-size: 11px;
  }
  .instructions article {
    padding: 4px 8px;
  }
  .info .btn {
    padding: 6px 16px;
  }
}
/* Bigger game board: the status message lives in the toolbox, so the board can use the full height. */
.control-panel .hint {
  margin-top: 10px;
  padding: 6px 10px;
  border-radius: 12px;
  font-size: 13px;
  max-width: none;
}
.control-title + .hint {
  margin-top: 10px;
}
@media (min-width: 701px) {
  .game-head {
    height: 52px;
  }
  .game-layout {
    height: calc(100% - 52px);
    padding: 6px 10px;
    gap: 26px;
  }
  .work-area canvas {
    width: min(calc((100vh - 78px) * 0.8333), calc(100vw - 420px));
    max-height: none;
    height: auto;
  }
  .control-panel {
    width: 340px;
  }
}
@media (min-width: 701px) and (max-height: 500px) {
  .game-head {
    height: 40px;
  }
  .game-layout {
    height: calc(100% - 40px);
    padding: 3px 8px;
    gap: 10px;
  }
  .work-area canvas {
    width: min(calc((100vh - 52px) * 0.8333), calc(100vw - 330px));
  }
  .control-panel {
    width: 300px;
  }
  .control-panel .hint {
    margin-top: 6px;
    padding: 4px 8px;
    font-size: 11px;
  }
}
@media (max-width: 700px) and (orientation: landscape) {
  .work-area canvas {
    width: min(calc((100vh - 76px) * 0.8333), calc(100vw - 330px));
  }
}
@media (max-width: 700px) and (orientation: portrait) {
  .work-area canvas {
    width: min(calc(100vw - 18px), calc((100vh - 300px) * 0.8333));
    max-height: none;
  }
}
@media (min-width: 701px) and (max-width: 1000px) {
  .control-panel {
    width: 285px;
    padding: 14px;
  }
  .work-area canvas {
    width: min(calc((100vh - 78px) * 0.8333), calc(100vw - 345px));
  }
}
@media (min-width: 701px) and (max-height: 500px) {
  .control-panel {
    width: 300px;
    padding: 8px;
  }
  .work-area canvas {
    width: min(calc((100vh - 52px) * 0.8333), calc(100vw - 330px));
  }
}
/* End of style.css */
