@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@500;600;700&family=Nunito:wght@600;700;800&display=swap');

:root {
  color-scheme: dark;
  --ink: #fff8ff;
  --muted: #c7b8e5;
  --panel: rgba(36, 16, 74, 0.72);
  --panel-strong: rgba(29, 11, 64, 0.92);
  --stroke: rgba(255, 255, 255, 0.13);
  --pink: #ff4fc8;
  --purple: #9858ff;
  --cyan: #46e9ff;
  --gold: #ffd84d;
  font-family: 'Nunito', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: #100326; }

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% 22%, rgba(125, 53, 238, 0.28), transparent 32%),
    radial-gradient(circle at 12% 75%, rgba(39, 202, 255, 0.13), transparent 25%),
    linear-gradient(145deg, #0d0320 0%, #190735 48%, #09021c 100%);
}
.auth-page { min-height:100vh; display:grid; place-items:center; padding:20px; }

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.5;
  background-image:
    radial-gradient(circle, rgba(255,255,255,.9) 0 1px, transparent 1.5px),
    radial-gradient(circle, rgba(125,215,255,.7) 0 1px, transparent 1.5px);
  background-position: 0 0, 47px 83px;
  background-size: 113px 113px, 157px 157px;
}

.aurora {
  position: fixed;
  width: 44vw;
  height: 44vw;
  border-radius: 50%;
  filter: blur(80px);
  opacity: .18;
  pointer-events: none;
}

.aurora-a { top: -18vw; right: -8vw; background: #ff3dcc; }
.aurora-b { bottom: -24vw; left: -9vw; background: #1fdfff; }

button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--cyan); outline-offset: 3px; }

.app { width: min(1180px, calc(100% - 28px)); margin: 0 auto; padding: 20px 0 28px; position: relative; }

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.header-actions { display: flex; align-items: center; gap: 10px; }
.account-button { padding: 9px 12px; border: 1px solid var(--stroke); border-radius: 12px; color: white; background: rgba(255,255,255,.07); cursor: pointer; font-size: 10px; font-weight: 900; }
.wallet { display: flex; gap: 7px; }
.wallet span { min-width: 54px; padding: 7px 9px; border: 1px solid var(--stroke); border-radius: 12px; color: var(--gold); background: rgba(255,255,255,.06); font-size: 12px; text-align: center; }
.wallet span:first-child { color: #ff70b8; }
.wallet span:last-child { color: var(--cyan); }
.wallet b { color: white; }

.brand { display: flex; gap: 12px; align-items: center; color: inherit; text-decoration: none; }
.brand strong { display: block; font-family: 'Fredoka', sans-serif; font-size: clamp(18px, 3vw, 25px); letter-spacing: .035em; line-height: .9; }
.brand strong i { color: var(--pink); font-size: .5em; font-style: normal; vertical-align: .2em; }
.brand small { display: block; margin-top: 6px; color: var(--muted); font-size: 9px; letter-spacing: .28em; }

.brand-orbit { position: relative; width: 44px; height: 44px; display: grid; place-items: center; border: 2px solid rgba(113,233,255,.72); border-radius: 50%; transform: rotate(-17deg); box-shadow: 0 0 18px rgba(70,233,255,.25), inset 0 0 14px rgba(70,233,255,.15); }
.brand-orbit::after { content: ''; position: absolute; width: 56px; height: 18px; border: 2px solid rgba(255,79,200,.8); border-top-color: transparent; border-radius: 50%; }
.brand-orbit span { width: 16px; height: 16px; border-radius: 50%; background: radial-gradient(circle at 30% 25%, white, var(--pink) 30%, #7a2aff 72%); box-shadow: 0 0 15px var(--pink); }

.icon-button, .rotate-button {
  border: 1px solid var(--stroke);
  color: var(--ink);
  background: rgba(255,255,255,.07);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.1), 0 8px 22px rgba(5,0,20,.22);
  cursor: pointer;
}

.icon-button { width: 42px; height: 42px; border-radius: 14px; font-size: 21px; }
.icon-button[aria-pressed="true"] { color: var(--cyan); box-shadow: 0 0 20px rgba(70,233,255,.2), inset 0 1px 0 rgba(255,255,255,.12); }

.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 315px; gap: 22px; align-items: start; }

.play-column, .mission-panel {
  border: 1px solid var(--stroke);
  background: linear-gradient(155deg, rgba(49,20,96,.64), rgba(21,7,51,.78));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.1), 0 30px 80px rgba(5,0,20,.35);
  backdrop-filter: blur(18px);
}

.play-column { border-radius: 28px; padding: 13px; }
.mission-panel { border-radius: 28px; padding: 28px 24px 22px; }

