:root {
  --bg: #050713;
  --panel: rgba(14, 18, 32, 0.9);
  --panel-2: rgba(23, 29, 50, 0.88);
  --line: rgba(255,255,255,0.12);
  --line-2: rgba(255,255,255,0.18);
  --text: #f8fbff;
  --muted: #96a2bc;
  --cyan: #55eaff;
  --violet: #a98cff;
  --pink: #ff65db;
  --green: #90ffbd;
  --gold: #ffe681;
  --orange: #ff9e5f;
  --danger: #ff6276;
  --shadow: 0 30px 92px rgba(0,0,0,0.52);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; overflow-x: hidden; }
body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 16% 3%, rgba(85,234,255,0.2), transparent 27%),
    radial-gradient(circle at 86% 10%, rgba(255,101,219,0.18), transparent 25%),
    radial-gradient(circle at 50% 105%, rgba(169,140,255,0.16), transparent 34%),
    linear-gradient(145deg, #050611, #0c1021 55%, #050611);
  user-select: none;
  touch-action: manipulation;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .35;
  background-image:
    linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(180deg, rgba(0,0,0,.7), transparent 75%);
}
button { font: inherit; border: 0; color: var(--text); cursor: pointer; }

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}
.phone-frame {
  width: min(100%, 520px);
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 34px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.09), rgba(255,255,255,0.025)),
    rgba(12, 16, 30, 0.86);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.06);
  backdrop-filter: blur(18px);
}
.app-topbar, .wallet-row, .bottom-nav, .dialog-head { display: flex; align-items: center; }
.app-topbar { justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.brand-block { min-width: 0; }
.eyebrow {
  margin: 0 0 4px;
  color: var(--cyan);
  font-size: 10px;
  font-weight: 950;
  letter-spacing: .18em;
}
h1, h2, h3, p { margin-top: 0; }
h1 {
  margin: 0;
  font-size: clamp(27px, 8vw, 43px);
  line-height: .88;
  letter-spacing: -.065em;
}
.wallet-row { gap: 8px; flex-shrink: 0; }
.wallet-pill, .best-pill {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.12);
  background: linear-gradient(180deg, rgba(255,255,255,.09), rgba(255,255,255,.045));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}
.wallet-pill { min-width: 88px; gap: 7px; padding: 0 13px; }
.wallet-pill span { color: var(--gold); font-size: 18px; text-shadow: 0 0 14px rgba(255,230,129,.42); }
.wallet-pill b, .best-pill b { font-size: 17px; }
.best-pill { min-width: 58px; flex-direction: column; padding: 5px 10px; gap: 0; }
.best-pill small { font-size: 8px; color: var(--muted); letter-spacing: .12em; font-weight: 950; }

.stage-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line-2);
  border-radius: 30px;
  background: #040614;
  box-shadow: inset 0 0 52px rgba(85,234,255,.08), 0 16px 38px rgba(0,0,0,.32);
}
.stage-card::before,
.stage-card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}
.stage-card::before {
  background:
    radial-gradient(circle at 50% -8%, rgba(85,234,255,.18), transparent 34%),
    radial-gradient(circle at 90% 12%, rgba(255,101,219,.13), transparent 27%);
}
.stage-card::after {
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.035), inset 0 18px 55px rgba(255,255,255,.025);
}
#gameCanvas {
  position: relative;
  z-index: 0;
  display: block;
  width: 100%;
  height: min(68vh, 690px);
  min-height: 535px;
  background: #040614;
}

