* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
    --bg: #05060d;
    --ink: #cfe3ff;
    --dim: #6f86ad;
    --cyan: #6fd6ff;
    --glass: rgba(14, 20, 38, 0.55);
    --line: rgba(120, 160, 220, 0.14);
}
html, body { width: 100%; height: 100%; overflow: hidden; background: var(--bg); overscroll-behavior: none; }
body { font-family: 'Inter', system-ui, sans-serif; color: var(--ink); user-select: none; cursor: none; }
#gl { position: fixed; inset: 0; display: block; touch-action: none; }

/* Touch devices: no fake cursor, allow real taps on the chrome. */
body.touch { cursor: auto; }
body.touch #cursor { display: none; }

/* Custom in-style cursor: a small neon dot with a soft halo + faint ring. */
#cursor {
    position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none;
    width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%;
    border: 1px solid rgba(111,214,255,0.35);
    transition: width .12s, height .12s, border-color .12s, opacity .2s;
}
#cursor::after {
    content: ''; position: absolute; left: 50%; top: 50%; width: 6px; height: 6px;
    transform: translate(-50%,-50%); border-radius: 50%;
    background: radial-gradient(circle, #fff, var(--cyan) 60%, rgba(111,214,255,0) 100%);
    box-shadow: 0 0 10px var(--cyan), 0 0 18px rgba(111,214,255,0.6);
}
#cursor.hover { width: 38px; height: 38px; margin: -19px 0 0 -19px; border-color: rgba(111,214,255,0.7); }
#cursor.hidden { opacity: 0; }

/* Chat */
#chat-log {
    position: fixed; top: 112px; left: 50%; transform: translateX(-50%); z-index: 9;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    pointer-events: none; max-width: 70vw;
}
.chat-msg {
    font-size: 12px; letter-spacing: 0.3px; color: var(--ink);
    background: rgba(10,14,28,0.5); border: 1px solid var(--line); border-radius: 14px;
    padding: 4px 12px; backdrop-filter: blur(6px); text-shadow: 0 0 10px rgba(0,0,0,0.8);
    animation: chatIn .3s ease; transition: opacity .8s;
}
.chat-msg .who { color: var(--cyan); font-weight: 500; margin-right: 6px; }
.chat-msg.me { border-color: rgba(111,214,255,0.35); }
.chat-msg.me .who { color: #9ee6ff; }
.chat-msg.fade { opacity: 0; }
@keyframes chatIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; } }
#chat-input {
    position: fixed; left: 50%; bottom: 120px; transform: translateX(-50%); z-index: 30;
    width: 440px; max-width: 80vw; padding: 11px 18px; font-size: 13px; font-family: inherit;
    color: var(--ink); letter-spacing: 0.4px; text-align: center; cursor: text;
    background: rgba(10,14,28,0.7); border: 1px solid var(--cyan); border-radius: 24px;
    outline: none; backdrop-filter: blur(10px); display: none;
    box-shadow: 0 0 30px rgba(111,214,255,0.25);
}
#chat-input.open { display: block; }

/* ---- top bar ---- */
#topbar {
    position: fixed; top: 0; left: 0; right: 0; min-height: 38px; z-index: 10;
    display: flex; align-items: center; justify-content: space-between;
    padding: env(safe-area-inset-top, 0px) calc(14px + env(safe-area-inset-right, 0px)) 0 calc(14px + env(safe-area-inset-left, 0px));
    font-size: 12px; letter-spacing: 0.5px;
    color: var(--dim);
    background: linear-gradient(180deg, rgba(5,7,14,0.85), rgba(5,7,14,0));
    pointer-events: none;
}
#topbar .seg { display: flex; align-items: center; gap: 12px; pointer-events: auto; }
#topbar .center { flex: 1; justify-content: center; }
.sector { color: var(--ink); font-weight: 500; letter-spacing: 2px; text-transform: lowercase; font-size: 13px; }
.galaxy { color: var(--cyan); font-weight: 500; letter-spacing: 2px; text-transform: lowercase; font-size: 12px; opacity: 0.85; }
.region { color: var(--ink); font-weight: 400; letter-spacing: 1.5px; text-transform: lowercase; font-size: 12px; opacity: 0.7; }
.sep { color: var(--dim); opacity: 0.5; margin: 0 2px; }