.hud { display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 10px; margin-bottom: 8px; }
.hud-item { min-width: 0; padding: 8px 14px; text-align: center; border-right: 1px solid var(--stroke); }
.hud-item:last-child { border-right: 0; }
.hud-label { display: block; color: var(--muted); font-size: 9px; letter-spacing: .18em; }
.hud strong { font-family: 'Fredoka', sans-serif; font-size: 22px; }
.hud-score strong { color: var(--gold); text-shadow: 0 0 16px rgba(255,216,77,.35); }

.board-card {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 23px;
  background:
    radial-gradient(circle at 50% 50%, rgba(150,64,255,.21), transparent 34%),
    linear-gradient(150deg, rgba(7,2,29,.58), rgba(24,5,57,.74));
}

.board-card::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% 50%, transparent 52%, rgba(4,0,17,.55) 100%);
}

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

.hint-pill {
  position: absolute;
  bottom: 15px;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 24px);
  padding: 8px 14px;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 999px;
  color: #e9dfff;
  background: rgba(15,4,39,.72);
  box-shadow: 0 8px 20px rgba(0,0,0,.2);
  font-size: 11px;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
  backdrop-filter: blur(8px);
}

.combo-banner {
  position: absolute;
  top: 12%;
  left: 50%;
  z-index: 4;
  transform: translate(-50%, -12px) scale(.82);
  font-family: 'Fredoka', sans-serif;
  font-size: clamp(24px, 5vw, 42px);
  color: white;
  text-shadow: 0 0 12px var(--pink), 0 3px 0 #7b23c8;
  opacity: 0;
  pointer-events: none;
}

.combo-banner.show { animation: combo-pop .9s ease-out; }
@keyframes combo-pop { 0% { opacity: 0; transform: translate(-50%, 10px) scale(.75); } 25% { opacity: 1; transform: translate(-50%, 0) scale(1.08); } 75% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -18px) scale(1); } }

.ring-controls { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 13px 8px 2px; }
.rotate-button { width: 48px; height: 42px; border-radius: 14px; font-size: 23px; transition: transform .15s ease, background .15s ease; }
.rotate-button:hover { background: rgba(255,255,255,.12); transform: translateY(-1px); }
.rotate-button:active { transform: scale(.95); }
.selected-ring { min-width: 128px; text-align: center; }
.selected-ring span { display: block; color: var(--muted); font-size: 8px; letter-spacing: .14em; }
.selected-ring strong { color: var(--cyan); font-family: 'Fredoka', sans-serif; font-size: 19px; }

.eyebrow { margin: 0 0 9px; color: var(--pink); font-size: 10px; font-weight: 800; letter-spacing: .19em; }
.mission-panel h1 { margin: 0 0 8px; font-family: 'Fredoka', sans-serif; font-size: 29px; line-height: 1; }
.mission-copy { margin: 0 0 26px; color: var(--muted); font-size: 13px; line-height: 1.55; }

.energy-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; font-size: 9px; letter-spacing: .11em; }
.energy-head strong { color: var(--gold); font-size: 13px; }
.progress-track { position: relative; height: 13px; margin-bottom: 24px; overflow: visible; border: 1px solid rgba(255,255,255,.11); border-radius: 99px; background: rgba(6,1,24,.58); }
.progress-fill { height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--pink), var(--purple) 48%, var(--cyan)); box-shadow: 0 0 16px rgba(255,79,200,.5); transition: width .35s cubic-bezier(.2,.9,.3,1); }
.progress-spark { position: absolute; top: 50%; left: 0; transform: translate(-50%,-50%); color: white; font-size: 18px; text-shadow: 0 0 11px var(--cyan); transition: left .35s cubic-bezier(.2,.9,.3,1); }

.objective-card { display: flex; align-items: center; gap: 13px; padding: 15px; margin-bottom: 20px; border: 1px solid rgba(255,255,255,.11); border-radius: 18px; background: rgba(255,255,255,.055); }
.objective-icon { width: 42px; height: 42px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; color: var(--gold); background: radial-gradient(circle, rgba(255,216,77,.25), rgba(255,216,77,.04)); box-shadow: inset 0 0 13px rgba(255,216,77,.25), 0 0 18px rgba(255,216,77,.1); font-size: 23px; }
.objective-card small { display: block; color: var(--muted); font-size: 8px; letter-spacing: .16em; }
.objective-card strong { font-size: 13px; }

.tips { display: grid; gap: 10px; margin-bottom: 23px; }
.tips > div { display: flex; align-items: center; gap: 12px; }
.tips p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.25; }
.tips p strong { color: var(--ink); }
.tip-gem { width: 29px; text-align: center; font-size: 21px; }
.gem-4 { color: var(--pink); text-shadow: 0 0 11px var(--pink); }
.gem-chain { color: var(--cyan); text-shadow: 0 0 11px var(--cyan); }