.screen-layer {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 26px;
  background: linear-gradient(180deg, rgba(4,6,20,.32), rgba(4,6,20,.9));
  backdrop-filter: blur(4px);
}
.screen-layer.hidden { display: none; }
.hero-logo {
  width: 96px;
  height: 96px;
  display: grid;
  place-items: center;
  margin-bottom: 10px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(85,234,255,.28), transparent 70%);
  animation: floaty 2.2s ease-in-out infinite;
}
.hero-logo span {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  border: 11px solid var(--cyan);
  border-top-color: var(--pink);
  border-right-color: var(--violet);
  box-shadow: 0 0 30px rgba(85,234,255,.48), inset 0 0 18px rgba(255,255,255,.16);
}
.menu-layer h2, .result-layer h2 {
  margin: 4px 0 9px;
  font-size: clamp(38px, 10vw, 64px);
  line-height: .88;
  letter-spacing: -.075em;
}
.hero-copy {
  max-width: 322px;
  margin-bottom: 18px;
  color: #d2dcee;
  line-height: 1.48;
}
.big-play {
  position: relative;
  min-width: 205px;
  min-height: 54px;
  padding: 0 28px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--cyan), var(--violet) 54%, var(--pink));
  font-size: 15px;
  font-weight: 950;
  letter-spacing: .09em;
  box-shadow: 0 20px 38px rgba(85,234,255,.25), inset 0 1px 0 rgba(255,255,255,.2);
  transition: transform .15s ease, filter .15s ease;
}
.big-play:hover { transform: translateY(-1px); filter: brightness(1.04); }
.big-play:active { transform: scale(.97); }
.big-play.compact { min-width: 184px; min-height: 50px; margin-top: 8px; }
.soft-btn, .icon-btn, .danger-btn {
  border-radius: 17px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  transition: transform .15s ease, background .15s ease;
}
.soft-btn { min-width: 184px; min-height: 45px; margin-top: 10px; font-weight: 900; }
.icon-btn { width: 42px; height: 42px; font-size: 28px; line-height: 1; }
.soft-btn:active, .icon-btn:active, .danger-btn:active { transform: scale(.97); }

.quick-stats {
  width: min(100%, 360px);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin-top: 18px;
}
.quick-stats div, .result-grid div, .score-stack, .mission-teaser, .collection-item, .mission-card, .shop-card, .toggle-row {
  border: 1px solid rgba(255,255,255,.11);
  background: linear-gradient(180deg, rgba(255,255,255,.085), rgba(255,255,255,.045));
  border-radius: 19px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}
.quick-stats div { padding: 12px 7px; }
small { display: block; color: var(--muted); font-size: 10px; font-weight: 950; letter-spacing: .11em; text-transform: uppercase; }
.quick-stats b, .result-grid b, .collection-item b { display: block; margin-top: 4px; font-size: 21px; }
.mission-teaser {
  width: min(100%, 360px);
  margin-top: 10px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  background: linear-gradient(135deg, rgba(144,255,189,.12), rgba(85,234,255,.055));
}
.mission-teaser b { display: block; margin-top: 2px; font-size: 14px; }
.mission-teaser span { color: var(--green); font-size: 13px; font-weight: 950; }

.score-stack { width: min(100%, 270px); padding: 16px; margin: 0 0 10px; }
.score-stack b { display: block; font-size: 72px; line-height: .88; letter-spacing: -.08em; }
.score-stack p { margin: 8px 0 0; color: var(--green); font-size: 12px; font-weight: 850; }
.result-grid {
  width: min(100%, 392px);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}
.result-grid div { padding: 11px 5px; }
.run-missions { width: min(100%, 392px); display: grid; gap: 7px; margin: 3px 0 4px; }
.run-mission {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(255,255,255,.06);
  color: #dce6f7;
  font-size: 12px;
  font-weight: 820;
}
.run-mission span { color: var(--green); font-weight: 950; }
.tap-retry-line { margin: 9px 0 0; color: var(--muted); font-size: 12px; }

.bottom-nav {
  gap: 9px;
  margin-top: 13px;
}
.bottom-nav button {
  flex: 1;
  min-height: 52px;
  display: grid;
  place-items: center;
  gap: 1px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.11);
  background: linear-gradient(180deg, rgba(27,34,56,.92), rgba(18,23,42,.92));
  color: #dce6f7;
  font-size: 11px;
  font-weight: 950;
  letter-spacing: .04em;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.045);
  transition: transform .15s ease, border-color .15s ease;
}
.bottom-nav button span { color: var(--cyan); font-size: 17px; line-height: 1; }
.bottom-nav button:hover { transform: translateY(-1px); border-color: rgba(85,234,255,.25); }
.bottom-nav button:active { transform: scale(.97); }

