/* styles.css — Mr. Mr UI system (flat pixel-line chrome, all code-drawn). */
:root {
  /* theme tokens */
  --ink: #15132B; --ink-2: #231F45; --ink-3: #322C5E;
  --paper: #F3E9D2; --paper-dim: #B9B0C4;
  --brass: #C8963E; --brass-hi: #F2CF7A;
  --echo: #5FE3D6; --danger: #E5484D; --violet: #8A63C9; --glimmer: #FFC94A;
  --q-step: 4px;            /* stepped-corner size */
  --q-line: 2px;            /* frame line weight */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px;
  --btn-h: 48px;
  --tick: 120ms;            /* UI motion beat (stepped easing) */
  --safe-t: env(safe-area-inset-top, 0px); --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-l: env(safe-area-inset-left, 0px);
  --stepped: polygon(0 var(--q-step), var(--q-step) var(--q-step), var(--q-step) 0,
    calc(100% - var(--q-step)) 0, calc(100% - var(--q-step)) var(--q-step), 100% var(--q-step),
    100% calc(100% - var(--q-step)), calc(100% - var(--q-step)) calc(100% - var(--q-step)), calc(100% - var(--q-step)) 100%,
    var(--q-step) 100%, var(--q-step) calc(100% - var(--q-step)), 0 calc(100% - var(--q-step)));
}

