/* Game styles scoped to #game-root.
   Visual language follows the hero sprite: chunky pixels, navy outlines,
   steel-blue / teal ramps and warm yellow highlights. Title frames use
   stepped pixel borders; touch controls use quieter rounded frames. */
#game-root {
  --px: 3px;
  --c-ink: #081833;
  --c-deep: #10213f;
  --c-steel: #12509e;
  --c-blue: #2c8ce0;
  --c-teal: #1a7187;
  --c-cyan: #4fd1c7;
  --c-pale: #b8fff6;
  --c-gold: #f7b733;
  --c-cream: #fff1a8;
  --c-white: #eef4ff;
  --c-red: #b8323a;
  --font: 'Silkscreen', ui-monospace, 'Courier New', monospace;
  /* stepped pixel frame: outer ink ring + inner teal ring, notched corners */
  --frame: 0 calc(var(--px) * -1) 0 0 var(--c-cyan), 0 var(--px) 0 0 var(--c-teal),
           calc(var(--px) * -1) 0 0 0 var(--c-cyan), var(--px) 0 0 0 var(--c-teal),
           0 calc(var(--px) * -2) 0 0 var(--c-ink), 0 calc(var(--px) * 2) 0 0 var(--c-ink),
           calc(var(--px) * -2) 0 0 0 var(--c-ink), calc(var(--px) * 2) 0 0 0 var(--c-ink),
           calc(var(--px) * -1) calc(var(--px) * -1) 0 0 var(--c-ink), var(--px) calc(var(--px) * -1) 0 0 var(--c-ink),
           calc(var(--px) * -1) var(--px) 0 0 var(--c-ink), var(--px) var(--px) 0 0 var(--c-ink);

  position: relative;
  display: block;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  --game-height: min(100dvh, 720px);
  --touch-dock-height: 168px;
  --touch-surface-height: 112px;
  --touch-core-height: 64px;
  --touch-safe-left: env(safe-area-inset-left, 0px);
  --touch-safe-right: env(safe-area-inset-right, 0px);
  --touch-safe-bottom: env(safe-area-inset-bottom, 0px);
  --touch-inset-left: calc(32px + var(--touch-safe-left));
  --touch-inset-right: calc(32px + var(--touch-safe-right));
  --touch-inset-bottom: calc(32px + var(--touch-safe-bottom));
  height: var(--game-height);
  min-height: 300px;
  overflow: hidden;
  background: var(--c-ink);
  font-family: var(--font);
  color: var(--c-white);
  -webkit-font-smoothing: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;

  *::-webkit-scrollbar { width: 6px; height: 6px; }
  *::-webkit-scrollbar-track { background: var(--c-deep); }
  *::-webkit-scrollbar-thumb { background: var(--c-teal); }
  *::-webkit-scrollbar-corner { background: transparent; }

  /* One shared low-res world buffer, with readable mobile scaling in JS. */
  #gameCanvas {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
  }

  &.compact { --game-height: min(60svh, 420px); }
  &.is-fullscreen { --game-height: 100dvh; max-width: 100vw; }
  &.touch-layout #gameCanvas { top: 0; transform: translateX(-50%); }
  @media (max-width: 768px) and (orientation: portrait) {
    --game-height: 100dvh;
    min-height: 0;
    &.compact, &.is-fullscreen { --game-height: 100dvh; }
  }
  @media (max-height: 500px) and (orientation: landscape) {
    min-height: 0;
    &.is-fullscreen { --game-height: 100dvh; }
  }

  .hidden { display: none !important; }

  /* Shared pixel UI pieces */
  .keycap {
    display: inline-block;
    min-width: 1.6em;
    padding: 2px 6px 3px;
    margin: 0 2px;
    background: var(--c-deep);
    color: var(--c-pale);
    font-size: 0.85em;
    line-height: 1.1;
    text-align: center;
    box-shadow: 0 -2px 0 0 var(--c-teal), 0 2px 0 0 var(--c-ink), -2px 0 0 0 var(--c-teal), 2px 0 0 0 var(--c-teal), 0 4px 0 0 var(--c-ink);
  }

  .pixel-btn, .go-send-btn, .fs-enter-btn, .fs-exit-btn {
    font-family: var(--font);
    font-size: 15px;
    color: var(--c-ink);
    background: var(--c-gold);
    border: 0;
    padding: 9px 18px 11px;
    cursor: pointer;
    text-transform: uppercase;
    box-shadow: 0 -3px 0 0 var(--c-cream), 0 3px 0 0 #c4581c, -3px 0 0 0 var(--c-ink), 3px 0 0 0 var(--c-ink),
                0 -6px 0 0 var(--c-ink), 0 6px 0 0 var(--c-ink);
    &:hover { background: var(--c-cream); }
    &:active { transform: translateY(3px); box-shadow: 0 -3px 0 0 var(--c-cream), -3px 0 0 0 var(--c-ink), 3px 0 0 0 var(--c-ink), 0 -6px 0 0 var(--c-ink), 0 3px 0 0 var(--c-ink); }
    &:focus-visible { outline: 3px solid var(--c-pale); outline-offset: 6px; }
  }

  /* ==================== LOADING ==================== */
  .loading-screen {
    position: absolute;
    inset: 0;
    z-index: 3000;
    display: grid;
    place-items: center;
    background: var(--c-ink);
    background-image: radial-gradient(var(--c-deep) 1px, transparent 1px);
    background-size: 6px 6px;
    text-align: center;
    padding: 24px;
  }
  .loading-content {
    width: min(340px, 90%);
    h1 { font-size: clamp(18px, 4vw, 26px); line-height: 1.25; margin: 0 0 24px; color: var(--c-pale); text-shadow: 3px 3px 0 var(--c-steel); font-weight: 700; }
  }
  .loading-bar-container {
    height: 15px;
    background: var(--c-deep);
    box-shadow: var(--frame);
    margin: 0 6px 16px;
  }
  .loading-bar {
    width: 0%;
    height: 100%;
    background: repeating-linear-gradient(90deg, var(--c-cyan) 0 9px, var(--c-teal) 9px 12px);
    transition: width 0.2s steps(5);
  }
  .loading-text { margin: 0; font-size: 13px; color: var(--c-cream); letter-spacing: 1px; }

  /* ==================== START SCREEN ==================== */
  .start-screen {
    position: absolute;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: 16px;
    cursor: pointer;
    /* lets the attract-mode demo play behind the card */
    background: linear-gradient(rgba(8, 24, 51, 0.25), rgba(8, 24, 51, 0.55));
  }
  .start-card {
    box-sizing: border-box;
    max-width: min(560px, 94%);
    max-height: 100%;
    overflow: auto;
    padding: 20px 26px 18px;
    background: rgba(8, 24, 51, 0.88);
    box-shadow: var(--frame);
    text-align: center;
    h1 {
      margin: 0 0 14px;
      font-size: clamp(20px, 4.4vw, 34px);
      line-height: 1.1;
      font-weight: 700;
      color: var(--c-cream);
      text-shadow: 3px 3px 0 #c4581c, 6px 6px 0 var(--c-ink);
      span { color: var(--c-pale); text-shadow: 3px 3px 0 var(--c-steel), 6px 6px 0 var(--c-ink); font-size: 0.72em; }
    }
  }
  .start-cta {
    margin: 0 0 14px;
    font-size: 15px;
    color: var(--c-white);
    line-height: 1.6;
  }
  .controls {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px 14px;
    margin: 0 auto 12px;
    padding: 12px 14px;
    text-align: left;
    font-size: 11px;
    background: var(--c-deep);
    dt { color: var(--c-gold); text-transform: uppercase; align-self: center; }
    dd { margin: 0; color: var(--c-pale); line-height: 1.7; }
  }
  .start-tip { margin: 0; font-size: 10px; color: var(--c-cyan); }
  @keyframes blink { 50% { opacity: 0.25; } }

  .start-actions {
    display: grid;
    justify-items: center;
    gap: 14px;
    width: min(280px, 100%);
    margin: 0 auto 14px;
  }
  .start-play-btn {
    width: 100%;
    min-height: 52px;
    font-size: 20px;
  }
  .start-actions .fs-enter-btn {
    margin: 0;
    min-height: 44px;
    padding: 8px 14px;
    color: var(--c-pale);
    background: var(--c-deep);
    font-size: 12px;
    box-shadow: 0 0 0 2px var(--c-teal);
    &:hover { background: var(--c-steel); }
    &:active { transform: translateY(1px); box-shadow: 0 0 0 2px var(--c-cyan); }
    &:disabled { opacity: 0.7; cursor: wait; }
  }
  .fullscreen-status {
    max-width: 32em;
    margin: 0 auto 12px;
    color: var(--c-pale);
    font-size: 10px;
    line-height: 1.6;
    &:empty { display: none; }
  }
  .fullscreen-open-game {
    display: inline-block;
    margin: 0 auto 12px;
    color: var(--c-cyan);
    font-size: 11px;
    &[hidden] { display: none; }
    &:focus-visible { outline: 2px solid var(--c-pale); outline-offset: 3px; }
  }
  @media (max-height: 500px) and (orientation: landscape) {
    .start-card { padding: 12px 16px; }
    .start-card h1 { font-size: 22px; margin-bottom: 8px; }
    .start-actions {
      grid-template-columns: minmax(150px, 220px) auto;
      justify-content: center;
      align-items: center;
      width: 100%;
      margin-bottom: 10px;
    }
    .start-play-btn { min-height: 46px; font-size: 16px; }
    .fullscreen-status { margin-bottom: 8px; font-size: 9px; }
    .start-cta { margin-bottom: 6px; font-size: 10px; }
    .controls { display: none; }
    .start-tip { font-size: 9px; }
  }
  &[data-fullscreen-mode] {
    width: 100vw;
    height: 100dvh;
    max-width: none;
    min-height: 0;
    margin: 0;
  }
  &[data-fullscreen-mode="expanded"] {
    position: fixed;
    inset: 0;
    z-index: 10000;
  }
  .fs-exit-btn {
    position: absolute;
    bottom: 12px;
    left: calc(50% - 17px);
    z-index: 9999;
    width: 34px;
    height: 34px;
    padding: 0;
    font-size: 18px;
    display: none;
  }
  &.is-playing[data-fullscreen-mode] .fs-exit-btn { display: block; }
  &.touch-layout .fs-exit-btn { display: none; }
  &.touch-layout.is-playing[data-fullscreen-mode] .fs-exit-btn { display: none; }
  &.touch-layout .start-tip { display: none; }

  /* ==================== GAME OVER ==================== */
  .go-overlay {
    position: absolute;
    inset: 0;
    z-index: 2000;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(8, 24, 51, 0.72);
    overscroll-behavior: contain;
    animation: go-in 0.3s steps(4) both;
  }
  @keyframes go-in { from { opacity: 0; } }
  .go-panel {
    width: min(640px, 100%);
    max-height: 100%;
    display: grid;
    grid-template-rows: auto auto auto 1fr auto;
    gap: 10px;
    padding: 18px 20px;
    background: var(--c-ink);
    box-shadow: var(--frame);
    overflow: hidden;
    h1 {
      margin: 0;
      text-align: center;
      font-size: clamp(24px, 6vw, 38px);
      font-weight: 700;
      color: var(--c-cream);
      letter-spacing: 2px;
      text-shadow: 3px 3px 0 var(--c-red), 6px 6px 0 #5c1424;
    }
  }
  .go-newbest {
    margin: 0;
    text-align: center;
    color: var(--c-gold);
    font-size: 13px;
    animation: blink 0.6s steps(2, jump-none) infinite;
  }
  .go-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
  }
  .go-stat {
    padding: 7px 4px 8px;
    text-align: center;
    background: var(--c-deep);
    span { display: block; font-size: 10px; color: var(--c-cyan); text-transform: uppercase; margin-bottom: 4px; }
    strong { font-size: clamp(13px, 2.6vw, 18px); color: var(--c-white); font-weight: 400; }
  }
  .go-form {
    margin: 0;
    label { display: block; text-align: center; margin-bottom: 10px; font-size: 12px; color: var(--c-pale); }
    .go-input-row { display: flex; gap: 14px; justify-content: center; align-items: center; padding: 0 6px; }
    #go-name-input {
      flex: 0 1 320px;
      min-width: 0;
      padding: 8px 10px;
      font-family: var(--font);
      font-size: 16px;
      color: var(--c-cream);
      background: var(--c-deep);
      border: 0;
      outline: none;
      text-transform: uppercase;
      box-shadow: 0 -3px 0 0 var(--c-teal), 0 3px 0 0 var(--c-teal), -3px 0 0 0 var(--c-teal), 3px 0 0 0 var(--c-teal);
      user-select: text;
      -webkit-user-select: text;
      &::placeholder { color: var(--c-teal); }
      &:focus-visible { box-shadow: 0 -3px 0 0 var(--c-cyan), 0 3px 0 0 var(--c-cyan), -3px 0 0 0 var(--c-cyan), 3px 0 0 0 var(--c-cyan); }
    }
  }
  .go-leaderboard {
    min-height: 0;
    overflow-y: auto;
    padding: 10px;
    background: var(--c-deep);
    h2 { margin: 0 0 8px; text-align: center; font-size: 13px; color: var(--c-gold); font-weight: 400; text-transform: uppercase; }
    ol { list-style: none; margin: 0; padding: 0; }
    li {
      display: grid;
      grid-template-columns: 3ch 2fr 1.2fr 1fr 0.7fr 1.6fr;
      gap: 6px;
      padding: 5px 6px;
      align-items: center;
      font-size: 11px;
      color: var(--c-pale);
      &:nth-child(odd) { background: rgba(26, 113, 135, 0.18); }
      &.current { background: var(--c-steel); color: var(--c-white); .col-name { color: var(--c-cream); } }
    }
    .col-rank { text-align: right; color: var(--c-cyan); }
    .col-score { text-align: right; color: var(--c-white); font-weight: 400; }
    .col-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; &.editable { cursor: text; text-decoration: underline dotted var(--c-cyan); } }
    .col-date { color: var(--c-teal); }
    input.name-input { font: inherit; padding: 2px 4px; color: var(--c-cream); background: var(--c-ink); border: 0; box-shadow: 0 0 0 2px var(--c-cyan); width: 100%; }
  }
  .go-actions {
    text-align: center;
    padding: 9px 12px 10px;
    background: var(--c-gold);
    color: var(--c-ink);
    cursor: pointer;
    box-shadow: 0 -3px 0 0 var(--c-cream), 0 3px 0 0 #c4581c;
    p { margin: 0; font-size: 13px; }
  }

  @media (max-width: 560px) {
    .go-overlay { padding: 8px; }
    .go-panel { padding: 14px 12px; }
    .go-stats { grid-template-columns: 1fr 1fr; }
    .go-form .go-input-row { flex-direction: column; align-items: stretch; }
    .go-leaderboard li { grid-template-columns: 3ch 2fr 1.2fr 1fr; .col-enemies, .col-date { display: none; } }
    .controls { font-size: 10px; }
  }
  @media (max-height: 460px) {
    .go-panel { gap: 6px; padding: 10px 14px; }
    .go-leaderboard h2, .start-tip { display: none; }
    .start-card { padding: 12px 16px; h1 { margin-bottom: 8px; } }
    .controls { margin-bottom: 6px; padding: 8px 10px; gap: 4px 10px; }
  }

  /* ==================== MOBILE CONTROLS ==================== */
  .mobile-controls-simple {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: calc(var(--touch-dock-height) + var(--touch-safe-bottom));
    display: none;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 23px var(--touch-inset-right) var(--touch-inset-bottom) var(--touch-inset-left);
    box-sizing: border-box;
    z-index: 1000;
    pointer-events: none;
  }
  .mobile-controls-movement, .mobile-controls-fire { display: flex; flex: 0 0 auto; pointer-events: auto; }
  .mobile-controls-utilities { display: flex; gap: 8px; position: absolute; right: var(--touch-inset-right); bottom: calc(100% + 12px); pointer-events: auto; }
  .dock-utilities .mobile-controls-utilities { position: static; flex: 0 0 160px; order: 1; align-self: flex-start; }
  .dock-utilities .mobile-controls-fire { order: 2; }
  .control-btn {
    font-family: var(--font);
    font-size: 14px;
    color: var(--c-white);
    border: 1px solid var(--btn);
    border-radius: 20px;
    background: rgba(16, 33, 63, 0.88);
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    touch-action: none;
    box-shadow: inset 0 1px 0 rgba(238, 244, 255, 0.08), 0 3px 0 var(--c-ink);
    &:active, &.active { transform: translateY(2px); background: var(--btn); color: var(--c-ink); }
    &:focus-visible { outline: 2px solid var(--c-pale); outline-offset: 3px; }
    &:disabled { opacity: 0.45; cursor: default; transform: none; }
    span, strong, small { display: block; }
  }
  .jump-btn, .shoot-btn { position: relative; height: var(--touch-surface-height); padding: 0; border: 0; overflow: hidden; }
  .jump-btn { --btn: var(--c-cyan); width: 128px; border-radius: 32px; color: var(--c-pale); box-shadow: inset 0 0 0 1px #376d79, inset 0 1px 0 #b8fff616, 0 3px 0 var(--c-ink); }
  .jump-btn:active, .shoot-btn:active { transform: none; }
  .jump-btn:active { color: var(--c-pale); background: rgba(16,33,63,.88); }
  .thumb-jump-core { display: grid!important; place-items: center; position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 64px; height: var(--touch-core-height); border-radius: 24px; border: 1px solid #3e8490; background: #153343; box-sizing: border-box; font-size: 12px; }
  .jump-btn.active .thumb-jump-core { background: #397e83; color: var(--c-pale); border-color: var(--c-cyan); }
  .jump-cue { position: absolute; top: 5px; }
  .thumb-steer-arc { position: absolute; left: 0; right: 0; bottom: 0; height: 48px; display: flex!important; justify-content: space-between; align-items: center; background: #102a3b; border-radius: 24px; }
  .steer-left, .steer-right { display: grid!important; place-items: center; width: 48px; height: 48px; font-size: 24px; color: #95c1c9; }
  .steer-knob { display: grid!important; place-items: center; position: absolute; left: 50%; top: 50%; width: 48px; height: 48px; margin-left: -24px; margin-top: -24px; border: 1px solid #386d76; box-sizing: border-box; border-radius: 22px; color: #77a5b0; background: #183444; pointer-events: none; transform: translate(var(--steer-offset, 0px), var(--steer-lift, 0px)); transition: transform 120ms ease-out; }
  .is-dragging .steer-knob { transition: none; }
  .thumb-surface svg, .weapon-strip svg { shape-rendering: crispEdges; }
  .is-steering .steer-knob { background: #305868; border-color: var(--c-cyan); }
  .shoot-btn { --btn: var(--c-gold); width: 80px; border-radius: 28px; color: var(--c-cream); background: #302f2e; box-shadow: inset 0 0 0 1px #b3914c, inset 0 1px 0 #fff1a816, 0 3px 0 var(--c-ink); }
  .shoot-btn:active { background: #302f2e; color: var(--c-cream); }
  .shoot-btn.active { background: #7b612b; color: var(--c-cream); }
  .fire-core { display: grid!important; place-items: center; position: absolute; inset: 0 0 auto; height: var(--touch-core-height); }
  .weapon-strip { display: flex!important; align-items: center; justify-content: center; gap: 3px; position: absolute; bottom: 0; left: 0; right: 0; height: 48px; border-top: 1px solid #7e703c; background: #182d37; color: #9cbbc6; box-sizing: border-box; }
  .weapon-label { font-size: 9px; line-height: 1.3; }
  .weapon-count { margin-top: 2px; font-size: 8px; line-height: 1.3; }
  .weapon-previous, .weapon-next { font-size: 17px; opacity: .2; }
  .can-switch .weapon-previous, .can-switch .weapon-next { opacity: .85; }
  .is-weapon-pressed .can-switch { background: #224454; }
  .swipe-next .weapon-next, .swipe-previous .weapon-previous { color: var(--c-gold); opacity: 1; }
  .utility-btn { --btn: #305868; display: grid; place-items: center; width: 48px; height: 48px; padding: 0; border-radius: 18px; color: #c0d8df; background: rgba(8,24,42,.88); touch-action: manipulation; }
  .utility-btn svg { shape-rendering: crispEdges; }
  .auto-charge-btn { display: flex; flex-direction: column; justify-content: center; gap: 2px; font-size: 8px; line-height: 1.3; color: #8cabb5; }
  .auto-charge-btn strong { font-size: 10px; color: var(--c-pale); }
  .auto-charge-btn.is-on { --btn: #386d76; background: #112e3a; }
  .fullscreen-exit-icon, .resume-icon { display: none; }
  &[data-fullscreen-mode] .fullscreen-enter-icon, .is-paused .pause-icon { display: none; }
  &[data-fullscreen-mode] .fullscreen-exit-icon, .is-paused .resume-icon { display: block; }
  .visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
  &.touch-layout .mobile-controls-simple { background: var(--c-ink); border-top: 1px solid #254251; }
  @media (max-height: 500px) and (orientation: landscape) {
    --touch-dock-height: 136px;
    --touch-surface-height: 96px;
    --touch-core-height: 48px;
    --touch-inset-bottom: calc(28px + var(--touch-safe-bottom));
    .mobile-controls-simple { padding-top: 11px; }
  }
  @media (prefers-reduced-motion: reduce) { .steer-knob { transition: none; } }

  /* Mobile/Desktop visibility */
  .mobile-only { display: none; }
  .desktop-only { display: block; }
  dl.desktop-only { display: grid; }
  @media (hover: none) and (pointer: coarse), (max-width: 768px) {
    .mobile-only { display: block; }
    .desktop-only, dl.desktop-only { display: none; }
  }
  @media (any-hover: none) {
    .mobile-only { display: block; }
    .desktop-only, dl.desktop-only { display: none; }
  }

  @media (prefers-reduced-motion: reduce) {
    .start-cta, .go-newbest { animation: none; }
  }
}

/* Keep touch UI inside curved displays, including embedded fullscreen. */
#game-root.touch-layout { border-radius: 28px; }
#game-root .pause-resume-btn {
  position: absolute; top: 52%; left: 50%; transform: translate(-50%, -50%);
  z-index: 1100; min-height: 56px; padding: 16px 24px; border-radius: 24px;
  border: 2px solid var(--c-cyan); background: var(--c-deep); color: var(--c-pale);
  font: 14px var(--font); cursor: pointer; touch-action: manipulation;
}
#game-root .pause-resume-btn[hidden] { display: none; }
.render-settings {
  position: absolute; bottom: 12px; left: 12px; z-index: 1200;
  max-width: min(300px, calc(100% - 24px)); color: #d7ecea;
  background: rgba(8, 24, 42, .94); border: 1px solid #315565; border-radius: 12px;
  font: 11px ui-monospace, monospace; box-shadow: 0 5px 24px #06122160;
}
.render-settings summary { padding: 10px 14px; cursor: pointer; color: #a7e3e7; }
.render-settings > div { padding: 4px 14px 14px; max-height: min(66vh, 440px); overflow: auto; }
.render-settings label { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.render-settings input[type="range"] { width: 100px; margin-left: auto; accent-color: #7cdfd9; }
.render-settings input[type="checkbox"] { accent-color: #7cdfd9; }
.render-settings select, .render-settings button { padding: 6px 8px; border: 1px solid #315565; border-radius: 6px; color: #d7ecea; background: #152b3a; }
.render-settings select { margin-left: auto; }
.touch-layout .render-settings { bottom: calc(var(--touch-dock-height) + env(safe-area-inset-bottom, 0px) + 72px); }
@media (max-height: 500px) and (orientation: landscape) {
  .touch-layout .render-settings {
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(var(--touch-dock-height) + env(safe-area-inset-bottom, 0px) + 8px);
  }
  .touch-layout .render-settings > div { max-height: max(24px, calc(var(--game-stage-height) - 72px)); }
  .touch-layout:has(.pause-resume-btn:not([hidden])) .render-settings { display: none; }
}

/* Pause loadout: weapons, cards, synergies, buffs and threats of the live run. */
#game-root .pause-loadout {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 1100;
  box-sizing: border-box; width: min(640px, calc(100% - 32px)); max-height: calc(100% - 32px); overflow-y: auto; overscroll-behavior: contain;
  padding: 16px; color: #e8f0e9; background: rgba(16, 36, 60, .96);
  box-shadow: 0 -4px 0 #618691, 0 4px 0 #25415d, -4px 0 0 #618691, 4px 0 0 #25415d, 8px 12px 0 #020b19;
  scrollbar-width: thin; scrollbar-color: #517787 #0b2035;
}
#game-root .pause-loadout[hidden] { display: none; }
#game-root .pause-loadout * { box-sizing: border-box; }
#game-root .pause-loadout-header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
#game-root .pause-loadout-header h2 { margin: 0; font: 20px/1.2 var(--font); color: var(--c-cream); text-transform: uppercase; text-shadow: 2px 2px #061225; }
#game-root .pause-loadout-stage { font: 9px/1.4 var(--font); color: #ff8a7a; text-transform: uppercase; }
#game-root .pause-loadout-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
#game-root .pause-loadout-section { min-width: 0; padding: 8px; background: #0b2035; border: 2px solid #2f5166; }
#game-root .pause-loadout-section h3 { margin: 0 0 6px; font: 9px/1.4 var(--font); color: #8fb6bf; text-transform: uppercase; letter-spacing: .04em; }
#game-root .pause-loadout-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
#game-root .pause-loadout-entry { --entry-color: #517787; display: flex; align-items: center; gap: 8px; min-width: 0; padding: 4px 6px; background: #12304a; border-left: 2px solid var(--entry-color); }
#game-root .pause-loadout-entry[data-active] { --entry-color: var(--c-cyan); background: #18405a; }
#game-root .pause-loadout-entry[data-tone="buff"] { --entry-color: #a4ce9b; }
#game-root .pause-loadout-entry[data-tone="synergy"] { --entry-color: var(--c-gold); }
#game-root .pause-loadout-entry[data-tone="malus"] { --entry-color: #ff8a7a; background: #2a2236; }
#game-root .pause-loadout-entry[data-tone="muted"] { opacity: .55; }
#game-root .pause-loadout-sprite { flex: 0 0 auto; width: 20px; height: 20px; image-rendering: pixelated; }
#game-root .pause-loadout-pair { display: flex; flex: 0 0 auto; gap: 1px; }
#game-root .pause-loadout-text { display: flex; flex-direction: column; min-width: 0; }
#game-root .pause-loadout-text strong { font: 10px/1.4 var(--font); color: #eff5d9; }
#game-root .pause-loadout-detail { font: 11px/1.35 system-ui, sans-serif; color: #b6d0d3; }
#game-root .pause-loadout-empty { padding: 4px 6px; font: 11px/1.35 system-ui, sans-serif; color: #7f9aa3; }
#game-root .pause-loadout-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; }
#game-root .pause-loadout-footer .pause-resume-btn { position: static; transform: none; min-height: 44px; padding: 10px 18px; border-radius: 0; box-shadow: inset 0 -3px #06172c, 2px 2px #061225; }
#game-root .pause-loadout-keys { font: 9px/1.4 var(--font); color: #8fb6bf; text-transform: uppercase; }
@media (max-width: 520px) {
  #game-root .pause-loadout { padding: 10px; }
  #game-root .pause-loadout-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-height: 420px) {
  #game-root .pause-loadout { padding: 10px; }
  #game-root .pause-loadout-header { margin-bottom: 6px; }
  #game-root .pause-loadout-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 6px; }
  #game-root .pause-loadout-detail { font-size: 10px; }
}