.panel-dialog {
  width: min(94vw, 500px);
  max-height: min(82vh, 730px);
  overflow: auto;
  padding: 16px;
  color: var(--text);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(18,23,41,.98), rgba(12,16,30,.98));
  box-shadow: var(--shadow);
}
.panel-dialog::backdrop { background: rgba(0,0,0,.62); backdrop-filter: blur(7px); }
.dialog-head { justify-content: space-between; gap: 14px; margin-bottom: 15px; }
.panel-dialog h3 { margin: 0; font-size: 28px; letter-spacing: -.055em; }
.card-list, .mission-list, .settings-list { display: grid; gap: 10px; }
.shop-card {
  display: grid;
  grid-template-columns: 58px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
}
.skin-preview {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 9px solid var(--cyan);
  box-shadow: 0 0 20px rgba(85,234,255,.42);
}
.shop-info h4 { margin: 0 0 4px; font-size: 16px; }
.shop-info p { margin: 0; color: var(--muted); font-size: 12px; }
.shop-action {
  min-width: 82px;
  min-height: 38px;
  border-radius: 14px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 950;
  background: rgba(85,234,255,.14);
  border: 1px solid rgba(85,234,255,.25);
}
.shop-action.locked { background: rgba(255,255,255,.07); border-color: rgba(255,255,255,.11); }
.shop-action.equipped { background: linear-gradient(135deg, rgba(144,255,189,.28), rgba(85,234,255,.18)); color: var(--green); }

.mission-card { padding: 13px; }
.mission-top { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.mission-top h4 { margin: 2px 0 3px; font-size: 15px; }
.mission-top p { margin: 0; color: var(--muted); font-size: 12px; }
.reward-tag { flex-shrink: 0; color: var(--green); font-size: 12px; font-weight: 950; }
.progress-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255,255,255,.1);
  margin-top: 11px;
}
.progress-bar span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--cyan), var(--violet));
  box-shadow: 0 0 16px rgba(144,255,189,.34);
}
.mission-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 7px; color: var(--muted); font-size: 12px; }
.claim-badge { color: var(--gold); font-weight: 950; }
.claim-badge.done { color: var(--green); }

.collection-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.collection-item { text-align: center; padding: 13px; }
.toggle-row {
  min-height: 68px;
  padding: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.toggle-row span { text-align: left; }
.toggle-row b { display: block; font-size: 15px; }
.toggle-row small { margin-top: 4px; letter-spacing: 0; text-transform: none; font-weight: 720; }
.toggle-row input {
  width: 50px;
  height: 29px;
  appearance: none;
  border-radius: 999px;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.14);
  position: relative;
  flex-shrink: 0;
}
.toggle-row input::before {
  content: "";
  position: absolute;
  width: 21px;
  height: 21px;
  left: 4px;
  top: 3px;
  border-radius: 50%;
  background: #dce6f7;
  transition: transform .18s ease, background .18s ease;
}
.toggle-row input:checked { background: rgba(85,234,255,.22); border-color: rgba(85,234,255,.35); }
.toggle-row input:checked::before { transform: translateX(20px); background: var(--cyan); }
.danger-btn {
  width: 100%;
  min-height: 46px;
  margin-top: 12px;
  color: #ffd6dd;
  font-size: 12px;
  font-weight: 950;
  letter-spacing: .08em;
  border-color: rgba(255,98,118,.3);
}

@keyframes floaty { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

@media (max-width: 430px) {
  .app-shell { padding: 9px; }
  .phone-frame { padding: 12px; border-radius: 28px; }
  #gameCanvas { min-height: 515px; height: 67vh; }
  .wallet-row { gap: 6px; }
  .wallet-pill { min-width: 76px; padding: 0 10px; }
  .best-pill { min-width: 52px; padding-inline: 8px; }
  .screen-layer { padding: 22px; }
  .quick-stats { gap: 7px; }
  .quick-stats b, .result-grid b { font-size: 18px; }
  .result-grid { gap: 6px; }
  .result-grid div { padding: 10px 4px; }
  .bottom-nav { gap: 7px; }
  .bottom-nav button { min-height: 49px; font-size: 10px; }
  .shop-card { grid-template-columns: 54px 1fr; }
  .shop-action { grid-column: 1 / -1; width: 100%; }
}