#ui { position: fixed; inset: 0; pointer-events: none; color: var(--paper); font-size: 16px; line-height: 1.35;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; z-index: 5; }
#ui * { box-sizing: border-box; }
:where(#ui) button { font: inherit; color: inherit; border: 0; margin: 0; padding: 0; background: none; cursor: pointer; }
.q-hidden { display: none !important; }
.q-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ------------------------------------------------------------------ q-btn */
.q-btn { pointer-events: auto; display: inline-flex; min-height: var(--btn-h); min-width: 132px; padding: var(--q-line);
  background: var(--brass); clip-path: var(--stepped); transition: transform var(--tick) steps(2); touch-action: manipulation; }
.q-btn-in { flex: 1; display: flex; align-items: center; justify-content: center; text-align: center; padding: 6px 18px;
  background: var(--ink-2); color: var(--paper); clip-path: var(--stepped); font-size: 17px; letter-spacing: 0.02em; white-space: nowrap; }
.q-btn.primary .q-btn-in { background: var(--brass-hi); color: var(--ink); }
.q-btn.danger { background: var(--danger); }
.q-btn:hover .q-btn-in { background: var(--ink-3); }
.q-btn.primary:hover .q-btn-in { background: #FFE39B; }
.q-btn:focus-visible { outline: none; background: var(--echo); }
.q-btn:active { transform: translateY(2px); }
.q-btn[disabled] { opacity: 0.45; cursor: default; }
.q-btn.small { min-height: 44px; min-width: 44px; }
.q-btn.small .q-btn-in { padding: 4px 12px; font-size: 15px; }

/* ------------------------------------------------------------------ title */
.q-title { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  padding: calc(6vh + var(--safe-t)) calc(24px + var(--safe-r)) calc(5vh + var(--safe-b)) calc(24px + var(--safe-l));
  background: linear-gradient(180deg, rgba(21,19,43,0.72) 0%, rgba(21,19,43,0.05) 38%, rgba(21,19,43,0.1) 55%, rgba(21,19,43,0.82) 100%); pointer-events: auto; }
.q-title-head { display: flex; flex-direction: column; align-items: center; gap: var(--sp-3); width: 100%; }
.q-logo { width: min(72vw, 380px); height: auto; image-rendering: pixelated; image-rendering: crisp-edges; }
.q-tagline { margin: 0; max-width: 34em; text-align: center; color: var(--paper); font-size: clamp(14px, 2.2vw, 18px); text-shadow: 0 2px 0 var(--ink); }
.q-title-actions { display: flex; flex-direction: column; align-items: stretch; gap: var(--sp-2); width: min(78vw, 300px); }
.q-title-row { display: flex; gap: var(--sp-2); }
.q-title-row .q-btn { flex: 1; min-width: 0; }
.q-title-pair { display: flex; flex-direction: column; gap: var(--sp-2); }
@media (max-height: 430px) {
  .q-title { padding-top: calc(3vh + var(--safe-t)); padding-bottom: calc(3vh + var(--safe-b)); }
  .q-logo { width: min(40vw, 240px); }
  .q-title-actions { width: min(80vw, 460px); flex-direction: row; flex-wrap: wrap; }
  .q-title-actions > .q-btn, .q-title-actions > div { flex: 1 1 100%; }
  .q-title-pair { flex-direction: row; }
  .q-title-pair .q-btn { flex: 1; min-width: 0; }
  .q-title-pair .q-btn-in { padding: 6px 8px; font-size: 16px; }
  .q-title-actions { --btn-h: 44px; }
}

/* ------------------------------------------------------------------ duo concept: spectator HUD (watch-only demo) */
.q-duo { position: absolute; inset: 0; }
.q-duo-top { position: absolute; left: calc(12px + var(--safe-l)); right: calc(12px + var(--safe-r)); top: calc(10px + var(--safe-t));
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: start; gap: 8px 12px; }
.q-duo-hp { display: flex; align-items: center; gap: 8px; min-height: 36px; min-width: 0; width: min(100%, 240px); padding: 4px 10px; background: rgba(21,19,43,0.9); }
.q-duo-hp.a { justify-self: start; border-left: 4px solid var(--paper); }
.q-duo-hp.b { justify-self: end; flex-direction: row-reverse; border-right: 4px solid #E0444A; }
.q-duo-who { flex: none; font-size: 14px; white-space: nowrap; }
.q-duo-bar { flex: 1 1 auto; min-width: 40px; height: 10px; background: #2a1830; outline: 2px solid var(--ink); border: 1px solid var(--paper-dim); }
.q-duo-bar b { display: block; height: 100%; width: var(--f, 100%); background: var(--paper); }
.q-duo-hp.b .q-duo-bar b { background: #E0444A; margin-left: auto; }
.q-duo-mid { max-width: 100%; }
.q-duo-mid .q-chip-in { flex-wrap: wrap; justify-content: center; gap: 4px 14px; padding: 5px 14px; }
.q-duo-name { font-size: 14px; color: var(--brass-hi); text-align: center; }
.q-duo-time { display: flex; align-items: center; gap: 8px; }
.q-duo-time .q-echoes { flex-wrap: nowrap; }
.q-echo.filled.b { background: #FF8F9A; }
.q-echo.filled.b::after { background: radial-gradient(circle at 50% 38%, #ffe3e6 0 22%, #a8394a 23% 100%); }
.q-duo-boss { grid-column: 1 / -1; justify-self: center; width: min(70vw, 360px); display: flex; flex-direction: column; align-items: center; gap: 4px; }
.q-duo-boss.exposed .q-boss-name { color: var(--echo); }
.q-duo-boss.exposed .q-boss-bar { border-color: var(--echo); }
.q-duo-bottom { position: absolute; left: calc(12px + var(--safe-l)); right: calc(12px + var(--safe-r)); bottom: calc(12px + var(--safe-b));
  display: flex; align-items: flex-end; justify-content: space-between; gap: 10px 16px; }
.q-duo-notes { flex: 0 1 520px; min-width: 0; display: flex; flex-direction: column; gap: 3px; padding: 8px 12px; background: rgba(21,19,43,0.88);
  border-top: 2px solid var(--brass); border-bottom: 2px solid var(--brass); font-size: 14px; }
.q-duo-goal { color: var(--paper-dim); font-size: 13px; }
.q-duo-note { display: flex; align-items: center; gap: 8px; min-width: 0; }
.q-duo-note i { flex: none; width: 9px; height: 9px; margin: 0 2px; transform: rotate(45deg); background: var(--paper); outline: 2px solid var(--ink); }
.q-duo-note.b i { background: #E0444A; }
.q-duo-note b { flex: none; min-width: 3.4em; font-weight: normal; color: var(--brass-hi); }
.q-duo-note span { min-width: 0; overflow-wrap: anywhere; }
.q-duo-ctrl { flex: none; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; max-width: 100%; }
@media (max-width: 760px) {
  .q-duo-top { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .q-duo-mid { grid-column: 1 / -1; grid-row: 1; justify-self: center; }
  .q-duo-hp { width: 100%; }
  .q-duo-bottom { flex-direction: column-reverse; align-items: stretch; }
  .q-duo-notes { flex: none; }
  .q-duo-ctrl { justify-content: center; }
  .q-duo-ctrl .q-btn.small .q-btn-in { padding: 4px 10px; }
}
@media (max-height: 430px) {
  .q-duo-goal { display: none; }
  .q-duo-notes { padding: 5px 10px; font-size: 13px; }
}

/* ------------------------------------------------------------------ HUD */
.q-hud { position: absolute; inset: 0; padding: calc(10px + var(--safe-t)) calc(12px + var(--safe-r)) calc(10px + var(--safe-b)) calc(12px + var(--safe-l)); }
.q-hud-tl { position: absolute; left: calc(12px + var(--safe-l)); top: calc(10px + var(--safe-t)); display: flex; flex-direction: column; gap: 6px; align-items: flex-start; max-width: 62vw; }
.q-hud-tr { position: absolute; right: calc(12px + var(--safe-r)); top: calc(10px + var(--safe-t)); display: flex; flex-direction: column; gap: 6px; align-items: flex-end; max-width: 46vw; }
.q-hud-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.q-chip { display: inline-flex; padding: var(--q-line); background: var(--brass); clip-path: var(--stepped); }
.q-chip-in { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 4px 12px; background: rgba(21,19,43,0.92); clip-path: var(--stepped); }
.q-timer .q-clock { width: 22px; height: 22px; border: 2px solid var(--brass-hi); border-radius: 50%; position: relative; flex: none; }
.q-timer .q-clock::after { content: ''; position: absolute; left: 50%; top: 50%; width: 2px; height: 8px; margin-left: -1px; background: var(--paper); transform-origin: 50% 0; transform: rotate(var(--hand, 180deg)); }
.q-timer-num { min-width: 4.2ch; text-align: right; font-size: 22px; font-variant-numeric: tabular-nums; letter-spacing: 0.03em; }
.q-timer.low .q-timer-num { color: var(--danger); }
.q-hp { display: flex; gap: 5px; padding: 0 3px; }
.q-hp i { width: 14px; height: 14px; transform: rotate(45deg); background: linear-gradient(0deg, var(--danger) var(--f, 100%), #3a2740 var(--f, 100%)); outline: 2px solid var(--ink); border: 1px solid #ffb3b3; }
.q-energy { width: 96px; height: 10px; background: #1d2a44; outline: 2px solid var(--ink); border: 1px solid #9fefe6; }
.q-energy b { display: block; height: 100%; width: var(--f, 100%); background: var(--echo); }
.q-echoes { display: flex; gap: 4px; flex-wrap: wrap; max-width: 300px; }
.q-echo { width: 22px; height: 22px; padding: 2px; background: var(--brass); clip-path: polygon(0 2px, 2px 2px, 2px 0, calc(100% - 2px) 0, calc(100% - 2px) 2px, 100% 2px, 100% calc(100% - 2px), calc(100% - 2px) calc(100% - 2px), calc(100% - 2px) 100%, 2px 100%, 2px calc(100% - 2px), 0 calc(100% - 2px)); }
.q-echo::after { content: ''; display: block; width: 100%; height: 100%; background: rgba(21,19,43,0.92); }
.q-echo.filled { background: var(--echo); }
.q-echo.filled::after { background: radial-gradient(circle at 50% 38%, #d8fffa 0 22%, #2a8f93 23% 100%); }
.q-floor { font-size: 15px; color: var(--brass-hi); }
.q-objective { font-size: 14px; color: var(--paper); text-align: right; text-shadow: 0 2px 0 var(--ink); max-width: 100%; }
.q-objective.done { color: var(--echo); }
.q-toast { position: absolute; left: 50%; top: calc(22% + var(--safe-t)); transform: translateX(-50%); max-width: min(86vw, 560px);
  padding: 8px 16px; background: rgba(21,19,43,0.9); border-top: 2px solid var(--brass); border-bottom: 2px solid var(--brass);
  text-align: center; font-size: 16px; opacity: 0; transition: opacity 180ms steps(3); }
.q-toast.show { opacity: 1; }

/* ------------------------------------------------------------------ touch controls */
.q-touch { position: absolute; inset: 0; }
.q-stick { pointer-events: auto; position: absolute; left: calc(18px + var(--safe-l)); bottom: calc(18px + var(--safe-b)); width: 132px; height: 132px; border-radius: 50%;
  background: rgba(21,19,43,0.42); border: 2px solid rgba(242,207,122,0.7); touch-action: none; }
.q-stick i { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: rgba(243,233,210,0.85); border: 2px solid var(--ink);
  transform: translate(calc(var(--kx, 0) * 40px), calc(var(--ky, 0) * 40px)); }
.q-acts { position: absolute; right: calc(18px + var(--safe-r)); bottom: calc(18px + var(--safe-b)); display: grid; grid-template-columns: repeat(2, auto); gap: 12px; align-items: end; justify-items: end; }
.q-act { pointer-events: auto; width: 64px; height: 64px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: rgba(21,19,43,0.6) !important; border: 2px solid var(--brass-hi) !important; font-size: 13px; color: var(--paper); touch-action: none; }
.q-act.big { width: 80px; height: 80px; font-size: 15px; border-color: var(--echo) !important; }
.q-act:active { background: rgba(95,227,214,0.35) !important; }

/* ------------------------------------------------------------------ q-panel (modal) */
.q-modal { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: auto;
  background: rgba(13,11,30,0.66); padding: calc(10px + var(--safe-t)) calc(10px + var(--safe-r)) calc(10px + var(--safe-b)) calc(10px + var(--safe-l)); z-index: 20; }
.q-panel { width: min(100%, 520px); max-height: 92dvh; display: flex; padding: var(--q-line); background: var(--brass); clip-path: var(--stepped); }
.q-panel-in { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--ink); clip-path: var(--stepped); }
.q-panel-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 10px 10px 18px; border-bottom: 2px solid var(--ink-3); }
.q-panel-title { margin: 0; font-size: 20px; color: var(--brass-hi); letter-spacing: 0.03em; }
.q-x { pointer-events: auto; width: 44px; height: 44px; display: flex !important; align-items: center; justify-content: center; font-size: 20px; color: var(--paper) !important; background: var(--ink-2) !important; }
.q-x:hover, .q-x:focus-visible { background: var(--ink-3) !important; outline: none; }
.q-panel-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 14px 18px; display: flex; flex-direction: column; gap: 10px; font-size: 15px; -webkit-overflow-scrolling: touch; }
.q-panel-body p { margin: 0; color: var(--paper); }
.q-panel-actions { flex: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 18px 16px; border-top: 2px solid var(--ink-3); }
/* content-sized basis: a long label widens its own button (or wraps the row) instead of spilling out of it */
.q-panel-actions .q-btn { flex: 1 1 auto; min-width: 140px; max-width: 100%; }
.q-panel-actions .q-btn-in { padding: 6px 14px; }
.q-setrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; }
.q-setrow > span { flex: 1; }
.q-setrow select { pointer-events: auto; min-height: 44px; min-width: 132px; padding: 4px 10px; background: var(--ink-2); color: var(--paper); border: 2px solid var(--brass); font: inherit; }
.q-list { margin: 0; padding-left: 1.2em; display: flex; flex-direction: column; gap: 8px; }

/* ------------------------------------------------------------------ HUD: objectives, ability, boss, prompts */
.q-toast { z-index: 30; pointer-events: none; }
.q-obj { text-align: right; text-shadow: 0 2px 0 var(--ink); }
.q-obj.done { color: var(--echo); }
.q-timer.drained .q-chip-in { background: rgba(120,20,30,0.92); }
.q-ability { position: relative; min-height: 28px; padding: 4px 10px; background: rgba(21,19,43,0.88); border-left: 3px solid var(--brass-hi); font-size: 14px; overflow: hidden; }
.q-ability b { position: absolute; left: 0; top: 0; bottom: 0; width: var(--f, 0%); background: rgba(95,227,214,0.28); }
.q-ability-name { position: relative; }
.q-ability.weak { color: var(--paper-dim); border-left-color: var(--paper-dim); }
.q-acts > [data-action="swap"] { grid-column: 1; grid-row: 1; }
.q-acts > [data-action="phase"] { grid-column: 1; grid-row: 2; }
.q-acts > [data-action="interact"] { grid-column: 2; grid-row: 2; }
.q-acts > [data-action="ability"] { grid-column: 1; grid-row: 3; }
.q-acts > [data-action="attack"] { grid-column: 2; grid-row: 3; }
.q-boss { position: absolute; left: 50%; bottom: calc(14px + var(--safe-b)); transform: translateX(-50%); width: min(36vw, 360px); display: flex; flex-direction: column; align-items: center; gap: 4px; }
.q-boss-name { font-size: 14px; color: var(--paper); text-shadow: 0 2px 0 var(--ink); white-space: nowrap; }
.q-boss-bar { width: 100%; height: 10px; background: #2a1830; outline: 2px solid var(--ink); border: 1px solid var(--brass); }
.q-boss-bar b { display: block; height: 100%; width: var(--f, 100%); background: var(--danger); }
.q-boss.exposed .q-boss-name { color: var(--echo); }
.q-boss.exposed .q-boss-bar { border-color: var(--echo); }
.q-prompt { position: absolute; left: 50%; bottom: calc(22% + var(--safe-b)); transform: translateX(-50%); padding: 6px 14px; background: rgba(21,19,43,0.9);
  border-top: 2px solid var(--echo); border-bottom: 2px solid var(--echo); font-size: 15px; white-space: nowrap; }
.q-act.mini { width: 56px; height: 56px; font-size: 13px; }
.q-act.weak { opacity: 0.55; }
.q-act[data-action="ability"] { background: linear-gradient(0deg, rgba(95,227,214,0.35) var(--cd, 0%), rgba(21,19,43,0.6) var(--cd, 0%)) !important; }

/* ------------------------------------------------------------------ universe map */
.q-map { position: absolute; inset: 0; display: grid; grid-template-columns: 62fr 38fr; gap: var(--sp-4); pointer-events: auto;
  padding: calc(14px + var(--safe-t)) calc(16px + var(--safe-r)) calc(14px + var(--safe-b)) calc(16px + var(--safe-l));
  background: linear-gradient(90deg, rgba(21,19,43,0.9) 0%, rgba(21,19,43,0.78) 60%, rgba(21,19,43,0.9) 100%); }
.q-map-main { min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: var(--sp-2); overflow-y: auto; -webkit-overflow-scrolling: touch; padding-right: 4px; }
.q-map-title { margin: 0 0 4px; font-size: 22px; color: var(--brass-hi); letter-spacing: 0.04em; }
.q-route { display: flex; flex-direction: column; gap: 6px; border-left: 2px dashed rgba(95,227,214,0.55); margin-left: 12px; padding-left: 14px; }
.q-uni { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 52px; padding: 4px 8px 4px 12px;
  background: rgba(35,31,69,0.82); border-left: 4px solid var(--uc, var(--brass)); }
.q-uni::before { content: ''; position: absolute; left: -23px; top: 50%; width: 10px; height: 10px; margin-top: -5px; background: var(--echo); transform: rotate(45deg); outline: 2px solid var(--ink); }
.q-uni-name { min-width: 0; display: flex; align-items: center; gap: 8px; font-size: 15px; }
.q-uni-name b { flex: none; width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; background: var(--uc); color: var(--ink); font-size: 13px; }
.q-uni-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-sigil { flex: none; width: 10px; height: 10px; background: var(--glimmer); transform: rotate(45deg); outline: 2px solid var(--echo); margin-left: 4px; }
.q-uni-nodes { flex: none; display: flex; gap: 8px; }
.q-node { pointer-events: auto; width: 76px; height: 44px; display: flex !important; align-items: center; justify-content: space-between; gap: 6px; padding: 0 10px !important;
  background: var(--ink) !important; border: 2px solid var(--brass) !important; color: var(--paper) !important; font-size: 15px; touch-action: manipulation; }
.q-node:hover, .q-node:focus-visible { background: var(--ink-3) !important; outline: none; }
.q-node:active { transform: translateY(2px); }
.q-node.open { border-color: var(--echo) !important; }
.q-node.cleared .q-node-rank { color: var(--brass-hi); font-size: 18px; }
.q-node.locked { border-color: #4a4668 !important; color: #7d789a !important; }
.q-map-side { min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: var(--sp-2); justify-content: flex-end; overflow-y: auto; }
.q-map-side .q-btn { width: 100%; }
.q-map-stats { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; margin-bottom: auto; background: rgba(21,19,43,0.88); border-top: 2px solid var(--brass); border-bottom: 2px solid var(--brass); }
@media (max-height: 430px) and (orientation: landscape) {
  .q-map-side { --btn-h: 44px; display: grid; grid-template-columns: 1fr 1fr; align-content: end; }
  .q-map-stats { grid-column: 1 / -1; margin-bottom: 0; }
  .q-map-side .q-btn.primary { grid-column: 1 / -1; }
  .q-map-side .q-btn { min-width: 0; }
  .q-map-side .q-btn-in { padding: 4px 8px; font-size: 15px; }
  .q-uni { min-height: 48px; }
}
@media (orientation: portrait) {
  .q-map { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  .q-map-side { display: grid; grid-template-columns: 1fr 1fr; }
  .q-map-stats { grid-column: 1 / -1; margin-bottom: 0; }
  .q-map-side .q-btn { min-width: 0; }
  .q-map-side .q-btn.primary { grid-column: 1 / -1; }
  .q-map-side .q-btn-in { padding: 4px 8px; font-size: 15px; }
  .q-node { width: 68px; }
}

/* ------------------------------------------------------------------ panel content: rows, result, slots */
.q-panel.wide { width: min(100%, 640px); }
.q-row { display: flex; justify-content: space-between; gap: 14px; align-items: baseline; }
.q-row-k { color: var(--paper-dim); flex: none; }
.q-row-v { text-align: right; min-width: 0; }
.q-row.gold .q-row-v { color: var(--glimmer); }
.q-row.echo .q-row-k, .q-row.echo .q-row-v { color: var(--echo); }
.q-row.tall { flex-direction: column; gap: 2px; }
.q-row.tall .q-row-v { text-align: left; }
.q-panel-body p.q-sub { color: var(--paper-dim); font-size: 14px; }
.q-panel-body p.q-quote { color: var(--brass-hi); border-left: 3px solid var(--brass); padding-left: 10px; }
.q-intro { display: flex; gap: 14px; align-items: center; }
.q-intro-text, .q-intro .q-list { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.q-portrait { flex: none; width: 128px; height: 128px; overflow: hidden; background: var(--ink-2); border: 2px solid var(--brass); }
.q-portrait { background: linear-gradient(180deg, #2E3A66 0%, #1B1A3A 100%); }
.q-portrait canvas { display: block; width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; image-rendering: crisp-edges; pointer-events: none; }

/* ------------------------------------------------------------------ spacetime gallery */
.q-worlds { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }
.q-world { pointer-events: auto; display: flex !important; flex-direction: column; min-width: 0; padding: 0 !important; text-align: left;
  background: var(--ink) !important; border: 2px solid var(--brass) !important; color: var(--paper) !important; touch-action: manipulation; }
.q-world:hover, .q-world:focus-visible { border-color: var(--echo) !important; outline: none; }
.q-world:active { transform: translateY(2px); }
.q-world-pic { position: relative; display: block; width: 100%; height: 64px; background-size: cover; background-position: center; image-rendering: pixelated; image-rendering: crisp-edges; }
.q-world-tile { position: absolute; left: 50%; bottom: 8px; width: 44px; height: 22px; margin-left: -22px; background: var(--uc);
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); box-shadow: inset 0 0 0 2px var(--ua); }
.q-world-cap { display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 4px 8px; font-size: 14px; line-height: 1.2; }
.q-world-cap b { flex: none; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; background: var(--uc); color: var(--ink); font-size: 13px; }
.q-world-cap span { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 640px) { .q-worlds { grid-template-columns: repeat(2, minmax(0, 1fr)); } .q-world-pic { height: 48px; } }
@media (max-height: 430px) and (orientation: landscape) { .q-worlds { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; } .q-world-pic { height: 40px; } .q-world-cap { flex-direction: column; align-items: flex-start; font-size: 12px; padding: 4px; } }
@media (max-width: 520px), (max-height: 430px) { .q-portrait { width: 88px; height: 88px; } }
.q-uprow > span { font-size: 14px; }
.q-uprow .q-btn { flex: none; min-width: 150px; }
.q-result { display: flex; gap: 18px; align-items: stretch; }
.q-rank { flex: none; width: 132px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 8px; background: var(--ink-2); border: 2px solid var(--brass); }
.q-rank-k { font-size: 13px; color: var(--paper-dim); }
.q-rank-v { font-size: 64px; line-height: 1; color: var(--brass-hi); animation: q-stamp 360ms steps(4) both; }
.q-rank-v.rank-S { color: var(--echo); }
.q-rank-v.rank-D { color: var(--paper-dim); }
.q-rank-s { font-size: 14px; }
.q-result-rows { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; justify-content: center; }
@keyframes q-stamp { from { transform: scale(1.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.q-slots { display: flex; flex-wrap: wrap; gap: 8px; }
.q-slot { pointer-events: auto; width: 44px; height: 44px; display: flex !important; align-items: center; justify-content: center; background: var(--ink-2) !important; border: 2px solid #2a8f93 !important; color: var(--paper) !important; font-size: 16px; }
.q-slot.selected { border-color: var(--brass-hi) !important; background: #2a8f93 !important; }
@media (max-width: 520px) {
  .q-result { flex-direction: column; }
  .q-rank { width: 100%; flex-direction: row; gap: 14px; }
  .q-rank-v { font-size: 44px; }
  .q-boss { bottom: auto; top: calc(150px + var(--safe-t)); width: 70vw; }
}
@media (max-height: 430px) {
  .q-panel-body { padding: 10px 16px; gap: 6px; }
  .q-panel-head { padding: 4px 8px 4px 16px; }
  .q-panel-actions { padding: 8px 16px 10px; --btn-h: 44px; }
  .q-rank-v { font-size: 48px; }
  .q-stick { width: 116px; height: 116px; }
}
@media (prefers-reduced-motion: reduce) { .q-rank-v { animation: none; } }

@media (max-width: 520px) {
  .q-timer-num { font-size: 19px; }
  .q-energy { width: 84px; }
  .q-hp i { width: 12px; height: 12px; }
  /* narrow screens: left column stays slim (HP above energy) so the stage name / goal on the right never collide */
  .q-hud-tl { max-width: 154px; }
  .q-echoes { max-width: 154px; }
  .q-hud-row > .q-chip:not(.q-timer) .q-chip-in { flex-direction: column; align-items: flex-start; justify-content: center; gap: 6px; padding: 7px 10px; }
  .q-hud-tr { max-width: calc(100vw - 190px - var(--safe-l) - var(--safe-r)); }
  .q-floor, .q-objective { font-size: 13px; text-align: right; }
}
@media (prefers-reduced-motion: reduce) { .q-btn, .q-toast { transition: none; } }
