/* STACKED — premium minimal arcade aesthetic */

:root {
  --bg: #07090f;
  --panel: #10131f;
  --panel-2: #171b2b;
  --line: #242b40;
  --text: #f4f6ff;
  --muted: #8b93ad;
  --purple: #8b7bff;
  --cyan: #4fd6ff;
  --green: #6ee7b7;
  --amber: #ffd166;
  --pink: #ff5d8f;
  --radius: 18px;
  --font: 'Sora', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'Space Mono', ui-monospace, 'SFMono-Regular', monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: radial-gradient(1200px 800px at 50% -10%, #191b3f 0%, transparent 60%), var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow-x: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
}

button,
input {
  font-family: inherit;
  font-size: 16px;
  color: inherit;
}

button {
  cursor: pointer;
  border: 0;
  background: none;
  -webkit-user-select: none;
  user-select: none;
}

.shell {
  width: min(100%, 540px);
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(var(--safe-top) + 18px) 18px calc(var(--safe-bottom) + 22px);
  display: flex;
  flex-direction: column;
  position: relative;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  animation: rise 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.flexcenter {
  align-items: center;
  justify-content: center;
  gap: 14px;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* -------- hero / menu -------- */

.hero-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.logo {
  width: 74px;
  height: 74px;
  position: relative;
  margin-bottom: 4px;
}

.logo-block {
  position: absolute;
  left: 9px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--purple), #5f44e8);
  box-shadow: 0 8px 22px rgba(139, 123, 255, 0.35);
}

.logo-block.b3 {
  bottom: 6px;
  width: calc(100% - 18px);
  height: 19px;
}
.logo-block.b2 {
  bottom: 25px;
  width: 38px;
  height: 19px;
}
.logo-block.b1 {
  bottom: 44px;
  width: 24px;
  height: 19px;
}

.wordmark {
  margin: 0;
  font-size: clamp(46px, 14vw, 64px);
  font-weight: 800;
  letter-spacing: -0.06em;
  line-height: 1;
  background: linear-gradient(130deg, #ffffff 0%, #c9d1ff 45%, var(--purple) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  margin: 0 0 14px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.card {
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01));
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 6px);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
  padding: 20px;
}

.name-card {
  width: 100%;
}

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.name {
  width: 100%;
  background: #0a0d16;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: #fff;
  padding: 15px 16px;
  font-size: 17px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.name::placeholder {
  color: #4a5268;
}

.name:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 4px rgba(139, 123, 255, 0.18);
}

.hint {
  margin: 9px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.primary {
  width: 100%;
  margin-top: 14px;
  padding: 17px 20px;
  border-radius: 15px;
  font-weight: 800;
  font-size: 17px;
  letter-spacing: 0.02em;
  color: #fff;
  background: linear-gradient(135deg, var(--purple) 0%, #5d78ff 100%);
  box-shadow: 0 14px 38px rgba(125, 102, 255, 0.38);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

.primary:active {
  transform: translateY(1.5px) scale(0.99);
  box-shadow: 0 8px 20px rgba(125, 102, 255, 0.3);
}

.primary.big {
  padding: 18px 20px;
  font-size: 19px;
}

button:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 3px;
  border-radius: 8px;
}

.secondary {
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 14px;
  padding: 14px 16px;
  font-weight: 700;
  transition: background 0.12s;
}

.secondary:active {
  background: rgba(255, 255, 255, 0.09);
}

.secondary.wide {
  width: 100%;
}

.linkish {
  color: var(--muted);
  font-size: 14.5px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 8px;
}

.linkish:hover {
  color: var(--text);
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  width: 100%;
  margin-top: 4px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: rgba(255, 255, 255, 0.028);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 14px;
  padding: 12px 14px;
}

.stat-label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
}

.stat-value {
  font-size: 21px;
  font-weight: 800;
  font-family: var(--mono);
}

.footer-actions {
  display: flex;
  justify-content: center;
  margin-top: 6px;
}

/* -------- hamburger menu -------- */

.burger {
  position: absolute;
  top: calc(var(--safe-top) + 12px);
  right: 18px;
  z-index: 20;
  font-size: 20px;
}

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 18, 0.5);
  backdrop-filter: blur(2px);
  z-index: 30;
}

