/* FluxRunner — Prism Plains UI: clean white glass, neon blue accents */
:root {
  --ink: #0d1b3d;
  --ink-soft: #4a5a80;
  --blue: #1f8fff;
  --blue-deep: #0b5fd6;
  --cyan: #2fd3ff;
  --violet: #7b5cff;
  --glass: rgba(255, 255, 255, 0.72);
  --line: rgba(31, 143, 255, 0.28);
  --head: 'Orbitron', 'Segoe UI', system-ui, sans-serif;
  --body: 'Exo 2', 'Segoe UI', system-ui, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #dfeaff; color: var(--ink); font-family: var(--body); -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
[hidden] { display: none !important; }

/* ---------- Screens ---------- */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: calc(16px + var(--safe-t)) 16px calc(16px + var(--safe-b)); overflow-y: auto; z-index: 10;
  background: radial-gradient(ellipse at 50% 40%, rgba(255,255,255,0.15), rgba(214,229,255,0.55)); }
.screen.dim { background: rgba(225, 236, 255, 0.55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.kicker { font-family: var(--head); font-size: 12px; letter-spacing: 0.28em; text-transform: uppercase; color: var(--blue); }
h1, h2 { font-family: var(--head); margin: 0; letter-spacing: 0.06em; }
h1 { font-size: clamp(42px, 9vw, 96px); font-weight: 800; line-height: 1; color: var(--ink); text-shadow: 0 6px 30px rgba(31,143,255,0.35); }
h1 span { color: var(--blue); }
h2 { font-size: clamp(22px, 4vw, 32px); }

.title-wrap { width: min(440px, 100%); display: flex; flex-direction: column; align-items: center; gap: 22px; text-align: center; }
.tag { margin: 8px 0 0; font-size: 18px; color: var(--ink-soft); letter-spacing: 0.12em; text-transform: uppercase; }
.menu { width: 100%; display: flex; flex-direction: column; gap: 10px; }
.ctrl-note { margin: 0; font-size: 13px; color: var(--ink-soft); max-width: 380px; }

button, .menu a { font: 600 18px var(--body); letter-spacing: 0.04em; color: #fff; background: linear-gradient(180deg, #2c9cff, #136ef0); border: 0; border-radius: 14px; padding: 14px 18px; cursor: pointer; text-decoration: none; text-align: center;
  box-shadow: 0 6px 18px rgba(19,110,240,0.3), inset 0 1px 0 rgba(255,255,255,0.4); transition: transform .12s, box-shadow .12s, filter .12s; outline: none; }
button:hover, .menu a:hover { filter: brightness(1.08); }
button:active { transform: scale(0.97); }
button.ghost, a.ghost { background: var(--glass); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); backdrop-filter: blur(6px); }
button small { display: block; font-size: 12px; font-weight: 400; opacity: 0.85; letter-spacing: 0.02em; }
button[aria-disabled="true"] { filter: grayscale(0.7) brightness(1.05); opacity: 0.65; }
/* focus ring for controller + keyboard */
:focus-visible, .pad-focus { outline: 3px solid var(--cyan) !important; outline-offset: 3px; box-shadow: 0 0 0 6px rgba(47,211,255,0.25), 0 8px 24px rgba(19,110,240,0.35) !important; transform: translateY(-1px); }

.wallet { display: inline-flex; align-items: center; gap: 8px; font: 700 18px var(--body); background: var(--glass); padding: 8px 14px; border-radius: 999px; box-shadow: inset 0 0 0 1.5px var(--line); }
.coin-ico { width: 18px; height: 18px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff3b0, #ffc531 45%, #c07a00); box-shadow: 0 0 0 2px rgba(192,122,0,0.25); display: inline-block; }

/* ---------- Level select / orbs pages ---------- */
.page { width: min(980px, 100%); align-self: flex-start; display: flex; flex-direction: column; gap: 18px; padding-bottom: 20px; }
.page-head { display: flex; align-items: center; gap: 14px; }
.page-head > div:nth-child(2) { flex: 1; }
.back { width: 52px; height: 52px; padding: 0; font-size: 22px; border-radius: 50%; background: var(--glass); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.level-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.level-tile { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-height: 108px; padding: 14px; background: var(--glass); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line), 0 6px 18px rgba(31,90,180,0.12); backdrop-filter: blur(6px); text-align: left; }
.level-tile .num { font: 800 30px var(--head); color: var(--blue); }
.level-tile .lname { font-size: 14px; font-weight: 600; }
.level-tile .lsub { font-size: 12px; color: var(--ink-soft); font-weight: 400; }
.level-tile.done { box-shadow: inset 0 0 0 2px rgba(31,143,255,0.6), 0 6px 18px rgba(31,90,180,0.12); }
.level-tile.locked { opacity: 0.55; filter: none; }
.level-tile.locked .num { color: var(--ink-soft); }
.level-tile.challenge { background: linear-gradient(140deg, rgba(123,92,255,0.92), rgba(31,143,255,0.92)); color: #fff; }
.level-tile.challenge .num, .level-tile.challenge .lsub { color: #fff; }
.ico-done { position: absolute; top: 10px; right: 12px; font-style: normal; font-weight: 700; color: var(--blue); }
.level-tile.challenge .ico-done { color: #fff; }
.ico-lock { position: absolute; top: 12px; right: 12px; width: 14px; height: 11px; border-radius: 3px; background: var(--ink-soft); }
.ico-lock::before { content: ''; position: absolute; left: 2px; top: -7px; width: 6px; height: 7px; border: 2px solid var(--ink-soft); border-bottom: 0; border-radius: 6px 6px 0 0; }
.worlds { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.world { padding: 12px 14px; border-radius: 14px; background: var(--glass); box-shadow: inset 0 0 0 1.5px var(--line); display: flex; flex-direction: column; gap: 2px; }
.world b { font: 600 13px var(--head); letter-spacing: 0.08em; }
.world span { font-size: 13px; color: var(--ink-soft); }
.world.current { box-shadow: inset 0 0 0 2px var(--blue); }
.world.locked { background: rgba(13,27,61,0.08); }

.orb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.orb-tile { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 10px 12px; background: var(--glass); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); backdrop-filter: blur(6px); }
.orb-tile img { width: 104px; height: 104px; object-fit: contain; filter: drop-shadow(0 6px 10px rgba(13,27,61,0.25)); pointer-events: none; }
.orb-tile .oname { font-size: 15px; }
.orb-tile.equipped { box-shadow: inset 0 0 0 2.5px var(--blue); }
.orb-tile .eq { position: absolute; top: 8px; right: 8px; font-size: 11px; background: var(--blue); color: #fff; padding: 2px 8px; border-radius: 999px; }
.rarity { font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; padding: 2px 8px; border-radius: 999px; background: rgba(13,27,61,0.08); color: var(--ink-soft); font-weight: 600; }
.r-royalty { background: linear-gradient(90deg, #f6d36a, #c8902a); color: #3b2600; }
.r-starter { background: rgba(31,143,255,0.15); color: var(--blue-deep); }
.note { font-size: 13px; color: var(--ink-soft); margin: 0; text-align: center; }

/* ---------- Panels (pause / over / done) ---------- */
.panel { width: min(380px, 100%); background: rgba(255,255,255,0.86); border-radius: 22px; padding: 26px 22px; display: flex; flex-direction: column; gap: 10px; text-align: center; box-shadow: 0 20px 60px rgba(13,27,61,0.25), inset 0 0 0 1.5px var(--line); backdrop-filter: blur(10px); }
.panel h2 { margin-bottom: 6px; }
.stats { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 10px; }
.stat { display: flex; justify-content: space-between; align-items: baseline; padding: 8px 12px; border-radius: 10px; background: rgba(31,143,255,0.07); font-size: 15px; }
.stat span { color: var(--ink-soft); }
.stat b { font-size: 18px; }
.stat em { font-style: normal; font-size: 12px; color: #fff; background: var(--violet); padding: 2px 8px; border-radius: 999px; margin-left: 6px; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
.hud-top { position: absolute; top: calc(12px + var(--safe-t)); left: 14px; right: 14px; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.hud-left { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
#hud-label { font: 600 13px var(--head); letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink); text-shadow: 0 1px 0 #fff; }
.progress { width: min(260px, 50vw); height: 8px; border-radius: 99px; background: rgba(13,27,61,0.12); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--blue), var(--cyan)); border-radius: 99px; }
#hud-score { font: 800 30px var(--head); color: var(--ink); text-shadow: 0 2px 0 #fff; }
.hud-right { display: flex; align-items: center; gap: 8px; font: 700 20px var(--body); background: var(--glass); padding: 6px 6px 6px 12px; border-radius: 999px; box-shadow: inset 0 0 0 1.5px var(--line); pointer-events: auto; }
#btn-pause { width: 40px; height: 40px; padding: 0; border-radius: 50%; font-size: 13px; margin-left: 4px; }
#energy { position: absolute; left: 50%; bottom: calc(18px + var(--safe-b)); transform: translateX(-50%); display: flex; align-items: center; gap: 10px; background: var(--glass); padding: 8px 14px; border-radius: 999px; box-shadow: inset 0 0 0 1.5px var(--line); }
#energy span { font: 600 11px var(--head); letter-spacing: 0.2em; color: var(--blue-deep); }
#energy .bar { width: min(220px, 50vw); height: 10px; border-radius: 99px; background: rgba(13,27,61,0.12); overflow: hidden; }
#energy .bar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--cyan), var(--blue)); }
#energy.on { box-shadow: inset 0 0 0 2px var(--cyan), 0 0 24px rgba(47,211,255,0.6); }
#energy.low .bar i { background: #ff6b6b; }

.hint { position: fixed; left: 50%; top: 26%; transform: translate(-50%, -10px); z-index: 6; text-align: center; pointer-events: none; opacity: 0; transition: opacity .35s, transform .35s; width: min(560px, 92vw); }
.hint.show { opacity: 1; transform: translate(-50%, 0); }
.hint b { display: block; font: 800 clamp(20px, 4vw, 30px) var(--head); color: var(--ink); text-shadow: 0 2px 0 #fff, 0 6px 24px rgba(31,143,255,0.4); letter-spacing: 0.05em; }
.hint span { display: inline-block; margin-top: 10px; font-size: 17px; font-weight: 600; background: rgba(255,255,255,0.85); padding: 8px 16px; border-radius: 999px; box-shadow: inset 0 0 0 1.5px var(--line); }
.toast { position: fixed; left: 50%; bottom: calc(80px + var(--safe-b)); transform: translate(-50%, 20px); z-index: 20; background: linear-gradient(90deg, var(--violet), var(--blue)); color: #fff; font-weight: 600; padding: 12px 20px; border-radius: 999px; box-shadow: 0 10px 30px rgba(31,90,200,0.35); opacity: 0; pointer-events: none; transition: opacity .3s, transform .3s; text-align: center; max-width: 92vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
#flash { position: fixed; inset: 0; pointer-events: none; opacity: 0; z-index: 4; }
#flash.go { animation: flash .6s ease-out; }
@keyframes flash { from { opacity: 1; } to { opacity: 0; } }

@media (max-width: 760px) {
  .level-grid { grid-template-columns: repeat(2, 1fr); }
  .worlds { grid-template-columns: repeat(2, 1fr); }
  .level-tile { min-height: 84px; }
  .orb-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .orb-tile img { width: 84px; height: 84px; }
  button, .menu a { font-size: 17px; padding: 13px 16px; }
}
