@font-face { font-family: 'Orbitron'; src: url('fonts/Orbitron-Bold.ttf') format('truetype'); font-weight: 700; font-display: swap; }
:root {
  --bg: #120c1c; --ink: #f3ecff; --dim: #b8a9cf; --panel: rgba(22, 14, 36, 0.94); --line: #4a3566;
  --mag: #ff4fd8; --gold: #ffc94a; --cyan: #5fe3ff; --green: #57f59a; --danger: #ff6464;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); overflow: hidden;
  font: 15px/1.4 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; user-select: none; -webkit-user-select: none;
  touch-action: none; overscroll-behavior: none; }
#stage { position: fixed; inset: 0; overflow: hidden; background: #000; }
#game { position: absolute; left: 0; top: 0; image-rendering: pixelated; image-rendering: crisp-edges; }
img { image-rendering: pixelated; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--mag); }

/* HUD */
#hud { position: fixed; left: 0; right: 0; top: 0; padding: max(6px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left)); pointer-events: none; z-index: 5; }
#hud .row { display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; }
.chip { display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 9px; border-radius: 8px;
  background: rgba(10, 6, 18, 0.72); border: 1px solid rgba(255, 255, 255, 0.12); font: 700 13px 'Orbitron', system-ui; white-space: nowrap; }