/* Small left-divider so the ship stats read as a group in the top bar. */
.stat.sep-l { border-left: 1px solid var(--line); padding-left: 12px; margin-left: 2px; }

#radar {
    position: fixed; right: 14px; top: 48px; z-index: 9;
    width: 124px; height: 124px; border-radius: 50%;
    background: rgba(8,12,24,0.4); backdrop-filter: blur(6px);
    border: 1px solid var(--line);
    box-shadow: 0 0 24px rgba(0,0,0,0.4);
}
.stat { display: inline-flex; align-items: center; gap: 5px; }
.stat i { color: var(--cyan); font-style: normal; display: inline-flex; align-items: center; }
.stat i .ico { width: 13px; height: 13px; }
/* SVG icon defaults */
.ico { width: 15px; height: 15px; display: inline-block; vertical-align: middle; }
.icon-btn .ico { width: 17px; height: 17px; }
.flag { width: 21px; height: 14px; border-radius: 2px; display: block; }
.flag-btn { padding: 4px 5px; line-height: 0; }
.stat b { color: var(--ink); font-weight: 500; font-variant-numeric: tabular-nums; display: inline-block; text-align: right; }
.stat.light b { color: var(--cyan); }
.stat .lbl { color: var(--dim); font-size: 9px; letter-spacing: 0.5px; text-transform: uppercase; margin-left: 3px; opacity: 0.75; }
/* Fixed widths so changing digits don't reflow the bar (no flicker). */
#hud-players, #hud-anomalies { min-width: 1.6ch; }
#st-speed { min-width: 4ch; }
#st-glow { min-width: 2.5ch; }
#st-dust { min-width: 5.5ch; }
#hud-time { min-width: 4ch; }
#hud-ly { min-width: 8ch; }
#hud-music { display: inline-block; min-width: 11ch; text-align: left; }
.statbtn {
    background: none; border: none; color: inherit; font: inherit; cursor: pointer;
    padding: 2px 4px; border-radius: 6px; transition: background .2s, color .2s;
}
.statbtn:hover { background: rgba(111,214,255,0.1); color: var(--cyan); }
.statbtn.active { background: rgba(111,214,255,0.15); color: var(--cyan); }

#players-panel {
    position: fixed; top: 184px; right: 14px; z-index: 12; width: 250px;
    background: var(--glass); border: 1px solid var(--line); border-radius: 14px;
    padding: 8px; backdrop-filter: blur(12px); display: flex; flex-direction: column; gap: 2px;
    transition: opacity .2s, transform .2s;
}
#players-panel.hidden { opacity: 0; transform: translateY(-6px); pointer-events: none; }
.players-head {
    font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--dim);
    padding: 4px 8px 6px; opacity: 0.7;
}
.player-row {
    display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink);
    padding: 6px 8px; border-radius: 9px;
}
.player-row.me-row { background: rgba(111,214,255,0.08); }
.player-row .prank { flex: none; width: 18px; text-align: center; font-size: 11px; color: var(--dim); }
.player-row .pdot { width: 9px; height: 9px; border-radius: 50%; box-shadow: 0 0 8px currentColor; flex: none; }
.player-row .pname { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: 0.5px; }
.player-row .pname em { color: var(--dim); font-size: 10px; font-style: normal; margin-left: 4px; }
.player-row .pstats { flex: none; text-align: right; font-size: 11px; line-height: 1.3; color: var(--ink); }
.player-row .pstats .pdust { color: var(--cyan); opacity: 0.85; font-size: 10px; }
.player-row .tp {
    flex: none; background: rgba(111,214,255,0.12); border: 1px solid rgba(111,214,255,0.3);
    color: var(--cyan); border-radius: 8px; padding: 4px 9px; font-size: 11px; cursor: pointer;
    transition: background .15s;
}
.player-row .tp:hover { background: rgba(111,214,255,0.28); }

.icon-btn {
    background: none; border: none; color: var(--dim); cursor: pointer;
    font-size: 15px; line-height: 1; padding: 4px; border-radius: 6px;
    transition: color .2s, background .2s;
}
.icon-btn:hover { color: var(--cyan); background: rgba(111,214,255,0.1); }
#volume-slider { width: 70px; accent-color: var(--cyan); cursor: pointer; height: 3px; }

