/* SPAN — shell styles. Glassy panels over a full-window canvas. System font stack only. */
:root {
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: ui-rounded, "SF Pro Rounded", "Segoe UI Variable Display", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, Menlo, monospace;

  --bg: #0b1120;
  --glass: rgba(13, 19, 33, 0.7);
  --glass-strong: rgba(13, 19, 33, 0.82);
  --glass-hi: rgba(255, 255, 255, 0.07);
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.22);
  --text: #eef3fb;
  --muted: #9aabc4;
  --dim: #6d7c94;
  --primary: #ffb547;
  --primary-2: #ff7a3d;
  --blue: #49c6f2;
  --blue-2: #3a7bff;
  --good: #3ee08f;
  --warn: #ffb429;
  --bad: #ff4d5e;
  --star: #ffd25e;
  --acc: #7bd389;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 10px 34px rgba(0, 0, 0, 0.35), 0 2px 6px rgba(0, 0, 0, 0.2);
  --blur: blur(16px) saturate(150%);
  --gap: 12px;
  --top-h: 62px;
  --ease: cubic-bezier(.22, .9, .3, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: var(--font); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body { user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; touch-action: none; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

#game-canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; background: linear-gradient(#9ed8f5, #e6f6ff); }
#ui { position: fixed; inset: 0; pointer-events: none; z-index: 10; }

.ico { width: 20px; height: 20px; flex: none; display: block; }
.star { width: 18px; height: 18px; fill: rgba(255, 255, 255, 0.16); stroke: rgba(0, 0, 0, 0.25); stroke-width: .6; flex: none; }
.star.on { fill: var(--star); filter: drop-shadow(0 0 6px rgba(255, 200, 80, 0.55)); }
kbd { font-family: var(--font-mono); font-size: 11px; padding: 1px 5px; border-radius: 5px; background: rgba(255, 255, 255, 0.1); border: 1px solid var(--line); border-bottom-width: 2px; }

.glass {
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--line);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  border-radius: var(--radius);
}

/* ------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 18px; border-radius: 12px; border: 1px solid transparent;
  background: transparent; cursor: pointer; font-weight: 650; font-size: 14px; letter-spacing: .01em;
  transition: transform .18s var(--ease), background .2s, border-color .2s, box-shadow .2s, opacity .2s, color .2s;
  white-space: nowrap; outline: none;
}
.btn:focus-visible, .tool:focus-visible, .mat:focus-visible, .tile:focus-visible { box-shadow: 0 0 0 2px var(--blue); }
.btn:active:not(:disabled) { transform: translateY(1px) scale(.98); }
.btn:disabled { opacity: .35; cursor: default; }
.btn-primary {
  background: linear-gradient(180deg, #ffc65c, var(--primary-2)); color: #2b1300; border-color: rgba(255, 255, 255, .25);
  box-shadow: 0 6px 20px rgba(255, 122, 61, .38), inset 0 1px 0 rgba(255, 255, 255, .45);
}
.btn-primary:hover { box-shadow: 0 8px 28px rgba(255, 122, 61, .55), inset 0 1px 0 rgba(255, 255, 255, .5); transform: translateY(-1px); }
.btn-glass { background: rgba(255, 255, 255, .08); border-color: var(--line); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); }
.btn-glass:hover { background: rgba(255, 255, 255, .14); border-color: var(--line-strong); }
.btn-ghost { background: transparent; color: var(--text); }
.btn-ghost:hover { background: rgba(255, 255, 255, .09); }
.btn-ghost.on { background: rgba(73, 198, 242, .18); color: #bfeeff; }
.btn-icon { width: 42px; padding: 0; }
.btn-icon.sm { width: 32px; height: 32px; border-radius: 9px; }
.btn-xl { height: 58px; padding: 0 30px; font-size: 18px; border-radius: 16px; min-width: 190px; }
.btn-xl .ico { width: 22px; height: 22px; }
.btn.danger { color: #ff9aa4; }
.btn.danger.confirm { background: rgba(255, 77, 94, .2); color: #fff; }

.chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 99px; background: rgba(255, 255, 255, .08); border: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.chip b { color: var(--text); font-size: 14px; }
.chip-lg { height: 38px; padding: 0 14px; font-size: 14px; }
.chip-lg b { font-size: 16px; }

/* ------------------------------------------------------------ screens */
.screen { position: absolute; inset: 0; opacity: 0; visibility: hidden; transition: opacity .45s var(--ease), visibility 0s linear .45s; }
.screen.active { opacity: 1; visibility: visible; transition: opacity .45s var(--ease), visibility 0s; }

/* ------------------------------------------------------------ boot */
.boot { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; background: radial-gradient(ellipse at 50% 40%, #18233d, #070b14); transition: opacity .6s var(--ease); }
.boot.gone { opacity: 0; pointer-events: none; }
.boot-logo { font-family: var(--font-display); font-weight: 900; font-size: 64px; letter-spacing: .32em; padding-left: .32em; color: #fff; opacity: .9; }
.boot-bar { width: 180px; height: 3px; border-radius: 3px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.boot-bar span { display: block; width: 40%; height: 100%; background: linear-gradient(90deg, var(--primary), var(--blue)); animation: bootbar 1s var(--ease) infinite; }
@keyframes bootbar { from { transform: translateX(-100%); } to { transform: translateX(260%); } }
.noscript { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 20px; }

/* ------------------------------------------------------------ title */
#screen-title { pointer-events: none; display: flex; align-items: center; justify-content: center; }
#screen-title.active { pointer-events: auto; }
.title-vignette { position: absolute; inset: 0; background:
  radial-gradient(ellipse 70% 55% at 50% 42%, rgba(7, 11, 22, .55), rgba(7, 11, 22, 0) 70%),
  linear-gradient(180deg, rgba(7, 11, 22, .55) 0%, rgba(7, 11, 22, .05) 40%, rgba(7, 11, 22, 0) 62%, rgba(7, 11, 22, .55) 100%); }
.title-wrap { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; margin-top: -14vh; }
.logo-art { width: min(640px, 78vw); height: auto; margin-bottom: -2.2vw; overflow: visible; filter: drop-shadow(0 4px 16px rgba(0, 0, 0, .35)); }
.logo-art .la { fill: none; stroke-linecap: round; }
.logo-art .tower { stroke: rgba(255, 255, 255, .9); stroke-width: 6; stroke-dasharray: 120; stroke-dashoffset: 120; animation: draw 1s var(--ease) .15s forwards; }
.logo-art .cable { stroke: url(#cableG); stroke-width: 3.5; stroke-dasharray: 900; stroke-dashoffset: 900; animation: draw 1.6s var(--ease) .5s forwards; }
.logo-art .hangers { stroke: rgba(255, 255, 255, .55); stroke-width: 1.6; opacity: 0; animation: fadein .8s ease 1.4s forwards; }
.logo-art .deck { stroke: rgba(255, 255, 255, .95); stroke-width: 5; stroke-dasharray: 600; stroke-dashoffset: 600; animation: draw 1.1s var(--ease) .05s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fadein { to { opacity: 1; } }
.logo { margin: 0; font-family: var(--font-display); font-weight: 900; font-size: clamp(96px, 15.5vw, 230px); line-height: .9; letter-spacing: .16em; padding-left: .16em; display: flex; }
.logo span {
  display: inline-block; background: linear-gradient(180deg, #ffffff 15%, #ffe2a8 60%, #ffb547 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 6px 0 rgba(120, 50, 10, .45)) drop-shadow(0 18px 30px rgba(0, 0, 0, .45));
  opacity: 0; transform: translateY(40px) scale(.9); animation: letter .9s var(--spring) forwards;
}
.logo span:nth-child(1) { animation-delay: .25s; }
.logo span:nth-child(2) { animation-delay: .35s; }
.logo span:nth-child(3) { animation-delay: .45s; }
.logo span:nth-child(4) { animation-delay: .55s; }
@keyframes letter { to { opacity: 1; transform: none; } }
.tagline { margin: 18px 0 0; font-size: clamp(16px, 1.6vw, 21px); color: rgba(255, 255, 255, .92); font-weight: 500; letter-spacing: .02em; text-shadow: 0 2px 12px rgba(0, 0, 0, .5); opacity: 0; animation: rise .8s var(--ease) .9s forwards; }
.tagline em { font-style: normal; color: var(--primary); }
.title-buttons { display: flex; gap: 14px; margin-top: 38px; opacity: 0; animation: rise .8s var(--ease) 1.1s forwards; flex-wrap: wrap; justify-content: center; }
.title-meta { position: fixed; top: 18px; right: 18px; display: flex; gap: 10px; align-items: center; opacity: 0; animation: rise .8s var(--ease) 1.3s forwards; }
.title-meta .chip { background: rgba(10, 16, 30, .45); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); }
.title-foot { position: absolute; bottom: 22px; left: 0; right: 0; text-align: center; font-size: 13px; color: rgba(255, 255, 255, .7); letter-spacing: .04em; text-shadow: 0 1px 6px rgba(0, 0, 0, .6); }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------ level select */
#screen-levels { pointer-events: none; background: linear-gradient(180deg, rgba(8, 12, 24, .72), rgba(8, 12, 24, .6)); -webkit-backdrop-filter: blur(8px) saturate(120%); backdrop-filter: blur(8px) saturate(120%); display: flex; flex-direction: column; }
#screen-levels.active { pointer-events: auto; }
.ls-head { margin: var(--gap) var(--gap) 0; height: 68px; display: flex; align-items: center; gap: 12px; padding: 0 12px; flex: none; }
.ls-title { flex: 1; min-width: 0; }
.ls-title h2 { margin: 0; font-family: var(--font-display); font-size: 22px; font-weight: 800; letter-spacing: .01em; }
.ls-title p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.ls-right { display: flex; align-items: center; gap: 8px; }
.ls-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 6px var(--gap) 40px; scroll-behavior: smooth; touch-action: pan-y; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .2) transparent; }
.chapters { max-width: 1120px; margin: 0 auto; display: flex; flex-direction: column; gap: 26px; padding-top: 18px; }
.chapter { position: relative; }
.ch-head { display: flex; align-items: center; gap: 14px; margin: 0 4px 12px; }
.ch-num { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; font-family: var(--font-display); font-weight: 900; font-size: 20px; color: #10131c; background: linear-gradient(160deg, var(--sky1), var(--acc)); box-shadow: 0 6px 18px color-mix(in srgb, var(--acc) 35%, transparent), inset 0 1px 0 rgba(255, 255, 255, .5); }
.ch-text { flex: 1; min-width: 0; }
.ch-text h3 { margin: 0; font-family: var(--font-display); font-size: 19px; font-weight: 800; }
.ch-text p { margin: 2px 0 0; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-stars { display: flex; align-items: center; gap: 5px; font-size: 13px; color: var(--muted); }
.ch-stars b { color: var(--text); font-size: 15px; }
.soon-tag { font-size: 12px; padding: 4px 10px; border-radius: 99px; border: 1px dashed var(--line-strong); color: var(--muted); }
.chapter::before { content: ""; position: absolute; left: -6px; right: -6px; top: 54px; bottom: -8px; border-radius: 20px; background: linear-gradient(180deg, color-mix(in srgb, var(--acc) 8%, transparent), transparent 70%); pointer-events: none; }
.tiles { position: relative; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.tile {
  position: relative; display: flex; flex-direction: column; text-align: left; padding: 0; overflow: hidden;
  border-radius: 14px; border: 1px solid var(--line); background: rgba(16, 23, 40, .72); cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .25); transition: transform .22s var(--ease), box-shadow .22s, border-color .22s;
  animation: tilein .5s var(--ease) both; outline: none;
}
@keyframes tilein { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }
.tile.open:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--acc) 70%, white 10%); box-shadow: 0 12px 28px rgba(0, 0, 0, .35), 0 0 0 1px color-mix(in srgb, var(--acc) 50%, transparent), 0 0 26px color-mix(in srgb, var(--acc) 30%, transparent); }
.tile.open:active { transform: translateY(-1px) scale(.985); }
.tile-art { position: relative; aspect-ratio: 100 / 52; overflow: hidden; background: #223; }
.tile-art .thumb { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.tile-art::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0, 0, 0, 0) 45%, rgba(0, 0, 0, .45)); }
.tile-num { position: absolute; left: 10px; bottom: 6px; z-index: 1; font-family: var(--font-display); font-weight: 900; font-size: 26px; color: #fff; text-shadow: 0 2px 8px rgba(0, 0, 0, .6); }
.tile-lock { position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; }
.tile-lock .ico { width: 30px; height: 30px; padding: 8px; box-sizing: content-box; border-radius: 50%; background: rgba(8, 12, 22, .65); color: rgba(255, 255, 255, .85); }
.tile-body { padding: 9px 11px 10px; display: flex; flex-direction: column; gap: 6px; }
.tile-name { font-weight: 650; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-stars { display: flex; gap: 3px; }
.tile-stars .star { width: 16px; height: 16px; }
.tile.done .tile-art::before { content: ""; position: absolute; top: 8px; right: 8px; z-index: 2; width: 10px; height: 10px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px rgba(62, 224, 143, .3); }
.tile.locked { cursor: not-allowed; }
.tile.locked .thumb { filter: grayscale(.85) brightness(.6); }
.tile.locked .tile-name { color: var(--muted); }
.tile.soon { cursor: default; background: rgba(16, 23, 40, .35); border-style: dashed; border-color: rgba(255, 255, 255, .14); box-shadow: none; }
.soon-art { display: grid; place-items: center; background: repeating-linear-gradient(135deg, rgba(255, 255, 255, .03) 0 10px, rgba(255, 255, 255, .06) 10px 20px); }
.soon-art span { font-family: var(--font-display); font-weight: 900; font-size: 28px; color: rgba(255, 255, 255, .22); }
.tile.soon .tile-name { color: var(--dim); font-weight: 600; }
.tile-stars.dim .star { fill: rgba(255, 255, 255, .07); }
.tile.nope { animation: nope .4s var(--ease); }
/* unlock rule (BG.Storage): skipped-but-open levels, chapter finales (gates), the (i) on chapter headers */
.tile-skip { position: absolute; left: 6px; top: 6px; z-index: 3; max-width: calc(100% - 26px); padding: 2px 7px; border-radius: 8px; background: rgba(255, 180, 41, .9); color: #1d1404; font-size: 10.5px; font-weight: 750; line-height: 1.3; letter-spacing: .01em; box-shadow: 0 2px 8px rgba(0, 0, 0, .35); pointer-events: none; }
.tile.skipped { border-color: rgba(255, 180, 41, .55); }
.tile-gate { position: absolute; left: 10px; bottom: 36px; z-index: 1; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; background: rgba(8, 12, 22, .6); color: #ffd38a; }
.tile-gate .ico { width: 13px; height: 13px; }
.ch-info { position: relative; flex: none; display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: rgba(255, 255, 255, .05); color: var(--muted); cursor: help; }
.ch-info .ico { width: 17px; height: 17px; }
.ch-info:hover, .ch-info:focus-visible { color: var(--text); background: rgba(255, 255, 255, .12); }
:root:not(.m-touch) .ch-info:hover::after, :root:not(.m-touch) .ch-info:focus-visible::after { content: attr(data-tip); position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; width: 300px; padding: 10px 12px; border-radius: 12px; background: rgb(14, 20, 34); border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0, 0, 0, .45); color: var(--text); font-size: 12.5px; font-weight: 500; line-height: 1.45; text-align: left; white-space: normal; pointer-events: none; }
@keyframes nope { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-6px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }
.ch-locked .ch-num { filter: grayscale(.7) brightness(.8); }

/* ------------------------------------------------------------ in-level HUD */
#screen-level { pointer-events: none; }
#screen-level.active .topbar, #screen-level.active .rail, #screen-level.active .palette, #screen-level.active .simbar,
#screen-level.active .test-btn, #screen-level.active .tpl-menu.open, #screen-level.active .hint.show, #screen-level.active .results.show { pointer-events: auto; }

.topbar { position: absolute; top: var(--gap); left: var(--gap); right: var(--gap); height: var(--top-h); display: flex; align-items: center; gap: 12px; padding: 0 10px; transition: transform .45s var(--ease), opacity .3s; }
.lvl-badge { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 52px; height: 44px; padding: 0 8px; border-radius: 12px; background: linear-gradient(160deg, color-mix(in srgb, var(--acc) 85%, white 15%), color-mix(in srgb, var(--acc) 70%, black 30%)); color: #0d1220; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45), 0 4px 14px color-mix(in srgb, var(--acc) 35%, transparent); }
.lvl-k { font-size: 9px; font-weight: 800; letter-spacing: .14em; opacity: .7; }
.lvl-n { font-family: var(--font-display); font-weight: 900; font-size: 20px; line-height: 1; }
.lvl-title { min-width: 0; flex: 0 1 260px; }
.lvl-name { font-family: var(--font-display); font-weight: 800; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lvl-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }

.budget { flex: 1 1 360px; max-width: 440px; min-width: 200px; margin: 0 auto; padding: 0 6px; }
.budget-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
.budget-k { display: inline-flex; align-items: center; gap: 5px; text-transform: uppercase; letter-spacing: .1em; font-weight: 700; font-size: 10.5px; }
.budget-k .ico { width: 14px; height: 14px; }
.budget-v { font-variant-numeric: tabular-nums; font-size: 13px; }
.budget-v b { font-size: 16px; color: var(--text); font-weight: 800; transition: color .25s; }
.budget-v i { font-style: normal; opacity: .5; padding: 0 1px; }
.budget-bar { position: relative; height: 10px; margin-top: 6px; border-radius: 99px; background: rgba(255, 255, 255, .09); box-shadow: inset 0 1px 2px rgba(0, 0, 0, .35); }
.budget-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 99px; background: var(--good); box-shadow: 0 0 12px rgba(62, 224, 143, .35); transition: background .35s; }
.budget-fill::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(180deg, rgba(255, 255, 255, .35), transparent 60%); }
.tick { position: absolute; top: -3px; bottom: -3px; width: 2px; border-radius: 2px; background: rgba(255, 255, 255, .45); }
.tick.t70 { left: 70%; } .tick.t85 { left: 85%; }
.tick-lbl { position: absolute; top: 13px; transform: translateX(-50%); font-size: 8.5px; letter-spacing: -1px; color: var(--star); opacity: .8; line-height: 1; }
.tick-lbl.l70 { left: 70%; } .tick-lbl.l85 { left: 85%; }
.budget.over .budget-v b { color: var(--bad); }
.budget.over .budget-fill { box-shadow: 0 0 14px rgba(255, 77, 94, .6); animation: overpulse 1.2s ease-in-out infinite; }
@keyframes overpulse { 50% { filter: brightness(1.25); } }
.budget.shake { animation: shake .45s var(--ease); }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-5px); } 40% { transform: translateX(4px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }

.traffic { display: flex; align-items: center; gap: 4px; padding: 0 4px; flex: none; max-width: 34vw; overflow: hidden; }
.tr-item { display: inline-flex; align-items: center; gap: 2px; padding: 4px 7px 4px 5px; border-radius: 9px; background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .06); font-size: 12px; font-weight: 700; color: var(--muted); }
.tr-item b { color: var(--text); font-variant-numeric: tabular-nums; }
.veh { width: 40px; height: 16px; display: block; }
.veh .vb { fill: #dfe7f3; }
.veh .vw { fill: #1c2230; stroke: #dfe7f3; stroke-width: .9; }
.veh .vh { fill: #9aa7ba; }
.tr-none { font-size: 12px; color: var(--muted); }

/* rail */
.rail { position: absolute; left: var(--gap); top: calc(var(--gap) * 2 + var(--top-h)); display: flex; flex-direction: column; gap: 3px; padding: 6px; transition: transform .45s var(--ease), opacity .3s; max-height: calc(100% - var(--top-h) - 140px); overflow-y: auto; scrollbar-width: none; }
.rail::-webkit-scrollbar { display: none; }
.rail-sep { height: 1px; margin: 4px 6px; background: var(--line); flex: none; }
.tool { position: relative; width: 62px; height: 54px; flex: none; border-radius: 12px; border: 1px solid transparent; background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; cursor: pointer; color: var(--text); transition: background .18s, color .18s, border-color .18s, transform .15s; outline: none; }
.tool span { font-size: 10.5px; font-weight: 650; color: var(--muted); transition: color .18s; }
.tool:hover:not(:disabled) { background: rgba(255, 255, 255, .08); }
.tool:active:not(:disabled) { transform: scale(.95); }
.tool:disabled { opacity: .32; cursor: default; }
.tool.active { background: linear-gradient(160deg, rgba(73, 198, 242, .3), rgba(58, 123, 255, .22)); border-color: rgba(73, 198, 242, .55); color: #e5f8ff; box-shadow: 0 0 16px rgba(73, 198, 242, .25); }
.tool.active span { color: #cdeffd; }
.tool.toggle.on { background: rgba(255, 181, 71, .18); border-color: rgba(255, 181, 71, .55); color: #ffe2b0; }
.tool.toggle.on span { color: #ffd38a; }
.tool.danger:hover { background: rgba(255, 77, 94, .15); color: #ffb3bb; }
.tool-wrap { position: relative; flex: none; }
.tpl-menu { position: fixed; z-index: 5; left: 100px; top: 100px; width: min(560px, calc(100vw - 130px)); padding: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; opacity: 0; visibility: hidden; transform: translateX(-8px); transition: opacity .2s, transform .25s var(--ease), visibility 0s .25s; background: var(--glass-strong); max-height: calc(100vh - 150px); overflow-y: auto; }
.tpl-menu.open { opacity: 1; visibility: visible; transform: none; transition: opacity .2s, transform .25s var(--ease), visibility 0s; }
.tool-wrap.open > .tool { background: rgba(255, 255, 255, .1); }
.tpl-head { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 700; padding: 6px 10px 6px; grid-column: 1 / -1; }
.tpl-item { display: flex; align-items: center; gap: 10px; text-align: left; padding: 8px 10px; border-radius: 10px; border: 1px solid transparent; background: transparent; cursor: pointer; color: inherit; font: inherit; transition: background .15s, border-color .15s; }
.tpl-pic { flex: 0 0 64px; height: 34px; border-radius: 8px; background: rgba(255,255,255,.06); display: grid; place-items: center; color: #c9d4e6; }
.tpl-pic svg { width: 58px; height: 28px; }
.tpl-item:hover .tpl-pic { color: #fff; background: rgba(255,255,255,.12); }
.tpl-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tpl-item:hover { background: rgba(255, 255, 255, .07); border-color: rgba(255,255,255,.1); }
.tpl-item b { font-size: 14px; font-weight: 650; }
.tpl-item small { font-size: 11.5px; color: var(--muted); line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* dock */
.dock { position: absolute; left: calc(var(--gap) + 90px); right: 200px; bottom: var(--gap); height: 96px; display: flex; justify-content: center; align-items: flex-end; }
.palette, .simbar { position: absolute; bottom: 0; transition: transform .45s var(--ease), opacity .3s; }
.palette { display: flex; gap: 6px; padding: 6px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.palette::-webkit-scrollbar { display: none; }
.mat { position: relative; flex: 0 1 152px; min-width: 112px; height: 82px; display: flex; flex-direction: column; justify-content: space-between; text-align: left; padding: 8px 10px 9px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, .06); background: rgba(255, 255, 255, .04); cursor: pointer; transition: background .18s, border-color .18s, transform .18s var(--ease), box-shadow .2s; outline: none; overflow: hidden; }
.mat:hover { background: rgba(255, 255, 255, .09); transform: translateY(-2px); }
.mat.active { background: linear-gradient(170deg, rgba(255, 181, 71, .22), rgba(255, 122, 61, .1)); border-color: rgba(255, 181, 71, .7); box-shadow: 0 0 0 1px rgba(255, 181, 71, .25), 0 6px 18px rgba(255, 140, 50, .25); }
.mat .kbd { position: absolute; top: 6px; right: 7px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 5px; font-family: var(--font-mono); font-size: 11px; font-weight: 700; display: grid; place-items: center; background: rgba(255, 255, 255, .1); color: var(--muted); border-bottom: 2px solid rgba(0, 0, 0, .3); }
.mat.active .kbd { background: var(--primary); color: #2b1300; }
.mat-ico { position: absolute; top: 5px; left: 8px; width: 40px; height: 24px; }
.mat-ico svg { width: 40px; height: 24px; display: block; }
.mat-info { display: flex; flex-direction: column; gap: 3px; margin-top: 22px; min-width: 0; }
.mat-info b { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mat-meta { display: flex; justify-content: space-between; gap: 6px; font-size: 11px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.mat-meta em { font-style: normal; color: #ffd38a; font-weight: 700; }
.mat-meta i { font-style: normal; color: var(--muted); }
.mat-str { display: block; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.mat-str span { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, #49c6f2, #8ef0c6); }
.mat-tag { position: absolute; top: 9px; left: 52px; right: 28px; font-size: 9px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 700; }

.simbar { display: flex; align-items: center; gap: 4px; padding: 6px 8px; height: 58px; transform: translateY(130%); opacity: 0; }
.sb-btn { height: 42px; padding: 0 12px; gap: 6px; }
.sb-sep { width: 1px; height: 28px; background: var(--line); margin: 0 4px; }
.seg { display: inline-flex; padding: 3px; border-radius: 11px; background: rgba(0, 0, 0, .25); border: 1px solid rgba(255, 255, 255, .06); }
.seg button { height: 34px; min-width: 42px; border: 0; border-radius: 8px; background: transparent; cursor: pointer; font-weight: 700; font-size: 13px; color: var(--muted); transition: background .18s, color .18s; }
.seg button:hover { color: var(--text); }
.seg button.active { background: rgba(255, 255, 255, .16); color: #fff; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .15); }
.sb-stat { display: inline-flex; align-items: baseline; gap: 5px; padding: 0 8px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sb-stat .ico { width: 15px; height: 15px; align-self: center; opacity: .8; }
.sb-stat b { font-size: 16px; color: var(--text); font-weight: 800; min-width: 2.4em; text-align: right; }
.sb-stat.warn b { color: var(--warn); }
.simbar.paused [data-act=pause] { color: var(--primary); }

/* test button */
.test-btn {
  position: absolute; right: var(--gap); bottom: var(--gap); width: 176px; height: 82px; border-radius: 20px; border: 1px solid rgba(255, 255, 255, .3);
  display: flex; align-items: center; justify-content: center; gap: 12px; cursor: pointer; outline: none; overflow: hidden;
  background: linear-gradient(170deg, #ffc65c 0%, #ff8f3d 55%, #ff6a3d 100%); color: #2b1300;
  box-shadow: 0 10px 30px rgba(255, 110, 50, .45), inset 0 1px 0 rgba(255, 255, 255, .5), inset 0 -3px 0 rgba(120, 40, 0, .25);
  transition: transform .2s var(--ease), box-shadow .25s, background .3s, filter .2s;
}
.test-btn::before { content: ""; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, .45) 45%, transparent 60%); transform: translateX(-120%); animation: sheen 4.5s ease-in-out 2s infinite; }
@keyframes sheen { 0%, 70% { transform: translateX(-120%); } 100% { transform: translateX(120%); } }
.test-btn:hover { transform: translateY(-2px); box-shadow: 0 14px 38px rgba(255, 110, 50, .6), inset 0 1px 0 rgba(255, 255, 255, .55), inset 0 -3px 0 rgba(120, 40, 0, .25); }
.test-btn:active { transform: translateY(1px) scale(.98); }
.tb-ico { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: rgba(43, 19, 0, .14); }
.tb-ico .ico { width: 24px; height: 24px; }
.tb-lbl { display: flex; flex-direction: column; align-items: flex-start; line-height: 1; }
.tb-lbl b { font-family: var(--font-display); font-size: 26px; font-weight: 900; letter-spacing: .02em; text-transform: uppercase; }
.tb-lbl small { margin-top: 5px; font-size: 10px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; opacity: .6; }
.tb-edit { display: none !important; }
.mode-sim .test-btn, .mode-results .test-btn { background: linear-gradient(170deg, #6fd8ff, #3a8bff 60%, #3567e8); color: #06173a; box-shadow: 0 10px 30px rgba(58, 123, 255, .45), inset 0 1px 0 rgba(255, 255, 255, .5), inset 0 -3px 0 rgba(0, 30, 90, .3); }
.mode-sim .test-btn::before, .mode-results .test-btn::before { animation: none; }
.mode-sim .tb-play, .mode-results .tb-play { display: none !important; }
.mode-sim .tb-edit, .mode-results .tb-edit { display: grid !important; }
.mode-sim b.tb-edit, .mode-results b.tb-edit { display: block !important; }

/* mode transitions */
.mode-sim .rail, .mode-results .rail { transform: translateX(calc(-100% - 30px)); opacity: 0; pointer-events: none !important; }
.mode-sim .palette, .mode-results .palette { transform: translateY(130%); opacity: 0; pointer-events: none !important; }
.mode-sim .simbar, .mode-results .simbar { transform: none; opacity: 1; }
.mode-edit .simbar { pointer-events: none !important; }
.mode-results .simbar [data-act=pause], .mode-results .simbar [data-act=step], .mode-results .simbar .seg { opacity: .35; pointer-events: none; }

/* hint */
.hint { position: absolute; top: calc(var(--gap) * 2 + var(--top-h) + 4px); left: 50%; width: min(580px, calc(100% - 220px)); display: flex; align-items: flex-start; gap: 12px; padding: 12px 10px 12px 14px; transform: translate(-50%, -14px); opacity: 0; transition: transform .45s var(--spring), opacity .3s; pointer-events: none; border-color: rgba(255, 210, 94, .35); }
.hint.show { transform: translate(-50%, 0); opacity: 1; }
.hint-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: rgba(255, 210, 94, .16); color: var(--star); flex: none; }
.hint p { margin: 0; flex: 1; font-size: 14px; line-height: 1.45; padding-top: 7px; color: #f3f6fb; }

/* tooltip */
.tooltip { position: fixed; left: 0; top: 0; z-index: 30; min-width: 170px; max-width: 260px; padding: 10px 12px; border-radius: 12px; background: rgba(10, 15, 27, .88); border: 1px solid var(--line); box-shadow: var(--shadow); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); opacity: 0; pointer-events: none; transition: opacity .15s; font-size: 12.5px; }
.tooltip.show { opacity: 1; }
.tt-head { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; font-size: 13.5px; }
.tt-sw { width: 12px; height: 12px; border-radius: 4px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25); }
.tt-rows { display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; }
.tt-rows .k { color: var(--muted); }
.tt-rows .v { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.tt-rows .v.good { color: var(--good); } .tt-rows .v.warn { color: var(--warn); } .tt-rows .v.bad { color: var(--bad); }
.tt-meter { position: relative; height: 5px; margin-top: 9px; border-radius: 5px; background: rgba(255, 255, 255, .1); }
.tt-meter span { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 5px; transition: width .1s; }
.tt-meter i { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: #fff; border-radius: 2px; }

/* toasts */
.toasts { position: fixed; left: 50%; bottom: 128px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 40; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 99px; font-size: 14px; font-weight: 550; background: var(--glass-strong); opacity: 0; transform: translateY(10px) scale(.96); transition: opacity .25s, transform .35s var(--spring); }
.toast.in { opacity: 1; transform: none; }
.toast.out { opacity: 0; transform: translateY(-6px) scale(.98); }
.toast.bump { animation: bump .3s var(--ease); }
@keyframes bump { 50% { transform: scale(1.04); } }
.toast .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 10px var(--blue); flex: none; }
.toast.warn .dot { background: var(--warn); box-shadow: 0 0 10px var(--warn); }
.toast.bad .dot { background: var(--bad); box-shadow: 0 0 10px var(--bad); }
.toast.good .dot { background: var(--good); box-shadow: 0 0 10px var(--good); }

/* results */
.results { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; opacity: 0; visibility: hidden; transition: opacity .35s, visibility 0s .35s; background: radial-gradient(ellipse at center, rgba(6, 10, 20, .55), rgba(6, 10, 20, .25)); }
.results.show { opacity: 1; visibility: visible; transition: opacity .35s, visibility 0s; }
.results.inspecting { background: transparent; pointer-events: none !important; }
.results-card { position: relative; width: min(580px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow-y: auto; padding: 26px 26px 22px; text-align: center; background: rgba(13, 19, 33, .82); transform: translateY(24px) scale(.95); opacity: 0; transition: transform .55s var(--spring), opacity .3s; border-radius: 22px; }
.results.show .results-card { transform: none; opacity: 1; }
.results.inspecting .results-card { transform: translateY(30px) scale(.92); opacity: 0; pointer-events: none; }
.res-banner { display: inline-block; padding: 5px 14px; border-radius: 99px; font-size: 11px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.pass .res-banner { background: rgba(62, 224, 143, .15); color: #8af2c0; border: 1px solid rgba(62, 224, 143, .35); }
.fail .res-banner { background: rgba(255, 77, 94, .15); color: #ffa3ad; border: 1px solid rgba(255, 77, 94, .35); }
.res-stars { display: flex; justify-content: center; align-items: flex-end; gap: 8px; margin: 16px 0 6px; height: 74px; }
.res-stars .star { width: 58px; height: 58px; fill: rgba(255, 255, 255, .1); stroke: rgba(255, 255, 255, .12); stroke-width: .5; transition: fill .2s; }
.res-stars .star.mid { width: 72px; height: 72px; }
.res-stars .star.on { fill: var(--star); stroke: #fff3c4; filter: drop-shadow(0 0 14px rgba(255, 200, 80, .7)); }
.res-stars .star.pop { animation: starpop .6s var(--spring); }
@keyframes starpop { 0% { transform: scale(.2) rotate(-40deg); } 60% { transform: scale(1.25) rotate(8deg); } 100% { transform: none; } }
.results-card h2 { margin: 4px 0 6px; font-family: var(--font-display); font-weight: 900; font-size: 30px; letter-spacing: .01em; }
.fail .results-card h2 { color: #ffd0d5; }
.res-reason { margin: 0 auto 16px; max-width: 400px; color: #c8d3e4; font-size: 14.5px; line-height: 1.5; }
.res-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.rs { padding: 9px 6px; border-radius: 12px; background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .06); display: flex; flex-direction: column; gap: 3px; }
.rs span { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 700; }
.rs b { font-size: 16px; font-variant-numeric: tabular-nums; }
.rs b.good { color: #8af2c0; } .rs b.bad { color: #ff8b97; }
.res-budget { margin: 4px 4px 20px; }
.rb-bar { position: relative; height: 10px; border-radius: 99px; background: rgba(255, 255, 255, .09); }
.rb-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 99px; transition: width 1.1s var(--ease); }
.rb-cap { position: absolute; right: 0; top: 14px; font-size: 11px; color: var(--muted); }
.res-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 26px; }
.res-actions .btn { height: 46px; padding: 0 14px; }   /* 14 px: four Danish buttons ("Undersøg", "Rediger", "Se igen", "Næste bane") still fit one row */
.res-pill { position: absolute; top: calc(var(--gap) * 2 + var(--top-h) + 6px); left: 50%; transform: translate(-50%, -16px); display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 8px 0 16px; border-radius: 99px; cursor: pointer; opacity: 0; visibility: hidden; transition: opacity .25s, transform .35s var(--spring), visibility 0s .3s; font-size: 14px; font-weight: 650; color: var(--text); }
.res-pill b { color: var(--star); font-weight: 800; }
.res-pill em { font-style: normal; padding: 7px 12px; border-radius: 99px; background: rgba(255, 255, 255, .12); font-size: 13px; }
.results.inspecting .res-pill { opacity: 1; visibility: visible; transform: translate(-50%, 0); pointer-events: auto; transition: opacity .25s, transform .35s var(--spring), visibility 0s; }

/* settings modal */
.modal { position: fixed; inset: 0; z-index: 45; display: flex; align-items: center; justify-content: center; background: rgba(5, 8, 16, .55); opacity: 0; visibility: hidden; transition: opacity .3s, visibility 0s .3s; pointer-events: none; }
.modal.show { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity .3s, visibility 0s; }
.modal-card { width: min(480px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow-y: auto; padding: 18px 20px 18px; background: rgba(13, 19, 33, .88); transform: scale(.96) translateY(10px); transition: transform .4s var(--spring); border-radius: 20px; }
.modal.show .modal-card { transform: none; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.modal-head h3 { margin: 0; display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-size: 20px; font-weight: 800; }
.set-row { display: flex; align-items: center; gap: 14px; padding: 13px 4px; border-top: 1px solid rgba(255, 255, 255, .07); cursor: pointer; }
.set-row > span:first-child { flex: 1; display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14.5px; }
.set-row > span:first-child .ico { color: var(--muted); }
.set-row output { width: 44px; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
.set-row.keys { align-items: flex-start; cursor: default; }
.kb { flex: 3; display: grid; grid-template-columns: auto auto; gap: 7px 14px; font-size: 12px; color: var(--muted); }
.kb > span { white-space: nowrap; }
.set-row.keys > span:first-child { flex: 0 0 auto; }
.kb i { font-style: normal; }
/* i18n: language picker (touch-sized on every device) */
.set-row.set-lang { cursor: default; }
.lang-seg button { min-height: 44px; min-width: 88px; padding: 0 14px; font-size: 14px; }
.lang-seg button.active { color: #fff; }
.modal-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 12px; padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, .07); }
input[type=range] { -webkit-appearance: none; appearance: none; width: 160px; height: 6px; border-radius: 6px; background: rgba(255, 255, 255, .14); outline: none; cursor: pointer; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, .4), 0 0 0 4px rgba(255, 181, 71, .35); }
input[type=range]::-moz-range-thumb { width: 20px; height: 20px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, .4), 0 0 0 4px rgba(255, 181, 71, .35); }
.switch { -webkit-appearance: none; appearance: none; width: 46px; height: 26px; border-radius: 99px; background: rgba(255, 255, 255, .16); position: relative; cursor: pointer; transition: background .25s; outline: none; flex: none; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .35); transition: transform .3s var(--spring); }
.switch:checked { background: linear-gradient(90deg, #3ee08f, #2bc4a0); }
.switch:checked::after { transform: translateX(20px); }

/* level-open flash */
.fader { position: fixed; inset: 0; z-index: 35; background: #070b14; opacity: 0; pointer-events: none; }
.fader.go { animation: fader .7s var(--ease); }
@keyframes fader { 0% { opacity: .85; } 100% { opacity: 0; } }

/* ------------------------------------------------------------ Iron Road (rail campaign) */
.camp-tabs { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: rgba(0, 0, 0, .25); border: 1px solid rgba(255, 255, 255, .06); flex: none; }
.camp-tab { position: relative; display: flex; align-items: center; gap: 9px; height: 46px; padding: 0 14px 0 11px; border: 0; border-radius: 11px; background: transparent; color: var(--muted); cursor: pointer; transition: background .2s, color .2s, box-shadow .2s; text-align: left; }
.camp-tab .ico { width: 20px; height: 20px; flex: none; }
.camp-tab .ct-txt { display: flex; flex-direction: column; line-height: 1.15; }
.camp-tab .ct-txt b { font-family: var(--font-display); font-size: 15px; font-weight: 800; color: inherit; }
.camp-tab .ct-txt small { font-size: 11px; font-weight: 600; color: var(--dim); white-space: nowrap; font-variant-numeric: tabular-nums; }
.camp-tab:hover { color: var(--text); background: rgba(255, 255, 255, .05); }
.camp-tab.active { color: #fff; background: linear-gradient(170deg, rgba(255, 181, 71, .26), rgba(255, 122, 61, .14)); box-shadow: inset 0 0 0 1px rgba(255, 181, 71, .45), 0 4px 14px rgba(255, 140, 60, .18); }
.camp-tab.active .ct-txt small { color: #ffd9a0; }
.camp-tab.is-rail.active { background: linear-gradient(170deg, rgba(120, 190, 255, .26), rgba(73, 198, 242, .12)); box-shadow: inset 0 0 0 1px rgba(120, 190, 255, .5), 0 4px 14px rgba(73, 198, 242, .18); }
.camp-tab.is-rail.active .ct-txt small { color: #bfe3ff; }
.camp-tab .ct-lock { display: none; }
.camp-tab.locked .ct-lock { display: grid; place-items: center; position: absolute; top: 4px; right: 4px; width: 16px; height: 16px; border-radius: 50%; background: rgba(8, 12, 22, .75); }
.camp-tab.locked .ct-lock .ico { width: 10px; height: 10px; }
.camp-tab.locked { color: var(--dim); padding-right: 24px; }
.camp-tab.locked .ct-txt small { color: #ffb4a0; }

.chapters[hidden], .camp-panel[hidden] { display: none !important; }
.camp-locked { display: flex; align-items: center; gap: 22px; padding: 20px 24px; border-radius: 18px; border: 1px dashed rgba(120, 190, 255, .35); background: linear-gradient(120deg, rgba(40, 70, 110, .45), rgba(13, 19, 33, .6)); }
.camp-locked .cl-art .veh { width: 120px; height: 48px; }
.camp-locked h3 { margin: 0 0 6px; display: flex; align-items: center; gap: 8px; font-family: var(--font-display); font-size: 20px; font-weight: 800; }
.camp-locked h3 .ico { width: 18px; height: 18px; color: #bfe3ff; }
.camp-locked p { margin: 0; color: #c8d3e4; font-size: 14px; line-height: 1.5; max-width: 640px; }

/* rail tiles: a strip of track along the bottom edge of the art, steel-blue rim */
.tile.is-rail { border-color: rgba(150, 190, 230, .2); }
.tile.is-rail .tile-art { border-bottom: 3px solid #4a3a2c; }
.tile.is-rail .tile-art::before { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; z-index: 2; background: repeating-linear-gradient(90deg, #7a614a 0 4px, transparent 4px 9px); }
.tile.is-rail.done .tile-art::before { inset: auto 0 0 0; width: auto; height: 3px; top: auto; right: 0; border-radius: 0; box-shadow: none; background: repeating-linear-gradient(90deg, #7a614a 0 4px, transparent 4px 9px); }
.tile.is-rail.done .tile-name::after { content: ""; display: inline-block; width: 8px; height: 8px; margin-left: 6px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 2px rgba(62, 224, 143, .3); vertical-align: 1px; }
.tile-train { position: absolute; right: 8px; bottom: 6px; z-index: 1; padding: 2px 4px; border-radius: 7px; background: rgba(8, 12, 22, .55); }
.tile-train .veh { width: 34px; height: 14px; }
.ch-rail .ch-num { border-radius: 50%; }

/* train traffic chips */
.veh .vr { stroke: #8792a3; stroke-width: 1.2; }
.veh.train .vw { stroke-width: .8; }
.tr-train { gap: 4px; }
.tr-train em { font-style: normal; color: var(--text); font-weight: 700; white-space: nowrap; }
.tr-train i { font-style: normal; color: var(--muted); }
.tr-train b { color: #bfe3ff; font-weight: 600; white-space: nowrap; }
.camp-rail .lvl-k { letter-spacing: .2em; }

/* material palette: track tile gets a sleeper strip */
.mat.mat-rail::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: 4px; height: 2px; border-radius: 2px; background: repeating-linear-gradient(90deg, rgba(160, 125, 90, .7) 0 3px, transparent 3px 7px); }

/* results: finale of the Iron Road */
.results.finale-rail .res-banner { background: rgba(120, 190, 255, .16); color: #cfe9ff; border-color: rgba(120, 190, 255, .45); }
[data-act=continue].is-rail .ico { color: #bfe3ff; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1280px) {
  .mat { flex-basis: 136px; min-width: 104px; }
  .traffic { max-width: 32vw; gap: 3px; }
  .tr-item { padding: 3px 5px 3px 4px; }
  .veh { width: 26px; height: 12px; }
}
@media (max-width: 1100px) {
  .ls-title p { display: none; }
  :root { --gap: 10px; --top-h: 56px; }
  .lvl-title { flex-basis: 180px; }
  .lvl-sub { display: none; }
  .budget { min-width: 170px; }
  .test-btn { width: 148px; height: 74px; gap: 8px; }
  .tb-ico { width: 38px; height: 38px; }
  .tb-lbl b { font-size: 22px; }
  .dock { right: 166px; left: calc(var(--gap) + 80px); height: 88px; }
  .mat { height: 74px; min-width: 96px; padding: 7px 8px 8px; }
  .mat-tag { display: none; }
  .mat-info { margin-top: 20px; }
  .tool { width: 56px; height: 50px; }
  .sb-btn span { display: none; }
  .sb-btn { width: 42px; padding: 0; }
  .sb-stat span { display: none; }
  .seg button { min-width: 34px; }
}
/* Iron Road: track recording strip (sim, rail levels) */
.track-strip { position: absolute; bottom: 66px; width: min(860px, 100%); height: 84px; padding: 4px 6px; border-radius: 14px; background: rgba(13, 19, 33, .86); opacity: 0; visibility: hidden; transform: translateY(12px); transition: opacity .3s, transform .4s var(--ease), visibility 0s .3s; pointer-events: none !important; }
.track-strip.show { opacity: 1; visibility: visible; transform: none; transition: opacity .3s, transform .4s var(--ease), visibility 0s; }
.track-strip canvas { display: block; width: 100%; height: 100%; }
.mode-edit .track-strip { opacity: 0; visibility: hidden; }
body.track-on .toasts { bottom: 176px; }

/* Iron Road: derailment callout (anchored to the offending wheel) */
.derail-callout { position: absolute; left: 0; top: 0; z-index: 6; pointer-events: none; opacity: 0; visibility: hidden; transition: opacity .18s, visibility 0s .18s; will-change: transform; }
.derail-callout.show { opacity: 1; visibility: visible; transition: opacity .18s, visibility 0s; }
.dc-card { width: min(380px, calc(100vw - 32px)); padding: 11px 14px 12px; border-radius: 14px; background: rgba(34, 10, 18, .88); border: 1px solid rgba(255, 77, 94, .6); box-shadow: 0 0 0 1px rgba(255, 77, 94, .15), 0 12px 34px rgba(0, 0, 0, .45), 0 0 26px rgba(255, 60, 80, .25); }
.derail-callout.show .dc-card { animation: dcpop .45s var(--spring); }
@keyframes dcpop { 0% { transform: scale(.85) translateY(8px); opacity: 0; } 100% { transform: none; opacity: 1; } }
.dc-head { display: flex; align-items: center; gap: 8px; }
.dc-head b { font-size: 11.5px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: #ffb3bb; }
.dc-head small { margin-left: auto; font-size: 11.5px; color: var(--muted); font-weight: 650; white-space: nowrap; }
.dc-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--bad); box-shadow: 0 0 0 0 rgba(255, 77, 94, .7); animation: dcpulse 1s infinite; flex: none; }
@keyframes dcpulse { 0% { box-shadow: 0 0 0 0 rgba(255, 77, 94, .7); } 100% { box-shadow: 0 0 0 9px rgba(255, 77, 94, 0); } }
.dc-cause { margin: 6px 0 4px; font-size: 16px; font-weight: 750; line-height: 1.3; color: #fff; font-variant-numeric: tabular-nums; }
.dc-advice { margin: 0; font-size: 12.5px; line-height: 1.42; color: #d5dceb; }
.dc-stem { position: absolute; top: 100%; width: 2px; margin-left: -1px; background: linear-gradient(rgba(255, 77, 94, .9), rgba(255, 77, 94, .25)); }
.derail-callout.below .dc-stem { top: auto; bottom: 100%; background: linear-gradient(rgba(255, 77, 94, .25), rgba(255, 77, 94, .9)); }

/* Iron Road: results verdicts + ride-quality card */
.res-rail { margin: 0 0 12px; text-align: left; }
.rv-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rv { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 12px; background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .07); min-width: 0; }
.rv.ok { border-color: rgba(62, 224, 143, .3); background: rgba(62, 224, 143, .07); }
.rv.no { border-color: rgba(255, 77, 94, .38); background: rgba(255, 77, 94, .08); }
.rv-ico { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-weight: 900; font-size: 14px; }
.rv.ok .rv-ico { background: rgba(62, 224, 143, .2); color: #8af2c0; }
.rv.no .rv-ico { background: rgba(255, 77, 94, .22); color: #ff8b97; }
.rv span { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.rv b { font-size: 13.5px; font-weight: 750; }
.rv small { font-size: 11.5px; line-height: 1.3; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ride-card { margin-top: 8px; padding: 8px 10px 10px; border-radius: 12px; background: rgba(73, 198, 242, .06); border: 1px solid rgba(73, 198, 242, .18); }
.rc-head { font-size: 10.5px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: #9fdcf5; margin-bottom: 6px; }
.rc-tiles { display: grid; grid-template-columns: repeat(3, 1fr) .8fr; gap: 6px; }
.rc-t { display: flex; flex-direction: column; gap: 1px; padding: 6px 8px; border-radius: 10px; background: rgba(0, 0, 0, .16); min-width: 0; }
.rc-t span { font-size: 9.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rc-t b { font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; }
.rc-t small { font-size: 10.5px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rc-t b.good { color: #8af2c0; } .rc-t b.warn { color: #ffd38a; } .rc-t b.bad { color: #ff8b97; }
.rc-grade { align-items: center; text-align: center; }
.rc-grade b { font-family: var(--font-display); font-size: 24px; font-weight: 900; line-height: 1.05; }
.results.is-rail .res-stars { height: 62px; margin: 10px 0 2px; }
.results.is-rail .res-stars .star { width: 48px; height: 48px; } .results.is-rail .res-stars .star.mid { width: 60px; height: 60px; }
.results.is-rail .res-reason { margin-bottom: 12px; }
/* rail: the verdict row already counts broken members - one compact row of five stats */
.results.is-rail .res-stats { grid-template-columns: repeat(5, 1fr); gap: 6px; }
.results.is-rail .res-stats .rs:nth-child(6) { display: none; }
.results.is-rail .rs { padding: 7px 4px; }
.results.is-rail .rs span { font-size: 9.5px; letter-spacing: .06em; white-space: nowrap; }
@media (max-height: 760px) { .results.is-rail .res-stars { height: 46px; margin: 6px 0 0; } .results.is-rail .res-stars .star { width: 36px; height: 36px; } .results.is-rail .res-stars .star.mid { width: 46px; height: 46px; } .results.is-rail .results-card h2 { font-size: 24px; } }
@media (max-width: 620px) {
  .rv-row { grid-template-columns: 1fr; }
  .results.is-rail .res-stats { grid-template-columns: repeat(3, 1fr); }
  .rc-tiles { grid-template-columns: 1fr 1fr; }
  .track-strip { height: 76px; }
}

@media (max-height: 760px) {
  .tool { height: 44px; }
  .tool span { display: none; }
  .rail { gap: 2px; }
  .hint { width: min(520px, calc(100% - 200px)); }
  .title-buttons { margin-top: 26px; }
  .logo { font-size: clamp(80px, 13vw, 170px); }
  .res-stars { height: 60px; margin-top: 10px; }
  .res-stars .star { width: 46px; height: 46px; } .res-stars .star.mid { width: 58px; height: 58px; }
  .results-card { padding: 18px 20px 16px; }
  .res-actions { margin-top: 18px; }
}
@media (max-width: 860px) {
  .traffic { display: none; }
  .ls-title { display: none; }
  .camp-tab .ct-txt small { display: none; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .ch-text p { white-space: normal; }
}
@media (pointer: coarse) {
  .tool { width: 60px; height: 52px; }
  .mat { height: 80px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; transition-duration: .01ms !important; }
}
