:root {
color-scheme: dark;
--bg: #090a12;
--panel: #171820;
--panel-2: #20222c;
--line: #3f4352;
--text: #f7f0e8;
--muted: #bdb7aa;
--green: #78f0b0;
--blue: #65c7e8;
--orange: #f0b35a;
--purple: #a855ff;
--red: #d95b66;
}

* { box-sizing: border-box; }

body {
margin: 0;
padding: 22px;
font-family: Arial, Helvetica, sans-serif;
background:
linear-gradient(180deg, rgba(120, 240, 176, .07), transparent 320px),
linear-gradient(90deg, rgba(168, 85, 255, .07), transparent 45%, rgba(240, 179, 90, .06)),
var(--bg);
color: var(--text);
line-height: 1.5;
}

body:before {
content: "";
position: fixed;
inset: 0;
pointer-events: none;
opacity: .11;
background-image:
linear-gradient(rgba(255, 255, 255, .04) 1px, transparent 1px),
linear-gradient(90deg, rgba(255, 255, 255, .04) 1px, transparent 1px);
background-size: 24px 24px;
mask-image: linear-gradient(to bottom, #000, transparent 78%);
}

button {
border: 1px solid rgba(120, 240, 176, .72);
border-radius: 7px;
padding: 11px 16px;
background: rgba(120, 240, 176, .08);
color: var(--text);
font-weight: 800;
cursor: pointer;
}

button:hover {
background: var(--green);
color: #07110c;
}

.layout-switcher,
.encounter-switcher,
.boundary-switcher {
display: flex;
align-items: center;
justify-content: flex-end;
gap: 8px;
margin-bottom: 12px;
}

.layout-switcher > span,
.encounter-switcher > span,
.boundary-switcher > span {
margin-right: auto;
color: var(--muted);
font-size: 13px;
font-weight: 800;
letter-spacing: .06em;
text-transform: uppercase;
}

.layout-button,
.encounter-button,
.boundary-button {
padding: 7px 11px;
border-color: var(--line);
background: #11131b;
color: var(--muted);
}

.layout-button.is-active,
.encounter-button.is-active,
.boundary-button.is-active {
border-color: rgba(120, 240, 176, .72);
background: rgba(120, 240, 176, .1);
color: var(--green);
}

kbd {
display: inline-block;
min-width: 28px;
padding: 2px 6px;
border: 1px solid var(--line);
border-radius: 5px;
background: #0d0f18;
color: var(--green);
font-weight: 800;
text-align: center;
}

.lab-shell {
position: relative;
max-width: 1120px;
margin: 0 auto;
}

.lab-header {
display: flex;
align-items: end;
justify-content: space-between;
gap: 16px;
margin-bottom: 18px;
}

.eyebrow {
margin: 0 0 6px;
color: var(--green);
font-size: 13px;
font-weight: 800;
letter-spacing: .08em;
text-transform: uppercase;
}

h1, h2 { margin-top: 0; line-height: 1.15; }
h1 { margin-bottom: 0; font-size: clamp(30px, 5vw, 54px); }
h2 { font-size: 22px; }

.build-note {
max-width: 300px;
margin: 0;
color: var(--muted);
text-align: right;
}

.lab-panel {
border: 1px solid var(--line);
border-radius: 8px;
padding: 16px;
background: linear-gradient(180deg, rgba(32, 34, 44, .96), rgba(19, 20, 27, .96));
box-shadow: 0 12px 30px rgba(0, 0, 0, .28);
}

.hud-strip {
display: grid;
grid-template-columns: repeat(5, minmax(0, 1fr));
gap: 10px;
margin-bottom: 12px;
}

.hud-strip div {
border: 1px solid var(--line);
border-radius: 7px;
padding: 10px;
background: var(--panel-2);
}

.hud-strip span {
display: block;
color: var(--muted);
font-size: 13px;
font-weight: 800;
text-transform: uppercase;
}

.hud-strip strong {
display: block;
font-size: clamp(16px, 2.2vw, 22px);
color: var(--orange);
}

.hud-strip small {
display: block;
margin-top: 2px;
color: var(--green);
font-size: 11px;
letter-spacing: .18em;
white-space: nowrap;
}

.lives-readout {
display: flex !important;
align-items: center;
gap: 5px;
height: 13px;
}

.life-ship {
display: block;
width: 14px;
height: 11px;
background: transparent;
clip-path: polygon(100% 50%, 5% 0, 27% 50%, 5% 100%);
opacity: 0;
transform: rotate(-90deg);
}

.life-ship.is-active {
background: var(--green);
filter: drop-shadow(0 0 4px rgba(120, 240, 176, .72));
opacity: 1;
}

.playfield-frame[data-hud-layout="top"] .hud-strip {
gap: 0;
overflow: hidden;
border: 1px solid var(--line);
border-radius: 7px;
background: #151720;
}

.playfield-frame[data-hud-layout="top"] .hud-strip div {
border: 0;
border-right: 1px solid var(--line);
border-radius: 0;
background: transparent;
}

.playfield-frame[data-hud-layout="top"] .hud-strip div:last-child {
border-right: 0;
}

.playfield-frame[data-hud-layout="edge"] {
position: relative;
}

.playfield-frame[data-hud-layout="edge"] .hud-strip {
position: absolute;
inset: 14px;
z-index: 2;
display: block;
margin: 0;
pointer-events: none;
}

.playfield-frame[data-hud-layout="edge"] .hud-strip div {
position: absolute;
min-width: 116px;
padding: 8px 10px;
border-color: rgba(63, 67, 82, .78);
background: rgba(13, 15, 24, .78);
backdrop-filter: blur(4px);
}

.playfield-frame[data-hud-layout="edge"] .hud-hull { top: 0; left: 0; text-align: left; }
.playfield-frame[data-hud-layout="edge"] .hud-wave {
top: 0;
left: 50%;
transform: translateX(-50%);
text-align: center;
}
.playfield-frame[data-hud-layout="edge"] .hud-score { top: 0; right: 0; text-align: right; }
.playfield-frame[data-hud-layout="edge"] .hud-energy { bottom: 0; left: 0; }
.playfield-frame[data-hud-layout="edge"] .hud-fragment { right: 0; bottom: 0; text-align: right; }

.playfield-frame[data-hud-layout="top"] .hud-hull { order: 1; }
.playfield-frame[data-hud-layout="top"] .hud-energy { order: 2; }
.playfield-frame[data-hud-layout="top"] .hud-wave { order: 3; }
.playfield-frame[data-hud-layout="top"] .hud-fragment { order: 4; }
.playfield-frame[data-hud-layout="top"] .hud-score { order: 5; }

.hud-fragment.is-charged {
border-color: rgba(168, 85, 255, .9) !important;
box-shadow: 0 0 18px rgba(168, 85, 255, .32), inset 0 0 18px rgba(168, 85, 255, .12);
}

.hud-fragment.is-charged strong {
color: #d7a8ff;
text-shadow: 0 0 10px rgba(168, 85, 255, .7);
}

.hud-fragment.is-pickup {
animation: fragment-acquired .65s ease-out;
}

@keyframes fragment-acquired {
0% { transform: scale(1); filter: brightness(1); }
35% { transform: scale(1.12); filter: brightness(1.8); }
100% { transform: scale(1); filter: brightness(1); }
}

.arena-wrap {
position: relative;
overflow: hidden;
border: 1px solid var(--line);
border-radius: 8px;
background: #070812;
}

#arena {
display: block;
width: 100%;
aspect-ratio: 16 / 9;
height: auto;
background: #070812;
}

