/* SIXTH WING — steel & afterburner theme */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; background: #0a0e14; color: #e8eef4;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  touch-action: none; user-select: none; -webkit-user-select: none; }
button { font-family: inherit; }
.hidden { display: none !important; }

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

/* ---------------- screens ---------------- */
.scr { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column;
  align-items: center; justify-content: safe center; gap: 14px; padding: 20px;
  padding-top: max(20px, env(safe-area-inset-top));
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  background: radial-gradient(120% 90% at 50% 0%, #16243a 0%, #0a0e14 62%, #06080c 100%);
  overflow-y: auto; }
.scr.seethru { background: rgba(6, 8, 12, 0.55); }
.backlink { position: absolute; top: max(12px, env(safe-area-inset-top)); left: 14px;
  color: #9fb4c8; text-decoration: none; font-size: 14px; z-index: 2; }
.backlink:hover { color: #fff; }
.game-title { font-size: clamp(42px, 9vw, 76px); letter-spacing: 0.06em; font-weight: 800;
  line-height: 1; text-transform: uppercase; margin-top: 10px;
  background: linear-gradient(180deg, #dff1ff 20%, #6fc3ff 52%, #1d5f96 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 14px rgba(60, 160, 255, 0.35)); }
.game-title .six { color: #ffb648; background: linear-gradient(180deg, #ffe9c2 15%, #ffb648 55%, #b35d00 100%);
  -webkit-background-clip: text; background-clip: text; }
.game-sub { color: #8fa8bd; font-size: clamp(13px, 2.6vw, 17px); letter-spacing: 0.14em; text-transform: uppercase; }
.scr-h { font-size: clamp(20px, 4.5vw, 30px); letter-spacing: 0.08em; color: #cfe4f6; text-transform: uppercase; }

.btn { background: linear-gradient(180deg, #1c2c42, #14202f); color: #dce9f5;
  border: 1px solid #2f4a68; border-radius: 10px; padding: 12px 26px; font-size: 17px;
  cursor: pointer; letter-spacing: 0.04em; transition: transform 0.08s, box-shadow 0.12s; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 18px rgba(80, 160, 255, 0.18); }
.btn.primary { background: linear-gradient(180deg, #ff9d3d, #d96a00); border-color: #ffb96e;
  color: #1c0e00; font-weight: 700; font-size: 19px; padding: 14px 42px; }
.btn.small { font-size: 13px; padding: 8px 14px; border-radius: 8px; }
.btn.on { border-color: #ffb648; color: #ffcf8a; box-shadow: 0 0 10px rgba(255, 165, 60, 0.25) inset; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; align-items: center; }
.ctl-lbl { color: #7d93a8; font-size: 13px; margin-right: 4px; }

/* craft cards */
.craft-cards { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; max-width: 860px; }
.craft-card { width: min(360px, 88vw); background: linear-gradient(180deg, #131e2e, #0d1420);
  border: 1px solid #263b55; border-radius: 14px; padding: 14px 16px 16px; cursor: pointer;
  color: inherit; text-align: left; transition: border-color 0.12s, transform 0.1s; }
.craft-card:hover { transform: translateY(-2px); }
.craft-card.on { border-color: #ffb648; box-shadow: 0 0 0 1px #ffb648, 0 6px 26px rgba(255, 160, 50, 0.15); }
.craft-name { font-size: 20px; font-weight: 800; letter-spacing: 0.04em; color: #eaf4fd; }
.craft-sub { font-size: 13px; color: #8fa8bd; margin: 4px 0 10px; line-height: 1.45; }
.craft-view { width: 100%; height: 120px; border-radius: 8px; display: block;
  background: radial-gradient(90% 130% at 50% 110%, #1b3048 0%, #0a1018 70%); }
.craft-view canvas { width: 100%; height: 100%; display: block; }
.stat-rows { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; margin-top: 10px; font-size: 12px; color: #7d93a8; }
.stat-bar { align-self: center; height: 7px; border-radius: 4px; background: #182636; overflow: hidden; }
.stat-bar i { display: block; height: 100%; background: linear-gradient(90deg, #3f9be0, #7fd0ff); }

/* stage select */
.stage-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 190px));
  gap: 12px; justify-content: center; max-width: 680px; }
.stage-card { position: relative; background: linear-gradient(180deg, #131e2e, #0d1420);
  border: 1px solid #263b55; border-radius: 12px; padding: 12px; cursor: pointer; color: inherit;
  text-align: left; min-height: 96px; }
.stage-card:hover:not(.locked) { border-color: #5f87b4; }
.stage-card.locked { opacity: 0.42; cursor: default; }
.stage-num { font-size: 11px; color: #ffb648; letter-spacing: 0.2em; }
.stage-name { font-size: 15px; font-weight: 700; margin: 2px 0 4px; color: #e8f2fb; }
.stage-sub { font-size: 11px; color: #7d93a8; line-height: 1.4; }
.stage-meta { margin-top: 6px; font-size: 11px; color: #c8a86a; }
.diff-row .btn.small { min-width: 74px; }

.help-box { max-width: 560px; background: rgba(13, 20, 32, 0.85); border: 1px solid #263b55;
  border-radius: 12px; padding: 18px 20px; font-size: 14px; line-height: 1.55; color: #b9cbda; }
.help-box h3 { color: #ffcf8a; font-size: 14px; letter-spacing: 0.1em; margin: 12px 0 4px; text-transform: uppercase; }
.help-box h3:first-child { margin-top: 0; }
.help-box .tip { margin-top: 12px; color: #7fd0ff; }

/* ---------------- HUD ---------------- */
#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none;
  font-variant-numeric: tabular-nums; }
.hud-top { position: absolute; top: max(6px, env(safe-area-inset-top)); left: 10px; right: 10px;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.hud-score { font-size: clamp(16px, 3.4vw, 22px); font-weight: 800; color: #fff;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8); }
.hud-score .hs { display: block; font-size: 11px; font-weight: 400; color: #93a9bd; }
.hud-chain { font-size: clamp(13px, 2.8vw, 18px); color: #ffb648; font-weight: 700; min-height: 20px;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8); }
.hud-btns { display: flex; gap: 6px; pointer-events: auto; }
.hud-btns button { width: 34px; height: 34px; border-radius: 8px; border: 1px solid #33506f;
  background: rgba(15, 24, 38, 0.75); color: #cfe4f6; font-size: 16px; cursor: pointer; }
.hud-bottom { position: absolute; left: 10px; right: 10px;
  bottom: max(8px, env(safe-area-inset-bottom)); display: flex; justify-content: space-between;
  align-items: flex-end; pointer-events: none; }
.hud-pods { font-size: 15px; color: #d6e6f4; text-shadow: 0 1px 5px #000; line-height: 1.5; }
.hud-pods .lbl { font-size: 10px; color: #7d93a8; letter-spacing: 0.12em; }
#hyper-wrap { width: min(200px, 34vw); }
#hyper-bar { height: 10px; background: rgba(255, 255, 255, 0.1); border: 1px solid #4a4a2a;
  border-radius: 6px; overflow: hidden; }
#hyper-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #c8922a, #ffd257); }
#hyper-wrap.ready #hyper-fill { animation: hyperpulse 0.5s infinite alternate; }
#hyper-lbl { font-size: 10px; letter-spacing: 0.14em; color: #b9a35e; margin-top: 3px; text-align: right; }
@keyframes hyperpulse { from { filter: brightness(1); } to { filter: brightness(1.7); } }
#boss-wrap { position: absolute; top: max(44px, calc(env(safe-area-inset-top) + 38px));
  left: 50%; transform: translateX(-50%); width: min(430px, 78vw); }
#boss-bar { position: relative; height: 9px; background: rgba(0, 0, 0, 0.5); border: 1px solid #7c2f3b; border-radius: 5px; overflow: hidden; }
#boss-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #ff5a4e, #ffb14e); transition: width .12s linear; }
/* the HP walls, drawn on the bar — a boss ALWAYS takes N gated stages, and the
   bar has to say so or a stalled bar looks broken */
.boss-pip { position: absolute; top: 0; width: 2px; height: 100%; background: rgba(10, 6, 8, 0.85);
  box-shadow: 0 0 0 1px rgba(255, 220, 190, 0.35); pointer-events: none; }
#boss-fill.vuln { background: linear-gradient(90deg, #6fe8ff, #d8f6ff); box-shadow: 0 0 10px #9fe8ff; }
#boss-name.guarded { color: #ffd257; }
#boss-name { text-align: center; font-size: 12px; letter-spacing: 0.18em; color: #ff9e94;
  text-shadow: 0 1px 5px #000; margin-bottom: 3px; text-transform: uppercase; }

/* side gutters (landscape / desktop tate-in-yoko) */
.gutter { position: absolute; top: 0; bottom: 0; width: var(--gutter-w, 0px); display: none;
  background: linear-gradient(180deg, #0b1119 0%, #0d1522 55%, #0b1119 100%); z-index: 9; }
#gutter-l { left: 0; border-right: 1px solid #1d2c40; }
#gutter-r { right: 0; border-left: 1px solid #1d2c40; }
body.gutters .gutter { display: block; }
.gutter-inner { padding: 52px 14px; color: #7d93a8; font-size: 12px; display: flex;
  flex-direction: column; gap: 14px; }
.gutter-inner b { color: #d6e6f4; font-size: 16px; }
.g-title { letter-spacing: 0.16em; text-transform: uppercase; font-size: 10px; color: #4d6a86; }
/* gutter legends: controls (left) + pickups (right) */
.g-sec { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.g-key { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: #9fb3c6; }
.g-key kbd { font: 600 10.5px/1 ui-monospace, Menlo, monospace; color: #d6e6f4;
  background: #17283c; border: 1px solid #2a445e; border-radius: 5px;
  padding: 3px 6px; min-width: 16px; text-align: center; }
.g-drop { font-size: 11.5px; color: #9fb3c6; }

/* banners / toasts / center text */
#center-banner { position: absolute; top: 34%; left: 0; right: 0; text-align: center;
  font-size: clamp(26px, 7vw, 54px); font-weight: 900; letter-spacing: 0.1em; color: #ffd257;
  text-shadow: 0 2px 18px rgba(255, 150, 40, 0.55), 0 2px 4px #000; opacity: 0;
  transform: scale(0.8); transition: opacity 0.18s, transform 0.22s; text-transform: uppercase; }
#center-banner.show { opacity: 1; transform: scale(1); }
#center-banner.warn { color: #ff5a4e; text-shadow: 0 2px 18px rgba(255, 60, 40, 0.6), 0 2px 4px #000; }
#sub-banner { position: absolute; top: 46%; left: 0; right: 0; text-align: center;
  font-size: clamp(13px, 3vw, 19px); color: #cfe4f6; text-shadow: 0 1px 6px #000; opacity: 0; transition: opacity 0.25s; }
#sub-banner.show { opacity: 1; }
#toast { position: absolute; bottom: 26%; left: 0; right: 0; text-align: center; font-size: 15px;
  color: #9fe1ff; text-shadow: 0 1px 6px #000; opacity: 0; transition: opacity 0.3s; }
#toast.show { opacity: 1; }

/* touch buttons */
#touch-ui { position: absolute; right: 10px; bottom: max(64px, calc(env(safe-area-inset-bottom) + 56px));
  display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.tbtn { pointer-events: auto; width: 64px; height: 64px; border-radius: 50%;
  border: 2px solid rgba(150, 190, 230, 0.5); background: rgba(20, 32, 50, 0.55);
  color: #dce9f5; font-size: 12px; font-weight: 800; letter-spacing: 0.04em; }
.tbtn:active { background: rgba(70, 110, 160, 0.6); }
.tbtn.bomb { border-color: rgba(255, 120, 90, 0.6); color: #ffb0a0; }
.tbtn.hyper { border-color: rgba(255, 210, 87, 0.7); color: #ffd257; opacity: 0.35; }
.tbtn.hyper.ready { opacity: 1; animation: hyperpulse 0.5s infinite alternate; }
body.kbm #touch-ui { display: none; }

/* overlay (pause / results) */
#overlay { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center;
  justify-content: center; background: rgba(5, 8, 12, 0.72); padding: 16px; }
#overlay .panel { background: linear-gradient(180deg, #131e2e, #0c1220); border: 1px solid #2c4562;
  border-radius: 16px; padding: 26px 30px; display: flex; flex-direction: column; gap: 10px;
  align-items: center; min-width: min(360px, 88vw); max-height: 86vh; overflow-y: auto; }
#ov-title { font-size: 24px; letter-spacing: 0.1em; color: #ffcf8a; text-transform: uppercase; }
#ov-rows { width: 100%; font-size: 15px; color: #b9cbda; }
#ov-rows .row { display: flex; justify-content: space-between; padding: 4px 2px; }
#ov-rows .row b { color: #fff; }
#ov-rows .rank-line { text-align: center; font-size: 40px; font-weight: 900; color: #ffd257; padding: 8px; }
#ov-rows .stars-line { text-align: center; font-size: 26px; color: #ffd257; letter-spacing: 6px; }
.ov-leave { margin-top: 6px; color: #7d93a8; font-size: 13px; text-decoration: none; }
.ov-leave:hover { color: #fff; }

#loading { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center;
  justify-content: center; flex-direction: column; gap: 14px; background: #06080c; color: #8fa8bd; }
#loadbar { width: min(320px, 70vw); height: 8px; border-radius: 4px; overflow: hidden;
  background: rgba(255, 255, 255, 0.12); border: 1px solid rgba(255, 255, 255, 0.25); }
#loadbar-fill { height: 100%; width: 0%; background: #6fc3ff; transition: width 0.15s; }
#loadnote { font-size: 12px; opacity: 0.6; }

/* stage-clear fireworks canvas sits above HUD, below overlay */
#fxcv { position: fixed; inset: 0; z-index: 25; pointer-events: none; }