/* ESC menu hint (top-left text button) */
.menu-hint {
    background: none; border: 1px solid var(--line); color: var(--dim); cursor: pointer;
    font-family: inherit; font-size: 10px; letter-spacing: 1px; text-transform: uppercase;
    padding: 5px 11px; border-radius: 14px; transition: color .2s, border-color .2s, background .2s;
}
.menu-hint:hover { color: var(--cyan); border-color: rgba(111,214,255,0.4); background: rgba(111,214,255,0.08); }

/* ---- ESC pause menu ---- */
#menu {
    position: fixed; inset: 0; z-index: 32; display: flex; align-items: center; justify-content: center;
    background: radial-gradient(ellipse at center, rgba(8,12,28,0.62), rgba(5,6,13,0.9));
    backdrop-filter: blur(3px); transition: opacity .25s;
}
#menu.hidden { opacity: 0; pointer-events: none; }
.menu-panel {
    width: 460px; max-width: 92vw; max-height: 84vh; overflow-y: auto;
    background: var(--glass); border: 1px solid var(--line); border-radius: 18px;
    padding: 18px 22px; backdrop-filter: blur(14px); box-shadow: 0 0 50px rgba(0,0,0,0.5);
}
.menu-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.menu-head h2 { font-weight: 200; font-size: 22px; letter-spacing: 6px; color: #fff; text-transform: lowercase; }
.menu-section { padding: 10px 0; border-top: 1px solid var(--line); }
.menu-section h3 { font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: var(--dim); margin-bottom: 8px; opacity: 0.8; }
.menu-audio { display: flex; align-items: center; gap: 12px; }
.menu-langs, .lang-row { display: flex; gap: 8px; flex-wrap: wrap; }
.lang-opt {
    display: flex; align-items: center; gap: 7px; cursor: pointer; font-family: inherit; font-size: 12px;
    color: var(--ink); background: rgba(255,255,255,0.04); border: 1px solid var(--line);
    border-radius: 10px; padding: 7px 12px; transition: border-color .15s, background .15s;
}
.lang-opt:hover { background: rgba(111,214,255,0.08); }
.lang-opt.active { border-color: rgba(111,214,255,0.5); background: rgba(111,214,255,0.12); color: var(--cyan); }
.lang-row { justify-content: center; margin-top: 18px; }
.lang-row .lang-opt { padding: 6px 9px; }
.menu-actions { padding-top: 12px; border-top: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: wrap; }
.menu-btn {
    display: inline-flex; align-items: center; gap: 7px; cursor: pointer; font-family: inherit;
    font-size: 12px; letter-spacing: 0.5px; color: var(--dim); background: rgba(255,255,255,0.04);
    border: 1px solid var(--line); border-radius: 10px; padding: 9px 14px;
    transition: color .15s, border-color .15s, background .15s;
}
.menu-btn:hover { color: var(--cyan); border-color: rgba(111,214,255,0.4); background: rgba(111,214,255,0.08); }

/* ---- active power-up chips (top-left, under the bar) ---- */
#buffs { position: fixed; left: 14px; top: 46px; z-index: 9; display: flex; flex-direction: row; flex-wrap: wrap; gap: 6px; max-width: 46vw; }
.buff-chip {
    font-size: 11px; color: var(--ink); letter-spacing: 0.5px;
    background: var(--glass); border: 1px solid var(--line); border-radius: 20px;
    padding: 5px 12px; display: flex; align-items: center; gap: 7px;
    backdrop-filter: blur(8px);
}
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; box-shadow: 0 0 8px currentColor; }