.scrim[hidden],
.drawer[hidden] {
  display: none;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(78vw, 300px);
  background: linear-gradient(200deg, #1c2240, #14182b);
  border-left: 1px solid var(--line);
  box-shadow: -18px 0 50px rgba(0, 0, 0, 0.45);
  z-index: 40;
  display: flex;
  flex-direction: column;
  padding: var(--safe-top) 14px calc(var(--safe-bottom) + 16px);
  animation: drawer-in 0.2s ease-out;
}

@keyframes drawer-in {
  from {
    transform: translateX(16px);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.drawer-title {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.2em;
  color: var(--muted);
}

.drawer-item {
  display: block;
  width: 100%;
  text-align: left;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  padding: 14px 16px;
  margin-bottom: 8px;
  cursor: pointer;
}

.drawer-item:active {
  background: rgba(255, 255, 255, 0.08);
}

.drawer-how {
  margin: 2px 4px 8px;
  border-left: 3px solid var(--purple);
  padding: 4px 12px;
}

.drawer-how p {
  margin: 6px 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.drawer-foot {
  margin: auto 4px 0;
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

/* -------- share & earn -------- */

.share-card {
  text-align: center;
  background: linear-gradient(170deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.012));
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 8px);
  padding: 22px 18px;
}

.share-big {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 800;
}

.share-big b {
  color: var(--amber);
}

.share-sub {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--muted);
}

.share-steps {
  text-align: left;
  margin: 0 0 16px;
  padding: 0 8px 0 22px;
  display: grid;
  gap: 6px;
  font-size: 13.5px;
  color: var(--text);
}

.share-card .name {
  display: block;
  width: 100%;
  margin: 12px 0 10px;
}

.share-card .mb {
  margin: 12px 0 0;
}

/* -------- game screen -------- */

.game-shell {
  padding-bottom: calc(var(--safe-bottom) + 10px);
}

.game-screen {
  justify-content: flex-start;
  gap: 0;
}

.hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  padding: 4px 4px 12px;
}

.hud-side {
  display: flex;
  flex-direction: column;
}

.hud-side.right {
  align-items: flex-end;
}

.hud-label {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--muted);
}

.hud-value {
  font-family: var(--mono);
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.hud-value.pop {
  animation: popnum 0.18s ease;
}

@keyframes popnum {
  50% {
    transform: scale(1.14);
    color: var(--amber);
  }
}

.hud-streak {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 13px;
  color: transparent;
  transition: color 0.2s;
  padding-bottom: 2px;
}

.hud-streak.on {
  color: var(--amber);
  animation: streakpulse 0.8s ease infinite;
}

@keyframes streakpulse {
  50% {
    opacity: 0.6;
  }
}

.canvas-wrap {
  width: 100%;
  aspect-ratio: 360 / 560;
  max-height: min(62dvh, 540px);
  margin: 0 auto;
  touch-action: none;
}

.canvas {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 20px;
  background: #0a0d16;
  box-shadow: inset 0 0 0 1px var(--line), 0 24px 70px rgba(0, 0, 0, 0.45);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.hint {
  text-align: center;
}

/* -------- game over -------- */

.over-screen {
  justify-content: center;
}

.over-card {
  text-align: center;
  background: linear-gradient(170deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.012));
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 8px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  padding: 26px 22px 22px;
}

.over-eyebrow {
  margin: 0 0 6px;
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--amber);
}