.chip img { height: 16px; width: auto; }
.chip.pol { color: var(--mag); }
.chip.pol img { height: 20px; }
.chip.btn { margin-left: auto; pointer-events: auto; font-size: 16px; }
#hDepth { min-width: 64px; justify-content: center; }
.fuel, #bossbar { display: flex; align-items: center; gap: 6px; margin-top: 5px; font: 700 10px 'Orbitron', system-ui; color: var(--dim); }
.bar { flex: 1; max-width: 320px; height: 9px; border-radius: 5px; background: rgba(10, 6, 18, 0.72); border: 1px solid rgba(255, 255, 255, 0.15); overflow: hidden; }
.bar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #ffb347, #ffe27a); transition: width 0.15s; }
.bar i.low { background: linear-gradient(90deg, #ff3b3b, #ff8a5c); animation: blink 0.6s steps(2) infinite; }
#bossbar { color: #ffd0d0; }
#bossbar .bar i { background: linear-gradient(90deg, #ff2d55, #ff8a3d); }
@keyframes blink { 50% { opacity: 0.45; } }

#toasts { position: fixed; left: 50%; top: calc(92px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 6; display: flex; flex-direction: column;
  align-items: center; gap: 6px; pointer-events: none; width: min(92vw, 460px); }
.toast { background: rgba(14, 8, 24, 0.9); border: 1px solid var(--line); border-radius: 10px; padding: 7px 12px; text-align: center;
  font-weight: 600; animation: tin 0.25s ease-out; }
.toast.mag { border-color: var(--mag); box-shadow: 0 0 18px rgba(255, 79, 216, 0.45); color: #ffd6f5; }
.toast.warn { border-color: #ff9a3d; color: #ffe0c2; }
.toast.good { border-color: #ffc94a; color: #fff2c4; }
.toast.boss { border-color: #ff2d55; color: #ffd0d0; font-family: 'Orbitron', system-ui; }
.toast.out { opacity: 0; transition: opacity 0.4s; }
@keyframes tin { from { transform: translateY(-8px); opacity: 0; } }

#act { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(150px + env(safe-area-inset-bottom)); z-index: 6;
  padding: 12px 22px; border-radius: 12px; border: 2px solid var(--gold); background: rgba(30, 18, 6, 0.92); color: var(--gold);
  font: 700 15px 'Orbitron', system-ui; }
@media (pointer: fine) { #act { bottom: 40px; } }

/* touch controls */
#touch { position: fixed; left: 0; right: 0; bottom: 0; padding: 0 max(14px, env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); z-index: 5;
  display: flex; justify-content: space-between; align-items: flex-end; pointer-events: none; }
#touch button { pointer-events: auto; touch-action: none; border: 2px solid rgba(255, 255, 255, 0.25); background: rgba(16, 10, 28, 0.55);
  color: #fff; border-radius: 16px; font-size: 24px; }
#touch button.on { background: rgba(255, 201, 74, 0.35); border-color: var(--gold); }
#touch .pad { display: grid; grid-template-columns: repeat(3, 64px); gap: 8px; }
#touch .pad button { height: 64px; }
#touch .thrust { width: 92px; height: 92px; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; }
#touch .thrust small { font: 700 11px 'Orbitron', system-ui; margin-top: 3px; }

/* panels */
.panel { position: fixed; inset: 0; z-index: 10; display: none; align-items: center; justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: rgba(8, 4, 14, 0.55); }
.panel.show { display: flex; }
.card { width: min(100%, 440px); max-height: calc(100% - 8px); overflow: auto; background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 18px 18px 16px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5); touch-action: pan-y; }
#title { background: linear-gradient(180deg, rgba(8, 4, 14, 0.15), rgba(8, 4, 14, 0.7)); }
#title .card { text-align: center; background: rgba(18, 11, 30, 0.86); }
h1 { font: 700 40px/1 'Orbitron', system-ui; margin: 4px 0 8px; letter-spacing: 1px; color: var(--gold);
  text-shadow: 0 3px 0 #6b3a00, 0 0 24px rgba(255, 201, 74, 0.35); }
h1 b { color: var(--mag); text-shadow: 0 3px 0 #5a0f4c, 0 0 24px rgba(255, 79, 216, 0.4); }
h2 { font: 700 20px 'Orbitron', system-ui; margin: 0 0 10px; color: var(--gold); }
.tag { color: var(--dim); margin: 0 0 14px; }
.mag { color: var(--mag); font-weight: 700; }
.col { display: flex; flex-direction: column; gap: 8px; }
.card button { padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line); background: #24173a; font-weight: 700; }
.card button.big { font: 700 17px 'Orbitron', system-ui; padding: 13px; background: linear-gradient(180deg, #ffd25e, #e59a1e); color: #2a1600; border: 0; }
.card button.ghost { background: transparent; color: var(--dim); }
.card button.danger { background: transparent; color: var(--danger); border-color: rgba(255, 100, 100, 0.4); }
.card button:disabled { opacity: 0.45; cursor: default; }
.card ul { padding-left: 18px; margin: 0 0 10px; }
.card li { margin-bottom: 6px; }
.proto { font-size: 12px; color: #ffb3ec; margin: 12px 0 4px; }
.credit { font-size: 12px; color: var(--dim); margin: 6px 0 0; }
.keys, .todo, .sub { font-size: 13px; color: var(--dim); }
.promo { font-size: 12px; color: var(--dim); border: 1px dashed var(--line); border-radius: 10px; padding: 8px; margin-top: 10px; }
.promo:empty { display: none; }

.up { display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.up img { width: 32px; height: 32px; object-fit: contain; }
.robicon { width: 32px; height: 32px; background: url('assets/robot_idle.png') 0 0 / 96px 96px; image-rendering: pixelated; transform: scale(1.25); }
.up .nm { font-weight: 700; }
.up .pips { color: var(--gold); letter-spacing: 2px; font-size: 12px; }
.up .ds { font-size: 12px; color: var(--dim); }
.up button { min-width: 86px; }
#shopElevators { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }

#dev { position: fixed; right: 6px; bottom: 50%; z-index: 7; display: flex; flex-direction: column; gap: 4px; font-size: 11px;
  background: rgba(0, 0, 0, 0.6); padding: 6px; border-radius: 8px; border: 1px solid #f0f; }
#dev button { font-size: 11px; padding: 4px 6px; background: #301040; border: 1px solid #a3a; border-radius: 6px; }

/* audio controls (title card + pause menu) */
.audio { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.card .audio button { flex: 1 1 0; min-width: 0; padding: 8px 10px; font-size: 13px; }
.audio .mvol { flex: 1 1 100%; display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--dim); text-align: left; }
.audio .mvol.off { opacity: 0.45; }
.audio input[type=range] { flex: 1; min-width: 0; accent-color: var(--gold); touch-action: auto; height: 28px; }
.col > .audio { margin: 0 0 2px; }
.note { font-size: 13px; color: #c9f7ff; border: 1px solid rgba(95, 227, 255, 0.4); border-radius: 10px; padding: 8px 10px; margin: 10px 0 0; }

/* shop: tabs, style items */
.shophead { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.shophead h2 { margin-bottom: 4px; }
.shophead .sub { margin: 0; }
.tabs { display: flex; gap: 6px; margin: 4px 0 2px; }
.card .tabs button { flex: 1; padding: 8px; font-size: 13px; background: transparent; color: var(--dim); }
.card .tabs button.on { background: #24173a; color: var(--gold); border-color: var(--gold); }
.robicon.jet { background-image: url('assets/robot_jump.png'); background-position: 0 -32px; }
.stitle { font: 700 12px 'Orbitron', system-ui; color: var(--dim); margin: 12px 0 6px; }
.sgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; }
.card .sitem { display: grid; grid-template-columns: 18px 1fr; grid-template-rows: auto auto; column-gap: 8px; text-align: left; padding: 8px; font-size: 13px; }
.sitem .sw { grid-row: span 2; width: 18px; height: 18px; border-radius: 50%; align-self: center; border: 1px solid rgba(255, 255, 255, 0.4); }
.sitem small { color: var(--gold); font-weight: 700; }
.card .sitem.on { border-color: var(--gold); opacity: 1; }

/* two-tap confirm */
.card button.armed { background: rgba(255, 100, 100, 0.18); color: #ffd0d0; border-color: var(--danger); }

/* small phones (320-359 px wide): HUD fits, a gap between the pad and FLY */
@media (max-width: 359px) {
  #hud .row { gap: 4px; }
  .chip { padding: 0 6px; gap: 3px; height: 28px; font-size: 11px; }
  .chip img { height: 13px; }
  .chip.pol img { height: 16px; }
  .chip.btn { font-size: 15px; }
  #hDepth { min-width: 44px; }
  #touch { padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
  #touch .pad { grid-template-columns: repeat(3, 56px); gap: 6px; }
  #touch .pad button { height: 58px; }
  #touch .thrust { width: 80px; height: 80px; }
  .up { grid-template-columns: 34px 1fr auto; gap: 8px; }
  .up button { min-width: 74px; }
}
/* short screens: the title card fits without scrolling */
@media (max-height: 620px) {
  h1 { font-size: 30px; margin: 0 0 6px; }
  .card { padding: 14px 14px 12px; }
  .tag { margin-bottom: 10px; font-size: 14px; }
  .col { gap: 6px; }
  .card button { padding: 8px 12px; }
  .card button.big { padding: 10px; font-size: 16px; }
  .audio { margin-top: 8px; gap: 6px; }
  .audio input[type=range] { height: 22px; }
  .proto { margin-top: 8px; }
  .promo { margin-top: 6px; padding: 6px; }
}
/* landscape phones: the shop fits on one card, the action button sits between the pad and FLY */
@media (orientation: landscape) and (max-height: 500px) {
  .panel { padding-top: max(8px, env(safe-area-inset-top)); padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  .card { max-height: 100%; }
  #shop .card { width: min(100%, 880px); padding: 10px 14px; }
  #shop h2 { font-size: 17px; margin: 0; }
  #shopList { display: grid; grid-template-columns: 1fr 1fr; column-gap: 16px; }
  .up { padding: 6px 0; }
  .up .ds { font-size: 11px; }
  #shop .todo { display: none; }
  #shop .close.big { padding: 8px; font-size: 15px; margin-top: 6px; }
  #shopElevators { flex-direction: row; flex-wrap: wrap; }
  #shopElevators button { flex: 1 1 200px; padding: 6px 8px; font-size: 12px; }
  .sgrid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .stitle { margin: 6px 0 4px; }
}
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  #act { bottom: calc(22px + env(safe-area-inset-bottom)); }
  #toasts { top: calc(70px + env(safe-area-inset-top)); }
}

/* 2026-10-28: the POL line on the title card and links inside toasts */
#polStatus { color: #ffd6f5; border-color: rgba(255, 79, 216, 0.45); line-height: 1.45; }
#polStatus:empty { display: none; }
#polStatus a, .toast a { color: #ff9be9; font-weight: 700; }

/* invite box (2026-10-28) */
.invite { margin-top: 12px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; text-align: left; }
.invite h2 { font: 700 13px 'Orbitron', system-ui; letter-spacing: 0.08em; margin: 0 0 6px; color: var(--gold); }
.invite input { width: 100%; box-sizing: border-box; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: #140d22; color: inherit; font: 13px ui-monospace, monospace; }
.invite .row { display: flex; gap: 8px; margin-top: 8px; }
.invite .ivnote { min-height: 1em; font-size: 12px; color: var(--gold); margin: 6px 0 0; }

/* badges (2026-10-28): toast with the medal, and the Badges screen (2 columns from 360 px, 1 below) */
.toast.badge { display: flex; align-items: center; gap: 10px; text-align: left; border-color: var(--gold); box-shadow: 0 0 18px rgba(255, 201, 74, 0.45); color: #fff2c4; }
.toast.badge small { display: block; font: 700 10px 'Orbitron', system-ui; letter-spacing: 0.12em; color: var(--gold); }
.toast.badge b { font: 700 14px 'Orbitron', system-ui; }
canvas.bicon { image-rendering: pixelated; flex: none; display: block; }
#badges .card { width: min(100%, 560px); }
#badges .sub { margin: 0 0 6px; color: var(--dim); }
#badgeList h3 { font: 700 12px 'Orbitron', system-ui; letter-spacing: 0.1em; color: var(--gold); margin: 12px 0 6px; text-transform: uppercase; }
.bgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; }
.btile { display: flex; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; background: rgba(0, 0, 0, 0.18); text-align: left; }
.btile.on { border-color: rgba(255, 201, 74, 0.55); background: rgba(255, 201, 74, 0.06); }
.btile b { display: block; font-size: 13px; }
.btile small { display: block; font-size: 11.5px; color: var(--dim); line-height: 1.3; }
.btile i { display: block; font-style: normal; font-size: 11px; color: var(--gold); margin-top: 2px; }
.btile:not(.on) b { color: #a99bc4; }
@media (max-width: 359px) { .bgrid { grid-template-columns: 1fr; } .btile canvas.bicon { width: 36px !important; height: 36px !important; } }
