:root {
  color-scheme: light;
  --ink: #202126;
  --muted: #5d626f;
  --tile: #fbf6e7;
  --cream: #fff9ed;
  --copper: #ad5733;
  --green: #2f8d66;
  --gold: #c88423;
  --red: #cc3e38;
  --panel: rgba(255, 250, 239, 0.94);
  --shadow: 0 18px 50px rgba(56, 39, 28, 0.24);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background:
    linear-gradient(135deg, rgba(255, 249, 236, 0.86), rgba(255, 237, 215, 0.78)),
    url("../assets/kitchen-floor.svg");
  background-size:
    auto,
    96px 96px;
}

button {
  font: inherit;
}

.game-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 22px 0;
}

.hud {
  display: grid;
  grid-template-columns:
    repeat(4, minmax(96px, 1fr))
    minmax(140px, 1fr)
    minmax(118px, 0.72fr)
    minmax(136px, 0.78fr);
  gap: 10px;
  align-items: stretch;
  margin-bottom: 12px;
}

.stat,
.wave-chip,
.pause-button,
.music-button {
  min-height: 58px;
  border: 1px solid rgba(88, 68, 44, 0.18);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 20px rgba(73, 52, 30, 0.1);
}

.stat {
  display: grid;
  gap: 2px;
  padding: 9px 12px;
}

.stat__label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.stat__icon {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  color: #fffaf2;
  font-size: 0.76rem;
  line-height: 1;
}

.stat__icon--heart {
  background: #c9423c;
}

.stat__icon--money {
  background: #2f8d66;
  font-weight: 900;
}

.stat strong {
  color: #201b18;
  font-size: clamp(1.15rem, 2.5vw, 1.7rem);
  line-height: 1;
}

.wave-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  color: #56371f;
  font-weight: 800;
  text-align: center;
}

.music-button,
.pause-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 12px;
  color: #5b3b27;
  cursor: pointer;
  font-weight: 900;
  white-space: nowrap;
}

.music-button:hover,
.music-button:focus-visible,
.pause-button:hover:not(:disabled),
.pause-button:focus-visible:not(:disabled) {
  border-color: rgba(167, 83, 34, 0.46);
  background: #fff1da;
  outline: none;
}

.pause-button:disabled {
  color: #92877c;
  background: rgba(233, 226, 215, 0.8);
  cursor: not-allowed;
}

.music-button.is-on {
  color: #fff8ed;
  border-color: rgba(113, 73, 40, 0.42);
  background: #a24d2b;
}

.pause-button.is-paused {
  color: #fff8ed;
  border-color: rgba(67, 94, 91, 0.45);
  background: #456267;
}

.music-button__icon,
.pause-button__icon {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  color: #fff8ed;
  background: #b86235;
  font-size: 1rem;
  line-height: 1;
}

.music-button.is-on .music-button__icon {
  color: #8d411f;
  background: #ffe1a4;
}

.pause-button__icon {
  background: #597078;
  font-size: 0.86rem;
}

.pause-button.is-paused .pause-button__icon {
  color: #2f5d49;
  background: #cfead8;
}

.stage {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(76, 54, 34, 0.22);
  border-radius: 8px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.04)),
    url("../assets/kitchen-floor.svg");
  background-size:
    auto,
    96px 96px;
  box-shadow: var(--shadow);
  aspect-ratio: 16 / 10;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.build-menu {
  position: absolute;
  z-index: 5;
  width: min(250px, calc(100% - 24px));
  padding: 10px;
  border: 1px solid rgba(86, 56, 32, 0.22);
  border-radius: 8px;
  background: rgba(255, 251, 242, 0.97);
  box-shadow: 0 16px 36px rgba(57, 35, 22, 0.25);
}

.build-menu__title {
  margin: 0 0 8px;
  color: #61432d;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.equipment-button {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 9px;
  align-items: center;
  width: 100%;
  min-height: 58px;
  padding: 8px;
  border: 1px solid rgba(170, 83, 38, 0.32);
  border-radius: 8px;
  color: #2c2119;
  background: #fff2dd;
  cursor: pointer;
  text-align: left;
}

.equipment-button + .equipment-button {
  margin-top: 8px;
}

.equipment-button:hover:not(:disabled),
.equipment-button:focus-visible:not(:disabled) {
  border-color: rgba(189, 82, 30, 0.74);
  background: #ffe8c4;
  outline: none;
}

.equipment-button:disabled {
  color: #8a817a;
  border-color: rgba(110, 101, 92, 0.18);
  background: #ece7df;
  cursor: not-allowed;
}

.equipment-button--big {
  border-color: rgba(126, 79, 155, 0.32);
  background: #f4edff;
}

.equipment-button--big:hover:not(:disabled),
.equipment-button--big:focus-visible:not(:disabled) {
  border-color: rgba(112, 75, 150, 0.72);
  background: #eadcff;
}

.equipment-button__icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #ffc36f;
  font-size: 1.35rem;
}

.equipment-button--big .equipment-button__icon {
  background: #caa7ff;
}

.equipment-button strong,
.equipment-button small {
  display: block;
}

.equipment-button small {
  margin-top: 2px;
  color: #765848;
  font-size: 0.74rem;
  line-height: 1.2;
}

.build-warning {
  min-height: 18px;
  margin-top: 8px;
  color: var(--red);
  font-size: 0.78rem;
  font-weight: 700;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 14px;
  z-index: 6;
  transform: translateX(-50%);
  max-width: min(520px, calc(100% - 28px));
  padding: 9px 14px;
  border-radius: 8px;
  color: #fffaf3;
  background: rgba(48, 33, 25, 0.88);
  box-shadow: 0 12px 28px rgba(38, 26, 17, 0.26);
  font-weight: 800;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.toast.is-visible {
  opacity: 1;
}

.game-overlay {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(38, 27, 20, 0.4);
}

.game-overlay__panel {
  width: min(360px, 100%);
  padding: 24px;
  border: 1px solid rgba(255, 244, 220, 0.4);
  border-radius: 8px;
  background: rgba(255, 250, 239, 0.96);
  box-shadow: 0 24px 58px rgba(40, 26, 18, 0.34);
  text-align: center;
}

.game-overlay h1 {
  margin: 0 0 8px;
  color: #211a17;
  font-size: 2rem;
  letter-spacing: 0;
}

.game-overlay p {
  margin: 0 0 18px;
  color: #5f5045;
}

.game-overlay button {
  min-width: 120px;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  color: #fff9ec;
  background: #a24d2b;
  box-shadow: 0 8px 20px rgba(123, 57, 31, 0.22);
  cursor: pointer;
  font-weight: 800;
}

.game-overlay button:hover,
.game-overlay button:focus-visible {
  background: #8e3f21;
  outline: 2px solid rgba(226, 124, 59, 0.4);
  outline-offset: 2px;
}

@media (max-width: 760px) {
  .game-shell {
    width: min(100vw - 16px, 1180px);
    padding: 8px 0;
  }

  .hud {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .wave-chip {
    min-height: 44px;
  }

  .music-button,
  .pause-button {
    min-height: 44px;
  }

  .stage {
    aspect-ratio: 16 / 11;
  }

  .stat {
    min-height: 52px;
  }
}
