:root {
  --gold: #ffd23f;
  --gold-deep: #f0a500;
  --ink: #1a1228;
  --panel: rgba(26, 18, 40, 0.92);
  --accent: #ff5b3a;
}

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

html, body {
  height: 100%;
  color: #fff;
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  overflow: hidden;
  user-select: none;
  touch-action: none;
}

/* desktop backdrop behind the game card */
body {
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(120% 90% at 50% -10%, #2a2350 0%, #14102a 45%, #0a0713 100%),
    #0a0713;
}

/* the stage: full-bleed on phones, a centered portrait card on desktop */
#game-wrap {
  position: relative;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
  background: #87c7ff;
  /* scale the in-game UI to THIS box, not the whole monitor */
  container-type: size;
  container-name: stage;
}

@media (min-width: 768px) {
  #game-wrap {
    width: auto;
    height: min(94dvh, 900px);
    aspect-ratio: 10 / 16;
    max-width: 94vw;
    border-radius: 28px;
    box-shadow:
      0 30px 80px rgba(0, 0, 0, 0.6),
      0 0 0 1px rgba(255, 255, 255, 0.06),
      0 0 0 7px rgba(0, 0, 0, 0.25);
  }
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  background: #87c7ff;
  image-rendering: optimizeQuality;
}

.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  padding: clamp(10px, 2.5cqmin, 22px);
}
.hud-left {
  position: absolute;
  top: clamp(10px, 2.5cqmin, 22px);
  left: clamp(10px, 2.5cqmin, 22px);
  display: flex;
  gap: 10px;
  flex-direction: column;
  align-items: flex-start;
}
.hud-right {
  position: absolute;
  top: clamp(10px, 2.5cqmin, 22px);
  right: clamp(10px, 2.5cqmin, 22px);
  display: flex;
  gap: 8px;
  pointer-events: auto;
}
.hud-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(26, 18, 40, 0.55);
  border: 2px solid rgba(255, 210, 63, 0.65);
  border-radius: 999px;
  padding: 5px 14px 5px 10px;
  font-size: clamp(16px, 3.2cqmin, 26px);
  font-weight: bold;
  letter-spacing: 0.5px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  min-width: 78px;
}
#ticker {
  position: absolute;
  top: clamp(10px, 2.5cqmin, 22px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(20, 14, 30, 0.6);
  border: 2px solid rgba(110, 231, 138, 0.6);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: clamp(11px, 2.3cqmin, 15px);
  font-weight: 900;
  letter-spacing: 0.3px;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
#ticker .t-name { color: var(--gold); }
#ticker #ticker-pct { color: #6ee78a; }
#ticker #ticker-pct.down { color: #ff7a6b; }

.ico { width: 22px; height: 22px; display: inline-block; flex: 0 0 auto; }
.coin-ico {
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff6c4, var(--gold) 55%, var(--gold-deep));
  box-shadow: inset 0 0 0 2px #b9760a;
}
.score-ico {
  background: var(--accent);
  clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}
.icon-btn {
  width: clamp(38px, 7cqmin, 50px);
  height: clamp(38px, 7cqmin, 50px);
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  background: rgba(26, 18, 40, 0.55);
  color: #fff;
  font-size: clamp(16px, 3cqmin, 22px);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:active { transform: scale(0.92); }

#powerup-bar {
  position: absolute;
  bottom: clamp(12px, 3cqmin, 26px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
}
.pu-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(26, 18, 40, 0.6);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: clamp(12px, 2.4cqmin, 16px);
  font-weight: bold;
  border: 2px solid currentColor;
}

