:root {
  --grease: #0a0406;
  --oil: #1a0a0e;
  --tray: #9b1b1b;
  --tray-dark: #5a0c0c;
  --neon: #ffb000;
  --neon-hot: #ff2d6a;
  --neon-lime: #39ff14;
  --neon-red: #ff2a2a;
  --cream: #ffe7b3;
  --menu: rgba(10, 6, 8, 0.82);
  --ok: #39ff14;
  --glass: rgba(18, 10, 12, 0.72);
  --rim: #ffc94a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% -10%, #6a1e28 0%, transparent 42%),
    radial-gradient(ellipse at 18% 88%, rgba(255, 45, 106, 0.18) 0%, transparent 40%),
    radial-gradient(ellipse at 88% 70%, rgba(57, 255, 20, 0.08) 0%, transparent 35%),
    radial-gradient(ellipse at 50% 40%, #2a0e12 0%, var(--grease) 55%, #050203 100%);
  color: var(--cream);
  font-family: Impact, Haettenschweiler, "Arial Black", "Franklin Gothic Heavy", system-ui, sans-serif;
}

/* subtle film grain / noise overlay */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  opacity: 0.055;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
  mix-blend-mode: overlay;
}

body {
  display: flex;
  justify-content: center;
  padding: 8px 12px;
  max-height: 100vh;
  position: relative;
}

.app {
  width: min(560px, 100%);
  height: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
  z-index: 1;
}

.sign, .chrome, .hud, .hint { flex-shrink: 0; }

.sign {
  text-align: center;
  margin-bottom: 8px;
  position: relative;
}

.sign h1 {
  font-size: clamp(26px, 5vw, 40px);
  letter-spacing: 0.06em;
  color: #ffe08a;
  text-shadow:
    0 0 4px #ffb000,
    0 0 12px #ff8a00,
    0 0 28px #ff4d00,
    0 0 48px rgba(255, 45, 106, 0.45),
    0 3px 0 #5a1800,
    0 5px 0 #2a0800;
  line-height: 0.95;
  animation: neon-flicker 4.5s ease-in-out infinite;
  position: relative;
  display: inline-block;
  padding: 6px 18px 8px;
  border: 3px solid #ffc94a;
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(255, 200, 80, 0.12) 0%, transparent 40%),
    linear-gradient(180deg, #1a0a08 0%, #0c0504 100%);
  box-shadow:
    0 0 0 2px #3a1608,
    0 0 20px rgba(255, 176, 0, 0.35),
    inset 0 1px 0 rgba(255, 230, 160, 0.35),
    inset 0 -2px 0 rgba(0, 0, 0, 0.45);
}

@keyframes neon-flicker {
  0%, 92%, 100% { opacity: 1; filter: brightness(1); }
  93% { opacity: 0.82; filter: brightness(0.85); }
  94.5% { opacity: 1; filter: brightness(1.08); }
  96% { opacity: 0.9; filter: brightness(0.92); }
  97.5% { opacity: 1; filter: brightness(1); }
}

.sign .sub {
  font-family: system-ui, sans-serif;
  font-weight: 800;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: #ffd27a;
  font-size: 13px;
  margin-top: 8px;
  text-shadow: 0 0 10px rgba(255, 176, 0, 0.4);
}

.sign .tag {
  font-family: system-ui, sans-serif;
  color: #e08aa0;
  font-size: 12px;
  margin-top: 2px;
  letter-spacing: 0.06em;
  text-shadow: 0 0 8px rgba(255, 45, 106, 0.35);
}

.chrome {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-bottom: 8px;
}

.menu-board, .bag-teaser, .hud, .tray {
  background: var(--glass);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 2px solid rgba(255, 201, 74, 0.65);
  box-shadow:
    0 0 0 2px #2a1008,
    0 8px 0 #120504,
    0 0 22px rgba(255, 120, 0, 0.18),
    inset 0 1px 0 rgba(255, 220, 140, 0.18),
    inset 0 0 28px rgba(255, 80, 40, 0.06);
}

.menu-board {
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 8px;
}

.lives {
  font-family: system-ui, sans-serif;
  font-size: 18px;
  letter-spacing: 2px;
  filter: drop-shadow(0 0 6px rgba(255, 42, 80, 0.45));
}