.menu-card {
position: absolute;
inset: 0;
display: grid;
place-items: center;
align-content: center;
gap: 12px;
padding: 24px;
text-align: center;
background: rgba(7, 8, 18, .82);
backdrop-filter: blur(5px);
z-index: 20;
}

.is-hidden { display: none !important; }

.menu-card h2 {
max-width: 620px;
margin: 0;
font-size: clamp(24px, 4vw, 42px);
}

.menu-card small,
.run-summary { color: var(--muted); }

.menu-actions {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 9px;
}

.secondary-button {
border-color: var(--line);
background: rgba(101, 199, 232, .08);
color: var(--blue);
}

.danger-button {
border-color: rgba(217, 91, 102, .7);
background: rgba(217, 91, 102, .1);
color: #f4a5ad;
}

.options-card label {
display: grid;
grid-template-columns: minmax(130px, 1fr) auto;
align-items: center;
gap: 5px 12px;
width: min(440px, 90%);
color: var(--muted);
font-weight: 700;
text-align: left;
}

.options-card input[type="range"] { grid-column: 1 / -1; width: 100%; }
.options-card output { color: var(--blue); }
.options-card .check-label { display: flex; justify-content: center; }

.archive-entries {
display: grid;
gap: 8px;
width: min(560px, 94%);
max-height: 290px;
overflow: auto;
text-align: left;
}

.archive-entry {
padding: 10px 12px;
border: 1px solid var(--line);
border-radius: 6px;
background: rgba(13, 15, 24, .78);
}

