:root {
  --ink: #0b1026;
  --ink-2: #16102a;
  --paper: #f6f0e4;
  --lime: #c8f542;
  --pink: #ff4f8b;
  --gold: #d4af37;
  --panel: rgba(10, 8, 22, 0.82);
  --line: rgba(255, 255, 255, 0.12);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--ink);
  color: var(--paper);
  font-family: "Trebuchet MS", "Arial Rounded MT Bold", "Segoe UI", system-ui, sans-serif;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
}

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.hidden { display: none !important; }

.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(24px + var(--safe-top)) 20px calc(24px + var(--safe-bot));
  background: linear-gradient(180deg, rgba(8, 6, 20, 0.28) 0%, rgba(8, 6, 20, 0.72) 100%);
  text-align: center;
}

.overlay.scroll-y {
  display: block;
  overflow-y: auto;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.overlay.scroll-y .panel-wide {
  margin: 0 auto;
}

.brand-mark {
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-size: 11px;
  color: var(--lime);
  margin-bottom: 8px;
}

.logo {
  font-size: clamp(52px, 16vw, 84px);
  line-height: 0.85;
  letter-spacing: -0.03em;
  text-transform: uppercase;
  color: #fff;
  text-shadow:
    0 0 24px rgba(200, 245, 66, 0.35),
    3px 4px 0 #ff4f8b,
    -2px 0 0 rgba(0, 0, 0, 0.5);
  margin-bottom: 12px;
}

.tagline, .sub, .hint {
  color: rgba(246, 240, 228, 0.8);
  font-size: 15px;
  line-height: 1.4;
}

.hint { margin-top: 16px; font-size: 12px; opacity: 0.7; }

.best-line {
  margin: 10px 0 16px;
  font-size: 16px;
  color: var(--lime);
}

.supporter-badge {
  display: inline-block;
  margin: -6px 0 16px;
  padding: 4px 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, #8a6a12, var(--gold), #8a6a12);
  color: #1a1204;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.04em;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(320px, 100%);
  margin: 0 auto;
}

.btn {
  appearance: none;
  border: 2px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: var(--paper);
  font: inherit;
  font-weight: 700;
  font-size: 17px;
  padding: 12px 18px;
  border-radius: 14px;
  cursor: pointer;
  width: 100%;
}

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

.btn-primary {
  background: var(--lime);
  color: #152006;
  border-color: #eaff9a;
  box-shadow: 0 4px 0 #6a8a18;
}

.btn-ghost {
  background: transparent;
}

.btn[disabled] {
  opacity: 0.55;
  cursor: default;
}

.shirt-link {
  display: inline-block;
  margin-top: 4px;
  color: var(--pink);
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
  border-bottom: 2px solid rgba(255, 79, 139, 0.4);
  padding-bottom: 1px;
}

.shirt-link:active { opacity: 0.8; }

#muteBtn {
  position: absolute;
  top: calc(10px + var(--safe-top));
  right: 10px;
  z-index: 8;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.16);
  background: rgba(10, 8, 22, 0.55);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}

#hud {
  position: absolute;
  top: calc(10px + var(--safe-top));
  left: 10px;
  right: 60px;
  z-index: 6;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.45);
}

#hudLeft { text-align: left; }
#hudWorld { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--lime); }
#hudStage { font-size: 13px; opacity: 0.9; }
#hudScore {
  font-size: 28px;
  font-weight: 800;
  color: #fff;
  text-align: center;
}
#hudRight { text-align: right; font-size: 13px; }
#hudSnacks::before { content: "🍪 "; }
#hudPower { min-height: 16px; color: var(--lime); }

