:root {
  --bg-sky-top: #f7f2c8;
  --bg-sky-bottom: #f5b99a;
  --wall-base: #f4d9b4;
  --window-frame: #74461f;
  --window-dark: #1f3d4f;
  --table-wood-1: #a5592f;
  --table-wood-2: #7a3f23;
  --table-line: rgba(54, 21, 8, 0.18);
  --panel-bg: rgba(252, 233, 201, 0.88);
  --panel-border: rgba(102, 57, 31, 0.36);
  --ink: #2a1f15;
  --danger: #c7362f;
  --success: #248f4e;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: 'Manrope', 'Segoe UI', sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg-sky-top) 0%, var(--bg-sky-bottom) 100%);
}

.game-shell {
  max-width: 1320px;
  min-height: calc(100dvh - 1rem);
  display: flex;
  flex-direction: column;
  background: rgba(255, 251, 241, 0.72);
  border: 4px solid rgba(122, 63, 35, 0.5);
  border-radius: 28px;
  box-shadow: 0 20px 45px rgba(77, 37, 16, 0.22);
  overflow: hidden;
}

.hud {
  padding: 0.7rem 1rem;
  border-bottom: 2px solid rgba(117, 67, 34, 0.2);
  background: linear-gradient(180deg, rgba(255, 240, 207, 0.9) 0%, rgba(255, 231, 177, 0.95) 100%);
}

.hud h1 {
  margin: 0;
  font-family: 'Bungee', Impact, fantasy;
  letter-spacing: 1px;
  font-size: clamp(1rem, 2.4vw, 1.75rem);
  color: #5d2f11;
}

.hud-stats {
  flex-wrap: wrap;
}

.stat {
  min-width: 118px;
  padding: 0.5rem 0.7rem;
  border-radius: 12px;
  border: 1px solid rgba(111, 55, 17, 0.22);
  background: rgba(255, 255, 255, 0.6);
  display: grid;
  gap: 0.15rem;
}

.stat span {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #7f4f2f;
}

.stat strong {
  font-size: 1.05rem;
  line-height: 1;
}

.scene {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.wall {
  position: relative;
  flex: 0 0 clamp(205px, 34vh, 360px);
  background: linear-gradient(180deg, var(--wall-base) 0%, #f2c587 100%);
}

.wall::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    45deg,
    rgba(255, 255, 255, 0.06) 0,
    rgba(255, 255, 255, 0.06) 12px,
    rgba(130, 79, 41, 0.05) 12px,
    rgba(130, 79, 41, 0.05) 24px
  );
  pointer-events: none;
}

.window {
  position: absolute;
  top: 12%;
  left: 50%;
  transform: translateX(-50%);
  width: clamp(230px, 55vw, 520px);
  height: 78%;
  border-radius: 18px;
  border: clamp(8px, 1.1vw, 14px) solid var(--window-frame);
  background: linear-gradient(180deg, #5b95b2 0%, var(--window-dark) 100%);
  box-shadow: inset 0 -14px 18px rgba(0, 0, 0, 0.25), 0 12px 18px rgba(66, 30, 12, 0.25);
  overflow: visible;
}

.window::before {
  content: '';
  position: absolute;
  left: 50%;
  width: clamp(4px, 0.7vw, 8px);
  top: 0;
  bottom: 0;
  transform: translateX(-50%);
  background: rgba(250, 245, 223, 0.5);
}

.order-bubble {
  position: absolute;
  left: 50%;
  top: clamp(-62px, -9vw, -72px);
  transform: translateX(-50%);
  min-width: clamp(185px, 34vw, 250px);
  max-width: clamp(230px, 45vw, 340px);
  padding: 0.5rem 0.7rem;
  background: #fffef8;
  border: 3px solid #654323;
  border-radius: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  flex-wrap: wrap;
  text-align: center;
  box-shadow: 0 9px 14px rgba(0, 0, 0, 0.15);
}

.order-bubble::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -10px;
  width: 16px;
  height: 16px;
  transform: translateX(-50%) rotate(45deg);
  background: #fffef8;
  border-right: 3px solid #654323;
  border-bottom: 3px solid #654323;
}

.order-token {
  font-size: clamp(1rem, 2.4vw, 1.15rem);
  line-height: 1;
}

.customer {
  position: absolute;
  left: 50%;
  bottom: 2%;
  transform: translateX(-50%);
  width: clamp(122px, 21vw, 175px);
  height: clamp(145px, 25vw, 205px);
  display: grid;
  justify-items: center;
  align-content: end;
}

