:root {
  --bg: #07060f;
  --ink: #f4f2ff;
  --dim: #a7a3c7;
  --cyan: #57e6ff;
  --magenta: #ff5fd0;
  --gold: #ffd45e;
  --green: #6dffa8;
  --red: #ff6b6b;
  --panel: rgba(16, 13, 34, 0.86);
  --line: rgba(87, 230, 255, 0.28);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  overflow: hidden;
}

#stage {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1200px 700px at 70% -10%, rgba(120, 40, 200, 0.25), transparent 60%),
    radial-gradient(900px 600px at 10% 110%, rgba(20, 120, 200, 0.20), transparent 60%),
    var(--bg);
}

canvas#game {
  display: block;
  width: min(100vw, calc(100vh * 1.6));
  height: min(100vh, calc(100vw / 1.6));
  border-radius: 10px;
  box-shadow: 0 0 0 1px rgba(87, 230, 255, 0.18), 0 24px 80px rgba(0, 0, 0, 0.6);
  background: #05040c;
}

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: min(96vw, calc(96vh * 1.6));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(10, 8, 22, 0.72);
  border: 1px solid var(--line);
  backdrop-filter: blur(8px);
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

.hud-group { display: flex; align-items: center; gap: 18px; }
.hud-item { display: flex; flex-direction: column; line-height: 1.15; }
.hud-label { font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim); }
.hud-value { font-size: 17px; font-weight: 700; }
#hud-time { color: var(--cyan); }
#hud-score { color: var(--gold); }

.hud-meters { flex-direction: column; gap: 6px; align-items: stretch; }
.meter { display: flex; align-items: center; gap: 8px; }
.meter .hud-label { width: 30px; }
.bar { width: 130px; height: 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.10); overflow: hidden; }
.bar-fill { height: 100%; width: 100%; border-radius: 999px; transition: width 0.15s linear; }
.bar-fill.fuel { background: linear-gradient(90deg, #ff9d42, #ffd45e); }
.bar-fill.hull { background: linear-gradient(90deg, #35d07f, #6dffa8); }
.bar-fill.low { background: linear-gradient(90deg, #d03535, #ff6b6b); }

.hud-stars { font-size: 15px; letter-spacing: 2px; color: var(--gold); min-height: 18px; }

/* ---------- start.ng profile card ---------- */
.startng-card {
  position: absolute;
  bottom: 16px;
  left: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px 8px 8px;
  border-radius: 999px;
  background: #292a23;
  color: #fffefa;
  border: 1px solid rgba(216, 253, 113, 0.35);
  z-index: 5;
}
.startng-card img { width: 48px; height: 48px; border-radius: 50%; background: #d8fd71; }
.startng-card b { display: block; font-size: 16px; }
.startng-card span { font-size: 12px; opacity: 0.7; }

/* ---------- Screens ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  padding: 24px;
  background: rgba(4, 3, 10, 0.62);
  backdrop-filter: blur(6px);
  z-index: 10;
  overflow: auto;
}
.screen.is-open { display: grid; }

.panel {
  width: min(560px, 92vw);
  padding: 34px 38px;
  border-radius: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  text-align: center;
}
.panel-wide { width: min(760px, 94vw); }

.eyebrow {
  margin: 0 0 10px;
  font-size: 11px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--magenta);
}

.title {
  margin: 0 0 14px;
  font-size: clamp(38px, 6vw, 60px);
  line-height: 1;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-shadow: 0 0 30px rgba(87, 230, 255, 0.45);
}
.title span { color: var(--cyan); }

h2 { margin: 0 0 12px; font-size: clamp(26px, 4vw, 38px); font-weight: 800; }
h3 { margin: 18px 0 6px; font-size: 13px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--cyan); }

.tagline { margin: 0 auto 22px; max-width: 52ch; color: var(--dim); font-size: 15px; line-height: 1.6; }

.char-row { display: flex; align-items: center; justify-content: center; gap: 18px; margin: 0 0 20px; }
.char-row canvas {
  width: 92px; height: 115px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.char-copy { text-align: left; max-width: 30ch; }
.char-label { font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--magenta); }
.char-copy p { margin: 6px 0 0; font-size: 13px; color: var(--dim); line-height: 1.5; }
.howto-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 34px; text-align: left; }
.howto-grid p { margin: 0; color: var(--dim); font-size: 14px; line-height: 1.65; }
.howto-grid b { color: var(--ink); }

.menu-buttons { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 6px; }

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(87, 230, 255, 0.08);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  padding: 12px 26px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}
.btn:hover { background: rgba(87, 230, 255, 0.16); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
.btn-primary {
  background: linear-gradient(135deg, var(--cyan), #2f9dff);
  color: #04121c;
  border-color: transparent;
  box-shadow: 0 8px 28px rgba(87, 230, 255, 0.35);
}
.btn-primary:hover { filter: brightness(1.07); background: linear-gradient(135deg, var(--cyan), #2f9dff); }

.hint { margin: 18px 0 0; font-size: 12px; color: var(--dim); }
kbd {
  display: inline-block;
  padding: 2px 7px;
  margin: 0 2px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-bottom-width: 2px;
  background: rgba(255, 255, 255, 0.07);
  font: 600 11px/1.4 ui-monospace, "Cascadia Mono", Consolas, monospace;
}

.pickup-legend { display: flex; gap: 16px; align-items: center; }
.badge {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px; border-radius: 50%;
  font-style: normal; font-size: 15px;
  border: 2px solid;
}
.badge.fuel { border-color: #ffd45e; background: rgba(255, 212, 94, 0.15); }
.badge.hull { border-color: #6dffa8; background: rgba(109, 255, 168, 0.15); }
.badge.time { border-color: #57e6ff; background: rgba(87, 230, 255, 0.15); }

.stars { display: flex; gap: 10px; justify-content: center; margin: 6px 0 14px; }
.stars i {
  width: 46px; height: 46px;
  display: grid; place-items: center;
  font-size: 34px; font-style: normal;
  color: rgba(255, 255, 255, 0.16);
  text-shadow: none;
  animation: pop 0.5s cubic-bezier(0.2, 1.6, 0.4, 1) backwards;
}
.stars i.on { color: var(--gold); text-shadow: 0 0 24px rgba(255, 212, 94, 0.7); }
.stars i:nth-child(2) { animation-delay: 0.18s; }
.stars i:nth-child(3) { animation-delay: 0.36s; }
@keyframes pop { from { transform: scale(0.2); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.score-line { margin: 4px 0 18px; font-size: 15px; color: var(--dim); }
.score-line b { font-size: 26px; color: var(--gold); margin-left: 8px; }

.board { list-style: none; margin: 0 auto 10px; padding: 0; max-width: 520px; text-align: left; }
.board li {
  display: grid;
  grid-template-columns: 34px 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 9px 14px;
  border-radius: 12px;
  font-size: 14px;
  color: var(--dim);
}
.board li + li { margin-top: 4px; }
.board li.me { background: rgba(87, 230, 255, 0.12); color: var(--ink); outline: 1px solid var(--line); }
.board .rank { font-weight: 800; color: var(--gold); }
.board .name { color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .num { font-variant-numeric: tabular-nums; }
.board .num.primary { color: var(--cyan); font-weight: 700; }
.board-note { margin: 6px 0 0; font-size: 13px; color: var(--dim); }

@media (max-width: 720px) {
  .howto-grid { grid-template-columns: 1fr; }
  #hud { flex-wrap: wrap; border-radius: 20px; justify-content: center; }
}