/* ---- power-up toast (bottom-center) ---- */
#toast {
    position: fixed; left: 50%; bottom: 40px; transform: translate(-50%, 20px); z-index: 9;
    background: var(--glass); border: 1px solid rgba(155,108,255,0.4); border-radius: 30px;
    padding: 11px 22px; font-size: 13px; letter-spacing: 0.3px; color: var(--ink);
    backdrop-filter: blur(10px); display: flex; align-items: center; gap: 9px;
    opacity: 0; pointer-events: none; transition: opacity .5s, transform .5s;
    box-shadow: 0 0 30px rgba(155,108,255,0.2);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast b { color: #c9b6ff; font-weight: 600; }

/* ---- notification bar (facts / hints) — top, prominent ---- */
#fact {
    position: fixed; left: 50%; top: 52px; transform: translate(-50%, -12px); z-index: 12;
    max-width: 720px; text-align: center; font-size: 16px; font-weight: 400;
    line-height: 1.5; color: var(--ink); letter-spacing: 0.4px;
    padding: 13px 28px 13px 48px;
    background: rgba(12, 18, 34, 0.78); border: 1px solid rgba(111, 214, 255, 0.32);
    border-radius: 26px; backdrop-filter: blur(10px);
    box-shadow: 0 0 34px rgba(111, 214, 255, 0.16);
    opacity: 0; pointer-events: none; transition: opacity .6s, transform .6s;
}
#fact::before {
    content: '✦'; position: absolute; left: 22px; top: 50%; transform: translateY(-50%);
    color: var(--cyan); font-size: 16px; text-shadow: 0 0 10px var(--cyan);
}
#fact.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- remote player labels ---- */
#labels { position: fixed; inset: 0; z-index: 7; pointer-events: none; }
.player-label {
    position: absolute; transform: translate(-50%, -100%);
    font-size: 10px; letter-spacing: 1px; color: var(--ink); opacity: 0.6;
    text-shadow: 0 0 10px rgba(0,0,0,0.9); white-space: nowrap;
}

/* ---- settings panel ---- */
#settings {
    position: fixed; top: 46px; left: 14px; z-index: 11; width: 240px;
    background: var(--glass); border: 1px solid var(--line); border-radius: 14px;
    padding: 14px; backdrop-filter: blur(12px);
    transform: translateX(-280px); opacity: 0; transition: transform .3s, opacity .3s;
    display: flex; flex-direction: column; gap: 10px;
}
#settings.open { transform: translateX(0); opacity: 1; }
.set-row { display: grid; grid-template-columns: 90px 1fr 34px; align-items: center; gap: 8px; font-size: 11px; color: var(--dim); }
.set-row input { accent-color: var(--cyan); height: 3px; }
.set-row em { font-style: normal; text-align: right; color: var(--ink); }
#settings-reset {
    margin-top: 6px; padding: 8px 12px; font-size: 11px; letter-spacing: 0.5px; font-family: inherit;
    color: var(--dim); background: rgba(255,255,255,0.04); border: 1px solid var(--line);
    border-radius: 9px; cursor: pointer; transition: color .15s, border-color .15s, background .15s;
}
#settings-reset:hover { color: var(--cyan); border-color: rgba(111,214,255,0.4); background: rgba(111,214,255,0.08); }

