:root {
  color-scheme: dark;
  --bg: #7d160d;
  --bg-deep: #3f0705;
  --bar: #dc6d23;
  --bar-light: #f29b3b;
  --panel: rgba(180, 58, 20, 0.9);
  --panel-deep: rgba(97, 18, 10, 0.78);
  --line: rgba(255, 185, 92, 0.42);
  --text: #fff8e8;
  --muted: #ffdba9;
  --shadow: rgba(42, 6, 2, 0.38);
  --blue: #42dbff;
  --pink: #ff4bd6;
  --green: #3df03d;
  --red: #ff382d;
  --yellow: #ffd540;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 50% 8%, rgba(255, 184, 71, 0.2), transparent 30%),
    linear-gradient(180deg, #a82912 0%, var(--bg) 38%, var(--bg-deep) 100%);
}

button {
  font: inherit;
}

.game-shell {
  width: min(1180px, 100vw);
  height: 100vh;
  height: 100svh;
  max-height: 100dvh;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    radial-gradient(circle at 50% 45%, rgba(255, 68, 31, 0.25), transparent 42%),
    linear-gradient(180deg, #8f1a0f, #5f0f0a 62%, #3d0704);
  background-size: 88px 88px, 100% 100%, 100% 100%;
}

.topbar {
  min-height: clamp(54px, 9svh, 74px);
  padding: clamp(6px, 1.4svh, 10px) clamp(8px, 2vw, 18px);
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 12px;
  background:
    linear-gradient(180deg, rgba(255, 183, 75, 0.44), rgba(191, 62, 18, 0.18)),
    linear-gradient(90deg, var(--bar), var(--bar-light));
  border-bottom: 4px solid rgba(82, 16, 5, 0.58);
  box-shadow: 0 8px 18px var(--shadow);
}

.title-block {
  min-width: 0;
  text-align: center;
}

.title-block p {
  margin: 0 0 2px;
  color: #4d1708;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.2rem, 3.6vw, 2.1rem);
  line-height: 1;
  text-shadow: 0 3px 0 rgba(73, 17, 7, 0.42);
}

.pill,
.icon-button {
  border: 2px solid rgba(255, 211, 111, 0.4);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.24),
    0 8px 14px var(--shadow);
}

.pill {
  min-width: 92px;
  min-height: clamp(34px, 6svh, 42px);
  padding: 5px 12px 5px 6px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  background: rgba(64, 13, 10, 0.82);
}

.pill strong {
  font-size: clamp(0.88rem, 2.4vw, 1.1rem);
}

.coin-icon,
.booster-art {
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: #6d2b00;
  background: radial-gradient(circle at 35% 30%, #fff5ae, #ffc539 55%, #c86805);
  font-weight: 950;
}

.coin-icon {
  width: clamp(24px, 4.8svh, 30px);
  height: clamp(24px, 4.8svh, 30px);
}

.gem-icon {
  width: clamp(24px, 4.8svh, 30px);
  height: clamp(24px, 4.8svh, 30px);
  border-radius: 10px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.65), transparent 35%),
    linear-gradient(135deg, #ff4bd6 0 32%, #37e86e 32% 64%, #40d9ff 64%);
  transform: rotate(-12deg);
}

.icon-button {
  width: clamp(38px, 7svh, 48px);
  height: clamp(38px, 7svh, 48px);
  border-radius: 999px;
  color: #6c2609;
  background: radial-gradient(circle at 35% 28%, #ffe98d, #f4a820 65%, #c76512);
  font-size: 1.8rem;
  font-weight: 950;
  cursor: pointer;
}

.playfield {
  position: relative;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(72px, 15vw, 150px);
  overflow: hidden;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}

#game-canvas.dragging {
  cursor: grabbing;
}

.booster-panel {
  margin: clamp(8px, 1.8svh, 22px) clamp(5px, 1.5vw, 18px) clamp(12px, 2svh, 24px) 0;
  padding: clamp(6px, 1.2svh, 12px) 6px;
  display: grid;
  align-content: start;
  gap: 12px;
  border: 4px solid rgba(255, 171, 72, 0.54);
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 142, 42, 0.35), rgba(92, 18, 9, 0.35)),
    var(--panel);
  box-shadow:
    inset 0 0 0 2px rgba(82, 19, 5, 0.32),
    0 16px 24px var(--shadow);
}

