:root {
  color-scheme: dark;
  --bg-1: #120922;
  --bg-2: #241250;
  --bg-3: #461673;
  --pink: #ff63c7;
  --pink-2: #ff9be4;
  --cyan: #55e8ff;
  --yellow: #ffe668;
  --mint: #84ffcc;
  --purple: #9e70ff;
  --ink: #ffffff;
  --muted: rgba(255, 255, 255, .72);
  --glass: rgba(255, 255, 255, .13);
  --line: rgba(255, 255, 255, .22);
  --shadow: 0 22px 60px rgba(0, 0, 0, .38);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  touch-action: none;
}

body {
  min-height: 100svh;
  font-family: Inter, ui-rounded, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 10%, rgba(255, 99, 199, .46), transparent 28%),
    radial-gradient(circle at 78% 16%, rgba(85, 232, 255, .38), transparent 27%),
    radial-gradient(circle at 50% 88%, rgba(255, 230, 104, .18), transparent 32%),
    linear-gradient(160deg, var(--bg-1), var(--bg-2) 45%, var(--bg-3));
  display: grid;
  place-items: center;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: -20%;
  pointer-events: none;
  background-image:
    radial-gradient(circle, rgba(255,255,255,.4) 0 1px, transparent 1px),
    radial-gradient(circle, rgba(255,255,255,.25) 0 1px, transparent 1px);
  background-size: 42px 42px, 78px 78px;
  animation: drift 22s linear infinite;
  opacity: .55;
}

body::after {
  filter: blur(1px);
  animation-duration: 34s;
  animation-direction: reverse;
  opacity: .28;
}

@keyframes drift {
  from { transform: translate3d(0, 0, 0) rotate(0deg); }
  to { transform: translate3d(48px, -62px, 0) rotate(2deg); }
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  cursor: pointer;
}

button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.phone-shell {
  width: min(100vw, 520px);
  height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
  padding: max(10px, env(safe-area-inset-top, 0px)) 10px max(10px, var(--safe-bottom));
  position: relative;
  z-index: 1;
}

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

.brand-pill,
.icon-btn,
.soft-btn,
.main-action,
.primary-btn,
.secondary-btn,
.ghost-btn {
  border: 1px solid var(--line);
  box-shadow: 0 12px 28px rgba(0, 0, 0, .2), inset 0 1px rgba(255,255,255,.18);
  backdrop-filter: blur(14px);
}

.brand-pill {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 13px;
  border-radius: 999px;
  background: rgba(255,255,255,.12);
  font-weight: 850;
  letter-spacing: .2px;
}

.pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--mint);
  box-shadow: 0 0 20px var(--mint);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  50% { transform: scale(1.35); opacity: .62; }
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 16px;
  background: rgba(255,255,255,.14);
}

.icon-btn.dark {
  background: rgba(22, 14, 44, .72);
}

.game-card {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 30px;
  background: linear-gradient(180deg, rgba(255,255,255,.18), rgba(255,255,255,.08));
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  overflow: hidden;
}

.hud {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.hud-item,
.mission-strip,
.result-stats > div,
.story-card,
.feature-grid article,
.unlock-box,
.outfit-card {
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(12, 8, 32, .48);
  box-shadow: inset 0 1px rgba(255,255,255,.12);
}

.hud-item {
  min-width: 0;
  padding: 8px 6px;
  border-radius: 17px;
  text-align: center;
}

.hud-item span,
.mission-strip small,
.result-stats span,
.outfit-card small,
.tiny-note {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
}

.hud-item strong {
  display: block;
  margin-top: 3px;
  font-size: clamp(15px, 3.8vw, 18px);
  white-space: nowrap;
}

.mission-strip {
  display: grid;
  grid-template-columns: 1.2fr .9fr;
  gap: 8px;
  align-items: center;
  padding: 9px;
  border-radius: 20px;
}

.mission-strip strong {
  display: block;
  font-size: 13px;
  line-height: 1.2;
}

.meter-wrap {
  min-width: 0;
}

#specialLabel {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 4px;
}

.meter {
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255,255,255,.16);
}

.meter i {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--pink), var(--yellow));
  box-shadow: 0 0 16px rgba(255,99,199,.8);
  transition: width .15s ease;
}

.canvas-wrap {
  position: relative;
  min-height: 0;
  border-radius: 26px;
  overflow: hidden;
  background: #100b26;
  border: 1px solid rgba(255,255,255,.18);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.06), 0 18px 50px rgba(0,0,0,.24);
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.gesture-hint {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  padding: 9px 13px;
  border-radius: 999px;
  color: rgba(255,255,255,.92);
  background: rgba(0,0,0,.28);
  border: 1px solid rgba(255,255,255,.18);
  backdrop-filter: blur(12px);
  font-weight: 800;
  white-space: nowrap;
  opacity: .9;
  transition: opacity .35s ease, transform .35s ease;
}

.gesture-hint.hide {
  opacity: 0;
  transform: translateX(-50%) translateY(10px);
}