/* ---- first-visit UI guide ---- */
#ui-guide {
    position: fixed; inset: 0; z-index: 40;
    background: radial-gradient(ellipse at center, rgba(5,8,18,0.55), rgba(4,6,13,0.8));
    backdrop-filter: blur(1.5px); transition: opacity .5s;
}
#ui-guide.hidden { opacity: 0; pointer-events: none; }
.guide-hint {
    position: fixed; max-width: 230px; font-size: 12px; line-height: 1.5; font-weight: 300;
    color: var(--ink); letter-spacing: 0.3px; padding: 9px 13px;
    background: rgba(12,18,34,0.85); border: 1px solid rgba(111,214,255,0.3); border-radius: 12px;
    box-shadow: 0 0 24px rgba(111,214,255,0.12); animation: chatIn .5s ease both;
}
.g-topleft { top: 46px; left: 14px; }
.g-topcenter { top: 46px; left: 50%; transform: translateX(-50%); text-align: center; }
.g-topright { top: 46px; right: 14px; text-align: right; }
.g-botleft { bottom: 64px; left: 14px; }
.g-botright { bottom: 150px; right: 14px; text-align: right; }
.guide-center {
    position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
    text-align: center; max-width: 440px; padding: 24px;
}
.guide-center h2 { font-weight: 200; font-size: 26px; letter-spacing: 8px; color: #fff; margin-bottom: 14px; text-transform: lowercase; }
.guide-center p { color: var(--dim); font-size: 13px; font-weight: 300; line-height: 1.7; margin-bottom: 12px; }
.guide-center b { color: var(--cyan); font-weight: 500; }
.guide-center .g-keys { font-size: 12px; opacity: 0.8; }
#guide-dismiss {
    margin-top: 10px; padding: 11px 30px; font-size: 12px; letter-spacing: 3px; font-weight: 600;
    color: var(--bg); cursor: pointer; border: none; border-radius: 28px; font-family: inherit;
    background: linear-gradient(135deg, #9ee6ff, var(--cyan)); box-shadow: 0 0 28px rgba(111,214,255,0.45);
    transition: transform .2s, box-shadow .2s;
}
#guide-dismiss:hover { transform: translateY(-2px); box-shadow: 0 0 40px rgba(111,214,255,0.65); }

/* ---- global scoreboard ---- */
#scoreboard {
    position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center;
    background: radial-gradient(ellipse at center, rgba(8,12,28,0.6), rgba(5,6,13,0.9));
    backdrop-filter: blur(3px); transition: opacity .3s;
}
#scoreboard.hidden { opacity: 0; pointer-events: none; }
.sb-panel {
    width: 540px; max-width: 92vw; max-height: 80vh; display: flex; flex-direction: column;
    background: var(--glass); border: 1px solid var(--line); border-radius: 18px;
    padding: 18px 20px; backdrop-filter: blur(14px); box-shadow: 0 0 50px rgba(0,0,0,0.5);
}
.sb-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sb-head h2 { font-weight: 200; font-size: 22px; letter-spacing: 4px; color: #fff; text-transform: lowercase; }
.sb-controls { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
#sb-search {
    flex: 1; padding: 9px 14px; font-size: 13px; font-family: inherit; color: var(--ink);
    background: rgba(255,255,255,0.04); border: 1px solid var(--line); border-radius: 20px;
    outline: none; letter-spacing: 0.5px;
}
#sb-search:focus { border-color: var(--cyan); }
.sb-sort { display: flex; gap: 4px; }
.sb-tab {
    background: none; border: 1px solid var(--line); color: var(--dim); font-family: inherit;
    font-size: 11px; letter-spacing: 0.5px; padding: 7px 12px; border-radius: 16px; cursor: pointer;
    transition: color .15s, border-color .15s, background .15s;
}
.sb-tab:hover { color: var(--ink); }
.sb-tab.active { color: var(--cyan); border-color: rgba(111,214,255,0.4); background: rgba(111,214,255,0.1); }
.sb-list { overflow-y: auto; display: flex; flex-direction: column; gap: 2px; padding-right: 4px; }
.sb-row {
    display: grid; grid-template-columns: 34px 1fr auto auto; gap: 14px; align-items: center;
    font-size: 13px; color: var(--ink); padding: 8px 10px; border-radius: 9px;
}
.sb-row:nth-child(odd) { background: rgba(255,255,255,0.02); }
.sb-rank { text-align: center; color: var(--dim); font-size: 12px; }
.sb-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: 0.5px; }
.sb-ly { color: var(--cyan); font-weight: 500; white-space: nowrap; }
.sb-dust { color: var(--dim); white-space: nowrap; min-width: 70px; text-align: right; }
.sb-empty { color: var(--dim); text-align: center; padding: 30px; opacity: 0.7; font-size: 13px; }

