:root {
  --ink: #efe4d4;
  --muted: #b9ab96;
  --gold: #e0a457;
  --panel: rgba(18, 14, 11, 0.72);
  --edge: rgba(224, 164, 87, 0.45);
  --red: #ff5a4a;
  --green: #7be38a;
  --cyan: #7fd8ff;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0c1220; color: var(--ink); font-family: 'Nunito', system-ui, sans-serif; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: none; }
#game { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
#vignette { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, transparent 45%, rgba(0, 0, 0, 0.55) 100%); }
body.ouch #vignette { animation: ouch 0.45s ease-out; }
@keyframes ouch { 0% { box-shadow: inset 0 0 140px rgba(255, 40, 30, 0.75); } 100% { box-shadow: inset 0 0 0 rgba(255, 40, 30, 0); } }

kbd { display: inline-block; min-width: 1.6em; padding: 1px 7px; margin: 0 2px; border: 1px solid var(--edge); border-bottom-width: 3px; border-radius: 6px; background: rgba(255, 255, 255, 0.06); font: 800 0.85em 'Nunito', sans-serif; color: var(--ink); text-align: center; }

/* HUD */
#hud { position: fixed; top: max(12px, env(safe-area-inset-top)); left: 12px; right: 12px; display: flex; gap: 12px; align-items: flex-start; pointer-events: none; opacity: 0; transition: opacity 0.4s; }
body.playing #hud { opacity: 1; }
.panel { background: var(--panel); border: 1px solid var(--edge); border-radius: 10px; padding: 10px 14px; backdrop-filter: blur(3px); }
.stats { width: 290px; }
.stats .name { font-family: 'Cinzel', serif; font-weight: 900; font-size: 15px; letter-spacing: 2px; color: var(--gold); margin-bottom: 6px; }
.bar { position: relative; height: 16px; border-radius: 8px; background: rgba(255, 255, 255, 0.08); overflow: hidden; border: 1px solid rgba(0, 0, 0, 0.6); }
#hp-fill { position: absolute; inset: 0 auto 0 0; width: 100%; background: linear-gradient(#8fe08a, #3f9f4a); transition: width 0.2s; }
#hp-fill.low { background: linear-gradient(#ff8a7a, #c8382c); animation: pulse 0.8s infinite; }
@keyframes pulse { 50% { opacity: 0.6; } }
#hp-text { position: absolute; right: 8px; top: -1px; font-size: 13px; font-weight: 900; text-shadow: 0 1px 2px #000; }
.stats .row { display: flex; gap: 8px; align-items: baseline; margin-top: 7px; font-size: 14px; }
.stats .label { color: var(--muted); font-weight: 600; }
.stats b { font-weight: 900; margin-right: 10px; }
#cash { color: #8fe08a; }
#objective { flex: 1; text-align: center; font-weight: 800; font-size: 16px; align-self: flex-start; max-width: 520px; margin: 0 auto; }
.icon-btn { pointer-events: auto; width: 46px; height: 46px; border-radius: 10px; border: 1px solid var(--edge); background: var(--panel); color: var(--ink); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.icon-btn svg { width: 22px; height: 22px; fill: currentColor; }

#boss { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); width: min(560px, 80vw); text-align: center; opacity: 0; transition: opacity 0.4s; pointer-events: none; }
#boss.show { opacity: 1; }
#boss-name { font-family: 'Cinzel', serif; font-weight: 900; letter-spacing: 3px; font-size: 17px; color: #ffb1a6; text-shadow: 0 2px 6px #000; margin-bottom: 6px; }
#boss .bar { height: 14px; }
#boss-fill { position: absolute; inset: 0 auto 0 0; width: 100%; background: linear-gradient(#ff7a6a, #a82a20); transition: width 0.15s; }
body.touch #boss { bottom: auto; top: 118px; }

#hint { position: fixed; left: 50%; bottom: 80px; transform: translate(-50%, 10px); max-width: min(640px, 86vw); padding: 12px 18px; background: var(--panel); border: 1px solid var(--edge); border-radius: 12px; font-weight: 800; font-size: 17px; text-align: center; opacity: 0; transition: opacity 0.3s, transform 0.3s; pointer-events: none; }
#hint.show { opacity: 1; transform: translate(-50%, 0); }
body.touch #hint { bottom: auto; top: 128px; }
#toast { position: fixed; left: 50%; top: 92px; transform: translateX(-50%); padding: 10px 18px; border-radius: 10px; background: rgba(224, 164, 87, 0.92); color: #1c1712; font-weight: 900; font-size: 16px; opacity: 0; pointer-events: none; max-width: 86vw; text-align: center; }
#toast.show { animation: toast 3.6s ease forwards; }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, -8px); } 8%, 85% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }
#prompt { position: fixed; left: 50%; bottom: 140px; transform: translateX(-50%); padding: 8px 14px; border-radius: 10px; background: rgba(10, 40, 60, 0.85); border: 1px solid var(--cyan); color: var(--cyan); font-weight: 900; opacity: 0; transition: opacity 0.2s; pointer-events: none; }
#prompt.show { opacity: 1; animation: bob 0.8s infinite alternate; }
@keyframes bob { to { transform: translate(-50%, -4px); } }
#banner { position: fixed; left: 0; right: 0; top: 34%; text-align: center; pointer-events: none; opacity: 0; }
#banner.show { animation: banner 4.2s ease forwards; }
#banner h2 { margin: 0; font-family: 'Cinzel', serif; font-weight: 900; font-size: clamp(30px, 6vw, 64px); letter-spacing: 4px; color: #ffb1a6; text-shadow: 0 4px 18px #000; }
#banner p { margin: 8px auto 0; max-width: 620px; font-weight: 800; font-size: 18px; text-shadow: 0 2px 8px #000; }
@keyframes banner { 0% { opacity: 0; transform: scale(1.2); } 10%, 80% { opacity: 1; transform: scale(1); } 100% { opacity: 0; } }

#floaters { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.floater { position: absolute; left: 0; top: 0; font-weight: 900; font-size: 20px; color: #fff; text-shadow: 0 2px 0 #000, 0 0 8px rgba(0, 0, 0, 0.8); white-space: nowrap; }
.floater.big { font-family: 'Cinzel', serif; font-size: 28px; color: #ffd36a; }
.floater.hurt { color: var(--red); }
.floater.cash { color: #8fe08a; font-size: 22px; }
.floater.heal { color: #9fe3ff; }
.floater.cap { color: var(--cyan); font-family: 'Cinzel', serif; font-size: 26px; }
.floater.alert { color: #ff6a5a; font-size: 30px; }

#bubble { position: fixed; left: 0; top: 0; max-width: 300px; padding: 12px 16px; background: #f4ecdc; color: #1c1712; border-radius: 14px; font-weight: 900; font-size: 17px; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
#bubble.show { opacity: 1; }
#bubble::after { content: ''; position: absolute; left: 50%; bottom: -10px; margin-left: -10px; border: 10px solid transparent; border-bottom: 0; border-top-color: #f4ecdc; }

/* Overlays */
.overlay { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; padding: 16px; background: rgba(6, 8, 14, 0.62); }
.overlay.show { display: flex; }
.card { width: min(620px, 100%); max-height: 100%; overflow: auto; background: rgba(28, 23, 18, 0.95); border: 1px solid var(--edge); border-radius: 16px; padding: 28px; text-align: center; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6); }
.card h1 { margin: 0; font-family: 'Cinzel', serif; font-weight: 900; font-size: clamp(48px, 10vw, 84px); letter-spacing: 8px; color: var(--gold); text-shadow: 0 0 30px rgba(125, 255, 74, 0.25); }
.card h2 { margin: 4px 0 10px; font-family: 'Cinzel', serif; font-weight: 900; font-size: 30px; color: var(--gold); }
.card .sub { font-weight: 800; letter-spacing: 3px; text-transform: uppercase; color: #9fe3a0; font-size: 14px; }
.card p { font-size: 17px; line-height: 1.5; }
.muted { color: var(--muted); }
.controls { display: grid; gap: 8px; margin: 18px 0 22px; font-size: 15px; color: var(--muted); }
.touch-only { display: none; }
body.touch .touch-only { display: block; color: var(--ink); }
.big-btn { min-height: 54px; padding: 0 30px; border: 0; border-radius: 12px; background: var(--gold); color: #1c1712; font: 900 18px 'Nunito', sans-serif; letter-spacing: 1px; cursor: pointer; box-shadow: 0 6px 0 #8a5f27; }
.big-btn:active { transform: translateY(3px); box-shadow: 0 3px 0 #8a5f27; }
.stat-table { margin: 16px 0; display: grid; gap: 6px; text-align: left; }
.stat-table div { display: flex; justify-content: space-between; padding: 8px 12px; background: rgba(255, 255, 255, 0.04); border-radius: 8px; }
.stat-table b { color: var(--gold); }

/* Touch controls (iPad) */
#touch { display: none; }
body.touch.playing #touch { display: block; }
body.touch #prompt { display: none; }
.stick { position: fixed; left: max(24px, env(safe-area-inset-left)); bottom: max(28px, env(safe-area-inset-bottom)); width: 150px; height: 150px; border-radius: 50%; background: rgba(255, 255, 255, 0.07); border: 2px solid rgba(224, 164, 87, 0.4); touch-action: none; }
.knob { position: absolute; left: 50%; top: 50%; width: 64px; height: 64px; margin: -32px 0 0 -32px; border-radius: 50%; background: rgba(224, 164, 87, 0.75); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5); }
.buttons { position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(20px, env(safe-area-inset-bottom)); width: 262px; height: 240px; transform-origin: bottom right; }
.tbtn { position: absolute; width: 84px; height: 84px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.25); color: #fff; font: 900 13px 'Nunito', sans-serif; letter-spacing: 0.5px; touch-action: none; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5); }
.tbtn.down { transform: scale(0.92); filter: brightness(1.3); }
.tbtn.punch { right: 0; bottom: 64px; width: 96px; height: 96px; background: rgba(200, 70, 50, 0.85); }
.tbtn.kick { right: 104px; bottom: 4px; width: 80px; height: 80px; background: rgba(210, 130, 40, 0.85); }
.tbtn.flip { right: 104px; bottom: 94px; width: 80px; height: 80px; background: rgba(60, 110, 200, 0.85); }
.tbtn.grab { right: 14px; bottom: 172px; width: 66px; height: 66px; font-size: 12px; background: rgba(120, 80, 170, 0.85); }
.tbtn.grab .g2, body.holding .tbtn.grab .g1 { display: none; }
body.holding .tbtn.grab .g2 { display: inline; }
.tbtn.capture { right: 92px; bottom: 186px; width: 94px; height: 48px; border-radius: 24px; background: rgba(40, 140, 190, 0.9); opacity: 0.25; }
body.can-capture .tbtn.capture { opacity: 1; animation: glow 0.7s infinite alternate; }
@keyframes glow { to { box-shadow: 0 0 22px var(--cyan); } }

@media (max-width: 700px) {
  .stats { width: 200px; }
  #objective { font-size: 13px; }
  .stats .row { flex-wrap: wrap; }
}

/* Sound button + volume */
.icon-btn + .icon-btn { margin-left: -4px; }
#mute-btn .snd-off, body.muted #mute-btn .snd-on { display: none; }
body.muted #mute-btn .snd-off { display: block; }
body.muted #mute-btn { color: var(--red); }
.sliders { display: grid; gap: 12px; margin: 0 auto 22px; max-width: 360px; text-align: left; font-weight: 800; }
.sliders label { display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.sliders input[type=range] { flex: 1; max-width: 200px; accent-color: var(--gold); height: 28px; }
.hint-line { color: #9fe3a0; font-weight: 700; }

/* Weapon slots */
.weapons { display: flex; gap: 6px; margin-top: 8px; }
.wslot { flex: 1; display: flex; align-items: center; gap: 4px; justify-content: center; padding: 4px 2px; border-radius: 7px; border: 1px solid rgba(255, 255, 255, 0.1); font-size: 12px; font-weight: 800; color: rgba(239, 228, 212, 0.35); }
.wslot kbd { font-size: 10px; min-width: 1.3em; padding: 0 4px; border-bottom-width: 2px; }
.wslot.owned { color: var(--ink); }
.wslot.active { border-color: var(--gold); background: rgba(224, 164, 87, 0.22); color: #ffd59e; }
body.touch .wslot kbd { display: none; }
.tbtn.weapon { right: 196px; bottom: 82px; width: 58px; height: 58px; font-size: 11px; background: rgba(90, 100, 115, 0.9); }
.tbtn.weapon[data-weapon=knife] { background: rgba(150, 165, 180, 0.95); color: #1c1712; }

#fade { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; }
.wslot i { font-style: normal; }

.byline { margin-top: 10px; font-family: 'Cinzel', serif; font-weight: 700; font-size: 16px; letter-spacing: 3px; color: var(--muted); }
.byline.small { margin-top: 16px; font-size: 13px; }

/* Map, flash grenade */
.map-card { width: min(720px, 100%); }
.map-wrap { overflow: auto; display: flex; justify-content: center; margin: 12px 0; }
#map-canvas { border-radius: 8px; border: 1px solid var(--edge); max-width: 100%; height: auto; }
.small { font-size: 14px; }
#whiteout { position: fixed; inset: 0; background: #fffaf0; opacity: 0; pointer-events: none; }
#whiteout.go { animation: whiteout 0.9s ease-out; }
@keyframes whiteout { 0% { opacity: 0.85; } 100% { opacity: 0; } }
.tbtn.flash { right: 192px; bottom: 4px; width: 66px; height: 66px; font-size: 12px; background: rgba(230, 200, 60, 0.9); color: #1c1712; }

/* Phones: shrink the stick and the button cluster so they never overlap. */
@media (max-width: 560px), (max-height: 500px) {
  .stick { width: 124px; height: 124px; left: max(16px, env(safe-area-inset-left)); bottom: max(18px, env(safe-area-inset-bottom)); }
  .knob { width: 54px; height: 54px; margin: -27px 0 0 -27px; }
  .buttons { transform: scale(0.8); right: max(10px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom)); }
}
@media (max-width: 400px) {
  .stick { width: 112px; height: 112px; }
  .buttons { transform: scale(0.72); }
}
@media (max-width: 560px) {
  #hud { left: max(8px, env(safe-area-inset-left)); right: max(8px, env(safe-area-inset-right)); gap: 6px; }
  .stats { width: 150px; padding: 7px 9px; }
  .stats .name { font-size: 12px; margin-bottom: 4px; }
  .bar { height: 12px; }
  #hp-text { font-size: 11px; top: -2px; }
  .stats .row { font-size: 12px; gap: 4px; margin-top: 5px; flex-wrap: wrap; }
  .stats b { margin-right: 4px; }
  .weapons { gap: 3px; margin-top: 5px; }
  .wslot { font-size: 10px; padding: 2px 1px; }
  #objective { font-size: 12px; padding: 7px 8px; }
  .icon-btn { width: 38px; height: 38px; border-radius: 8px; }
  .icon-btn svg { width: 18px; height: 18px; }
  body.touch #hint { top: auto; bottom: 200px; font-size: 14px; }
  body.touch #boss { top: auto; bottom: 200px; }
  #toast { top: 150px; font-size: 14px; }
}

/* Title actions, Safehouse */
.title-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; align-items: center; }
.big-btn.alt { background: #9fe3a0; box-shadow: 0 6px 0 #4c8a4d; }
.link-btn { background: none; border: 0; color: var(--muted); font: 800 15px 'Nunito', sans-serif; text-decoration: underline; cursor: pointer; padding: 10px; min-height: 44px; }
.link-btn:hover, .link-btn:focus-visible { color: var(--ink); }
.safe-card { width: min(920px, 100%); text-align: left; }
.safe-card > .sub, .safe-card > h2, .safe-card > .wallet { text-align: center; }
.wallet { font-weight: 800; font-size: 18px; color: var(--muted); margin-bottom: 16px; }
.wallet b { color: #8fe08a; font-size: 24px; margin-left: 6px; font-variant-numeric: tabular-nums; }
.safe-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-bottom: 22px; }
.safe-room { background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(224, 164, 87, 0.25); border-radius: 12px; padding: 14px; min-width: 0; }
.safe-room h3 { margin: 0 0 10px; font-family: 'Cinzel', serif; color: var(--gold); letter-spacing: 2px; font-size: 18px; }
.safe-room.locked { opacity: 0.6; }
.jail-row { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-bottom: 1px dashed rgba(255, 255, 255, 0.08); font-weight: 700; }
.jail-row b { color: var(--cyan); font-variant-numeric: tabular-nums; }
.shop-item { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 8px 0; border-bottom: 1px dashed rgba(255, 255, 255, 0.08); }
.shop-item .nm { font-weight: 900; }
.shop-item .ds { grid-column: 1; font-size: 13px; color: var(--muted); }
.shop-item .ow { grid-column: 1; font-size: 12px; color: #9fe3a0; font-weight: 800; }
.shop-item button { grid-row: 1 / span 3; grid-column: 2; align-self: center; min-width: 76px; min-height: 44px; border-radius: 10px; border: 0; background: var(--gold); color: #1c1712; font: 900 15px 'Nunito', sans-serif; cursor: pointer; }
.shop-item button:disabled { background: rgba(255, 255, 255, 0.1); color: var(--muted); cursor: default; }

/* Chapter 2: stars, mask filter, mash prompt */
.stars-only, .tbtn.star { display: none; }
body.has-stars .stars-only { display: inline; }
body.touch.playing.has-stars .tbtn.star { display: block; }
.filter-row { display: none; align-items: center; gap: 8px; margin-top: 6px; font-size: 12px; }
body.has-spores .filter-row { display: flex; }
.filter-row .label { color: var(--muted); font-weight: 700; white-space: nowrap; }
.small-bar { flex: 1; height: 10px; }
#filter-fill { position: absolute; inset: 0 auto 0 0; width: 60%; background: linear-gradient(#b8ff8a, #4caf3a); transition: width 0.2s; }
#filter-fill.low { background: linear-gradient(#ff8a7a, #c8382c); animation: pulse 0.6s infinite; }
body.masked .filter-row .label { color: #b8ff8a; }
.tbtn.star { right: 196px; bottom: 150px; width: 58px; height: 58px; font-size: 11px; background: rgba(200, 210, 225, 0.92); color: #1c1712; }
body.has-stars .tbtn.capture { right: 92px; }
#mash { position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%); width: min(460px, 86vw); text-align: center; opacity: 0; pointer-events: none; }
#mash.show { opacity: 1; animation: bob 0.35s infinite alternate; }
#mash-label { font-family: 'Cinzel', serif; font-weight: 900; font-size: clamp(18px, 3.4vw, 26px); color: #ffd36a; text-shadow: 0 3px 10px #000; margin-bottom: 10px; }
#mash .bar { height: 18px; }
#mash-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(#ffd36a, #d9a521); transition: width 0.1s; }

/* Full screen, difficulty, sneak */
.fs-btn .fs-off, body.is-fs .fs-btn .fs-on { display: none; }
body.is-fs .fs-btn .fs-off { display: block; }
.diff-row { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-items: center; margin: 0 0 16px; }
.diff-row .label { color: var(--muted); font-weight: 800; margin-right: 6px; }
.diff-btn { min-height: 40px; padding: 0 14px; border-radius: 20px; border: 1px solid var(--edge); background: rgba(255, 255, 255, 0.04); color: var(--ink); font: 800 15px 'Nunito', sans-serif; cursor: pointer; }
.diff-btn[aria-pressed="true"] { background: var(--gold); color: #1c1712; border-color: var(--gold); }
.diff-btn:focus-visible, .link-btn:focus-visible, .big-btn:focus-visible, .icon-btn:focus-visible { outline: 3px solid #9fe3a0; outline-offset: 2px; }
.fs-link { display: block; margin: -6px auto 10px; }
.tbtn.sneak { right: 14px; bottom: 246px; width: 66px; height: 40px; border-radius: 20px; font-size: 11px; background: rgba(60, 70, 60, 0.9); }
.tbtn.sneak[aria-pressed="true"] { background: rgba(120, 200, 120, 0.95); color: #1c1712; }
body.sneaking #vignette { box-shadow: inset 0 0 120px rgba(0, 0, 0, 0.6); }
#diff-tag { margin-left: auto; font-size: 11px; font-weight: 800; color: var(--muted); letter-spacing: 1px; }
.stats .row { flex-wrap: wrap; row-gap: 2px; }
.stats b { white-space: nowrap; }

/* Phones and tablets: touch help instead of the keyboard wall, a title that fits, a card you can scroll. */
.touch-help { display: none; }
@media (pointer: coarse), (max-width: 560px), (max-height: 520px) { .keys-only { display: none; } .touch-help { display: grid; } .fs-link { display: none; } }
body.touch .keys-only { display: none; }
body.touch .touch-help { display: grid; }
.touch-help b { color: var(--ink); }
.overlay { touch-action: pan-y; }
.card { -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
@media (max-width: 560px) {
  .card { padding: 20px 16px; }
  .card h1 { font-size: clamp(34px, 12vw, 52px); letter-spacing: 3px; }
  .card p { font-size: 15px; }
}
@media (max-height: 520px) {
  .overlay { align-items: flex-start; padding: max(8px, env(safe-area-inset-top)) 12px 8px; }
  .card { padding: 14px 18px; }
  .card h1 { font-size: 36px; letter-spacing: 4px; }
  #title .card > p, #title .byline { display: none; }
  .controls { margin: 8px 0 10px; gap: 4px; font-size: 13px; }
  .diff-row { margin-bottom: 8px; }
  .big-btn { min-height: 46px; }
}

/* Save codes */
.sc-card { width: min(520px, 100%); }
.sc-code { font-family: 'Cinzel', serif; font-weight: 900; font-size: clamp(24px, 6vw, 36px); letter-spacing: 2px; color: var(--gold); background: rgba(0, 0, 0, 0.35); border: 2px dashed var(--edge); border-radius: 12px; padding: 14px 10px; margin: 6px 0 12px; user-select: all; -webkit-user-select: all; word-break: break-word; }
.sc-load { margin: 22px 0 6px; padding-top: 18px; border-top: 1px solid rgba(255, 255, 255, 0.08); text-align: left; }
.sc-label { display: block; font-weight: 800; margin-bottom: 8px; }
.sc-row { display: flex; gap: 10px; flex-wrap: wrap; }
.sc-row input { flex: 1 1 200px; min-width: 0; min-height: 50px; padding: 0 14px; border-radius: 12px; border: 2px solid var(--edge); background: rgba(0, 0, 0, 0.35); color: var(--ink); font: 800 18px 'Nunito', sans-serif; letter-spacing: 1px; text-transform: uppercase; user-select: text; -webkit-user-select: text; touch-action: manipulation; }
.sc-row input:focus { outline: 3px solid var(--cyan); outline-offset: 2px; }
.sc-error { min-height: 1.4em; color: #ff9a8a; font-weight: 800; margin: 8px 0 0; }
.sc-error.ok { color: var(--green); }

/* Controls screen */
.ctl-card { width: min(640px, 100%); }
.ctl-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: 8px; margin: 12px 0; text-align: left; }
.ctl-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 8px 6px 12px; border-radius: 10px; background: rgba(255, 255, 255, 0.04); }
.ctl-row span { font-weight: 700; color: var(--muted); }
.ctl-key { min-width: 76px; min-height: 40px; padding: 0 10px; border-radius: 9px; border: 1px solid var(--edge); border-bottom-width: 3px; background: rgba(0, 0, 0, 0.35); color: var(--gold); font: 900 15px 'Nunito', sans-serif; cursor: pointer; }
.ctl-key.listening { color: #1c1712; background: var(--gold); animation: pulse 0.7s infinite; }
.ctl-key.changed { border-color: #9fe3a0; }
.toggle-row { display: flex; flex-wrap: wrap; gap: 10px 22px; justify-content: center; align-items: center; margin: 10px 0 18px; }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; cursor: pointer; min-height: 44px; }
.toggle input { width: 22px; height: 22px; accent-color: var(--gold); }
/* Left-handed touch layout: mirror the controls */
.buttons { --bs: 1; transform: scale(var(--bs)); }
@media (max-width: 560px), (max-height: 500px) { .buttons { --bs: 0.8; transform: scale(var(--bs)); } }
@media (max-width: 400px) { .buttons { --bs: 0.72; transform: scale(var(--bs)); } }
body.lefty .stick { left: auto; right: max(24px, env(safe-area-inset-right)); }
body.lefty .buttons { right: auto; left: max(16px, env(safe-area-inset-left)); transform-origin: bottom center; transform: scaleX(-1) scale(var(--bs)); }
body.lefty .tbtn { transform: scaleX(-1); }
.tbtn.down { transform: none; scale: 0.92; }
body.lefty .tbtn.down { transform: scaleX(-1); }

/* Health kits, the trader */
.kits-only, .tbtn.heal { display: none; }
body.has-kits .kits-only { display: inline; }
body.touch.playing.has-kits .tbtn.heal { display: block; }
.tbtn.heal { right: 196px; bottom: 214px; width: 58px; height: 58px; font-size: 11px; background: rgba(220, 70, 90, 0.92); }
.trader-card { width: min(720px, 100%); }
.trader-line { text-align: center; font-style: italic; color: #ffd27a; font-weight: 700; }
.trader-items { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 4px 18px; margin-bottom: 8px; }