.lives small {
  display: block;
  color: #b88968;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.bag-teaser {
  padding: 8px 12px;
  min-width: 170px;
  text-align: right;
  border-radius: 8px;
  border-color: rgba(255, 45, 106, 0.45);
  box-shadow:
    0 0 0 2px #2a1008,
    0 8px 0 #120504,
    0 0 18px rgba(255, 45, 106, 0.2),
    inset 0 1px 0 rgba(255, 180, 200, 0.12);
}

.bag-teaser .kicker {
  color: var(--neon);
  font-size: 16px;
  letter-spacing: 0.08em;
  text-shadow: 0 0 12px rgba(255, 176, 0, 0.5);
}

.bag-teaser p {
  font-family: system-ui, sans-serif;
  font-size: 12px;
  color: #d8b48a;
}

.bag-teaser .stub {
  display: inline-block;
  margin-top: 3px;
  font-family: system-ui, sans-serif;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: #111;
  background: linear-gradient(180deg, #ffd36a, #ffb000);
  padding: 1px 6px;
  border-radius: 3px;
  box-shadow: 0 0 10px rgba(255, 176, 0, 0.45);
}

.hud {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0;
  margin-bottom: 8px;
  padding: 8px 8px 10px;
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(40, 18, 12, 0.55) 0%, transparent 50%),
    var(--glass);
}

.level-hud {
  grid-column: 1 / -1;
  text-align: center;
  font-family: system-ui, sans-serif;
  font-size: 12px;
  letter-spacing: 0.16em;
  color: #ffb000;
  padding-bottom: 4px;
  pointer-events: none;
  text-shadow: 0 0 10px rgba(255, 176, 0, 0.45);
}

.stat {
  text-align: center;
  border-right: 1px dashed rgba(255, 176, 0, 0.25);
  padding: 4px 2px;
  margin: 0 2px;
  border-radius: 6px;
  background: rgba(255, 140, 40, 0.04);
}
.stat:last-of-type { border-right: none; }

.stat .lbl {
  font-family: system-ui, sans-serif;
  font-size: 11px;
  letter-spacing: 0.18em;
  color: #ffb000;
  text-shadow: 0 0 8px rgba(255, 176, 0, 0.35);
}

.stat .val {
  font-size: 26px;
  line-height: 1;
  color: #fff6d8;
  text-shadow:
    0 0 12px #ff8a00,
    0 0 24px rgba(255, 45, 106, 0.25);
}

.bar-wrap {
  grid-column: 1 / -1;
  height: 12px;
  margin: 10px 10px 0;
  background: #1a0a08;
  border: 1px solid #9a5a20;
  border-radius: 6px;
  overflow: hidden;
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.55),
    0 0 10px rgba(255, 120, 0, 0.15);
}

.bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ff2a2a 0%, #ff6a00 40%, #ffb000 75%, #39ff14 100%);
  background-size: 140% 100%;
  transition: width 180ms ease-out;
  border-radius: 5px;
  box-shadow: 0 0 12px rgba(255, 176, 0, 0.55);
  position: relative;
}

.bar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.35) 0%, transparent 45%);
  border-radius: inherit;
  pointer-events: none;
}

.tray {
  background:
    linear-gradient(180deg, rgba(255, 200, 100, 0.12) 0%, transparent 28%),
    linear-gradient(180deg, #d42828 0%, var(--tray) 38%, var(--tray-dark) 100%);
  border-color: #ffd36a;
  padding: 10px;
  border-radius: 12px;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  box-shadow:
    0 0 0 2px #3a1008,
    0 10px 0 #1a0604,
    0 0 28px rgba(255, 80, 0, 0.22),
    inset 0 2px 0 rgba(255, 230, 160, 0.35),
    inset 0 -8px 20px rgba(0, 0, 0, 0.35);
  position: relative;
}

.tray::before {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 10px;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(255, 240, 180, 0.12) 0%, transparent 40%, transparent 60%, rgba(0, 0, 0, 0.15) 100%);
  z-index: 0;
}

#game {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 50% 28%, #6a2a14 0%, #2a100a 62%, #140806 100%);
  border-radius: 8px;
  overflow: hidden;
  box-shadow:
    inset 0 0 50px rgba(0, 0, 0, 0.55),
    inset 0 0 0 2px rgba(255, 180, 60, 0.25),
    0 0 18px rgba(255, 120, 0, 0.35);
  position: relative;
  z-index: 1;
}