/* ---- start screen ---- */
#start-screen {
    position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center;
    background: radial-gradient(ellipse at center, rgba(8,12,28,0.6), rgba(5,6,13,0.95));
    transition: opacity .8s; backdrop-filter: blur(2px);
}
#start-screen.hidden { opacity: 0; pointer-events: none; }
.panel { text-align: center; max-width: 440px; padding: 20px; }
.orb-mark {
    width: 46px; height: 46px; margin: 0 auto 22px; border-radius: 50%;
    background: radial-gradient(circle, #fff, var(--cyan) 45%, rgba(111,214,255,0) 72%);
    box-shadow: 0 0 50px var(--cyan), 0 0 90px rgba(111,214,255,0.5);
    animation: breathe 4s ease-in-out infinite;
}
@keyframes breathe { 0%,100% { transform: scale(1); opacity: .9; } 50% { transform: scale(1.12); opacity: 1; } }
.panel h1 { font-weight: 200; font-size: 34px; letter-spacing: 12px; color: #fff; margin-bottom: 10px; }
.panel .sub { color: var(--dim); font-size: 13px; font-weight: 300; letter-spacing: 1px; margin-bottom: 26px; }
#name-input {
    width: 260px; padding: 12px 16px; font-size: 14px; text-align: center; color: var(--ink);
    background: rgba(255,255,255,0.04); border: 1px solid var(--line); border-radius: 30px;
    outline: none; font-family: inherit; letter-spacing: 1px; margin-bottom: 14px;
}
#name-input:focus { border-color: var(--cyan); }
#begin-btn {
    display: block; margin: 0 auto; padding: 12px 38px; font-size: 13px; letter-spacing: 3px;
    color: var(--bg); font-weight: 600; cursor: pointer; border: none; border-radius: 30px;
    background: linear-gradient(135deg, #9ee6ff, var(--cyan)); font-family: inherit;
    box-shadow: 0 0 30px rgba(111,214,255,0.5); transition: transform .2s, box-shadow .2s;
}
#begin-btn:hover { transform: translateY(-2px); box-shadow: 0 0 44px rgba(111,214,255,0.7); }
.panel .hint { color: var(--dim); font-size: 11px; font-weight: 300; letter-spacing: 0.5px; margin-top: 22px; opacity: 0.7; }

/* ====================================================================
   Mobile / touch
   ==================================================================== */

/* ---- floating virtual joystick (steering area, only in-game on touch) ---- */
#stick { display: none; }
body.touch.playing #stick {
    display: block; position: fixed; z-index: 25;
    left: calc(26px + env(safe-area-inset-left, 0px));
    bottom: calc(30px + env(safe-area-inset-bottom, 0px));
    width: 122px; height: 122px; border-radius: 50%;
    background: radial-gradient(circle at 50% 50%, rgba(111,214,255,0.05), rgba(10,16,32,0.32));
    border: 1.5px solid rgba(111,214,255,0.22);
    box-shadow: inset 0 0 18px rgba(111,214,255,0.06);
    opacity: 0.4; pointer-events: none; transition: opacity .15s;
    touch-action: none;
}
/* While steering: the stick floats to the finger (JS sets left/top to the
   touch point, so centre it on that point) and brightens. */
body.touch.playing #stick.active {
    margin: -61px 0 0 -61px; bottom: auto; opacity: 0.95;
    border-color: rgba(111,214,255,0.5);
    box-shadow: 0 0 24px rgba(111,214,255,0.22), inset 0 0 18px rgba(111,214,255,0.1);
}
#stick-knob {
    position: absolute; left: 50%; top: 50%; width: 54px; height: 54px;
    margin: -27px 0 0 -27px; border-radius: 50%;
    background: radial-gradient(circle at 50% 40%, #fff, var(--cyan) 55%, rgba(111,214,255,0.2) 100%);
    box-shadow: 0 0 22px rgba(111,214,255,0.6); will-change: transform;
}

/* ---- on-screen boost button (only in-game on touch devices) ---- */
#boost-btn { display: none; }
body.touch.playing #boost-btn {
    display: flex; align-items: center; justify-content: center;
    position: fixed; z-index: 25;
    right: calc(22px + env(safe-area-inset-right, 0px));
    bottom: calc(30px + env(safe-area-inset-bottom, 0px));
    width: 84px; height: 84px; border-radius: 50%;
    color: var(--cyan); cursor: pointer; -webkit-tap-highlight-color: transparent;
    touch-action: none; -webkit-user-select: none; user-select: none;
    background: radial-gradient(circle at 50% 38%, rgba(111,214,255,0.22), rgba(10,16,32,0.55));
    border: 1.5px solid rgba(111,214,255,0.5);
    box-shadow: 0 0 26px rgba(111,214,255,0.3), inset 0 0 18px rgba(111,214,255,0.12);
    backdrop-filter: blur(6px); transition: transform .1s, box-shadow .1s, background .1s;
}
#boost-btn .ico { width: 34px; height: 34px; }
#boost-btn:active {
    transform: scale(0.92);
    background: radial-gradient(circle at 50% 38%, rgba(111,214,255,0.45), rgba(20,40,70,0.7));
    box-shadow: 0 0 42px rgba(111,214,255,0.6), inset 0 0 22px rgba(111,214,255,0.3);
}

