:root {
  --ink: #3a2214;
  --wood: #6b4228;
  --cell: 40px;
  --pad: 6px;
  --frame: 10px;
}
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  overflow: hidden;
  background: #4a2415 url("assets/coffee-store-bg.webp") center/cover no-repeat;
  font-family:
    Fredoka,
    Trebuchet MS,
    Arial,
    sans-serif;
  color: #fff8e8;
}
button {
  font: inherit;
  color: inherit;
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}
button:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.app {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  margin: 0;
  overflow: hidden;
  background-color: #4a2415;
  background-image:
    linear-gradient(#2a13051f, #1b0b0638), url("assets/coffee-store-bg.webp");
  background-position: center center;
  background-size: cover;
  background-repeat: no-repeat;
  box-shadow: 0 0 80px #0006;
}
.app:after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 1;
  background: radial-gradient(
    ellipse at center,
    transparent 35%,
    #1c090535 100%
  );
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  padding: max(14px, env(safe-area-inset-top)) 14px
    max(12px, env(safe-area-inset-bottom));
  z-index: 1;
}
.screen.active {
  display: flex;
  animation: screenIn 0.25s ease-out;
}
@keyframes screenIn {
  from {
    opacity: 0;
    transform: scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.home-screen {
  align-items: center;
  justify-content: center;
  text-align: center;
}
.brand {
  z-index: 2;
  filter: drop-shadow(0 6px 0 #8a4a18);
}
.brand-kicker {
  display: block;
  font-weight: 700;
  letter-spacing: 0.42em;
  font-size: clamp(14px, 4vw, 20px);
  color: #fff3c8;
  margin-left: 0.42em;
}
.brand h1 {
  font-size: clamp(54px, 16vw, 88px);
  line-height: 0.78;
  margin: 8px 0 10px;
  letter-spacing: -0.04em;
  color: #fffaf0;
  -webkit-text-stroke: 3px #6a3210;
}
.brand h1 em {
  font-style: normal;
  color: #ffc030;
  -webkit-text-stroke: 3px #8a4010;
}
.brand p {
  font-weight: 700;
  letter-spacing: 0.16em;
  font-size: 13px;
  color: #fff3c8;
  margin: 0;
  text-shadow: 0 2px #6a3a10;
}

.hero-board {
  --cell: 42px;
  position: relative;
  width: calc(var(--cell) * 3);
  height: calc(var(--cell) * 2);
  margin: 20px 0 24px;
  z-index: 2;
  pointer-events: none;
  filter: drop-shadow(0 8px 6px #1b080777);
  animation: floaty 3.2s ease-in-out infinite;
}
.hero-piece {
  animation: none;
}
@keyframes floaty {
  50% {
    transform: translateY(-6px);
  }
}

.home-actions {
  display: grid;
  gap: 12px;
  width: min(82%, 340px);
  z-index: 2;
}
.home-actions .game-btn.primary {
  animation: playPulse 1.8s ease-in-out infinite;
}
@keyframes playPulse {
  50% {
    filter: brightness(1.07);
  }
}
.home-actions .game-btn.primary:active {
  animation: none;
}
.game-btn {
  min-height: 56px;
  border-radius: 14px;
  padding: 8px 22px;
  font-weight: 700;
  letter-spacing: 0.08em;
  font-size: 18px;
  background: linear-gradient(#8a5630, #5c3418);
  border: 3px solid #c48a50;
  color: #fff6dc;
  box-shadow:
    inset 0 3px #b07848,
    inset 0 -5px #3d2010,
    0 6px 0 #2a1408;
}
.game-btn.primary {
  background: linear-gradient(#ffd24a, #e88818);
  border-color: #ffe08a;
  color: #6a2e0c;
  box-shadow:
    inset 0 4px #fff0a8,
    inset 0 -6px #c86810,
    0 6px 0 #8a4010;
}
.game-btn:active,
.wood-btn:active {
  transform: translateY(3px);
  filter: brightness(0.94);
}
.btn-icon {
  display: inline-block;
  width: 22px;
  height: 22px;
  margin-right: 10px;
  vertical-align: -5px;
}
.play-icon {
  background: currentColor;
  clip-path: polygon(18% 8%, 100% 50%, 18% 92%);
}
.grid-icon {
  background: conic-gradient(
    currentColor 0 25%,
    transparent 0 50%,
    currentColor 0 75%,
    transparent 0
  );
  background-size: 12px 12px;
}

.wood-btn {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  border-radius: 12px;
  background: linear-gradient(#8d5a34, #5a361c);
  border: 3px solid #c49258;
  color: #fff6dc;
  box-shadow:
    inset 0 2px #b07848,
    inset 0 -4px #3a2010,
    0 4px 0 #2a1408;
  display: grid;
  place-items: center;
  position: relative;
}
.corner-btn {
  position: absolute;
  right: 18px;
  top: max(18px, env(safe-area-inset-top));
}
.wood-btn span {
  position: relative;
  display: block;
  width: 22px;
  height: 22px;
}
.sound-icon {
  width: 34px !important;
  height: 34px !important;
  background: url("assets/sound-on.webp") center/contain no-repeat;
  filter: drop-shadow(0 2px 1px #35170899);
}
.sound-icon:before,
.sound-icon:after {
  display: none;
}
#sound-home-btn.muted .sound-icon {
  opacity: 0.42;
  filter: grayscale(1) brightness(0.8) drop-shadow(0 2px 1px #35170899);
}

.screen-header,
.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 20;
  gap: 10px;
}
.screen-header {
  text-align: center;
}
.screen-header small,
.modal-card small {
  font-weight: 700;
  letter-spacing: 0.14em;
  color: #fff3c8;
  text-shadow: 0 2px #6a3a10;
}
.screen-header h2 {
  font-size: 32px;
  margin: 0;
  color: #fffaf0;
  text-shadow: 0 3px #6a3a10;
}
.header-spacer {
  width: 52px;
}
.back-icon:before {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border-left: 5px solid #fff6dc;
  border-bottom: 5px solid #fff6dc;
  transform: rotate(45deg);
  top: 3px;
  left: 5px;
}

.levels-screen {
  align-items: center;
  background: linear-gradient(#1b080512, #12060438);
}
.levels-screen .screen-header {
  flex: 0 0 68px;
  width: min(94vw, 760px);
  margin: 0 auto;
}
.level-grid {
  flex: 0 1 auto;
  align-content: start;
  display: grid;
  grid-template-columns: repeat(6, minmax(72px, 1fr));
  gap: 14px;
  width: min(92vw, 760px);
  max-height: calc(100dvh - 96px);
  margin: auto;
  padding: 18px;
  border: 3px solid #d09a58;
  border-radius: 26px;
  background: linear-gradient(#4b281dcc, #29140ee8);
  box-shadow:
    inset 0 3px #f0c17b44,
    inset 0 -8px #14080699,
    0 14px 30px #0008;
  overflow-y: auto;
}
.level-card {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 18px;
  font-size: 26px;
  font-weight: 700;
  position: relative;
  color: #fffaf0;
  background: linear-gradient(145deg, #f0b63e, #c66b18);
  border: 3px solid #ffe08a;
  box-shadow:
    inset 0 3px #fff0a6,
    inset 0 -7px #8d3811,
    0 6px 0 #3b180c,
    0 9px 12px #0005;
  text-shadow: 0 2px #7a310e;
}
.level-card:nth-child(3n + 2) {
  background: linear-gradient(145deg, #de8d42, #9a4d25);
}
.level-card:nth-child(3n) {
  background: linear-gradient(145deg, #d0a258, #82502b);
}
.level-card .mini-stars {
  position: absolute;
  bottom: 9px;
  left: 0;
  right: 0;
  font-size: 11px;
  letter-spacing: 1px;
  color: #fff2a0;
  text-shadow: 0 1px #6e2c0d;
}
.level-card.locked {
  filter: saturate(0.18) brightness(0.58);
  color: #d8c5ad;
}
.level-card.locked .mini-stars {
  font-size: 9px;
  color: #e0cfb9;
}
.level-card:hover:not(.locked) {
  transform: translateY(-3px);
  filter: brightness(1.08);
}

.game-screen {
  padding-left: 8px;
  padding-right: 8px;
}
.hud {
  height: 64px;
}
.status-plaque {
  flex: 1;
  height: 56px;
  border-radius: 12px;
  padding: 4px 12px 6px;
  background: linear-gradient(#f0c24a, #d89018);
  border: 3px solid #ffe08a;
  box-shadow:
    inset 0 3px #ffe9a0,
    inset 0 -5px #b86810,
    0 4px 0 #8a4810;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  text-shadow: 0 2px #8a4010;
}
.lvl-line {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.1;
}
.lvl-line strong {
  font-size: 20px;
}
.bean-line {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 16px;
  margin-top: 1px;
}
.bean-line.score-pop strong {
  animation: scorePop 0.28s ease;
}
@keyframes scorePop {
  50% {
    transform: scale(1.28);
  }
}
.bean {
  position: relative;
  display: inline-block;
  width: 14px;
  height: 18px;
  border-radius: 50%;
  background: #6b3410;
  transform: rotate(28deg);
  box-shadow:
    inset 2px 0 #c47828,
    0 1px 0 #3a1808;
}
.bean:after {
  content: "";
  position: absolute;
  width: 2px;
  height: 11px;
  background: #e0a050;
  transform: rotate(18deg);
  margin: 3px 0 0 6px;
  border-radius: 2px;
}
.bean.bean-pop {
  animation: beanToss 0.3s ease;
}
@keyframes beanToss {
  40% {
    transform: rotate(28deg) scale(1.38);
  }
  100% {
    transform: rotate(28deg) scale(1);
  }
}
.score-fly {
  position: fixed;
  z-index: 90;
  pointer-events: none;
  margin: 0;
  flex: none;
  width: 22px;
  height: 25px;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 5px 4px #0006);
}
.score-plus {
  position: fixed;
  z-index: 91;
  pointer-events: none;
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #fff4b0;
  text-shadow:
    0 2px #6a3010,
    0 0 8px #ffd24a88;
  transform: translate(-50%, -50%);
}
.restart-icon {
  width: 34px !important;
  height: 34px !important;
  background: url("assets/nav-back.webp") center/contain no-repeat;
  filter: drop-shadow(0 2px 1px #35170899);
}
.restart-icon:before,
.restart-icon:after {
  display: none;
}
.pause-icon:before,
.pause-icon:after {
  content: "";
  position: absolute;
  top: 2px;
  width: 6px;
  height: 18px;
  border-radius: 2px;
  background: #fff6dc;
}
.pause-icon:before {
  left: 4px;
}
.pause-icon:after {
  right: 4px;
}

.game-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: visible;
  padding: 6px;
}
.board-wrap {
  position: relative;
  width: min(78vw, 400px);
  aspect-ratio: 1;
  z-index: 2;
  overflow: visible;
}
.board-sizer {
  width: 100%;
  aspect-ratio: 1;
  pointer-events: none;
}
.board-wood {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  border-radius: 14px;
  background: #3d281c;
  border: var(--frame) solid #5c3c28;
  box-shadow:
    inset 0 0 0 3px #2a1810,
    0 0 0 3px #c49258,
    0 10px 0 #4a2c18,
    0 16px 22px #0005;
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}
.board-wood:before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0.16;
  background: repeating-linear-gradient(
    92deg,
    transparent 0 5px,
    #00000022 5px 6px
  );
}
.board-wood.shaped {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.board-rim {
  position: absolute;
  inset: calc(var(--frame) + var(--pad));
  z-index: 1;
  pointer-events: none;
  overflow: visible;
}
.board {
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: 14px;
  background: transparent;
  border: var(--frame) solid transparent;
  touch-action: none;
  overflow: visible;
}
.wells {
  position: absolute;
  inset: var(--pad);
  display: grid;
  z-index: 0;
  pointer-events: none;
  grid-template-columns: repeat(8, var(--cell));
  grid-template-rows: repeat(8, var(--cell));
}
.wells i {
  margin: 2px;
  background: #2a1812;
  border-radius: 4px;
  box-shadow: inset 0 1px 3px #0008;
}
.wells i.hole {
  background: transparent;
  box-shadow: none;
}

.block {
  position: absolute;
  z-index: 2;
  pointer-events: none;
  overflow: visible;
  left: calc(var(--pad) + var(--x) * var(--cell));
  top: calc(var(--pad) + var(--y) * var(--cell));
  width: calc(var(--bw) * var(--cell));
  height: calc(var(--bh) * var(--cell));
}
.hero-board .block {
  left: calc(var(--x) * var(--cell));
  top: calc(var(--y) * var(--cell));
}
.cell {
  pointer-events: auto;
  position: absolute;
  user-select: none;
  touch-action: none;
  left: calc(var(--lx) * var(--cell) + 1px);
  top: calc(var(--ly) * var(--cell) + 1px);
  width: calc(var(--cell) - 2px);
  height: calc(var(--cell) - 2px);
  border-radius: 7px;
  background: linear-gradient(
    180deg,
    var(--light) 0%,
    var(--color) 42%,
    var(--dark) 100%
  );
  box-shadow:
    inset 0 3px 0 #fff5,
    inset 0 -4px 0 #0003,
    0 5px 0 var(--shadow),
    0 8px 10px #0004;
}
.cell:after {
  display: none;
}
.hero-board .cell:after {
  display: none;
}
.slot {
  position: absolute;
  width: 30%;
  height: 30%;
  border-radius: 50%;
  pointer-events: none;
  left: calc(16% + var(--sx) * 38%);
  top: calc(16% + var(--sy) * 38%);
  background: radial-gradient(circle at 35% 30%, #fff8 0 28%, #0003 70%);
  box-shadow:
    inset 0 2px 3px #0004,
    0 1px 0 #fff3;
}
.slot.filled {
  background: transparent;
  box-shadow: none;
}
.pod {
  position: absolute;
  inset: 4%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 32%, #fff8 0 18%, transparent 22%),
    radial-gradient(circle at 50% 55%, #6b3a18 0 42%, #3d200e 70%);
  box-shadow:
    0 1px 2px #0005,
    inset 0 -2px 0 #2a1408;
  animation: cupLand 0.18s cubic-bezier(0.2, 1.4, 0.3, 1) both;
}
.pod:before {
  content: "";
  position: absolute;
  left: 50%;
  top: 42%;
  width: 42%;
  height: 10%;
  background: #c47838;
  border-radius: 40%;
  transform: translate(-50%, -50%) rotate(-18deg);
}
@keyframes cupLand {
  0% {
    transform: scale(0.25);
  }
  70% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}
.move-arrow {
  position: absolute;
  z-index: 6;
  pointer-events: none;
  display: none;
  left: 0;
  top: 0;
  width: calc(var(--bw) * var(--cell));
  height: calc(var(--bh) * var(--cell));
  place-items: center;
  font-size: clamp(22px, 7vmin, 36px);
  font-weight: 700;
  color: #fff;
  text-shadow:
    0 2px 0 #0006,
    0 0 8px #0005;
}
.block.dragging {
  z-index: 9;
}
.block.dragging .move-arrow {
  display: grid;
}
.block.dragging .cell {
  filter: brightness(1.08);
}
.block.hint .cell {
  animation: hintPulse 0.5s ease-in-out 3;
}
.block.invalid {
  animation: shake 0.25s;
}
@keyframes hintPulse {
  50% {
    filter: brightness(1.45);
    box-shadow:
      0 0 18px #fff,
      0 5px 0 var(--shadow);
  }
}
@keyframes shake {
  25% {
    margin-left: -4px;
  }
  75% {
    margin-left: 4px;
  }
}
.block.serving {
  z-index: 10;
}
.cell.cleared {
  animation: cellVanish 0.38s cubic-bezier(0.15, 0.85, 0.2, 1) forwards;
  pointer-events: none;
  z-index: 12;
}
@keyframes cellVanish {
  0% {
    transform: scale(1);
    opacity: 1;
    filter: brightness(1.15);
  }
  40% {
    transform: scale(1.16);
    filter: brightness(1.45);
  }
  100% {
    transform: scale(0);
    opacity: 0;
    filter: brightness(1.8);
  }
}
.slot {
  z-index: 2;
}
.pod {
  z-index: 3;
}

.cup-fx {
  position: absolute;
  inset: 0;
  z-index: 18;
  pointer-events: none;
  overflow: visible;
}
.cup-jump {
  position: absolute;
  z-index: 19;
  margin: 0;
  flex: none;
  filter: drop-shadow(0 6px 4px #0005);
}
.mini-cup.spent {
  flex-basis: 0 !important;
  width: 0 !important;
  height: 0 !important;
  margin: 0;
  opacity: 0;
  overflow: hidden;
  transform: scale(0.2);
  transition: 0.2s ease-in;
}

.gates-layer {
  position: absolute;
  inset: var(--frame);
  z-index: 4;
  pointer-events: none;
}
.gate {
  position: absolute;
  background: linear-gradient(
    180deg,
    var(--light),
    var(--color) 55%,
    var(--dark)
  );
  box-shadow:
    0 2px 0 var(--shadow),
    0 0 8px #0003;
}
.gate.left,
.gate.right {
  width: 18px;
  height: calc(var(--span) * var(--cell) - 4px);
  top: calc(var(--pos) * var(--cell) + var(--pad) + 2px);
  border-radius: 4px;
}
.gate.left {
  left: -16px;
  clip-path: polygon(0 0, 70% 0, 100% 50%, 70% 100%, 0 100%);
}
.gate.right {
  right: -16px;
  clip-path: polygon(30% 0, 100% 0, 100% 100%, 30% 100%, 0 50%);
}
.gate.top,
.gate.bottom {
  height: 18px;
  width: calc(var(--span) * var(--cell) - 4px);
  left: calc(var(--pos) * var(--cell) + var(--pad) + 2px);
  border-radius: 4px;
}
.gate.top {
  top: -16px;
  clip-path: polygon(0 0, 100% 0, 100% 70%, 50% 100%, 0 70%);
}
.gate.bottom {
  bottom: -16px;
  clip-path: polygon(50% 0, 100% 30%, 100% 100%, 0 100%, 0 30%);
}
.gate:after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  border: 5px solid transparent;
  transform: translate(-50%, -50%);
}
.gate.left:after {
  border-left: 7px solid #fff;
  margin-left: 1px;
}
.gate.right:after {
  border-right: 7px solid #fff;
  margin-left: -1px;
}
.gate.top:after {
  border-top: 7px solid #fff;
  margin-top: 1px;
}
.gate.bottom:after {
  border-bottom: 7px solid #fff;
  margin-top: -1px;
}
.gate.ready {
  filter: brightness(1.35);
  animation: gatePulse 0.4s infinite alternate;
}
@keyframes gatePulse {
  to {
    filter: brightness(1.6) drop-shadow(0 0 6px #fff);
  }
}

.belts {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  overflow: visible;
}
.belt-track {
  position: absolute;
  display: flex;
  align-items: center;
  overflow: hidden;
  background: linear-gradient(#4a301c, #2a1810 55%, #24140c);
  border: 2px solid #c48448;
  border-radius: 9px;
  box-shadow:
    inset 0 1px #6a4428,
    inset 0 -2px #1a0c08,
    0 2px 0 #1a0c08;
  padding: 3px 4px;
}
.belt-flow {
  display: flex;
  align-items: center;
  gap: 3px;
  will-change: transform;
}
.belt-track.left,
.belt-track.right {
  height: 34px;
  width: min(36vw, 210px);
  top: calc(
    var(--frame) + var(--pad) + var(--pos) * var(--cell) + var(--span) *
      var(--cell) / 2 - 17px
  );
}
.belt-track.top,
.belt-track.bottom {
  width: 34px;
  height: min(28vh, 210px);
  left: calc(
    var(--frame) + var(--pad) + var(--pos) * var(--cell) + var(--span) *
      var(--cell) / 2 - 17px
  );
}
.belt-track.left {
  right: calc(100% + 2px);
  justify-content: flex-end;
}
.belt-track.right {
  left: calc(100% + 2px);
}
.belt-track.top {
  bottom: calc(100% + 2px);
  align-items: flex-end;
}
.belt-track.bottom {
  top: calc(100% + 2px);
  align-items: flex-start;
}
.belt-track.left .belt-flow {
  flex-direction: row-reverse;
  animation: conveyX 1.5s linear infinite;
}
.belt-track.right .belt-flow {
  animation: conveyXrev 1.5s linear infinite;
}
.belt-track.top .belt-flow {
  flex-direction: column-reverse;
  animation: conveyY 1.5s linear infinite;
}
.belt-track.bottom .belt-flow {
  flex-direction: column;
  animation: conveyYrev 1.5s linear infinite;
}
.belt-track.paused .belt-flow {
  animation-play-state: paused;
}
@keyframes conveyX {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(22px);
  }
}
@keyframes conveyXrev {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-22px);
  }
}
@keyframes conveyY {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(22px);
  }
}
@keyframes conveyYrev {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-22px);
  }
}
.belt-track.left {
  -webkit-mask-image: linear-gradient(to left, #000 55%, transparent);
  mask-image: linear-gradient(to left, #000 55%, transparent);
}
.belt-track.right {
  -webkit-mask-image: linear-gradient(to right, #000 55%, transparent);
  mask-image: linear-gradient(to right, #000 55%, transparent);
}
.belt-track.top {
  -webkit-mask-image: linear-gradient(to top, #000 55%, transparent);
  mask-image: linear-gradient(to top, #000 55%, transparent);
}
.belt-track.bottom {
  -webkit-mask-image: linear-gradient(to bottom, #000 55%, transparent);
  mask-image: linear-gradient(to bottom, #000 55%, transparent);
}
.mini-cup {
  position: relative;
  flex: 0 0 22px;
  width: 22px;
  height: 24px;
  background: linear-gradient(#fffaf0, var(--color));
  border-radius: 4px 4px 11px 11px;
  border: 2px solid #fff8ee;
  box-shadow:
    inset 0 -3px #0002,
    0 2px 3px #0004;
}
.mini-cup:before {
  content: "";
  position: absolute;
  left: 4px;
  right: 4px;
  top: 3px;
  height: 8px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #8a4a22, #4a2410);
}
.mini-cup:after {
  content: "";
  position: absolute;
  left: 50%;
  top: 5px;
  width: 5px;
  height: 5px;
  background: #fff;
  transform: translate(-50%) rotate(45deg);
  border-radius: 1px;
  box-shadow:
    -2px 0 0 #fff,
    0 -2px 0 #fff;
}

.power-bar {
  height: 78px;
  display: flex;
  justify-content: center;
  align-items: end;
  gap: 16px;
  z-index: 20;
  padding-bottom: 2px;
}
.wood-btn.tool {
  width: 62px;
  height: 62px;
  flex-basis: 62px;
}
.wood-btn.tool i {
  position: absolute;
  right: -6px;
  top: -6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #7edc4a;
  color: #fff;
  border: 2px solid #fff;
  font-style: normal;
  font-weight: 700;
  font-size: 11px;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 0 #2a8a20;
}
.wood-btn.tool:not(.locked) b {
  display: none;
}
.wood-btn.tool.locked {
  filter: saturate(0.2) brightness(0.75);
}
.wood-btn.tool.locked b {
  position: absolute;
  bottom: 5px;
  font-size: 9px;
  letter-spacing: 0;
  color: #fff6dc;
}
.wood-btn.tool.locked i {
  display: none;
}

.wood-btn.tool > span {
  width: 46px;
  height: 46px;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  filter: drop-shadow(0 2px 1px #3b1c0c99);
}
.wood-btn.tool > span:before,
.wood-btn.tool > span:after {
  display: none;
}
.saw-icon {
  background-image: url("assets/power-hint.webp");
}
.bomb-icon {
  background-image: url("assets/power-shuffle.webp");
}
.wood-btn.tool.armed {
  box-shadow:
    inset 0 2px #b07848,
    inset 0 -4px #3a2010,
    0 0 0 3px #ffd24a,
    0 6px 16px #ff9a1844;
}
.game-screen.bomb-aim .block.bomb-target .cell,
.game-screen.hammer-aim .block.hammer-target .cell,
.game-screen.saw-aim .block.saw-target .cell {
  animation: hintPulse 0.7s ease-in-out infinite;
}
.fly-bomb,
.fly-hammer,
.fly-saw {
  position: fixed;
  z-index: 95;
  pointer-events: none;
  margin: 0;
  filter: drop-shadow(0 8px 10px #0009);
}
.fly-bomb {
  background: url("assets/power-shuffle.webp") center/contain no-repeat;
}
.fly-hammer {
  background: url("assets/power-hammer.webp") center/contain no-repeat;
}
.fly-saw {
  background: url("assets/power-hint.webp") center/contain no-repeat;
}
.saw-slash {
  position: fixed;
  z-index: 96;
  pointer-events: none;
  width: 8px;
  height: 78px;
  margin: 0;
  border-radius: 4px;
  background: linear-gradient(#fff, #7aeeff, #3ad4d4);
  box-shadow: 0 0 12px #7aeeff;
  transform: translate(-50%, -50%) rotate(-32deg) scaleY(0.15);
  animation: sawCut 0.28s ease-out forwards;
}
@keyframes sawCut {
  40% {
    transform: translate(-50%, -50%) rotate(-32deg) scaleY(1.15);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) rotate(-32deg) scaleY(1.35);
    opacity: 0;
  }
}
.boom-burst {
  position: fixed;
  z-index: 96;
  pointer-events: none;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    #fff6c8 0%,
    #ffc02a 30%,
    #ff6a18 58%,
    transparent 72%
  );
  transform: translate(-50%, -50%) scale(0.2);
  animation: boomPop 0.42s ease-out forwards;
}
@keyframes boomPop {
  55% {
    transform: translate(-50%, -50%) scale(1.35);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(1.75);
    opacity: 0;
  }
}
.boom-spark {
  position: fixed;
  z-index: 96;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  pointer-events: none;
  background: #ffd24a;
  box-shadow: 0 0 6px #ff8a18;
}
.lock-icon {
  background-image: url("assets/power-hammer.webp");
}
.wood-btn.tool.locked .lock-icon {
  opacity: 0.82;
}

.tutorial {
  position: absolute;
  inset: 0;
  z-index: 12;
  pointer-events: none;
}
.coach-banner {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 13;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
  max-width: calc(100% - 12px);
  background: #3a2010f0;
  border: 2px solid #e8b45a;
  border-radius: 12px;
  padding: 8px 8px 8px 12px;
  box-shadow: 0 4px 0 #2a140899;
}
.coach-banner p {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #fffaf0;
  white-space: nowrap;
}
.coach-banner button {
  flex: 0 0 auto;
  border-radius: 8px;
  padding: 6px 10px;
  background: linear-gradient(#ffd24a, #e88818);
  color: #6a2e0c;
  font-size: 11px;
  font-weight: 700;
  box-shadow: inset 0 2px #fff0a8;
}
.coach-hand {
  position: absolute;
  z-index: 14;
  width: 26px;
  height: 36px;
  border-radius: 14px 14px 8px 10px;
  background: #fff8e8;
  box-shadow: 0 4px 0 #c48a50;
  pointer-events: none;
  animation: coachSlide 1.4s ease-in-out infinite;
}
.coach-hand:after {
  content: "";
  position: absolute;
  left: 7px;
  bottom: -8px;
  width: 12px;
  height: 14px;
  border-radius: 0 0 6px 6px;
  background: #fff8e8;
  box-shadow: 0 3px 0 #c48a50;
}
@keyframes coachSlide {
  0%,
  12% {
    transform: translate(0, 0) scale(1);
  }
  55% {
    transform: translate(var(--dx, 64px), var(--dy, 0px)) scale(0.9);
  }
  100% {
    transform: translate(0, 0) scale(1);
  }
}
.block.coach-target .cell {
  animation: hintPulse 0.85s ease-in-out infinite;
}
.gate.coach-gate {
  outline: 3px solid #fff8e8;
  outline-offset: 3px;
  animation: gatePulse 0.85s ease-in-out infinite;
}
@keyframes gatePulse {
  50% {
    filter: brightness(1.35);
    box-shadow:
      0 0 16px #fff8,
      0 2px 0 var(--shadow);
  }
}

.modal {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: #2a1408cc;
  backdrop-filter: blur(5px);
  padding: 24px;
}
.hidden {
  display: none !important;
}
.modal-card {
  width: min(90%, 360px);
  padding: 28px 22px 20px;
  border-radius: 18px;
  text-align: center;
  background: linear-gradient(#8d5a34, #5a361c);
  border: 4px solid #c49258;
  box-shadow:
    inset 0 4px #b07848,
    inset 0 -8px #3a2010,
    0 16px 36px #0006;
  animation: pop 0.25s ease-out;
}
.modal-card h2 {
  font-size: 40px;
  line-height: 1;
  margin: 8px 0 20px;
  color: #ffd24a;
  text-shadow: 0 3px #4a2008;
}
.modal-card .game-btn {
  width: 100%;
  margin: 6px 0;
}
.stars {
  font-size: 40px;
  color: #ffd24a;
  text-shadow: 0 3px #8a4010;
  letter-spacing: 4px;
}
.result-line {
  font-size: 14px;
  letter-spacing: 0.06em;
  color: #ffe8b8;
}
@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.75);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.toast {
  position: absolute;
  z-index: 50;
  left: 50%;
  top: 16%;
  transform: translate(-50%, -16px);
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  border: 2px solid #e8b45a;
  border-radius: 12px;
  background: #3a2010ee;
  color: #fffaf0;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 700;
  transition: 0.2s;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
.confetti {
  position: absolute;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  overflow: hidden;
}
.confetti i {
  position: absolute;
  top: -16px;
  width: 10px;
  height: 16px;
  background: var(--c);
  border-radius: 3px;
  animation: fall 1.8s ease-in forwards;
}
@keyframes fall {
  to {
    transform: translate3d(var(--dx), 110vh, 0) rotate(720deg);
  }
}

@media (max-height: 720px) {
  .hud {
    height: 54px;
  }
  .wood-btn {
    width: 46px;
    height: 46px;
    flex-basis: 46px;
  }
  .status-plaque {
    height: 48px;
  }
  .board-wrap {
    width: min(70vw, 300px);
  }
  .power-bar {
    height: 68px;
  }
  .wood-btn.tool {
    width: 54px;
    height: 54px;
    flex-basis: 54px;
  }
  .hero-board {
    --cell: 34px;
  }
}
@media (min-width: 700px) {
  .app {
    max-width: 100%;
  }
  .game-screen {
    max-width: 760px;
    left: 50%;
    transform: translateX(-50%);
  }
  .board-wrap {
    width: min(56vh, 420px);
  }
}
@media (max-width: 699px) {
  .levels-screen {
    padding-left: 8px;
    padding-right: 8px;
  }
  .levels-screen .screen-header {
    height: 58px;
    flex-basis: 58px;
    width: min(94vw, 380px);
  }
  .screen-header h2 {
    font-size: 27px;
  }
  .level-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    width: min(94vw, 380px);
    max-height: calc(100dvh - 76px);
    padding: 12px;
    border-radius: 20px;
  }
  .level-card {
    border-radius: 14px;
    font-size: 22px;
    border-width: 2px;
    box-shadow:
      inset 0 2px #fff0a6,
      inset 0 -5px #8d3811,
      0 4px 0 #3b180c,
      0 7px 10px #0005;
  }
  .level-card .mini-stars {
    bottom: 6px;
    font-size: 9px;
  }
}
@media (orientation: landscape) and (min-width: 700px) {
  .app {
    max-width: none;
  }
  .game-screen {
    max-width: none;
    left: 0;
    transform: none;
    padding: 6px max(16px, env(safe-area-inset-right)) 6px
      max(16px, env(safe-area-inset-left));
  }
  .hud {
    position: absolute;
    z-index: 20;
    left: 50%;
    top: 8px;
    transform: translateX(-50%);
    width: min(420px, 46vw);
  }
  .game-stage {
    position: absolute;
    inset: 0;
  }
  .board-wrap {
    width: min(64vh, 430px);
    margin-top: 10px;
  }
  .power-bar {
    position: absolute;
    z-index: 20;
    left: 50%;
    bottom: 8px;
    transform: translateX(-50%);
    height: auto;
    width: auto;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *:before,
  *:after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Dedicated portrait composition keeps the coffee shop visible on phones. */
@media (orientation: portrait) {
  html,
  body {
    background-image: url("assets/coffee-store-bg-mobile.webp");
    background-position: center;
    background-size: cover;
  }
  .app {
    background-image:
      linear-gradient(#2a130514, #1b0b0628),
      url("assets/coffee-store-bg-mobile.webp");
    background-position: center;
    background-size: cover;
  }
}

/* Generated WebP conveyor cup sprite */
.cups i {
  flex: 0 0 32px;
  width: 32px;
  height: 36px;
  border: 0;
  border-radius: 0;
  background: url("assets/coffee-cup.webp") center/contain no-repeat;
  box-shadow: none;
}
.cups i:before,
.cups i:after {
  display: none;
}
.cups i:nth-child(4n + 1) {
  filter: drop-shadow(0 2px 2px #0008);
}
.cups i:nth-child(4n + 2) {
  filter: hue-rotate(70deg) drop-shadow(0 2px 2px #0008);
}
.cups i:nth-child(4n + 3) {
  filter: hue-rotate(155deg) drop-shadow(0 2px 2px #0008);
}
.cups i:nth-child(4n + 4) {
  filter: hue-rotate(245deg) drop-shadow(0 2px 2px #0008);
}

/* WebP coffee cups used by the gate conveyor tracks */
.mini-cup {
  flex-basis: 28px;
  width: 28px;
  height: 31px;
  border: 0;
  border-radius: 0;
  background: url("assets/coffee-cup.webp") center/contain no-repeat;
  box-shadow: none;
  filter: drop-shadow(0 2px 2px #0008);
}
.mini-cup:before,
.mini-cup:after {
  display: none;
}
.belt-track[data-color="red"] .mini-cup,
.belt-track[data-color="pink"] .mini-cup {
  filter: drop-shadow(0 2px 2px #0008);
}
.belt-track[data-color="orange"] .mini-cup,
.belt-track[data-color="yellow"] .mini-cup {
  filter: hue-rotate(38deg) saturate(1.25) drop-shadow(0 2px 2px #0008);
}
.belt-track[data-color="green"] .mini-cup {
  filter: hue-rotate(92deg) saturate(1.2) drop-shadow(0 2px 2px #0008);
}
.belt-track[data-color="cyan"] .mini-cup,
.belt-track[data-color="blue"] .mini-cup {
  filter: hue-rotate(175deg) saturate(1.15) drop-shadow(0 2px 2px #0008);
}
.belt-track[data-color="purple"] .mini-cup {
  filter: hue-rotate(265deg) drop-shadow(0 2px 2px #0008);
}

/* Exact game-palette cup variants: track, gate and flying cup always match. */
.belt-track[data-color="red"] .mini-cup,
.mini-cup[data-color="red"] {
  background-image: url("assets/coffee-cup-red.webp");
  filter: drop-shadow(0 2px 2px #0008);
}
.belt-track[data-color="orange"] .mini-cup,
.mini-cup[data-color="orange"] {
  background-image: url("assets/coffee-cup-orange.webp");
  filter: drop-shadow(0 2px 2px #0008);
}
.belt-track[data-color="yellow"] .mini-cup,
.mini-cup[data-color="yellow"] {
  background-image: url("assets/coffee-cup-yellow.webp");
  filter: drop-shadow(0 2px 2px #0008);
}
.belt-track[data-color="green"] .mini-cup,
.mini-cup[data-color="green"] {
  background-image: url("assets/coffee-cup-green.webp");
  filter: drop-shadow(0 2px 2px #0008);
}
.belt-track[data-color="cyan"] .mini-cup,
.mini-cup[data-color="cyan"] {
  background-image: url("assets/coffee-cup-cyan.webp");
  filter: drop-shadow(0 2px 2px #0008);
}
.belt-track[data-color="blue"] .mini-cup,
.mini-cup[data-color="blue"] {
  background-image: url("assets/coffee-cup-blue.webp");
  filter: drop-shadow(0 2px 2px #0008);
}
.belt-track[data-color="purple"] .mini-cup,
.mini-cup[data-color="purple"] {
  background-image: url("assets/coffee-cup-purple.webp");
  filter: drop-shadow(0 2px 2px #0008);
}
.belt-track[data-color="pink"] .mini-cup,
.mini-cup[data-color="pink"] {
  background-image: url("assets/coffee-cup-pink.webp");
  filter: drop-shadow(0 2px 2px #0008);
}

/* A landed conveyor cup stays visible inside its matching block slot. */
.slot .pod {
  inset: -10%;
  border-radius: 0;
  background-position: center;
  background-size: contain;
  background-repeat: no-repeat;
  box-shadow: none;
  filter: drop-shadow(0 1px 1px #0007);
}
.slot .pod:before {
  display: none;
}
.pod[data-color="red"] {
  background-image: url("assets/coffee-cup-red.webp");
}
.pod[data-color="orange"] {
  background-image: url("assets/coffee-cup-orange.webp");
}
.pod[data-color="yellow"] {
  background-image: url("assets/coffee-cup-yellow.webp");
}
.pod[data-color="green"] {
  background-image: url("assets/coffee-cup-green.webp");
}
.pod[data-color="cyan"] {
  background-image: url("assets/coffee-cup-cyan.webp");
}
.pod[data-color="blue"] {
  background-image: url("assets/coffee-cup-blue.webp");
}
.pod[data-color="purple"] {
  background-image: url("assets/coffee-cup-purple.webp");
}
.pod[data-color="pink"] {
  background-image: url("assets/coffee-cup-pink.webp");
}

/* WebP block-cell palette */
.block .cell {
  border-radius: 0;
  background-color: transparent;
  background-position: center;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  box-shadow: none;
}
.block[data-color="red"] .cell {
  background-image: url("assets/block-cell-joined-red.webp");
}
.block[data-color="orange"] .cell {
  background-image: url("assets/block-cell-joined-orange.webp");
}
.block[data-color="yellow"] .cell {
  background-image: url("assets/block-cell-joined-yellow.webp");
}
.block[data-color="green"] .cell {
  background-image: url("assets/block-cell-joined-green.webp");
}
.block[data-color="cyan"] .cell {
  background-image: url("assets/block-cell-joined-cyan.webp");
}
.block[data-color="blue"] .cell {
  background-image: url("assets/block-cell-joined-blue.webp");
}
.block[data-color="purple"] .cell {
  background-image: url("assets/block-cell-joined-purple.webp");
}
.block[data-color="pink"] .cell {
  background-image: url("assets/block-cell-joined-pink.webp");
}
.block[data-color="navy"] .cell {
  background-image: url("assets/block-cell-joined-blue.webp");
}
.block[data-color="lime"] .cell {
  background-image: url("assets/block-cell-joined-green.webp");
}
.block[data-color="white"] .cell {
  background-image: url("assets/block-cell-joined-yellow.webp");
  filter: saturate(0.18) brightness(1.4);
}
.block .slot {
  background: transparent;
  box-shadow: none;
}
.block .cell {
  left: calc(var(--lx) * var(--cell));
  top: calc(var(--ly) * var(--cell));
  width: calc(var(--cell) + 1px);
  height: calc(var(--cell) + 1px);
}

.belt-track .mini-cup {
  flex-basis: 24px;
  width: 24px;
  height: 27px;
}
.belt-track[data-color="navy"] .mini-cup,
.mini-cup[data-color="navy"] {
  background-image: url("assets/coffee-cup-blue.webp");
  filter: drop-shadow(0 2px 2px #0008);
}
.belt-track[data-color="lime"] .mini-cup,
.mini-cup[data-color="lime"] {
  background-image: url("assets/coffee-cup-green.webp");
  filter: hue-rotate(-28deg) saturate(1.25) brightness(1.12)
    drop-shadow(0 2px 2px #0008);
}
.belt-track[data-color="white"] .mini-cup,
.mini-cup[data-color="white"] {
  background-image: url("assets/coffee-cup-yellow.webp");
  filter: saturate(0.18) brightness(1.42) drop-shadow(0 2px 2px #0008);
}

/* Home preview: one served tile demonstrates coffee filling four slots. */
.hero-board .cell.with-coffee:after {
  display: block;
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background-image:
    url("assets/coffee-cup-blue.webp"), url("assets/coffee-cup-blue.webp"),
    url("assets/coffee-cup-blue.webp"), url("assets/coffee-cup-blue.webp");
  background-repeat: no-repeat;
  background-size: 28% 31%;
  background-position:
    20% 18%,
    80% 18%,
    20% 80%,
    80% 80%;
  filter: drop-shadow(0 1px 1px #0008);
  animation: heroCoffeePop 2.4s ease-in-out infinite;
}
@keyframes heroCoffeePop {
  0%,
  72%,
  100% {
    transform: scale(1);
  }
  82% {
    transform: scale(1.08);
  }
}
.hero-board .block[data-color="red"] .with-coffee:after {
  background-image:
    url("assets/coffee-cup-red.webp"), url("assets/coffee-cup-red.webp"),
    url("assets/coffee-cup-red.webp"), url("assets/coffee-cup-red.webp");
}
.hero-board .block[data-color="orange"] .with-coffee:after {
  background-image:
    url("assets/coffee-cup-orange.webp"), url("assets/coffee-cup-orange.webp"),
    url("assets/coffee-cup-orange.webp"), url("assets/coffee-cup-orange.webp");
}
.hero-board .block[data-color="yellow"] .with-coffee:after {
  background-image:
    url("assets/coffee-cup-yellow.webp"), url("assets/coffee-cup-yellow.webp"),
    url("assets/coffee-cup-yellow.webp"), url("assets/coffee-cup-yellow.webp");
}
.hero-board .block[data-color="green"] .with-coffee:after {
  background-image:
    url("assets/coffee-cup-green.webp"), url("assets/coffee-cup-green.webp"),
    url("assets/coffee-cup-green.webp"), url("assets/coffee-cup-green.webp");
}
.hero-board .block[data-color="cyan"] .with-coffee:after {
  background-image:
    url("assets/coffee-cup-cyan.webp"), url("assets/coffee-cup-cyan.webp"),
    url("assets/coffee-cup-cyan.webp"), url("assets/coffee-cup-cyan.webp");
}
.hero-board .block[data-color="purple"] .with-coffee:after {
  background-image:
    url("assets/coffee-cup-purple.webp"), url("assets/coffee-cup-purple.webp"),
    url("assets/coffee-cup-purple.webp"), url("assets/coffee-cup-purple.webp");
}