.final-score {
  font-family: var(--mono);
  font-size: 76px;
  font-weight: 700;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.final-label {
  margin: 0 0 16px;
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.over-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.over-stat {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 13px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.over-stat span {
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 700;
}

.over-stat b {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 700;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.undo-actions {
  margin-top: 10px;
}

/* -------- in-game continue (revive) -------- */

.revive-area {
  margin: 0 0 16px;
  padding: 12px 12px 10px;
  background: rgba(93, 173, 226, 0.06);
  border: 1px dashed rgba(93, 173, 226, 0.4);
  border-radius: 15px;
}

.revive-title {
  margin: 0 0 10px;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: var(--muted);
}

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

.revive-row .rev {
  margin: 0;
  padding: 12px 6px;
  font-weight: 700;
  font-size: 13.5px;
}

.rev.dim,
.rev:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.revive-hint {
  margin: 10px 0 0;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--amber);
  text-align: center;
}

.revive-balance {
  margin: 10px 0 0;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
}

/* -------- streak -------- */

.streak-chip {
  margin: 8px 0 4px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--amber, #f5c04d);
  text-align: center;
}

.shop-hint {
  margin: 8px 0 0;
  font-size: 11px;
  letter-spacing: 0.04em;
}

/* -------- leaderboard -------- */

.board-head {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  margin-bottom: 14px;
}

.board-title {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
}

.iconbtn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 13px;
  font-size: 19px;
}

.my-rank {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: linear-gradient(135deg, rgba(139, 123, 255, 0.16), rgba(79, 214, 255, 0.07));
  border: 1px solid rgba(139, 123, 255, 0.35);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 12px;
}

.my-rank.podium {
  border-color: var(--amber);
  background: linear-gradient(135deg, rgba(255, 209, 102, 0.14), rgba(139, 123, 255, 0.08));
}

.mr-rank {
  font-family: var(--mono);
  font-size: 34px;
  font-weight: 700;
}

.mr-label {
  font-size: 11.5px;
  letter-spacing: 0.18em;
  color: var(--muted);
  font-weight: 800;
}

.mr-score {
  font-size: 14px;
  color: var(--text);
  font-weight: 600;
}

.lb-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--line);
  border-radius: 16px;
  max-height: 62dvh;
  overflow-y: auto;
}

.lb-row {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  align-items: center;
  gap: 6px;
  padding: 11px 14px;
  border-radius: 12px;
}

.lb-row + .lb-row {
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.lb-row.me {
  background: linear-gradient(90deg, rgba(139, 123, 255, 0.18), transparent);
  box-shadow: inset 3px 0 0 var(--purple);
}

.lb-medal {
  font-size: 20px;
  text-align: center;
}

.lb-pos {
  font-family: var(--mono);
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.lb-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-name-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
}

.lb-sup {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  border: 1px solid var(--gold, #d98a12);
  border-radius: 999px;
  color: var(--gold, #f5c04d);
  background: rgba(245, 166, 35, 0.08);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.my-rank .lb-sup {
  margin-top: 6px;
}

.lb-score {
  font-family: var(--mono);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.lb-empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
}

.lb-empty.err {
  color: var(--pink);
}

.lb-done {
  margin-left: 6px;
  font-size: 13px;
}

.supporter-badge {
  margin: 10px 0 2px;
  padding: 10px 14px;
  border: 1px solid var(--gold, #d98a12);
  border-radius: 13px;
  color: var(--gold, #f5c04d);
  background: rgba(245, 166, 35, 0.08);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

/* -------- shop -------- */

#shop {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.diamonds-pill {
  background: rgba(93, 173, 226, 0.14);
  border: 1px solid rgba(93, 173, 226, 0.4);
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.balance-line {
  font-size: 22px;
  font-weight: 800;
  margin: 6px 0 2px;
  color: var(--text);
}

.shop-sep {
  margin: 14px 2px 4px;
  font-size: 11px;
  letter-spacing: 0.14em;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
}

.shop-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--line);
}

.shop-name {
  font-weight: 700;
}

.shop-desc {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
}

.buy {
  min-width: 88px;
}

.buy.dim {
  opacity: 0.5;
}

.buy.owned {
  opacity: 0.7;
}

#diamond-value {
  font-variant-numeric: tabular-nums;
}

/* -------- toast -------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 24px);
  transform: translate(-50%, 20px);
  background: rgba(22, 26, 40, 0.95);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 13px;
  font-size: 14.5px;
  font-weight: 600;
  max-width: min(90vw, 420px);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s, transform 0.22s;
  z-index: 60;
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.45);
}

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

.toast.err {
  border-color: rgba(255, 93, 143, 0.5);
}

.toast.ach {
  border-color: rgba(255, 209, 102, 0.5);
  background: rgba(40, 34, 12, 0.95);
}

/* -------- spinner -------- */

.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--purple);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* -------- responsive ---------- */

@media (min-width: 560px) {
  .canvas-wrap {
    aspect-ratio: 360 / 520;
    max-height: 66dvh;
  }
}

@media (max-height: 700px) {
  .final-score {
    font-size: 60px;
  }
  .over-card {
    padding: 20px 18px 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
  }
  .screen {
    animation: none;
  }
}

@media (display-mode: standalone) {
  body {
    padding-top: var(--safe-top);
  }
}