#game::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 8px;
  box-shadow:
    inset 0 0 0 1px rgba(255, 210, 100, 0.35),
    inset 0 0 24px rgba(255, 100, 40, 0.12);
}

#game canvas {
  display: block;
  width: auto !important;
  height: auto !important;
  max-width: 100% !important;
  max-height: 100% !important;
  aspect-ratio: 1 / 1 !important;
  object-fit: contain !important;
  flex: 0 0 auto;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 1, 2, 0.82);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 20;
  backdrop-filter: blur(3px);
}

.overlay.show { display: flex; }

.modal {
  width: min(420px, 92vw);
  background:
    linear-gradient(180deg, #2a120c 0%, #140806 55%, #0c0404 100%);
  border: 4px solid var(--neon);
  border-radius: 10px;
  box-shadow:
    0 0 30px #ff4d00,
    0 0 60px rgba(255, 45, 106, 0.25),
    0 12px 0 #3a0c00,
    inset 0 1px 0 rgba(255, 220, 140, 0.25);
  padding: 28px 22px;
  text-align: center;
}

.modal h2 {
  font-size: 42px;
  color: var(--neon);
  text-shadow: 0 0 12px #ff6a00, 0 0 28px rgba(255, 176, 0, 0.5);
}

.modal p {
  font-family: system-ui, sans-serif;
  margin: 10px 0 22px;
  color: var(--cream);
  font-size: 16px;
}

.modal button {
  font-family: inherit;
  font-size: 28px;
  letter-spacing: 0.08em;
  padding: 8px 28px;
  border: 3px solid #fff0c0;
  border-radius: 6px;
  background: linear-gradient(180deg, #ff4a4a, var(--neon-red));
  color: #fff8e0;
  cursor: pointer;
  box-shadow:
    0 5px 0 #6a0000,
    0 0 16px rgba(255, 42, 42, 0.35);
  transition: filter 0.12s, transform 0.08s, box-shadow 0.08s;
}

.modal button:hover {
  filter: brightness(1.1);
  box-shadow:
    0 5px 0 #6a0000,
    0 0 22px rgba(255, 176, 0, 0.45);
}
.modal button:active { transform: translateY(2px); box-shadow: 0 3px 0 #6a0000; }
.modal button + button { margin-left: 12px; }

.hint {
  margin-top: 6px;
  text-align: center;
  font-family: system-ui, sans-serif;
  font-size: 12px;
  color: #c9a07a;
}

@media (max-height: 850px) {
  .sign h1 { font-size: clamp(22px, 4.2vh, 34px); padding: 4px 12px 6px; }
  .sign { margin-bottom: 4px; }
  .chrome, .hud { margin-bottom: 4px; }
  .stat .val { font-size: 22px; }
  .tray { padding: 6px; }
}

#game, #game canvas { touch-action: none; user-select: none; -webkit-user-select: none; }

.wallet-btn {
  font-family: inherit;
  font-size: 14px;
  letter-spacing: 0.08em;
  padding: 6px 10px;
  border: 2px solid #fff0c0;
  border-radius: 5px;
  background: linear-gradient(180deg, #2a120c, #1a0a06);
  color: var(--neon);
  cursor: pointer;
  box-shadow:
    0 3px 0 #3a1608,
    0 0 10px rgba(255, 176, 0, 0.2);
  transition: filter 0.12s, box-shadow 0.12s, transform 0.08s;
}
.wallet-btn.connected {
  color: #111;
  background: linear-gradient(180deg, #ffe08a, var(--neon));
  box-shadow: 0 3px 0 #7a4a08, 0 0 14px rgba(255, 176, 0, 0.45);
}
.wallet-btn:hover {
  filter: brightness(1.1);
  box-shadow: 0 3px 0 #3a1608, 0 0 16px rgba(255, 176, 0, 0.45);
}
.wallet-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #3a1608; }

.shop {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-bottom: 6px;
  flex-shrink: 0;
}
.sku {
  font-family: system-ui, sans-serif;
  font-size: 10px;
  letter-spacing: 0.04em;
  text-align: center;
  padding: 6px 4px;
  border: 2px solid rgba(224, 160, 32, 0.75);
  border-radius: 6px;
  background: rgba(20, 8, 6, 0.85);
  color: var(--cream);
  cursor: pointer;
  min-width: 0;
  box-shadow: 0 0 8px rgba(255, 120, 0, 0.12);
  transition: filter 0.12s, box-shadow 0.12s;
}
.sku strong {
  display: block;
  font-size: 11px;
  color: var(--neon);
  letter-spacing: 0.06em;
}
.sku span {
  display: block;
  margin-top: 2px;
  color: #d8b48a;
}
.sku:hover {
  filter: brightness(1.12);
  box-shadow: 0 0 14px rgba(255, 176, 0, 0.35);
}

.shop-status {
  font-family: system-ui, sans-serif;
  font-size: 11px;
  text-align: center;
  color: #c9a07a;
  margin: 0 0 6px;
  min-height: 14px;
  flex-shrink: 0;
}

.shop-modal .shop-price {
  font-size: 36px;
  color: var(--neon);
  margin: 8px 0;
  text-shadow: 0 0 14px rgba(255, 176, 0, 0.45);
}
.shop-modal .shop-price small {
  font-size: 14px;
  letter-spacing: 0.08em;
}
.shop-fine {
  font-family: system-ui, sans-serif;
  font-size: 12px;
  color: #d8b48a;
  margin: 8px 0 16px;
}
.shop-buy, .shop-cancel, .food-pick {
  font-family: inherit;
  letter-spacing: 0.08em;
  padding: 8px 22px;
  border: 3px solid #fff0c0;
  border-radius: 6px;
  cursor: pointer;
  margin: 4px;
}
.shop-buy {
  background: linear-gradient(180deg, #ff4a4a, var(--neon-red));
  color: #fff8e0;
  font-size: 24px;
  box-shadow: 0 5px 0 #6a0000, 0 0 14px rgba(255, 42, 42, 0.3);
}
.shop-cancel {
  background: #1a0a06;
  color: var(--cream);
  font-size: 18px;
}
.food-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  margin: 12px 0;
}
.food-pick {
  background: #2a120c;
  color: var(--neon);
  font-size: 14px;
}

@media (max-width: 520px) {
  .shop { grid-template-columns: repeat(3, 1fr); }
}
@media (max-height: 850px) {
  .shop, .shop-status { margin-bottom: 4px; }
  .sku { padding: 4px 2px; }
}

.sfx-btn {
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 0.08em;
  padding: 6px 8px;
  margin-right: 6px;
  border: 2px solid #fff0c0;
  border-radius: 5px;
  background: linear-gradient(180deg, #2a120c, #1a0a06);
  color: var(--cream);
  cursor: pointer;
  box-shadow: 0 3px 0 #3a1608, 0 0 8px rgba(255, 176, 0, 0.15);
  transition: filter 0.12s, box-shadow 0.12s, transform 0.08s;
}
.sfx-btn:hover {
  filter: brightness(1.1);
  box-shadow: 0 3px 0 #3a1608, 0 0 14px rgba(255, 176, 0, 0.4);
}
.sfx-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #3a1608; }
.sfx-btn[aria-pressed="false"] { color: #8a6a50; }

/* —— dopamine juice —— */
.level-row {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-bottom: 4px;
}
.level-row .level-hud {
  grid-column: auto;
  padding-bottom: 0;
}
.meta-chips {
  display: flex;
  gap: 6px;
  align-items: center;
}
.best-stars, .streak-chip {
  font-family: system-ui, sans-serif;
  font-size: 11px;
  letter-spacing: 0.08em;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 176, 0, 0.55);
  background: rgba(20, 8, 6, 0.85);
  color: #ffd27a;
  box-shadow: 0 0 12px rgba(255, 176, 0, 0.25);
}
.best-stars {
  color: #ffb000;
  text-shadow: 0 0 8px rgba(255, 176, 0, 0.5);
}
.streak-chip {
  color: #39ff14;
  border-color: rgba(57, 255, 20, 0.55);
  text-shadow: 0 0 10px rgba(57, 255, 20, 0.55);
  box-shadow: 0 0 14px rgba(57, 255, 20, 0.25);
}

.bar-wrap { position: relative; overflow: visible; }
.bar.pulse-mid, .bar.pulse-hot {
  box-shadow: 0 0 14px #ffb000, 0 0 24px rgba(255, 80, 0, 0.65);
}
.bar.pulse-hot {
  box-shadow: 0 0 16px #ff2a2a, 0 0 28px rgba(255, 176, 0, 0.8);
  animation: bar-glow 0.7s ease-out;
}
.bar-wrap.glow-mid {
  box-shadow: 0 0 14px rgba(255, 176, 0, 0.55);
}
.bar-wrap.glow-hot {
  box-shadow: 0 0 20px rgba(255, 42, 42, 0.65);
  animation: bar-wrap-pulse 0.85s ease-out;
}
@keyframes bar-glow {
  0% { filter: brightness(1.5); }
  100% { filter: brightness(1); }
}
@keyframes bar-wrap-pulse {
  0% { transform: scaleY(1.4); }
  100% { transform: scaleY(1); }
}

#game.shake {
  animation: fitb-shake 0.28s ease-out;
}
@keyframes fitb-shake {
  0%, 100% { transform: translate(0, 0); }
  15% { transform: translate(-5px, 3px); }
  30% { transform: translate(5px, -3px); }
  45% { transform: translate(-4px, -2px); }
  60% { transform: translate(4px, 2px); }
  75% { transform: translate(-2px, 1px); }
}

.end-stars {
  font-size: 44px;
  letter-spacing: 0.2em;
  color: #ffb000;
  text-shadow:
    0 0 16px #ff6a00,
    0 0 32px rgba(255, 176, 0, 0.55),
    0 3px 0 #5a2200;
  margin: 8px 0 4px;
  min-height: 48px;
  animation: star-glow 1.6s ease-in-out infinite;
}
@keyframes star-glow {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.2); }
}
.end-stars .star-on { color: #ffb000; }
.end-stars .star-off { color: #3a2210; text-shadow: none; }
.end-streak {
  font-family: system-ui, sans-serif;
  font-size: 14px;
  letter-spacing: 0.14em;
  color: #39ff14;
  margin: 0 0 4px !important;
  text-shadow: 0 0 12px rgba(57, 255, 20, 0.55);
}
.modal.near-miss {
  border-color: #ff8a00;
  box-shadow:
    0 0 36px rgba(255, 138, 0, 0.55),
    0 0 60px rgba(255, 80, 0, 0.25),
    0 12px 0 #3a0c00;
  animation: near-miss-pulse 1.1s ease-in-out infinite;
}
.modal.near-miss h2 {
  color: #ffb000;
  text-shadow: 0 0 16px #ff8a00, 0 0 28px rgba(255, 100, 0, 0.5);
}
.modal.win-smash {
  border-color: #ffe08a;
  box-shadow:
    0 0 40px rgba(255, 200, 60, 0.65),
    0 0 70px rgba(57, 255, 20, 0.25),
    0 12px 0 #3a0c00;
}
.modal.win-smash h2 {
  color: #39ff14;
  text-shadow:
    0 0 18px #39ff14,
    0 0 12px #ffb000,
    0 0 40px rgba(57, 255, 20, 0.45);
}
@keyframes near-miss-pulse {
  0%, 100% { box-shadow: 0 0 28px rgba(255, 138, 0, 0.45), 0 12px 0 #3a0c00; }
  50% { box-shadow: 0 0 48px rgba(255, 138, 0, 0.75), 0 12px 0 #3a0c00; }
}

.home-btn {
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 0.08em;
  padding: 6px 8px;
  margin-right: 6px;
  border: 2px solid #fff0c0;
  border-radius: 5px;
  background: linear-gradient(180deg, #2a120c, #1a0a06);
  color: var(--neon);
  text-decoration: none;
  display: inline-block;
  cursor: pointer;
  box-shadow: 0 3px 0 #3a1608, 0 0 8px rgba(255, 176, 0, 0.15);
  transition: filter 0.12s, box-shadow 0.12s, transform 0.08s;
}
.home-btn:hover {
  filter: brightness(1.1);
  box-shadow: 0 3px 0 #3a1608, 0 0 14px rgba(255, 176, 0, 0.4);
  color: #ffe08a;
}
.home-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #3a1608; }