.panel {
  width: min(380px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 22px 18px 20px;
  backdrop-filter: blur(10px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}

.panel-wide { width: min(440px, 100%); }

.panel-head { margin-bottom: 14px; }
.panel-head h2, .panel h2, .title-world {
  font-size: 32px;
  letter-spacing: -0.03em;
  text-transform: uppercase;
  text-shadow: 2px 3px 0 var(--pink);
}

.big-score {
  font-size: 56px;
  font-weight: 800;
  line-height: 1;
  margin: 6px 0 4px;
}

.stars { font-size: 28px; color: var(--gold); margin-bottom: 4px; letter-spacing: 4px; }

.title-card { width: min(380px, 100%); }
.title-world { font-size: clamp(36px, 11vw, 56px); }
.title-stage { margin: 8px 0; color: var(--lime); letter-spacing: 0.14em; text-transform: uppercase; font-size: 13px; }
.title-flavor { margin-bottom: 18px; }

.loadout { margin: 0 0 16px; }
.loadout-label { font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; opacity: 0.8; margin-bottom: 8px; }
.loadout-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.loadout-row button {
  flex: 1;
  min-width: 90px;
  border-radius: 12px;
  border: 2px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.08);
  color: var(--paper);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 6px;
  cursor: pointer;
}
.loadout-row button.on {
  border-color: var(--lime);
  background: rgba(200, 245, 66, 0.2);
  color: var(--lime);
}

.panel-royal {
  border-color: var(--gold);
  background: linear-gradient(180deg, rgba(40, 20, 8, 0.9), rgba(10, 8, 22, 0.9));
}
.crown { font-size: 56px; color: var(--gold); filter: drop-shadow(0 6px 0 #8a6a12); }

.wallet {
  margin-top: 10px;
  font-size: 13px;
  color: rgba(246, 240, 228, 0.85);
}

.shop-section { text-align: left; margin: 18px 0; }
.shop-section h3 {
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--lime);
  margin-bottom: 10px;
}

.shop-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.card {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px;
  text-align: left;
  min-height: 150px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card.wide { grid-column: 1 / -1; }

.card canvas { display: block; margin: 0 auto; width: 80px; height: 80px; }

.card h4 { font-size: 15px; }
.card p { font-size: 12px; color: rgba(246, 240, 228, 0.72); flex: 1; }

.price-tag {
  display: inline-block;
  background: var(--pink);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  border-radius: 999px;
  padding: 2px 8px;
}

.chip {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 2px 8px;
  background: rgba(200, 245, 66, 0.15);
  color: var(--lime);
}

.card .btn { font-size: 13px; padding: 8px 10px; }

.world-card {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 12px;
  margin: 0 0 12px;
  text-align: left;
}

.world-card.locked { opacity: 0.55; }
.world-card h3 { font-size: 18px; text-transform: uppercase; }
.world-card .flavor { font-size: 12px; opacity: 0.75; margin: 2px 0 10px; }

.stage-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }

.stage-btn {
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
  color: var(--paper);
  border-radius: 12px;
  padding: 8px 4px;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.stage-btn.unlocked { border-color: rgba(200, 245, 66, 0.4); }
.stage-btn.cleared { background: rgba(200, 245, 66, 0.16); color: var(--lime); }
.stage-btn.locked { opacity: 0.4; cursor: default; }

.toast {
  position: absolute;
  left: 50%;
  bottom: calc(24px + var(--safe-bot));
  transform: translateX(-50%);
  z-index: 12;
  background: #111;
  color: #fff;
  border: 1px solid var(--lime);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  max-width: 90%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.shop-foot { margin-top: 8px; }

@media (max-height: 640px) {
  .logo { font-size: 48px; }
  .panel-head h2, .panel h2 { font-size: 26px; }
}

.credit {
  margin-top: 14px;
  font-size: 11px;
  letter-spacing: 0.04em;
  opacity: 0.75;
}
.credit a {
  color: rgba(246, 240, 228, 0.8);
  text-decoration: none;
  border-bottom: 1px solid rgba(200, 245, 66, 0.35);
  padding-bottom: 1px;
}
.credit a:hover, .credit a:focus {
  color: var(--lime);
  opacity: 1;
}

#hudCombo {
  position: absolute;
  left: 50%;
  top: calc(52px + var(--safe-top));
  transform: translateX(-50%);
  font-size: 22px;
  font-weight: 800;
  color: var(--lime);
  text-shadow: 0 2px 0 rgba(0,0,0,0.45);
  pointer-events: none;
  letter-spacing: 0.04em;
}
#hud { position: absolute; } /* already set */

#startScreen.overlay,
#titleScreen.overlay {
  justify-content: flex-start;
  padding-top: calc(36px + var(--safe-top));
  padding-bottom: calc(170px + var(--safe-bot));
}
#startScreen .stack,
#titleScreen .title-card { margin-top: auto; }
#startScreen { justify-content: center; }