.customer-head {
  width: clamp(52px, 8vw, 80px);
  height: clamp(52px, 8vw, 80px);
  border-radius: 50%;
  border: 4px solid #3d2614;
  background: radial-gradient(circle at 38% 35%, #ffe2c5 0%, #f4c8a3 70%);
  position: relative;
  z-index: 2;
}

.customer-head::before,
.customer-head::after {
  content: '';
  position: absolute;
  width: clamp(5px, 0.8vw, 8px);
  height: clamp(5px, 0.8vw, 8px);
  background: #2b1c11;
  border-radius: 50%;
  top: 40%;
}

.customer-head::before {
  left: 26%;
}

.customer-head::after {
  right: 26%;
}

.customer-shirt {
  width: clamp(114px, 20vw, 165px);
  height: clamp(74px, 13vw, 120px);
  margin-top: -12px;
  border-radius: 22px 22px 10px 10px;
  border: 4px solid #3c2413;
  background:
    linear-gradient(90deg, var(--stripe-color, rgba(255, 255, 255, 0.22)) 0 18%, transparent 18% 36%, var(--stripe-color, rgba(255, 255, 255, 0.22)) 36% 54%, transparent 54% 72%, var(--stripe-color, rgba(255, 255, 255, 0.22)) 72% 90%),
    var(--shirt-color, #5ea7ff);
}

.serve-hint {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.22rem 0.56rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  color: #fefefe;
  background: rgba(0, 0, 0, 0.22);
  font-size: clamp(0.65rem, 1.8vw, 0.77rem);
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
}

.coin-pop {
  position: absolute;
  left: 50%;
  top: 34%;
  transform: translateX(-50%);
  font-weight: 800;
  font-size: clamp(1.1rem, 2.6vw, 1.4rem);
  color: #ffe173;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
}

.coin-pop.show {
  animation: coinRise 0.9s ease-out;
}

@keyframes coinRise {
  0% {
    opacity: 0;
    transform: translate(-50%, 14px) scale(0.75);
  }

  18% {
    opacity: 1;
    transform: translate(-50%, -2px) scale(1);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -34px) scale(1.05);
  }
}

.countertop {
  position: relative;
  flex: 1;
  min-height: 0;
  background:
    repeating-linear-gradient(
      90deg,
      var(--table-line) 0,
      var(--table-line) 2px,
      transparent 2px,
      transparent 76px
    ),
    linear-gradient(180deg, var(--table-wood-1) 0%, var(--table-wood-2) 100%);
  box-shadow: inset 0 11px 12px rgba(0, 0, 0, 0.18);
  overflow: auto;
}

.countertop .row {
  min-height: 100%;
}

.left-station,
.right-station,
.plate-zone {
  border-radius: 18px;
  border: 2px solid var(--panel-border);
  background: var(--panel-bg);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.45);
}

.left-station,
.right-station {
  padding: 0.6rem;
  display: grid;
  grid-template-rows: auto 1fr;
}

.station-title,
.plate-title {
  font-weight: 800;
  font-size: clamp(0.72rem, 1.9vw, 0.92rem);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #63371a;
}

.left-grid {
  margin-top: 0.45rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 0.55rem;
  min-height: 0;
}

.ingredient {
  width: 100%;
  min-height: 76px;
  border: 2px solid rgba(115, 57, 27, 0.35);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(255, 238, 205, 0.95));
  color: var(--ink);
  cursor: pointer;
  padding: 0.35rem;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 0.1rem;
  transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
  user-select: none;
}

.ingredient:hover {
  transform: translateY(-2px);
  border-color: #8a4f2b;
  box-shadow: 0 8px 12px rgba(52, 25, 10, 0.2);
}

.ingredient:active {
  transform: translateY(1px);
}

.ingredient .emoji {
  font-size: clamp(1.05rem, 2.5vw, 1.45rem);
}

.ingredient .name {
  font-size: clamp(0.68rem, 1.75vw, 0.82rem);
  font-weight: 800;
}

.ingredient .price {
  font-size: clamp(0.58rem, 1.45vw, 0.67rem);
  font-weight: 700;
  color: #7a502e;
}

.ingredient.correct {
  border-color: var(--success);
  box-shadow: 0 0 0 3px rgba(36, 143, 78, 0.18);
}

.ingredient.wrong {
  border-color: var(--danger);
  animation: shake 0.3s linear;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-4px);
  }

  50% {
    transform: translateX(4px);
  }

  75% {
    transform: translateX(-3px);
  }
}

.right-layout {
  margin-top: 0.45rem;
  display: grid;
  gap: 0.5rem;
  grid-template-columns: 1fr 1fr;
  grid-template-areas:
    'bunBottom bunTop'
    'patty cabbage'
    '. cheese';
}

.right-layout .ingredient[data-id='bunBottom'] {
  grid-area: bunBottom;
}