.booster {
  min-height: clamp(58px, 10.5svh, 82px);
  padding: clamp(5px, 1svh, 7px) 5px;
  display: grid;
  justify-items: center;
  gap: 3px;
  border: 0;
  border-radius: 22px;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.05)),
    rgba(57, 15, 12, 0.7);
  box-shadow:
    inset 0 -4px 0 rgba(0, 0, 0, 0.18),
    0 7px 12px var(--shadow);
  cursor: pointer;
}

.booster.is-active {
  outline: 3px solid #fff0a3;
  background:
    linear-gradient(180deg, rgba(255, 238, 120, 0.38), rgba(255, 255, 255, 0.06)),
    rgba(99, 26, 12, 0.86);
}

.booster:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.booster-art {
  width: clamp(32px, 6.4svh, 44px);
  height: clamp(32px, 6.4svh, 44px);
  color: #665f63;
  background:
    radial-gradient(circle at 38% 30%, #ffffff, #bfc3c9 52%, #73777d);
}

.booster strong {
  font-size: 0.76rem;
}

.booster small {
  color: var(--muted);
  font-size: 0.64rem;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: clamp(82px, 13svh, 132px);
  min-width: 190px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 10px 14px;
  border-radius: 999px;
  color: #4b1806;
  background: #fff0c0;
  box-shadow: 0 12px 22px var(--shadow);
  text-align: center;
  font-weight: 850;
  transform: translate(-50%, 14px);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.modal {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(43, 4, 2, 0.58);
}

.modal[hidden] {
  display: none;
}

.modal-card {
  width: min(380px, 92vw);
  padding: 24px;
  border: 3px solid rgba(255, 206, 103, 0.62);
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 147, 42, 0.42), transparent 55%),
    #6f160c;
  box-shadow: 0 24px 44px rgba(31, 4, 2, 0.5);
  text-align: center;
}

.modal-card p {
  color: var(--muted);
}

#modal-kicker {
  margin: 0 0 5px;
  color: #ffe47c;
  font-weight: 950;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.modal-card h2 {
  margin: 0;
  font-size: 2rem;
}

.modal-card button {
  border: 0;
  border-radius: 999px;
  padding: 11px 20px;
  color: #5a2108;
  background: #ffd44f;
  font-weight: 950;
  cursor: pointer;
}

.help-card {
  padding: clamp(6px, 1svh, 9px) 14px calc(clamp(6px, 1svh, 9px) + env(safe-area-inset-bottom));
  color: var(--muted);
  background: rgba(47, 8, 5, 0.72);
  border-top: 1px solid rgba(255, 205, 104, 0.18);
  font-size: clamp(0.76rem, 2vw, 0.92rem);
  text-align: center;
}

@media (max-width: 760px) {
  .topbar {
    grid-template-columns: 1fr auto auto;
    gap: 6px;
  }

  .title-block {
    display: none;
  }

  .pill {
    min-width: 74px;
    padding-right: 8px;
  }

  .playfield {
    grid-template-columns: minmax(0, 1fr) clamp(66px, 18vw, 82px);
  }

  .booster-panel {
    margin: 8px 5px 10px 0;
    padding: 6px 4px;
    border-radius: 22px;
  }

  .booster {
    min-height: clamp(54px, 10svh, 72px);
    border-radius: 18px;
  }

  .booster small {
    display: none;
  }

  .booster-art {
    width: clamp(30px, 6svh, 38px);
    height: clamp(30px, 6svh, 38px);
  }
}

@media (max-width: 420px), (max-height: 720px) {
  .help-card {
    font-size: 0.72rem;
    line-height: 1.25;
  }

  .booster strong {
    font-size: 0.68rem;
  }
}

@media (max-height: 600px) {
  .help-card {
    display: none;
  }

  .booster-panel {
    margin-bottom: 8px;
  }
}
