/* Neon Swarm UI: dark ink panels with cut corners and cyan / magenta neon edges. */
:root {
  --bg: #04060f; --ink: #eaf8ff; --muted: #8fa6c8; --panel: rgba(8, 14, 34, .94); --well: rgba(61, 245, 255, .07);
  --cyan: #3df5ff; --cyan-d: #0a7d8c; --pink: #ff3d9a; --pink-d: #8c0f4c; --gold: #ffd23f; --good: #9dff4d;
  --st: env(safe-area-inset-top, 0px); --sb: env(safe-area-inset-bottom, 0px);
  --sl: env(safe-area-inset-left, 0px); --sr: env(safe-area-inset-right, 0px);
  --cut: polygon(14px 0, 100% 0, 100% calc(100% - 14px), calc(100% - 14px) 100%, 0 100%, 0 14px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; width: 100%; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -ms-touch-action: none; touch-action: none; -webkit-user-select: none; user-select: none; overscroll-behavior: none;
}
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; -ms-touch-action: none; touch-action: none; cursor: crosshair; }
[hidden] { display: none !important; }
body.aiming #game { cursor: none; } /* the game draws its own crosshair while playing */

/* ---- HUD ---- */
#hud { position: fixed; z-index: 3; left: 0; right: 0; top: 0; pointer-events: none; }
#xpbar { height: 8px; background: rgba(61, 245, 255, .12); }
#xpbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ffb43d, #ffe14d); box-shadow: 0 0 10px #ffe14d; transition: width .12s linear; }
.hudrow { display: flex; gap: 6px; align-items: center; padding: calc(5px + var(--st)) calc(60px + var(--sr)) 0 calc(8px + var(--sl)); }
.hudrow .round { pointer-events: auto; margin-left: auto; }
.pill { background: rgba(8, 14, 34, .85); border: 1.5px solid rgba(61, 245, 255, .35); color: #fff; height: 36px; padding: 0 12px; display: flex; align-items: center; gap: 6px;
  font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px); }