.right-layout .ingredient[data-id='bunTop'] {
  grid-area: bunTop;
}

.right-layout .ingredient[data-id='patty'] {
  grid-area: patty;
}

.right-layout .ingredient[data-id='cabbage'] {
  grid-area: cabbage;
}

.right-layout .ingredient[data-id='cheese'] {
  grid-area: cheese;
}

.plate-zone {
  padding: 0.65rem;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.plate {
  position: relative;
  margin: 0.55rem auto 0;
  width: min(260px, 100%);
  min-height: clamp(145px, 24vh, 200px);
  border-radius: 50% / 39%;
  border: 6px solid rgba(126, 74, 38, 0.4);
  background: radial-gradient(circle at 50% 42%, #fffefe 0%, #f4f4f4 74%, #dadada 100%);
  box-shadow: inset 0 -8px 10px rgba(0, 0, 0, 0.11);
  display: grid;
  align-items: end;
  justify-items: center;
  padding-bottom: 16px;
}

.burger-stack {
  --drag-x: 0px;
  --drag-y: 0px;
  position: relative;
  width: 116px;
  min-height: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  touch-action: none;
}

.burger-stack.ready {
  cursor: grab;
}

.burger-stack.ready::after {
  content: 'Готово к подаче';
  position: absolute;
  bottom: -28px;
  font-size: 0.66rem;
  font-weight: 800;
  color: #6a3d1a;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  border: 1px solid rgba(106, 61, 26, 0.35);
  background: rgba(255, 248, 229, 0.95);
  white-space: nowrap;
}

.burger-stack.dragging {
  position: fixed;
  z-index: 35;
  left: 0;
  top: 0;
  transform: translate(calc(var(--drag-x) - 50%), calc(var(--drag-y) - 50%));
  pointer-events: none;
}

.layer {
  width: var(--w, 86px);
  height: var(--h, 14px);
  border-radius: var(--r, 999px);
  background: var(--bg, #ddd);
  border: 2px solid var(--bd, rgba(0, 0, 0, 0.2));
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.28);
}

.plate-help {
  margin-top: 0.45rem;
  text-align: center;
  font-size: clamp(0.65rem, 1.5vw, 0.76rem);
  font-weight: 700;
  color: #704124;
}

.plate-help.error {
  color: var(--danger);
}

.plate-help.good {
  color: var(--success);
}

.drop-zone-highlight {
  box-shadow: 0 0 0 4px rgba(255, 220, 107, 0.65), inset 0 -14px 18px rgba(0, 0, 0, 0.25), 0 12px 18px rgba(66, 30, 12, 0.25);
}

@media (max-width: 1199.98px) {
  .countertop .row {
    min-height: auto;
  }

  .left-station,
  .right-station,
  .plate-zone {
    min-height: 230px;
  }

  .plate {
    min-height: 160px;
  }
}

@media (max-width: 991.98px) {
  .game-shell {
    border-radius: 20px;
  }

  .wall {
    flex-basis: clamp(180px, 31vh, 270px);
  }

  .window {
    width: clamp(220px, 68vw, 490px);
  }

  .serve-hint {
    bottom: 4px;
  }
}

@media (max-width: 767.98px) {
  .game-shell {
    min-height: calc(100dvh - 0.7rem);
    border-width: 3px;
  }

  .hud {
    padding: 0.55rem 0.7rem;
  }

  .hud-stats {
    width: 100%;
  }

  .stat {
    flex: 1;
    min-width: 0;
  }

  .wall {
    flex-basis: clamp(160px, 30vh, 235px);
  }

  .window {
    width: clamp(210px, 78vw, 430px);
    top: 10%;
  }

  .order-bubble {
    top: -56px;
    border-width: 2px;
  }

  .order-bubble::after {
    width: 12px;
    height: 12px;
    bottom: -7px;
    border-right-width: 2px;
    border-bottom-width: 2px;
  }

  .left-station,
  .right-station,
  .plate-zone {
    min-height: 210px;
  }

  .ingredient {
    min-height: 66px;
  }

  .plate {
    width: min(230px, 92%);
    min-height: 145px;
  }

  .burger-stack {
    width: 102px;
  }
}

@media (max-width: 480px) {
  .app-root {
    --bs-gutter-x: 0.5rem;
  }

  .wall {
    flex-basis: clamp(148px, 28vh, 210px);
  }

  .window {
    width: 84vw;
  }

  .serve-hint {
    display: none;
  }

  .left-grid,
  .right-layout {
    gap: 0.35rem;
  }

  .left-station,
  .right-station,
  .plate-zone {
    border-radius: 14px;
    padding: 0.5rem;
  }
}