.archive-entry strong { display: block; color: var(--green); }
.archive-entry.is-locked { opacity: .54; }
.archive-entry.is-locked strong { color: var(--muted); }

.unlock-note {
max-width: 520px;
padding: 10px 13px;
border: 1px solid rgba(120, 240, 176, .55);
border-radius: 6px;
background: rgba(120, 240, 176, .1);
color: var(--green);
font-weight: 800;
}

.touch-controls,
.portrait-notice { display: none; }

.touch-controls {
position: absolute;
inset: 0;
z-index: 12;
align-items: flex-end;
justify-content: space-between;
padding: 14px;
pointer-events: none;
}

.touch-cluster {
display: grid;
gap: 7px;
pointer-events: auto;
}

.touch-flight { grid-template-columns: repeat(3, 54px); }
.touch-flight button:last-child { grid-column: 2; }
.touch-actions { grid-template-columns: repeat(2, 62px); }
.touch-actions button:last-child { grid-column: 2; }
.touch-controls button {
min-height: 48px;
padding: 7px;
border-color: rgba(247, 240, 232, .45);
background: rgba(9, 10, 18, .72);
touch-action: none;
user-select: none;
}

.touch-controls button.is-held {
background: rgba(120, 240, 176, .72);
color: #07110c;
}

.portrait-notice {
position: absolute;
inset: 0;
z-index: 30;
place-items: center;
align-content: center;
gap: 8px;
padding: 30px;
background: rgba(7, 8, 18, .96);
text-align: center;
}

.portrait-notice strong { color: var(--green); font-size: 28px; }
.portrait-notice span { max-width: 360px; color: var(--muted); }

.status-line {
min-height: 28px;
margin: 12px 0 0;
color: var(--muted);
font-weight: 700;
}

.lab-telemetry {
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 8px;
margin-top: 10px;
}

.lab-telemetry div {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 10px;
padding: 7px 9px;
border: 1px dashed rgba(63, 67, 82, .78);
border-radius: 6px;
background: rgba(13, 15, 24, .45);
}

.lab-telemetry span {
color: var(--muted);
font-size: 12px;
font-weight: 800;
letter-spacing: .05em;
text-transform: uppercase;
}

.lab-telemetry strong {
color: var(--blue);
font-size: 15px;
}

.notes-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 14px;
margin-top: 14px;
}

.notes-grid ul {
margin: 0;
padding-left: 20px;
color: var(--muted);
}

.notes-grid li { margin: 6px 0; }

@media (max-width: 760px) {
body { padding: 12px; }
.lab-header { align-items: start; flex-direction: column; }
.build-note { text-align: left; }
.hud-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.playfield-frame[data-hud-layout="top"] .hud-strip { gap: 1px; }
.playfield-frame[data-hud-layout="top"] .hud-strip div {
border-right: 0;
background: var(--panel-2);
}

.hud-strip .hud-wave { grid-column: 1 / -1; }
.hud-strip .hud-score { text-align: right; }
.playfield-frame[data-hud-layout="edge"] .hud-strip {
position: static;
display: grid;
margin-bottom: 12px;
}
.playfield-frame[data-hud-layout="edge"] .hud-strip div {
position: static;
min-width: 0;
transform: none;
text-align: left;
}
.lab-telemetry { grid-template-columns: 1fr; }
.notes-grid { grid-template-columns: 1fr; }
}

@media (pointer: coarse) and (orientation: landscape),
       (max-width: 900px) and (max-height: 500px) and (orientation: landscape) {
.touch-controls { display: flex; }
.lab-header,
.layout-switcher,
.encounter-switcher,
.boundary-switcher,
.notes-grid,
.lab-telemetry { display: none; }
body { padding: 4px; }
.lab-panel { padding: 4px; border: 0; }
.status-line { margin: 5px 8px 0; font-size: 13px; }
.playfield-frame[data-hud-layout="edge"] .hud-energy { top: 84px; bottom: auto; }
.playfield-frame[data-hud-layout="edge"] .hud-fragment { top: 84px; bottom: auto; }
}

@media (pointer: coarse) and (orientation: portrait),
       (max-width: 700px) and (orientation: portrait) {
.portrait-notice { display: grid; position: fixed; }
.touch-controls { display: none; }
}
/* Public Archive Cartridge integration */
.public-hidden { display: none !important; }
.archive-return { color: #78f0b0; font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-decoration: none; text-transform: uppercase; }
.archive-return:hover, .archive-return:focus-visible { color: #f7f0e8; text-decoration: underline; }
.archive-copy { margin-top: 1rem; max-width: none; }
.archive-copy p:last-child { margin-bottom: 0; }