.pill.lvl { color: var(--cyan); } .pill.lvl b { color: #fff; }
.pill.bump { animation: bump .3s; }
.hearts { gap: 4px; padding: 0 10px; }
.hearts i { width: 16px; height: 14px; background: #ff4d8d; clip-path: path('M8 14 L1.3 7.2 A3.8 3.8 0 0 1 8 2.5 A3.8 3.8 0 0 1 14.7 7.2 Z'); }
.hearts i.off { background: rgba(255,255,255,.18); }
.hearts.hurt { animation: bump .35s; }
.gemi { width: 12px; height: 16px; background: #ffe14d; clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.build { position: fixed; left: calc(8px + var(--sl)); bottom: calc(6px + var(--sb)); display: flex; gap: 4px; flex-wrap: wrap; max-width: 60%; }
.build span { position: relative; width: 30px; height: 30px; background: rgba(8, 14, 34, .8); border: 1px solid rgba(61, 245, 255, .25); }
.build span canvas { width: 100%; height: 100%; display: block; }
.build span b { position: absolute; right: 1px; bottom: -1px; font-size: 10px; color: #fff; text-shadow: 0 0 3px #000, 0 0 3px #000; }
.build.big { position: static; max-width: none; justify-content: center; }
.build.big span { width: 36px; height: 36px; }
@keyframes bump { 50% { transform: scale(1.15); } }

.round { width: 42px; height: 42px; border: 1.5px solid rgba(61, 245, 255, .45); border-radius: 50%; background: rgba(8, 14, 34, .85); color: #fff; display: grid; place-items: center; cursor: pointer; padding: 0; }
#btn-sound { position: fixed; z-index: 6; right: calc(8px + var(--sr)); top: calc(11px + var(--st)); }
#btn-sound .slash { display: none; }
#btn-sound.off .slash { display: inline; }
#btn-sound.off .waves { display: none; }
#toast { position: fixed; z-index: 9; left: 50%; bottom: calc(18px + var(--sb)); transform: translateX(-50%); background: var(--panel); border: 1.5px solid var(--pink); color: #fff; padding: 10px 18px; font-size: 15px; font-weight: 700; max-width: 90%; text-align: center; }
#tip { position: fixed; z-index: 3; left: 50%; bottom: calc(46px + var(--sb)); transform: translateX(-50%); width: min(560px, calc(100% - 20px)); background: var(--panel); border: 1.5px solid var(--cyan);
  padding: 10px 14px; box-shadow: 0 0 20px rgba(61, 245, 255, .3); pointer-events: none; clip-path: var(--cut); }
#tip p { margin: 0; font-size: 16px; line-height: 1.35; font-weight: 700; text-align: center; }

/* ---- screens ---- */
.screen { position: fixed; inset: 0; z-index: 4; display: none; align-items: center; justify-content: center; padding: calc(8px + var(--st)) calc(8px + var(--sr)) calc(8px + var(--sb)) calc(8px + var(--sl)); }
.screen.show { display: flex; }
.screen.dim { background: rgba(2, 3, 10, .62); }
#screen-menu { background: radial-gradient(ellipse at center, rgba(2, 3, 10, .72) 0 35%, rgba(2, 3, 10, .3) 85%); }
#screen-loading { background: var(--bg); }
.stack { display: flex; flex-direction: column; align-items: center; gap: 12px; width: min(460px, 100%); text-align: center; }
.logo { margin: 0; font-size: clamp(44px, 11vmin, 84px); line-height: .9; font-weight: 900; letter-spacing: .04em; text-transform: uppercase; color: #fff;
  text-shadow: 0 0 6px var(--cyan), 0 0 22px var(--cyan), 0 0 44px rgba(61, 245, 255, .6); }
.logo span { display: block; color: #fff; text-shadow: 0 0 6px var(--pink), 0 0 22px var(--pink), 0 0 44px rgba(255, 61, 154, .6); }
.tagline { margin: 0 0 4px; font-size: 16px; color: #fff; font-weight: 700; text-shadow: 0 2px 4px rgba(0,0,0,.8); }
.muted { color: var(--muted); margin: 0; }
#screen-loading .muted { color: #fff; }
.bar { width: 100%; height: 10px; background: rgba(61, 245, 255, .12); overflow: hidden; }
#load-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--cyan), var(--pink)); transition: width .15s; }
.hint { margin: 0; color: #cfe8ff; font-size: 14px; font-weight: 700; text-shadow: 0 1px 3px #000; }

.card { background: var(--panel); border: 1.5px solid var(--cyan); padding: 18px 20px; width: min(400px, 100%); max-height: 100%; overflow-y: auto; touch-action: pan-y; -ms-touch-action: pan-y;
  display: flex; flex-direction: column; gap: 10px; box-shadow: 0 0 30px rgba(61, 245, 255, .25), inset 0 0 30px rgba(61, 245, 255, .06); clip-path: var(--cut); }
.card.center { text-align: center; align-items: stretch; }
.card.wide { width: min(700px, 100%); }
.card h2 { margin: 0; font-size: 26px; font-weight: 900; text-transform: uppercase; letter-spacing: .04em; }
.card p { margin: 0; }
.good { color: var(--good); font-size: 18px; font-weight: 800; }
.kicker { color: var(--pink); font-weight: 900; text-transform: uppercase; letter-spacing: .12em; font-size: 14px; }

.btn { font: inherit; font-size: 17px; font-weight: 800; color: #fff; background: rgba(61, 245, 255, .1); border: 1.5px solid rgba(61, 245, 255, .6); min-height: 46px; padding: 8px 18px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; flex: 0 0 auto; text-transform: uppercase; letter-spacing: .05em; clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px); }
.btn:hover { background: rgba(61, 245, 255, .2); }
.btn:active { transform: translateY(2px); }
.btn:disabled { opacity: .4; cursor: default; transform: none; }
.btn.primary { background: linear-gradient(180deg, #ff5aa9, var(--pink)); border-color: #ffb0d6; box-shadow: 0 0 22px rgba(255, 61, 154, .6); }
.btn.big { font-size: 28px; min-height: 66px; padding: 8px 28px; width: 100%; flex-direction: column; gap: 0; line-height: 1.1; }
.btn.big small { font-size: 13px; font-weight: 700; opacity: .92; text-transform: none; letter-spacing: 0; }
.btn.small { font-size: 14px; min-height: 38px; padding: 4px 14px; align-self: center; }
.row { display: flex; gap: 10px; justify-content: center; width: 100%; }
.row .btn { flex: 1 1 0; }

/* ---- level-up cards ---- */
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.upg { font: inherit; color: var(--ink); background: rgba(10, 20, 46, .95); border: 2px solid var(--c, var(--cyan)); padding: 12px 10px 14px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 6px;
  min-height: 190px; clip-path: var(--cut); box-shadow: inset 0 0 24px rgba(0,0,0,.4); transition: transform .08s, background .08s; }
.upg:hover, .upg:focus-visible { background: rgba(30, 44, 86, .95); transform: translateY(-3px); outline: none; }
.upg:active { transform: translateY(1px); }
.upg canvas { width: 64px; height: 64px; }
.upg b { font-size: 18px; font-weight: 900; text-transform: uppercase; letter-spacing: .03em; color: var(--c, #fff); }
.upg .lvtag { font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.upg .lvtag.new { color: var(--gold); }
.upg .desc { font-size: 14px; line-height: 1.3; color: #dfeeff; }
.upg .key { margin-top: auto; font-size: 12px; color: var(--muted); font-weight: 800; }
.cards.locked .upg { pointer-events: none; opacity: .75; }

.scores { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.scores > div { background: var(--well); padding: 7px 4px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.scores b { display: block; font-size: 21px; color: #fff; font-variant-numeric: tabular-nums; letter-spacing: 0; }

.guide { overflow-y: auto; touch-action: pan-y; -ms-touch-action: pan-y; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; gap: 6px; min-height: 0; flex: 1 1 auto; }
.guide h3 { margin: 8px 0 0; font-size: 13px; color: var(--cyan); text-transform: uppercase; letter-spacing: .1em; }
.guide p { font-size: 15px; line-height: 1.4; }
.entry { display: flex; align-items: center; gap: 10px; background: var(--well); padding: 6px 10px; text-align: left; }
.entry canvas { width: 40px; height: 40px; flex: 0 0 40px; }
.entry b { display: block; font-size: 15px; }
.entry span { font-size: 13px; color: var(--muted); line-height: 1.3; }
.ad-ico { flex: 0 0 auto; }

@media (max-width: 640px) {
  .cards { grid-template-columns: 1fr; gap: 7px; }
  .upg { min-height: 0; display: grid; grid-template-columns: 50px 1fr; grid-template-rows: auto auto auto; text-align: left; column-gap: 10px; row-gap: 2px; padding: 8px 12px; }
  .upg canvas { grid-row: 1 / 4; width: 48px; height: 48px; align-self: center; }
  .upg .key { display: none; }
  .scores { grid-template-columns: repeat(2, 1fr); }
  .pill { font-size: 15px; height: 32px; padding: 0 8px; } .hudrow { gap: 4px; }
  .hearts i { width: 13px; height: 12px; clip-path: path('M6.5 12 L1.1 6.1 A3.1 3.1 0 0 1 6.5 2.1 A3.1 3.1 0 0 1 11.9 6.1 Z'); }
  .build span { width: 24px; height: 24px; }
}
@media (max-width: 380px) { .pill.score { display: none; } }
@media (max-height: 480px) {
  .logo { font-size: 40px; } .tagline { display: none; } .btn.big { font-size: 22px; min-height: 50px; }
  .card { padding: 10px 14px; gap: 7px; } .card h2 { font-size: 21px; }
  .upg { min-height: 0; padding: 8px; gap: 3px; } .upg canvas { width: 42px; height: 42px; } .upg .desc { font-size: 13px; }
  #tip { bottom: calc(36px + var(--sb)); } #tip p { font-size: 14px; }
}
