:root {
  color-scheme: dark;
  --ink: #f7f8ff;
  --muted: #a9afd3;
  --panel: rgba(17, 19, 54, 0.76);
  --panel-line: rgba(151, 161, 255, 0.16);
  --cyan: #5af2e1;
  --violet: #8a7dff;
  --pink: #ff79c6;
  --warning: #ffb86b;
  --shadow: 0 24px 70px rgba(1, 2, 18, 0.45);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  font-family: Inter, Pretendard, "Noto Sans KR", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 18% 12%, rgba(91, 74, 255, 0.23), transparent 28rem),
    radial-gradient(circle at 85% 78%, rgba(21, 198, 184, 0.15), transparent 30rem),
    linear-gradient(145deg, #070818 0%, #0b0d28 48%, #08091d 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.5;
  background-image:
    radial-gradient(circle, rgba(255,255,255,.95) 0 1px, transparent 1.5px),
    radial-gradient(circle, rgba(118,255,242,.7) 0 1px, transparent 1.5px);
  background-position: 0 0, 37px 53px;
  background-size: 113px 113px, 173px 173px;
  mask-image: linear-gradient(to bottom, black, transparent 88%);
}

button { font: inherit; }

.app-shell {
  width: min(1480px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 20px;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  margin-bottom: 24px;
}

.brand { display: flex; align-items: center; gap: 14px; }
.brand h1 { margin: -1px 0 0; font-size: clamp(24px, 3vw, 38px); letter-spacing: -0.07em; }
.eyebrow, .panel-label, .overlay-kicker {
  margin: 0;
  color: var(--cyan);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .18em;
}

.brand-orbit {
  position: relative;
  display: grid;
  width: 50px;
  height: 50px;
  place-items: center;
  border: 1px solid rgba(90, 242, 225, .42);
  border-radius: 50%;
  transform: rotate(-18deg);
}
.brand-orbit::before { content: ""; width: 19px; height: 19px; border-radius: 50%; background: linear-gradient(135deg, #8c7bff, #4fe4d8); box-shadow: 0 0 22px rgba(90,242,225,.55); }
.brand-orbit i { position: absolute; top: 3px; width: 7px; height: 7px; border-radius: 50%; background: #fff; box-shadow: 0 0 8px #fff; }

.score-cluster { display: flex; align-items: stretch; gap: 10px; }
.score-card {
  min-width: 112px;
  padding: 10px 18px;
  text-align: center;
  border: 1px solid var(--panel-line);
  border-radius: 17px;
  background: rgba(13, 15, 45, .72);
  box-shadow: inset 0 1px rgba(255,255,255,.04);
}
.score-card span { display: block; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .08em; }
.score-card strong { display: block; margin-top: 2px; font-size: 26px; line-height: 1; font-variant-numeric: tabular-nums; }
.best-card strong { color: #ffd68a; }

.icon-button {
  justify-self: end;
  width: 48px;
  height: 48px;
  color: var(--cyan);
  font-size: 23px;
  cursor: pointer;
  border: 1px solid var(--panel-line);
  border-radius: 15px;
  background: rgba(13,15,45,.72);
  transition: .2s ease;
}
.icon-button:hover { border-color: rgba(90,242,225,.5); transform: translateY(-2px); }
.icon-button[aria-pressed="false"] { color: var(--muted); }

.game-layout {
  display: grid;
  grid-template-columns: minmax(190px, 235px) minmax(420px, 820px) minmax(190px, 235px);
  justify-content: center;
  align-items: center;
  gap: clamp(16px, 2.2vw, 34px);
}

.mission-card, .queue-card {
  padding: 24px;
  border: 1px solid var(--panel-line);
  border-radius: 26px;
  background: linear-gradient(155deg, rgba(23, 25, 68, .88), rgba(12, 14, 44, .72));
  box-shadow: var(--shadow), inset 0 1px rgba(255,255,255,.05);
  backdrop-filter: blur(18px);
}

.mission-card h2 { margin: 12px 0 25px; font-size: 21px; line-height: 1.35; letter-spacing: -.045em; }
.mission-card ol { display: grid; gap: 18px; margin: 0; padding: 0; list-style: none; }
.mission-card li { color: #c9cdec; font-size: 13px; line-height: 1.45; }
.mission-card li span { display: block; margin-bottom: 4px; color: var(--violet); font-size: 10px; font-weight: 900; letter-spacing: .12em; }
.danger-note { display: flex; gap: 9px; align-items: center; margin-top: 28px; padding-top: 18px; color: #ffcf9d; font-size: 11px; line-height: 1.45; border-top: 1px solid var(--panel-line); }
.danger-dot { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; background: var(--warning); box-shadow: 0 0 12px var(--warning); }

.game-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid rgba(129, 140, 255, .25);
  border-radius: 50%;
  background: #080a25;
  box-shadow: 0 0 0 9px rgba(43, 48, 112, .12), 0 35px 100px rgba(0,0,20,.58), inset 0 0 85px rgba(77,60,197,.22);
}

#gameCanvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }

.stage-hud { position: absolute; inset: 0; pointer-events: none; }
.status-pill {
  position: absolute;
  left: 50%;
  bottom: 8%;
  padding: 8px 14px;
  color: #bfc5eb;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  border: 1px solid rgba(151,161,255,.2);
  border-radius: 999px;
  background: rgba(8,10,37,.66);
  transform: translateX(-50%);
  backdrop-filter: blur(10px);
}
.power-meter {
  position: absolute;
  left: 50%;
  bottom: 13.5%;
  display: grid;
  grid-template-columns: auto minmax(90px, 150px) 38px;
  align-items: center;
  gap: 9px;
  width: min(285px, 64%);
  padding: 9px 12px;
  border: 1px solid rgba(151,161,255,.22);
  border-radius: 14px;
  background: rgba(7,9,34,.72);
  transform: translateX(-50%);
  backdrop-filter: blur(10px);
}
.power-meter > span { color: var(--cyan); font-size: 9px; font-weight: 950; letter-spacing: .13em; }
.power-meter strong { color: #fff4b0; font-size: 11px; font-variant-numeric: tabular-nums; text-align: right; }
.power-track { height: 7px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.1); }
.power-track i { display: block; width: 35%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #5af2e1, #ffe16d, #ff7a9f); box-shadow: 0 0 13px rgba(90,242,225,.5); transition: width .04s linear; }
.power-meter.charging { border-color: rgba(90,242,225,.58); box-shadow: 0 0 24px rgba(90,242,225,.14); }
.combo-badge {
  position: absolute;
  top: 19%;
  left: 50%;
  padding: 8px 13px;
  color: #10122b;
  font-size: 12px;
  font-weight: 1000;
  border-radius: 999px;
  background: var(--cyan);
  box-shadow: 0 0 25px rgba(90,242,225,.48);
  opacity: 0;
  transform: translate(-50%, 12px) scale(.85);
}
.combo-badge.show { animation: combo-pop .85s ease; }
@keyframes combo-pop { 15%, 65% { opacity: 1; transform: translate(-50%, 0) scale(1); } 100% { opacity: 0; transform: translate(-50%, -16px) scale(.92); } }

.screen-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 10%;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle, rgba(18,20,63,.65), rgba(5,6,25,.93));
  transition: opacity .28s ease;
  backdrop-filter: blur(8px);
}
.screen-overlay.active { pointer-events: auto; opacity: 1; }
.overlay-card { width: min(410px, 100%); text-align: center; }
.overlay-card h2 { margin: 18px 0 12px; font-size: clamp(27px, 4vw, 45px); line-height: 1.12; letter-spacing: -.065em; }
.overlay-card > p:not(.overlay-kicker) { margin: 0 auto 24px; color: #bbc0e0; font-size: 14px; line-height: 1.7; }
.overlay-kicker { color: #8175ff; }
.hero-planet { position: relative; display: grid; width: 120px; height: 120px; margin: 24px auto 5px; place-items: center; }
.hero-face { position: relative; z-index: 2; display: grid; width: 82px; height: 82px; place-items: center; font-size: 48px; border-radius: 50%; background: radial-gradient(circle at 35% 25%, #77dfff, #1768bf 55%, #082e6f); box-shadow: 0 0 35px rgba(67,190,255,.4), inset -8px -8px 20px rgba(0,0,0,.22); }
.hero-ring { position: absolute; width: 116px; height: 34px; border: 7px solid rgba(160,146,255,.68); border-radius: 50%; transform: rotate(-17deg); box-shadow: 0 0 20px rgba(139,125,255,.3); }

.primary-button {
  display: inline-flex;
  min-width: 190px;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 15px 23px;
  color: #0c0e2a;
  font-weight: 950;
  cursor: pointer;
  border: 0;
  border-radius: 15px;
  background: linear-gradient(135deg, #65f3e4, #8ef4be);
  box-shadow: 0 12px 30px rgba(61,225,204,.28);
  transition: .2s ease;
}
.primary-button:hover { transform: translateY(-3px); box-shadow: 0 17px 35px rgba(61,225,204,.36); }
.overlay-card.compact h2 { font-size: clamp(28px, 4vw, 40px); }
.result-icon { margin: 22px auto 0; font-size: 58px; filter: drop-shadow(0 0 18px rgba(120,104,255,.65)); }
.result-score { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 20px 0 14px; }
.result-score span { color: var(--muted); font-size: 13px; }
.result-score strong { color: var(--cyan); font-size: 38px; }

.queue-card { text-align: center; }
.next-main { margin: 15px 0 18px; padding: 18px 10px; border-radius: 20px; background: rgba(7,9,34,.5); }
.next-main > span, .queue-item span, .merge-guide > span { display: block; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .08em; }
.next-main strong { display: block; margin-top: 8px; font-size: 13px; }
.planet-preview, .queue-item i, .merge-planets i { position: relative; display: block; border-radius: 50%; box-shadow: inset -6px -7px 11px rgba(0,0,0,.22), 0 0 20px var(--glow, rgba(255,255,255,.2)); }
.planet-preview[data-level="5"]::after, .queue-item i[data-level="5"]::after, .merge-planets i[data-level="5"]::after { content: ""; position: absolute; z-index: -1; left: 50%; top: 50%; width: 150%; height: 35%; border: 3px solid rgba(244,213,154,.85); border-radius: 50%; transform: translate(-50%,-50%) rotate(-14deg); }
.planet-preview { width: 72px; height: 72px; margin: 12px auto; }
.queue-list { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.queue-item { padding: 12px 6px; border: 1px solid var(--panel-line); border-radius: 15px; }
.queue-item i { width: 32px; height: 32px; margin: 8px auto 0; }
.merge-guide { margin-top: 21px; padding-top: 18px; border-top: 1px solid var(--panel-line); }
.merge-planets { display: flex; align-items: center; justify-content: space-between; gap: 3px; margin-top: 12px; }
.merge-planets i { width: 17px; height: 17px; box-shadow: inset -3px -3px 5px rgba(0,0,0,.2); }

footer { display: flex; justify-content: center; gap: 28px; padding-top: 18px; color: #858caf; font-size: 11px; }
footer p { margin: 0; }
kbd { padding: 3px 6px; color: #bac1e8; font-family: inherit; border: 1px solid var(--panel-line); border-radius: 5px; background: rgba(20,23,62,.6); }
.mobile-hint { display: none; }

@media (max-width: 1100px) {
  .game-layout { grid-template-columns: minmax(0, 760px) 190px; }
  .mission-card { display: none; }
}

@media (max-width: 780px) {
  .app-shell { width: min(100% - 20px, 640px); padding-top: 14px; }
  .topbar { grid-template-columns: 1fr auto; gap: 10px; margin-bottom: 14px; }
  .score-cluster { grid-column: 1 / -1; grid-row: 2; width: 100%; }
  .score-card { flex: 1; min-width: 0; padding: 8px 12px; }
  .score-card strong { font-size: 22px; }
  .icon-button { grid-column: 2; grid-row: 1; }
  .game-layout { display: flex; flex-direction: column; }
  .game-stage { order: 1; }
  .queue-card { order: 2; width: 100%; padding: 14px 18px; }
  .queue-card .panel-label, .queue-list, .merge-guide { display: none; }
  .next-main { display: flex; align-items: center; gap: 12px; margin: 0; padding: 0; background: transparent; text-align: left; }
  .next-main .planet-preview { width: 43px; height: 43px; margin: 0; }
  .next-main strong { margin: 0; }
  .screen-overlay { padding: 9%; }
  .hero-planet { margin-top: 15px; }
  footer { padding: 6px 0 16px; }
  footer p:first-child { display: none; }
  .mobile-hint { display: block; }
}

@media (max-width: 460px) {
  .brand-orbit { width: 42px; height: 42px; }
  .brand h1 { font-size: 25px; }
  .eyebrow { font-size: 9px; }
  .icon-button { width: 42px; height: 42px; }
  .game-stage { border-radius: 28px; }
  .overlay-card h2 { font-size: 29px; }
  .overlay-card > p:not(.overlay-kicker) { font-size: 12px; }
  .hero-planet { width: 95px; height: 95px; }
  .hero-face { width: 67px; height: 67px; font-size: 39px; }
  .hero-ring { width: 93px; height: 28px; border-width: 5px; }
  .status-pill { bottom: 5%; }
  .power-meter { bottom: 12%; grid-template-columns: auto 1fr 34px; width: 76%; padding: 7px 10px; }
}

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