/* ===== Star Nova — calm cosmic theme ===== */
:root {
  --space:   #070b1c;
  --panel:   rgba(14, 20, 46, .72);
  --panel-2: rgba(20, 28, 62, .85);
  --line:    rgba(125, 150, 255, .22);
  --ink:     #eef1ff;
  --ink-dim: #9aa5d1;
  --teal:    #55e6ff;
  --violet:  #b78bff;
  --gold:    #ffc94d;
  --ff: "Quicksand", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; user-select: none; }
/* the hidden attribute must win over any element's own display rule (e.g. .overlay{display:flex}) */
[hidden] { display: none !important; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--space); color: var(--ink); font-family: var(--ff);
  touch-action: none; overscroll-behavior: none;
}

#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

.vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 5;
  background: radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(2, 4, 12, .55) 100%);
}

/* ===== HUD ===== */
.hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
.hud-top {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  padding: calc(12px + env(safe-area-inset-top)) 14px 0;
}
.hud-left, .hud-right { display: flex; gap: 8px; align-items: center; }
.hud-right { pointer-events: auto; }

.level-badge {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 8px 13px; font-weight: 700; font-size: 14px; letter-spacing: .12em;
  color: var(--teal); backdrop-filter: blur(6px);
}

/* single "left to collect" counter */
.remain {
  display: flex; align-items: baseline; gap: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 17px; backdrop-filter: blur(6px);
}
.remain #remainNum {
  font-weight: 800; font-size: 21px; line-height: 1; color: var(--teal);
  min-width: 1.2em; text-align: right; font-variant-numeric: tabular-nums;
}
.remain .remain-label {
  font-weight: 700; font-size: 11.5px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-dim);
}

.hud-btn {
  pointer-events: auto; width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  font-size: 17px; cursor: pointer; backdrop-filter: blur(6px);
  display: grid; place-items: center; transition: transform .1s ease;
  font-family: var(--ff);
}
.hud-btn:active { transform: scale(.92); }

/* cargo (carrying) dots */
.hud-bottom {
  position: absolute; left: 0; right: 0;
  bottom: calc(18px + env(safe-area-inset-bottom));
  display: flex; justify-content: center; pointer-events: none;
}
.cargo {
  display: flex; gap: 10px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 15px; backdrop-filter: blur(6px);
}
.cargo .carry {
  display: flex; align-items: center; gap: 6px;
  font-weight: 800; font-size: 13.5px; color: var(--ink);
}
.cargo .cdot { width: 12px; height: 12px; border-radius: 50%; box-shadow: 0 0 8px currentColor; }

/* ===== toast ===== */
.toast {
  position: fixed; z-index: 12; left: 50%; top: 24%;
  transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--line);
  color: var(--ink); font-weight: 700; font-size: 16px; letter-spacing: .06em;
  padding: 13px 24px; border-radius: 16px; text-align: center;
  backdrop-filter: blur(8px); pointer-events: none;
  animation: toastIn .4s cubic-bezier(.2,.9,.3,1.2);
  box-shadow: 0 10px 40px rgba(0,0,0,.4);
}
.toast small { display: block; font-size: 12.5px; color: var(--ink-dim); font-weight: 600; margin-top: 4px; letter-spacing: .02em; }
.toast.fade { animation: toastOut .5s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(-12px) scale(.95); } to { opacity: 1; transform: translateX(-50%); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(-50%) translateY(-8px); } }

/* ===== joystick ===== */
.joy { position: fixed; z-index: 9; pointer-events: none; width: 0; height: 0; }
.joy-base {
  position: absolute; left: -56px; top: -56px; width: 112px; height: 112px;
  border-radius: 50%; border: 2px solid rgba(125, 150, 255, .35);
  background: radial-gradient(circle, rgba(85, 230, 255, .07), rgba(20, 28, 62, .25) 70%);
  backdrop-filter: blur(2px);
}
.joy-knob {
  position: absolute; left: -22px; top: -22px; width: 44px; height: 44px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #b6ecff, #55b8ff 55%, #2f6fd8);
  box-shadow: 0 0 16px rgba(85, 184, 255, .6), 0 2px 8px rgba(0,0,0,.4);
}

/* ===== overlays ===== */
.overlay {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 38%, rgba(17, 24, 58, .55), rgba(4, 6, 16, .88) 75%);
  backdrop-filter: blur(3px);
  animation: fadeIn .5s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.overlay.hide { animation: fadeOut .45s ease forwards; }
@keyframes fadeOut { to { opacity: 0; } }

.title-inner, .clear-inner {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 20px; max-width: 90vw;
}
.mark { filter: drop-shadow(0 0 24px rgba(139, 124, 246, .45)); animation: floaty 5s ease-in-out infinite; }
@keyframes floaty { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

.wordmark {
  margin: 18px 0 0; font-size: clamp(38px, 9vw, 56px); font-weight: 700;
  letter-spacing: .22em; text-indent: .22em; line-height: 1.05;
  background: linear-gradient(100deg, #9be8ff 10%, #eef1ff 45%, #c9b4ff 90%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 0 40px rgba(85, 230, 255, .25);
}
.wordmark span { font-weight: 500; }
.tagline { margin: 10px 0 34px; color: var(--ink-dim); font-weight: 600; font-size: 14px; letter-spacing: .28em; text-indent: .28em; }

.start-btn {
  pointer-events: auto; cursor: pointer; border: none; border-radius: 999px;
  font-family: var(--ff); font-weight: 700; font-size: 16px; letter-spacing: .18em; text-indent: .18em;
  color: #06131f; padding: 16px 42px;
  background: linear-gradient(180deg, #8fefff, #55e6ff 45%, #38b8e8);
  box-shadow: 0 0 30px rgba(85, 230, 255, .45), 0 6px 18px rgba(0,0,0,.4), inset 0 1px 0 rgba(255,255,255,.7);
  transition: transform .12s ease;
  animation: pulse 2.2s ease-in-out infinite;
}
.start-btn:active { transform: scale(.94); }
@keyframes pulse { 0%,100% { box-shadow: 0 0 22px rgba(85,230,255,.35), 0 6px 18px rgba(0,0,0,.4), inset 0 1px 0 rgba(255,255,255,.7);} 50% { box-shadow: 0 0 44px rgba(85,230,255,.6), 0 6px 18px rgba(0,0,0,.4), inset 0 1px 0 rgba(255,255,255,.7);} }

.continue-note { margin-top: 18px; color: var(--ink-dim); font-weight: 600; font-size: 13px; }
.continue-note b { color: var(--gold); }
.continue-note button {
  pointer-events: auto; background: none; border: none; color: var(--ink-dim);
  font-family: var(--ff); font-weight: 700; font-size: 12px; cursor: pointer;
  text-decoration: underline; margin-left: 6px;
}

/* clear screen */
.clear-spark { font-size: 44px; color: var(--gold); text-shadow: 0 0 30px rgba(255,201,77,.8); animation: spin 6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.clear-title {
  margin: 14px 0 6px; font-size: clamp(28px, 7vw, 40px); font-weight: 700; letter-spacing: .16em; text-indent: .16em;
  background: linear-gradient(100deg, #ffe9b0, #ffc94d 60%, #ff9e6e);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.clear-stats { margin: 4px 0 30px; color: var(--ink-dim); font-weight: 600; font-size: 15px; letter-spacing: .04em; }
.clear-stats b { color: var(--ink); }