.bottom-actions {
  display: grid;
  grid-template-columns: 1fr 1.3fr 1fr;
  gap: 8px;
}

.soft-btn,
.main-action,
.primary-btn,
.secondary-btn,
.ghost-btn {
  min-height: 48px;
  border-radius: 18px;
  font-weight: 900;
}

.soft-btn {
  background: rgba(255,255,255,.12);
}

.main-action,
.primary-btn {
  background: linear-gradient(135deg, #ff63c7, #8b73ff 52%, #55e8ff);
  text-shadow: 0 1px rgba(0,0,0,.25);
}

.secondary-btn {
  background: linear-gradient(135deg, rgba(255,255,255,.18), rgba(255,255,255,.08));
}

.ghost-btn {
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.86);
}

.ghost-btn.danger {
  color: #ffd1d1;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none;
  align-items: center;
  justify-content: center;
  padding: max(18px, env(safe-area-inset-top, 0px)) 16px max(18px, env(safe-area-inset-bottom, 0px));
  background: radial-gradient(circle at 50% 18%, rgba(255, 99, 199, .28), transparent 34%), rgba(10, 6, 24, .72);
  backdrop-filter: blur(16px);
}

.overlay.active {
  display: flex;
}

.panel {
  width: min(100%, 480px);
  max-height: calc(100svh - 26px);
  overflow: auto;
  border-radius: 30px;
  padding: 22px;
  border: 1px solid rgba(255,255,255,.22);
  background:
    linear-gradient(180deg, rgba(255,255,255,.2), rgba(255,255,255,.1)),
    linear-gradient(150deg, rgba(36,18,80,.96), rgba(20,10,42,.98));
  box-shadow: var(--shadow);
}

.hero-panel {
  text-align: center;
}

.compact-panel {
  text-align: center;
}

.sparkle-row {
  font-size: 26px;
  letter-spacing: 6px;
  filter: drop-shadow(0 0 18px rgba(255,255,255,.34));
}

.kicker {
  margin: 8px 0 4px;
  color: var(--mint);
  font-size: 13px;
  font-weight: 1000;
  letter-spacing: .16em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(32px, 8vw, 48px);
  line-height: .96;
  text-wrap: balance;
}

h2 {
  margin-bottom: 10px;
  font-size: clamp(26px, 7vw, 36px);
}

.lead {
  color: var(--muted);
  line-height: 1.42;
}

.lead.small {
  margin-bottom: 12px;
}

.story-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  padding: 13px;
  margin: 16px 0;
  border-radius: 22px;
  text-align: left;
}

.story-card p {
  margin: 4px 0 0;
  color: rgba(255,255,255,.78);
  line-height: 1.35;
}

.mascot {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(255,230,104,.24), rgba(255,99,199,.24));
  font-size: 34px;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
  margin: 16px 0;
}

.feature-grid article {
  padding: 12px 8px;
  border-radius: 20px;
}

.feature-grid article span {
  display: block;
  font-size: 25px;
}

.feature-grid article strong {
  display: block;
  margin: 4px 0 2px;
}

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

.menu-row.smaller {
  grid-template-columns: 1fr 1fr;
  margin-top: 8px;
}

.tiny-note {
  margin: 12px 0 0;
}

.result-emoji {
  font-size: 52px;
  margin-bottom: 4px;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin: 14px 0;
}

.result-stats > div {
  border-radius: 18px;
  padding: 10px 6px;
}

.result-stats strong {
  display: block;
  margin-top: 4px;
  font-size: 20px;
}

.unlock-box {
  margin: 10px 0 4px;
  padding: 12px;
  border-radius: 18px;
  color: #fff7c4;
}

.hidden {
  display: none !important;
}

.shop-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.outfit-list {
  display: grid;
  gap: 10px;
}

.outfit-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: 20px;
  text-align: left;
}

.outfit-preview {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 18px;
  font-size: 28px;
  background: linear-gradient(135deg, rgba(255,255,255,.20), rgba(255,255,255,.08));
}

.outfit-card strong {
  display: block;
}

.outfit-card button {
  min-width: 92px;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 15px;
  background: rgba(255,255,255,.13);
  border: 1px solid rgba(255,255,255,.2);
  font-weight: 900;
}

.toast-stack {
  position: fixed;
  top: max(14px, env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: grid;
  gap: 8px;
  pointer-events: none;
  width: min(92vw, 420px);
}

.toast {
  padding: 12px 14px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.24);
  background: rgba(18, 9, 34, .86);
  box-shadow: 0 14px 34px rgba(0,0,0,.32);
  backdrop-filter: blur(14px);
  animation: toastIn .24s ease both;
  font-weight: 800;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-10px) scale(.96); }
}

@media (min-width: 650px) {
  .phone-shell {
    height: min(100svh, 900px);
    border-radius: 36px;
  }
}

@media (max-height: 720px) {
  .panel {
    padding: 18px;
  }

  .feature-grid {
    display: none;
  }

  h1 {
    font-size: 32px;
  }

  .story-card {
    margin: 10px 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}