/* ---------- Overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(12, 8, 20, 0.35), rgba(12, 8, 20, 0.8));
  backdrop-filter: blur(2px);
  z-index: 10;
}
.panel {
  background: var(--panel);
  border: 3px solid var(--gold);
  border-radius: 22px;
  padding: clamp(22px, 5cqmin, 42px);
  text-align: center;
  max-width: min(90cqw, 460px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  animation: pop 0.35s cubic-bezier(0.18, 1.4, 0.4, 1);
}
@keyframes pop { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.logo {
  font-size: clamp(46px, 12cqmin, 96px);
  line-height: 0.9;
  letter-spacing: 2px;
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 4px 0 var(--gold-deep), 0 8px 18px rgba(0, 0, 0, 0.6);
  transform: rotate(-3deg);
}
.logo span { color: #fff; -webkit-text-stroke: 2px var(--accent); }
.tagline { margin: 14px 0 22px; font-size: clamp(14px, 3cqmin, 19px); opacity: 0.9; }
.tagline em { color: var(--accent); font-style: normal; font-weight: bold; }

h2 { font-size: clamp(28px, 7cqmin, 46px); margin-bottom: 18px; color: var(--gold); }

.big-btn {
  display: inline-block;
  background: linear-gradient(180deg, var(--gold), var(--gold-deep));
  color: var(--ink);
  border: none;
  border-radius: 14px;
  font-size: clamp(20px, 4.5cqmin, 30px);
  font-weight: 900;
  letter-spacing: 1px;
  padding: 14px 38px;
  cursor: pointer;
  box-shadow: 0 6px 0 #b9760a, 0 10px 24px rgba(0, 0, 0, 0.4);
  transition: transform 0.06s, box-shadow 0.06s;
}
.big-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #b9760a, 0 5px 14px rgba(0, 0, 0, 0.4); }
.ghost-btn {
  display: block;
  margin: 14px auto 0;
  background: transparent;
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 12px;
  padding: 9px 22px;
  font-size: clamp(14px, 3cqmin, 18px);
  cursor: pointer;
}
.ghost-btn:active { transform: scale(0.95); }

.airdrop-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  margin: 0 auto 20px;
  max-width: 94%;
  padding: 10px 14px;
  border-radius: 14px;
  background: linear-gradient(100deg, rgba(154, 255, 208, 0.16), rgba(255, 210, 63, 0.16));
  border: 1.5px solid rgba(154, 255, 208, 0.55);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2) inset, 0 6px 18px rgba(0, 0, 0, 0.25);
  font-size: clamp(12px, 2.5cqmin, 15px);
  line-height: 1.35;
  color: #e6fff2;
  animation: dropglow 2.4s ease-in-out infinite;
}
.airdrop-banner b { color: #9affd0; }
.airdrop-banner .drop-ico {
  font-size: 1.5em;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.4));
  animation: dropfloat 2.4s ease-in-out infinite;
}
@keyframes dropglow {
  50% { border-color: rgba(255, 210, 63, 0.75); box-shadow: 0 0 18px rgba(154, 255, 208, 0.3), 0 6px 18px rgba(0, 0, 0, 0.25); }
}
@keyframes dropfloat {
  50% { transform: translateY(-3px) rotate(-6deg); }
}
.airdrop-note {
  margin: 4px 0 16px;
  font-size: clamp(12px, 2.6cqmin, 15px);
  font-weight: bold;
  color: #9affd0;
}
.rekt-msg {
  margin: -4px 0 14px;
  font-size: clamp(13px, 2.9cqmin, 16px);
  font-weight: bold;
  color: var(--accent);
}

/* ---------- contract / token box ---------- */
.ca-box {
  margin: 16px auto 4px;
  max-width: 96%;
  background: rgba(20, 14, 30, 0.55);
  border: 1.5px solid rgba(255, 210, 63, 0.4);
  border-radius: 12px;
  padding: 8px 10px;
  text-align: left;
}
.ca-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 5px; }
.ca-label { font-size: clamp(10px, 2.2cqmin, 12px); letter-spacing: 0.6px; color: var(--gold); font-weight: bold; }
.token-stat { font-size: clamp(10px, 2.2cqmin, 12px); color: #9affd0; font-weight: bold; white-space: nowrap; }
.token-stat.down { color: #ff7a6b; }
.ca-row { display: flex; align-items: center; gap: 6px; }
#ca-text {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: clamp(9px, 2cqmin, 12px); color: #e6dcff;
  background: rgba(0, 0, 0, 0.3); border-radius: 7px; padding: 6px 8px;
}
.ca-copy {
  flex: 0 0 auto; border: none; border-radius: 7px; cursor: pointer;
  background: var(--gold); color: var(--ink); font-weight: 900;
  font-size: clamp(10px, 2.2cqmin, 12px); padding: 6px 9px; white-space: nowrap;
}
.ca-copy:active { transform: scale(0.94); }
.ca-links { display: flex; gap: 14px; margin-top: 6px; }
.ca-links a { color: #8fd0ff; font-size: clamp(11px, 2.3cqmin, 13px); text-decoration: none; font-weight: bold; }
.ca-links a:active { opacity: 0.7; }

/* ---------- leaderboard ---------- */
#leaderboard-screen { z-index: 30; }
.lb-list { list-style: none; text-align: left; margin: 8px 0 12px; max-height: 46cqh; overflow-y: auto; }
.lb-list li {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 9px;
  font-size: clamp(13px, 2.8cqmin, 17px);
}
.lb-list li:nth-child(odd) { background: rgba(255, 255, 255, 0.05); }
.lb-list .lb-rank { width: 1.9em; text-align: right; color: var(--gold); font-weight: 900; }
.lb-list .lb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-list .lb-score { font-weight: 900; color: #fff; }
.lb-list li.me { background: rgba(255, 210, 63, 0.18); outline: 1px solid rgba(255, 210, 63, 0.5); }
.lb-list li.lb-empty { justify-content: center; opacity: 0.7; }
.lb-scope { font-size: clamp(11px, 2.3cqmin, 13px); opacity: 0.7; margin-bottom: 12px; }

/* ---------- game-over score submit ---------- */
.lb-submit { display: flex; gap: 8px; justify-content: center; margin: 10px 0 4px; }
#lb-name {
  width: 46%; max-width: 180px; border-radius: 10px; border: 2px solid rgba(255, 255, 255, 0.3);
  background: rgba(0, 0, 0, 0.3); color: #fff; padding: 8px 12px; font-size: clamp(14px, 3cqmin, 17px);
  font-family: inherit; text-align: center;
}
#lb-name:focus { outline: none; border-color: var(--gold); }
.lb-result { font-size: clamp(12px, 2.6cqmin, 15px); color: #9affd0; min-height: 1.1em; margin-bottom: 8px; font-weight: bold; }

.coin-dot {
  display: inline-block;
  width: 14px; height: 14px;
  vertical-align: -2px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff6c4, #ffd23f 55%, #f0a500);
  box-shadow: inset 0 0 0 1.5px #b9760a;
}

.controls-help {
  margin-top: 22px;
  font-size: clamp(12px, 2.6cqmin, 15px);
  line-height: 1.9;
  opacity: 0.85;
}
.controls-help b { color: var(--gold); }
.best-line { margin-top: 16px; font-size: clamp(14px, 3cqmin, 18px); opacity: 0.8; }

.result-grid {
  display: flex;
  justify-content: center;
  gap: clamp(14px, 4cqmin, 30px);
  margin-bottom: 18px;
}
.result-grid > div { display: flex; flex-direction: column; gap: 4px; }
.r-label { font-size: clamp(11px, 2.4cqmin, 14px); text-transform: uppercase; letter-spacing: 1px; opacity: 0.7; }
.r-val { font-size: clamp(26px, 6cqmin, 40px); font-weight: 900; color: var(--gold); }

.new-best {
  color: var(--accent);
  font-weight: 900;
  font-size: clamp(16px, 3.6cqmin, 22px);
  margin-bottom: 16px;
  animation: blink 0.8s steps(2, jump-none) infinite;
}
@keyframes blink { 50% { opacity: 0.35; } }

#orientation-hint {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.6);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 20;
}