/* ---- chat button (mobile only; sits just above the boost button) ---- */
#chat-btn { display: none; }
body.touch.playing #chat-btn {
    display: flex; align-items: center; justify-content: center;
    position: fixed; z-index: 25;
    right: calc(37px + env(safe-area-inset-right, 0px));
    bottom: calc(126px + env(safe-area-inset-bottom, 0px));
    width: 54px; height: 54px; border-radius: 50%;
    color: var(--cyan); cursor: pointer; -webkit-tap-highlight-color: transparent;
    background: radial-gradient(circle at 50% 40%, rgba(111,214,255,0.16), rgba(10,16,32,0.5));
    border: 1.5px solid rgba(111,214,255,0.4);
    box-shadow: 0 0 18px rgba(111,214,255,0.22);
    backdrop-filter: blur(6px); transition: transform .1s, background .1s;
}
#chat-btn .ico { width: 24px; height: 24px; }
#chat-btn:active {
    transform: scale(0.92);
    background: radial-gradient(circle at 50% 40%, rgba(111,214,255,0.34), rgba(20,40,70,0.65));
}

/* Bigger tap targets for the top-bar controls on touch. */
body.touch .icon-btn { padding: 7px; }
body.touch .menu-hint { padding: 7px 11px; }
body.touch .set-row input[type=range] { height: 18px; }
/* Bigger, easier teleport target on touch + roomier rows so taps land. */
body.touch .player-row { padding: 9px 8px; }
body.touch .player-row .tp { padding: 9px 15px; font-size: 13px; }
body.touch #players-panel { touch-action: pan-y; }

/* ---- narrow screens (phones): trim the HUD so it never overflows ---- */
@media (max-width: 760px) {
    #topbar { padding: 0 8px; font-size: 11px; }
    #topbar .seg { gap: 9px; }
    .stat .lbl { display: none; }                 /* drop unit labels */
    .stat.sep-l { border-left: none; padding-left: 0; margin-left: 0; }
    .hide-narrow { display: none !important; }     /* anomalies · music · glow · time */
    #radar { width: 92px; height: 92px; top: 44px; right: 10px; }
    #chat-input { bottom: 92px; }
    #fact { font-size: 14px; padding: 11px 18px 11px 40px; max-width: 92vw; }
    #chat-log { top: 96px; max-width: 86vw; }
    #players-panel { width: min(250px, 88vw); }
}
@media (max-width: 600px) {
    #topbar .center { display: none; }             /* galaxy · region · sector */
    #topbar { font-size: 10px; }
    .stat i .ico { width: 12px; height: 12px; }
    .sector, .galaxy, .region { font-size: 11px; }
    .panel h1 { font-size: 26px; letter-spacing: 6px; }
    .panel .sub { font-size: 12px; }
    .menu-head h2 { font-size: 18px; letter-spacing: 4px; }
    .menu-panel { padding: 16px 16px; }
    #fact { font-size: 13px; padding: 10px 16px 10px 36px; }
    #fact::before { left: 16px; font-size: 14px; }
    .guide-center h2 { font-size: 22px; letter-spacing: 5px; }
    .guide-center p { font-size: 12px; }
    .chat-msg { font-size: 11px; }
    /* On phones the language flag + (iOS-flaky) fullscreen just crowd the bar;
       language still lives in the menu. Keeps menu + exit always reachable. */
    body.touch #lang-flag, body.touch #fullscreen-btn { display: none; }
}

/* Keep the top cluster clear of the notch / Dynamic Island (env() is 0 on
   devices without one, so this is inert on desktop). Placed last so it wins
   over the base top: values above. */
#radar { top: calc(48px + env(safe-area-inset-top, 0px)); right: calc(14px + env(safe-area-inset-right, 0px)); }
#buffs { top: calc(46px + env(safe-area-inset-top, 0px)); }
#fact  { top: calc(52px + env(safe-area-inset-top, 0px)); }
#chat-log { top: calc(112px + env(safe-area-inset-top, 0px)); }