.level-route { position: relative; display: flex; align-items: center; justify-content: space-between; margin: 0 8px 25px; }
.level-route::before { content: ''; position: absolute; left: 6%; right: 6%; top: 50%; height: 2px; background: rgba(255,255,255,.12); }
.route-node { position: relative; z-index: 1; width: 26px; height: 26px; display: grid; place-items: center; border: 2px solid rgba(255,255,255,.2); border-radius: 50%; color: var(--muted); background: #271050; font-size: 9px; }
.route-node.done { border-color: var(--purple); color: white; background: var(--purple); }
.route-node.current { width: 35px; height: 35px; border-color: var(--cyan); color: #14042f; background: var(--cyan); box-shadow: 0 0 19px rgba(70,233,255,.55); font-weight: 900; }

.primary-button, .secondary-button { width: 100%; border-radius: 15px; padding: 12px 16px; color: white; cursor: pointer; font-weight: 800; }
.primary-button { border: 0; background: linear-gradient(110deg, #ff3bbd, #8d43ff 52%, #27dffa); box-shadow: 0 10px 25px rgba(144,55,255,.38); }
.secondary-button { border: 1px solid var(--stroke); background: rgba(255,255,255,.06); }
.keyboard-help { margin: 12px 0 0; color: rgba(199,184,229,.58); font-size: 9px; text-align: center; }
.hub-buttons { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-top: 10px; }
.hub-button { padding: 9px 4px; border: 1px solid var(--stroke); border-radius: 13px; color: var(--muted); background: rgba(255,255,255,.055); cursor: pointer; font-size: 9px; font-weight: 800; }
.hub-button span { display: block; margin-bottom: 3px; color: var(--cyan); font-size: 17px; }
.hub-button:hover { color: white; background: rgba(255,255,255,.1); }

.panel-backdrop { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 18px; background: rgba(5,0,18,.78); backdrop-filter: blur(10px); }
.panel-backdrop[hidden] { display: none; }
.meta-panel { position: relative; width: min(560px, 100%); max-height: min(720px, 90vh); overflow: auto; padding: 29px; border: 1px solid var(--stroke); border-radius: 27px; background: linear-gradient(155deg, #321369, #160630 70%); box-shadow: 0 30px 100px #050013; }
.meta-panel h2 { margin: 0 35px 20px 0; font-family: 'Fredoka', sans-serif; font-size: 32px; }
.panel-close { position: absolute; top: 17px; right: 17px; width: 38px; height: 38px; border: 1px solid var(--stroke); border-radius: 13px; color: white; background: rgba(255,255,255,.08); cursor: pointer; font-size: 24px; }
.meta-grid { display: grid; gap: 10px; }
.meta-card { display: flex; align-items: center; gap: 13px; padding: 15px; border: 1px solid var(--stroke); border-radius: 17px; background: rgba(255,255,255,.055); }
.meta-card .meta-icon { width: 42px; height: 42px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; color: var(--gold); background: rgba(255,216,77,.12); font-size: 20px; }
.meta-card .meta-copy { flex: 1; min-width: 0; }
.meta-card strong, .meta-card small { display: block; }
.meta-card small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.meta-card button { padding: 8px 11px; border: 0; border-radius: 10px; color: #17052f; background: var(--cyan); cursor: pointer; font-weight: 900; font-size: 10px; }
.meta-card button:disabled { color: var(--muted); background: rgba(255,255,255,.09); cursor: default; }
.progress-mini { height: 5px; margin-top: 8px; overflow: hidden; border-radius: 9px; background: rgba(255,255,255,.1); }
.progress-mini i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--pink), var(--cyan)); }
.streak { margin-bottom: 14px; padding: 13px 15px; border-radius: 15px; color: var(--gold); background: rgba(255,216,77,.08); font-weight: 800; }
.price { white-space: nowrap; color: var(--gold); font-weight: 900; }
.legal-note { margin: 15px 2px 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.auth-tabs { display: grid; grid-template-columns:1fr 1fr; gap: 8px; margin-bottom: 15px; }
.auth-tabs button { padding: 9px; border: 1px solid var(--stroke); border-radius: 11px; color: white; background: rgba(255,255,255,.06); cursor:pointer; }
.auth-tabs button.active { color:#160630; background:var(--cyan); }
.auth-form { display:grid; gap:12px; }
.auth-form label { color:var(--muted); font-size:11px; }
.auth-form input { width:100%; margin-top:5px; padding:11px; border:1px solid var(--stroke); border-radius:10px; color:white; background:rgba(5,0,20,.45); }
.auth-form .text-button { border:0; color:var(--cyan); background:none; cursor:pointer; font-size:11px; }
.account-summary { display:grid; gap:10px; }
.world-head { display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:15px; }
.world-head button { width:36px; height:36px; border:1px solid var(--stroke); border-radius:11px; color:white; background:rgba(255,255,255,.07); cursor:pointer; }
.world-head strong { text-align:center; font-family:Fredoka,sans-serif; }
.campaign-map { display:grid; grid-template-columns:repeat(5,1fr); gap:11px; }
.level-node { position:relative; aspect-ratio:1; border:2px solid rgba(255,255,255,.16); border-radius:50%; color:var(--muted); background:#25104d; cursor:pointer; font-weight:900; }
.level-node:disabled { opacity:.35; cursor:default; }
.level-node.current { border-color:var(--cyan); color:#13042d; background:var(--cyan); box-shadow:0 0 18px rgba(70,233,255,.45); }
.level-node.boss { border-radius:13px; border-color:var(--pink); }
.level-node .stars { position:absolute; left:50%; bottom:-8px; width:48px; transform:translateX(-50%); color:var(--gold); font-size:8px; letter-spacing:-1px; }
.map-summary { margin-top:20px; padding:12px 15px; border-radius:14px; color:var(--muted); background:rgba(255,255,255,.055); font-size:11px; text-align:center; }
.toast { position: fixed; left: 50%; bottom: 22px; z-index: 50; max-width: calc(100% - 30px); padding: 11px 17px; border: 1px solid var(--stroke); border-radius: 999px; color: white; background: #341364; box-shadow: 0 12px 40px #050013; transform: translate(-50%, 30px); opacity: 0; pointer-events: none; transition: .25s ease; font-size: 12px; font-weight: 800; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
body.theme-solar { --pink: #ff8a3d; --purple: #ca3eff; --cyan: #ffe466; }
body.theme-ocean { --pink: #37d4ff; --purple: #3568ff; --cyan: #5cffc7; }

.result-overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 34px;
  text-align: center;
  background: radial-gradient(circle at 50% 43%, rgba(146,60,255,.4), rgba(11,2,32,.91) 58%);
  backdrop-filter: blur(8px);
}
.result-overlay[hidden] { display: none; }
.result-star { width: 94px; height: 94px; display: grid; place-items: center; margin-bottom: 16px; border-radius: 50%; color: white; background: radial-gradient(circle, white 0 7%, #ffe660 14%, #ff4fc8 39%, rgba(151,70,255,.16) 70%); box-shadow: 0 0 35px #ff4fc8, 0 0 85px rgba(70,233,255,.55); font-size: 46px; animation: star-breathe 1.8s ease-in-out infinite; }
@keyframes star-breathe { 50% { transform: scale(1.08) rotate(5deg); filter: brightness(1.18); } }
.result-overlay h1 { margin: 0 0 9px; font-family: 'Fredoka', sans-serif; font-size: clamp(34px,7vw,56px); }
.result-overlay p:not(.eyebrow) { max-width: 320px; margin: 0 0 23px; color: var(--muted); }
.result-overlay .primary-button { width: min(260px, 100%); }

@media (max-width: 860px) {
  .game-layout { grid-template-columns: minmax(0, 1fr); }
  .mission-panel { display: grid; grid-template-columns: 1fr 1fr; column-gap: 24px; align-items: start; }
  .mission-panel > .eyebrow, .mission-panel > h1, .mission-panel > .mission-copy, .mission-panel > .secondary-button, .mission-panel > .keyboard-help { grid-column: 1 / -1; }
  .mission-copy { margin-bottom: 19px; }
  .objective-card { grid-column: 2; grid-row: 4 / span 2; margin-top: 0; }
}

@media (max-width: 560px) {
  .app { width: min(100% - 14px, 620px); padding-top: 12px; }
  .app-header { margin-inline: 7px; margin-bottom: 11px; }
  .brand small { display: none; }
  .wallet span { min-width: 43px; padding: 6px; font-size: 10px; }
  .wallet span:first-child { display: none; }
  .account-button { display:none; }
  .play-column { padding: 7px; border-radius: 22px; }
  .board-card { border-radius: 18px; }
  .hud-item { padding: 7px 5px; }
  .hud strong { font-size: 18px; }
  .hint-pill { bottom: 9px; font-size: 9px; padding: 6px 10px; }
  .ring-controls { padding-top: 9px; }
  .mission-panel { display: block; padding: 24px 20px 20px; }
  .keyboard-help { display: none; }
}

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