/* Automatik-Werkstatt – alle Styles */
    *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

    :root {
      --red:      #cc0000;
      --red-hi:   #ff1a1a;
      --red-dim:  #660000;
      --bg:       #000;
      --bg1:      #0a0a0a;
      --bg2:      #111;
      --bg3:      #1a1a1a;
      --border:   #222;
      --border2:  #2e2e2e;
      --text:     #e0e0e0;
      --text2:    #aaa;
      --text3:    #666;
      --green:    #44cc44;
      --blue:     #4488ff;
      --yellow:   #ffaa00;
      --purple:   #ff4d88;   /* Kaputt/Reklamation: Pink statt Lila — Lila war Blau zu ähnlich (#21) */

      --site-bg: #0d1214;
      --site-card: #151b1e;
      --site-card-strong: #1b2228;
      --site-accent: #ff3300;
      --site-text: #e8edf2;
      --site-muted: #95a0aa;
      --site-border: #1f262c;
      --site-shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
      --site-radius: 14px;
    }

    html { scroll-behavior: smooth; }

    body {
      margin: 0;
      background: var(--site-bg);
      color: var(--site-text);
      font-family: "Nunito", "Segoe UI", Arial, sans-serif;
      font-size: 16px;
      line-height: 1.6;
      min-height: 100vh;
      display: flex;
      flex-direction: column;
    }

    a { color: var(--site-accent); text-decoration: none; }

    /* ─── Site Header ───────────────────────────────────────────── */
    .site-header {
      position: sticky;
      top: 0;
      z-index: 50;
      background: rgba(13, 18, 20, 0.94);
      backdrop-filter: blur(8px);
      border-bottom: 1px solid var(--site-border);
      flex-shrink: 0;
    }
    /* backdrop-filter is one of the priciest mobile-GPU effects and it's recomputed on
       every scroll frame while the header is visible — skip it on touch devices, where
       there's no hover-driven reason to see through it anyway. */
    @media (hover: none) and (pointer: coarse) {
      .site-header {
        backdrop-filter: none;
        background: rgba(13, 18, 20, 0.98);
      }
    }
    .site-shell {
      max-width: 1200px;
      margin: 0 auto;
      width: 100%;
    }
    .nav-bar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 24px;
      padding: 14px 18px;
      min-height: 70px;
    }
    .brand { display: flex; align-items: center; }
    .brand img {
      height: 40px;
      width: auto;
      display: block;
    }
    .site-nav {
      display: flex;
      align-items: center;
      gap: 18px;
    }
    .site-nav a,
    .nav-dropdown-toggle {
      color: var(--site-text);
      font-weight: 600;
      font-size: 0.95rem;
      padding: 8px 12px;
      border-radius: 30px;
      font-family: inherit;
      transition: color 0.2s ease, background 0.2s ease;
    }
    .site-nav a:hover,
    .site-nav a.active,
    .nav-dropdown-toggle:hover {
      color: #fff;
      background: rgba(255, 51, 0, 0.14);
    }
    .nav-dropdown {
      position: relative;
    }
    .nav-dropdown-toggle {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      background: none;
      border: none;
      cursor: pointer;
    }
    .nav-caret {
      font-size: 0.7rem;
      transition: transform 0.2s ease;
    }
    .nav-dropdown:hover .nav-caret,
    .nav-dropdown:focus-within .nav-caret,
    .nav-dropdown.open .nav-caret {
      transform: rotate(180deg);
    }
    .dropdown-menu {
      position: absolute;
      top: 100%;
      left: 0;
      min-width: 220px;
      padding: 10px 6px 6px;
      display: none;
      flex-direction: column;
      gap: 2px;
      z-index: 200;
    }
    .dropdown-menu::before {
      content: '';
      position: absolute;
      inset: 10px 0 0;
      background: rgba(13, 18, 20, 0.98);
      border: 1px solid var(--site-border);
      border-radius: 12px;
      box-shadow: var(--site-shadow);
      z-index: -1;
    }
    .nav-dropdown:hover .dropdown-menu,
    .nav-dropdown:focus-within .dropdown-menu,
    .nav-dropdown.open .dropdown-menu {
      display: flex;
    }
    .dropdown-menu a {
      display: block;
      font-size: 0.9rem;
      padding: 8px 12px;
      border-radius: 8px;
    }
    .dropdown-divider {
      height: 1px;
      background: var(--site-border);
      margin: 4px 0;
    }
    .site-nav a.lang-switch {
      border: 1px solid var(--site-border);
      background: rgba(255, 255, 255, 0.04);
      padding: 6px 10px;
      font-size: 0.85rem;
      line-height: 1;
      display: inline-flex;
      align-items: center;
      gap: 6px;
    }
    .site-nav a.lang-switch:hover {
      background: rgba(255, 255, 255, 0.08);
    }
    .lang-toggle {
      color: var(--site-text);
      font-weight: 600;
      font-size: 0.85rem;
      padding: 6px 10px;
      border-radius: 30px;
      font-family: inherit;
      border: 1px solid var(--site-border);
      background: rgba(255, 255, 255, 0.04);
      cursor: pointer;
      transition: color 0.2s ease, background 0.2s ease;
      line-height: 1;
    }
    .lang-toggle:hover {
      background: rgba(255, 255, 255, 0.08);
      color: #fff;
    }
    .flag-icon {
      width: 1.1em;
      height: auto;
      display: inline-block;
      flex-shrink: 0;
      border-radius: 2px;
      box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12);
    }

    /* ─── Page Layout ───────────────────────────────────────────── */
    .page-content {
      width: 100%;
      flex: 1;
      overflow: hidden;
    }
    .game-hero {
      padding: 140px 18px 64px;
      background:
        linear-gradient(120deg, rgba(12, 16, 20, 0.9), rgba(12, 16, 20, 0.5)),
        url("https://edvsupport-nbg.de/img/pREq0ns_p_E.jpg") center/cover no-repeat;
      border-bottom: 1px solid var(--site-border);
    }
    .page-intro {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
      gap: 24px;
      align-items: center;
      margin-top: 40px;   /* Blöcke stehen jetzt UNTER dem Spiel */
    }
    .page-intro-text {
      background: rgba(21, 27, 30, 0.88);
      border: 1px solid var(--site-border);
      border-radius: var(--site-radius);
      box-shadow: var(--site-shadow);
      padding: 32px;
    }
    .eyebrow {
      text-transform: uppercase;
      letter-spacing: 2px;
      font-size: 0.85rem;
      color: var(--site-accent);
      font-weight: 800;
      margin-bottom: 10px;
    }
    .pill {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      background: rgba(255, 51, 0, 0.1);
      color: var(--site-accent);
      padding: 8px 14px;
      border-radius: 999px;
      font-weight: 700;
      margin-bottom: 14px;
    }
    .page-intro-text h1 {
      font-family: "Lexend Deca", "Nunito", sans-serif;
      font-size: clamp(2.1rem, 4vw, 2.6rem);
      font-weight: 700;
      line-height: 1.15;
      color: #fff;
      margin-bottom: 14px;
    }
    .page-intro-text p {
      color: var(--site-muted);
      font-size: 1.08rem;
      max-width: 680px;
    }
    .divider {
      height: 2px;
      width: 120px;
      background: linear-gradient(90deg, transparent, var(--site-accent), transparent);
      margin: 18px 0;
    }
    .intro-copy { display: grid; gap: 12px; }
    .intro-copy p { margin: 0; }
    .time-note {
      display: inline-flex; align-items: center; gap: 10px;
      width: fit-content; max-width: 100%; margin-top: 6px;
      padding: 10px 14px; border: 1px solid var(--site-border);
      border-radius: 10px; background: rgba(255,255,255,0.03);
      color: var(--site-text); font-weight: 700;
    }
    .time-note i { color: var(--site-accent); flex: 0 0 auto; }
    .intro-actions {
      display: flex;
      gap: 12px;
      flex-wrap: wrap;
      margin-top: 22px;
    }
    .site-btn {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 10px;
      padding: 12px 18px;
      font-weight: 800;
      text-transform: uppercase;
      border-radius: 10px;
      border: 1px solid transparent;
      transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
    }
    .site-btn-primary {
      background: var(--site-accent);
      color: #0b0e11;
      box-shadow: 0 10px 30px rgba(255, 51, 0, 0.35);
    }
    .site-btn-primary:hover { transform: translateY(-2px); }
    .site-btn-ghost {
      color: var(--site-text);
      border-color: var(--site-border);
      background: rgba(255, 255, 255, 0.02);
    }
    .intro-card {
      background: rgba(21, 27, 30, 0.88);
      border: 1px solid var(--site-border);
      border-radius: var(--site-radius);
      padding: 26px;
      box-shadow: var(--site-shadow);
      display: grid;
      gap: 10px;
      align-content: start;
    }
    .intro-card h2 {
      font-family: "Lexend Deca", "Nunito", sans-serif;
      font-size: 1.15rem;
      color: #fff;
      margin: 0;
    }
    .intro-card p { color: var(--site-muted); margin: 0; }
    .badge-list {
      display: grid;
      gap: 10px;
      margin: 14px 0 0 0;
      padding: 0;
    }
    .badge-list li {
      list-style: none;
      padding: 12px 14px;
      background: rgba(255, 255, 255, 0.02);
      border-radius: 10px;
      border: 1px solid var(--site-border);
      display: flex;
      gap: 12px;
      align-items: flex-start;
      color: var(--site-text);
    }
    .li-icon {
      width: 22px;
      height: 22px;
      display: grid;
      place-items: center;
      border-radius: 8px;
      background: rgba(255, 51, 0, 0.12);
      color: var(--site-accent);
      flex: 0 0 22px;
      margin-top: 2px;
    }
    .li-icon i { font-size: 0.95rem; }
    .level-panel {
      border-top: 1px solid var(--site-border);
      padding-top: 14px;
      display: grid;
      gap: 8px;
    }
    .level-indicators { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
    .lvl-dot {
      width: 10px; height: 10px; border-radius: 50%;
      background: var(--border2); transition: background 0.3s;
    }
    .lvl-dot.done { background: var(--green); }
    .lvl-dot.current { background: var(--red); }
    .lvl-label { font-size: 0.7rem; color: var(--text3); text-transform: uppercase; letter-spacing: 1px; }
    .site-note {
      margin-top: 24px;
      color: var(--site-muted);
      font-size: 0.95rem;
      text-align: center;
    }
    .game-section-label {
      color: var(--site-accent);
      font-weight: 800;
      letter-spacing: 2px;
      text-transform: uppercase;
      text-align: center;
      margin: 6px 0 18px;
    }
    .mobile-rotate-notice {
      display: none;
      min-height: calc(100svh - 110px);
      place-items: center;
      padding: 22px;
    }
    /* Spiegelfall: Hochformat-Modus gewählt, Gerät quer — eigene Klasse, damit
       die Portrait-Regel (.mobile-rotate-notice { display:grid }) sie nicht
       fälschlich im Hochkant-Fall einblendet. Sichtbar nur im Quer-Media-Block. */
    .rotate-notice-quer {
      display: none;
      place-items: center;
      padding: 22px;
    }
    .rotate-card {
      width: min(100%, 420px);
      background: rgba(21, 27, 30, 0.94);
      border: 1px solid var(--site-border);
      border-radius: var(--site-radius);
      box-shadow: var(--site-shadow);
      padding: 24px;
      text-align: center;
    }
    .rotate-icon {
      width: 58px;
      height: 58px;
      margin: 0 auto 14px;
      display: grid;
      place-items: center;
      border-radius: 16px;
      background: rgba(255, 51, 0, 0.12);
      color: var(--site-accent);
      font-size: 1.6rem;
    }
    .rotate-card h2 {
      font-family: "Lexend Deca", "Nunito", sans-serif;
      color: #fff;
      font-size: 1.35rem;
      line-height: 1.2;
      margin: 0 0 10px;
    }
    .rotate-card p {
      color: var(--site-muted);
      margin: 0;
    }
    /* the whole card is a tap target: fullscreen + (Android) auto-rotate */
    .rotate-card { cursor: pointer; -webkit-tap-highlight-color: transparent; transition: transform 0.12s ease; }
    .rotate-card:active { transform: scale(0.97); }
    .rotate-tap {
      display: inline-flex; align-items: center; gap: 10px;
      margin-top: 18px; padding: 12px 22px;
      background: var(--site-accent); color: #0b0e11;
      border-radius: 10px; font-weight: 800; text-transform: uppercase;
      font-size: 0.9rem; letter-spacing: 1px;
      box-shadow: 0 10px 30px rgba(255, 51, 0, 0.35);
    }
    .game-viewport {
      --game-scale: 1;
      display: flex;
      justify-content: center;
      width: 100%;
    }

    /* ─── Game Box ──────────────────────────────────────────────── */
    .game-box {
      border: 1px solid var(--border);
      border-top: 3px solid var(--red);
      background: var(--bg1);
      width: 100%;
      min-height: 620px;
      position: relative;
      overflow: hidden;
      font-family: 'Segoe UI', -apple-system, Arial, sans-serif;
    }

    /* ─── Screens ───────────────────────────────────────────────── */
    .screen {
      display: none; flex-direction: column;
      align-items: center; justify-content: center;
      min-height: 620px; padding: 48px 40px;
      text-align: center; animation: fadeIn 0.25s ease;
    }
    .screen.active { display: flex; }
    @keyframes fadeIn {
      from { opacity: 0; transform: translateY(6px); }
      to   { opacity: 1; transform: translateY(0); }
    }
    .badge {
      display: inline-block; background: var(--red); color: #fff;
      font-size: 0.65rem; font-weight: 700; letter-spacing: 3px;
      text-transform: uppercase; padding: 4px 14px; margin-bottom: 20px;
    }
    .screen h2 {
      font-size: 2.2rem; font-weight: 900; letter-spacing: 3px;
      text-transform: uppercase; color: var(--red);
      margin-bottom: 12px; line-height: 1.1;
    }
    .screen h3 { font-size: 1.2rem; font-weight: 700; color: var(--text); margin-bottom: 10px; }
    .screen p { color: var(--text2); max-width: 560px; margin-bottom: 10px; line-height: 1.7; }
    .info-box {
      background: var(--bg2); border-left: 3px solid var(--red);
      padding: 14px 20px; margin: 16px 0; text-align: left;
      max-width: 560px; width: 100%;
    }
    .info-box p { color: var(--text2); font-size: 0.88rem; margin: 0; }
    .hint-text { font-size: 0.82rem; color: var(--text3); margin-top: 4px; }

    /* ─── Buttons ───────────────────────────────────────────────── */
    .btn {
      display: inline-flex; align-items: center; gap: 8px;
      padding: 12px 28px; font-size: 0.85rem; font-weight: 700;
      letter-spacing: 2px; text-transform: uppercase; border: none;
      cursor: pointer; transition: all 0.15s; font-family: inherit;
    }
    .btn-primary { background: var(--red); color: #fff; }
    .btn-primary:hover { background: var(--red-hi); }
    .btn-outline { background: transparent; color: var(--red); border: 2px solid var(--red); }
    .btn-outline:hover { background: var(--red); color: #fff; }
    .btn-sm { padding: 8px 18px; font-size: 0.75rem; }
    .mt20 { margin-top: 20px; }
    .mt28 { margin-top: 28px; }
    .flex-gap { display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap; }

    /* ─── HAND SORT SCREEN ──────────────────────────────────────── */
    #screen-hand-sort {
      padding: 22px 26px;
      align-items: stretch;
      justify-content: flex-start;
      text-align: left;
      background:
        radial-gradient(circle at 24% 36%, rgba(255, 51, 0, 0.13), transparent 34%),
        radial-gradient(circle at 82% 18%, rgba(68, 136, 255, 0.09), transparent 32%),
        linear-gradient(180deg, #0b0f12 0%, #07090b 100%);
    }
    .hs-header {
      display: flex; align-items: center; gap: 14px;
      border: 1px solid rgba(255,255,255,0.08);
      border-radius: 16px;
      padding: 10px 14px; margin-bottom: 16px;
      background: rgba(15, 20, 24, 0.88);
      box-shadow: 0 10px 26px rgba(0,0,0,0.28);
    }
    .hs-header .title { font-size: 1.4rem; font-weight: 900; letter-spacing: 2px; text-transform: uppercase; color: var(--text); }
    .hs-header .counter { margin-left: auto; font-size: 1.4rem; color: var(--text2); font-weight: 800; }
    .hs-stage {
      display: grid;
      grid-template-columns: minmax(320px, 440px) 1fr;
      gap: 18px;
      flex: 1;
      min-height: 400px;
    }
    .hs-workbench {
      position: relative;
      min-height: 400px;
      display: grid;
      place-items: center;
      overflow: hidden;
      border-radius: 24px;
      border: 1px solid rgba(255,255,255,0.08);
      background:
        linear-gradient(90deg, rgba(58,209,122,0.055) 0 1px, transparent 1px),
        linear-gradient(0deg, rgba(255,255,255,0.045) 0 1px, transparent 1px),
        radial-gradient(circle at 50% 8%, rgba(255,255,255,0.07), transparent 36%),
        rgba(10, 13, 16, 0.86);
      background-size: 34px 34px, 34px 34px, auto, auto;
      box-shadow: inset 0 0 0 1px rgba(0,0,0,0.45), 0 16px 34px rgba(0,0,0,0.32);
      padding: 18px;
    }
    .hs-conveyor-rail {
      position: absolute;
      left: -12%; right: -12%; top: 50%; height: 68px;
      transform: translateY(-50%);
      border-radius: 999px;
      background:
        repeating-linear-gradient(90deg, rgba(255,255,255,0.18) 0 7px, transparent 7px 22px),
        linear-gradient(180deg, #26312d, #121815);
      box-shadow: inset 0 0 0 2px rgba(58,209,122,0.22), inset 0 12px 18px rgba(255,255,255,0.04), inset 0 -12px 18px rgba(0,0,0,0.38);
      opacity: 0.95;
    }
    .hs-conveyor-rail::before,
    .hs-conveyor-rail::after {
      content: ''; position: absolute; top: 50%; width: 18px; height: 18px;
      border-radius: 50%; transform: translateY(-50%);
      background: #0b0e10; border: 2px solid rgba(255,255,255,0.12);
      box-shadow: 0 0 0 7px rgba(0,0,0,0.18);
    }
    .hs-conveyor-rail::before { left: 28px; }
    .hs-conveyor-rail::after  { right: 28px; }
    .hs-source {
      position: relative; z-index: 2;
      width: min(100%, 390px);
      background:
        linear-gradient(180deg, rgba(255,255,255,0.075), rgba(255,255,255,0.025)),
        #10161a;
      border: 2px solid rgba(255,255,255,0.11);
      border-top-color: rgba(255,51,0,0.55);
      border-radius: 24px;
      display: flex; flex-direction: column; align-items: center;
      justify-content: center; gap: 12px; padding: 18px;
      box-shadow: 0 18px 42px rgba(0,0,0,0.52), inset 0 0 0 1px rgba(0,0,0,0.55);
    }
    .hs-source::before {
      content: ''; position: absolute; left: 18px; right: 18px; top: 10px; height: 3px;
      border-radius: 99px; background: linear-gradient(90deg, transparent, var(--red-hi), transparent);
      opacity: 0.65;
    }
    .hs-source .src-label { font-size: 1.35rem; color: var(--text2); text-transform: uppercase; letter-spacing: 2.2px; font-weight: 900; }
    .hs-scan-window {
      position: relative;
      width: 100%; min-height: 210px;
      display: grid; place-items: center;
      border-radius: 20px;
      background: radial-gradient(circle at 50% 45%, rgba(255,255,255,0.11), rgba(0,0,0,0.22) 62%), #080b0d;
      border: 1px solid rgba(255,255,255,0.08);
      overflow: hidden;
    }
    .hs-scan-window::before {
      content: 'SCAN'; position: absolute; top: 9px; left: 11px;
      font-size: 0.56rem; letter-spacing: 2px; font-weight: 900; color: rgba(255,255,255,0.24);
    }
    .hs-scanner-head {
      position: absolute; top: 0; left: 50%; transform: translateX(-50%);
      width: 96px; height: 24px; border-radius: 0 0 12px 12px;
      background: linear-gradient(180deg, #313840, #151a1f);
      box-shadow: inset 0 -1px 0 rgba(255,255,255,0.1), 0 6px 16px rgba(0,0,0,0.45);
      z-index: 2;
    }
    .hs-scanner-head span {
      position: absolute; left: 50%; bottom: 4px; transform: translateX(-50%);
      width: 48px; height: 4px; border-radius: 8px;
      background: var(--red-hi); box-shadow: 0 0 12px rgba(255,26,26,0.75);
    }
    .hs-scan-line {
      position: absolute; left: 12%; right: 12%; height: 2px; top: 36%;
      background: linear-gradient(90deg, transparent, rgba(255,26,26,0.95), transparent);
      box-shadow: 0 0 18px rgba(255,26,26,0.8);
      animation: hsScanLine 1.5s ease-in-out infinite;
      pointer-events: none;
    }
    @keyframes hsScanLine { 0%,100% { transform: translateY(-34px); opacity: 0.35; } 50% { transform: translateY(48px); opacity: 1; } }
    /* The scan line runs for the whole hand-sort phase. steps() caps it at ~10
       compositor updates/s instead of 60 — same look from arm's length, a
       fraction of the GPU wakeups (#6). */
    @media (hover: none) and (pointer: coarse) {
      .hs-scan-line { animation: hsScanLine 2.6s steps(26) infinite; }
    }
    .hs-package-data {
      width: 100%;
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 7px;
    }
    .hs-data-chip {
      min-width: 0;
      border: 1px solid rgba(255,255,255,0.08);
      border-radius: 10px;
      padding: 5px 6px;
      background: rgba(255,255,255,0.035);
      text-align: center;
      box-shadow: inset 0 0 0 1px rgba(0,0,0,0.18);
    }
    .hs-data-chip span { display: block; font-size: 0.9rem; color: var(--text3); text-transform: uppercase; letter-spacing: 1px; font-weight: 900; white-space: nowrap; }
    .hs-data-chip strong { display: block; margin-top: 1px; color: #fff; font-size: 1.31rem; line-height: 1.05; overflow: hidden; text-overflow: ellipsis; }
    .hs-data-color strong { color: var(--chip, #fff); text-shadow: 0 0 8px color-mix(in srgb, var(--chip, #fff) 40%, transparent); }
    .hs-data-express strong { color: var(--yellow); }
    .hs-data-damaged strong { color: var(--purple); }
    .hs-target-panel {
      min-width: 0;
      display: flex;
      flex-direction: column;
      gap: 12px;
    }
    .hs-route-question {
      display: flex; align-items: center; gap: 10px;
      min-height: 42px;
      padding: 0 14px;
      border-radius: 14px;
      border: 1px solid rgba(255,255,255,0.08);
      background: rgba(255,255,255,0.035);
      color: #fff;
      font-size: 1.54rem;
      font-weight: 900;
      letter-spacing: 1.2px;
      text-transform: uppercase;
    }
    .hs-route-question::before { content: '↳'; color: var(--text2); font-size: 2.5rem; line-height: 1; }
    .hs-targets {
      flex: 1;
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
      gap: 12px;
      align-content: stretch;
    }
    .sort-target {
      --mc: #888;
      position: relative;
      min-height: 104px;
      width: 100%;
      background:
        radial-gradient(circle at 20% 20%, color-mix(in srgb, var(--mc) 22%, transparent), transparent 46%),
        linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.018));
      border: 2px solid rgba(255,255,255,0.08);
      border-left: 5px solid var(--mc);
      border-radius: 20px;
      color: var(--mc);
      display: flex; align-items: center; justify-content: flex-start;
      gap: 12px;
      padding: 13px 34px 13px 78px;
      cursor: pointer; transition: transform 0.12s, background 0.15s, border-color 0.15s, box-shadow 0.15s;
      text-align: left;
      font-family: inherit;
      overflow: hidden;
    }
    .sort-target::before {
      content: '';
      position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
      width: 50px; height: 50px; border-radius: 15px;
      background: linear-gradient(180deg, color-mix(in srgb, var(--mc) 18%, #242a2f), #0d1114);
      box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--mc) 42%, transparent), 0 0 20px color-mix(in srgb, var(--mc) 24%, transparent);
    }
    .sort-target::after {
      content: '›'; position: absolute; right: 13px; top: 50%; transform: translateY(-53%);
      color: rgba(255,255,255,0.38); font-size: 2rem; font-weight: 900;
    }
    .sort-target:hover, .sort-target.drag-over {
      transform: translateY(-2px);
      border-color: color-mix(in srgb, var(--mc) 70%, #fff);
      box-shadow: 0 14px 30px rgba(0,0,0,0.32), 0 0 22px color-mix(in srgb, var(--mc) 18%, transparent);
      background:
        radial-gradient(circle at 20% 20%, color-mix(in srgb, var(--mc) 32%, transparent), transparent 48%),
        linear-gradient(180deg, rgba(255,255,255,0.09), rgba(255,255,255,0.028));
    }
    .sort-target:active { transform: translateY(0) scale(0.985); }
    /* Endpoint-style icon on the sort targets: the glow in the target colour IS
       the label (matches the tinted packages). The markup puts the ⚡ before the
       📦, row-reverse flips it so the bolt sits to the RIGHT of the package. */
    .sort-target .st-icon {
      position: absolute; left: 22px; top: 50%; transform: translateY(-50%);
      width: 34px; height: 44px;
      font-size: 2.05rem; line-height: 1;
      display: flex; flex-direction: row-reverse; align-items: center; justify-content: center;
      gap: 3px; pointer-events: none;
      filter: drop-shadow(0 0 12px var(--mc)) drop-shadow(0 0 4px var(--mc));
    }
    /* Stacked drop-shadows rasterize the glyph twice on every repaint — one
       pass is plenty on a phone screen (#6). */
    @media (hover: none) and (pointer: coarse) {
      .sort-target .st-icon { filter: drop-shadow(0 0 8px var(--mc)); }
    }
    .sort-target .st-icon .cn-ei-bolt { font-size: 0.5em; line-height: 1; }
    .sort-target .st-text { display: flex; flex-direction: column; gap: 5px; min-width: 0; pointer-events: none; }
    .sort-target .st-kicker { color: var(--text3); font-size: 1.01rem; letter-spacing: 1.4px; text-transform: uppercase; font-weight: 900; }
    .sort-target .st-name { color: #fff; font-size: 1.91rem; line-height: 1.05; font-weight: 900; overflow-wrap: anywhere; }
    .sort-target .st-rule {
      display: inline-flex; width: fit-content; max-width: 100%;
      border-radius: 999px; padding: 4px 8px;
      background: color-mix(in srgb, var(--mc) 14%, rgba(255,255,255,0.045));
      color: color-mix(in srgb, var(--mc) 78%, #fff);
      font-size: 1.16rem; line-height: 1.25; font-weight: 900;
      white-space: normal; overflow-wrap: anywhere;
    }

    /* ─── Package Visual ────────────────────────────────────────── */
    .pkg {
      width: 108px; height: 108px; border: 2px solid;
      display: flex; flex-direction: column;
      align-items: center; justify-content: center;
      gap: 4px; cursor: grab; user-select: none;
      position: relative; transition: transform 0.1s;
    }
    .pkg:active { cursor: grabbing; transform: scale(1.04); }
    .pkg.is-dragging { opacity: 0.45; }
    /* Identitätsfarben rot/grün: farbfehlsichtigkeits-freundlich — Grün als
       Türkis (abseits der Rot-Grün-Verwechslungsachse), Rot leicht orangewärts. */
    .pkg[data-farbe="rot"]   { background: #1d0600; border-color: #993017; color: #ff6f4d; }
    .pkg[data-farbe="blau"]  { background: #00001c; border-color: #224499; color: #6699ff; }
    .pkg[data-farbe="gruen"] { background: #001c15; border-color: #14664f; color: #4dd9b3; }
    .pkg-icon  { font-size: 2.5rem; line-height: 1; }
    .pkg-name  { font-size: 1.16rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; }
    .pkg-tag {
      position: absolute; top: -7px; right: -7px;
      font-size: 1.04rem; font-weight: 900; letter-spacing: 1px; padding: 2px 5px;
    }
    .pkg-tag.eil    { background: var(--yellow); color: #000; }
    .pkg-tag.kaputt { background: var(--purple); color: #000; }

    /* ─── Package fly animation (hand sort) ─────────────────────── */
    .pkg-fly {
      position: fixed; pointer-events: none; z-index: 200; margin: 0;
      transition: transform 0.38s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.18s 0.26s;
    }
    .sort-target { transition: background 0.15s, border-color 0.15s, box-shadow 0.15s; }
    .sort-target.flash-ok {
      background: color-mix(in srgb, var(--mc) 22%, transparent) !important;
      border-color: var(--mc) !important; border-style: solid !important;
      box-shadow: 0 0 18px color-mix(in srgb, var(--mc) 35%, transparent);
    }
    .sort-target.flash-fail {
      background: rgba(255, 60, 60, 0.18) !important;
      border-color: #ff5555 !important; border-style: solid !important;
      box-shadow: 0 0 18px rgba(255,60,60,0.3);
    }
    .sort-target.flash-hint {
      background: color-mix(in srgb, var(--mc) 10%, transparent) !important;
      border-color: var(--mc) !important; border-style: dashed !important;
    }

    /* ─── BUILD CHAIN SCREEN (canvas) ──────────────────────────── */
    #screen-build-chain {
      padding: 0;
      flex-direction: column;
      align-items: stretch;
      justify-content: flex-start;
      text-align: left;
      min-height: 620px;
      position: relative;
    }
    .dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
    .cn-bar {
      display: flex; align-items: center; justify-content: flex-start;
      padding: 9px 16px; border-bottom: 1px solid var(--border);
      flex-shrink: 0; background: var(--bg2); gap: 10px;
    }
    .cn-bar-title {
      font-size: 0.65rem; font-weight: 700;
      letter-spacing: 3px; text-transform: uppercase; color: var(--red);
    }
    .cn-bar-tools {
      display: flex; align-items: center; gap: 8px;
      margin-left: auto; flex-shrink: 0;
    }
    .cn-icon-btn {
      width: 38px; height: 38px; padding: 0;
      border-radius: 12px;
      background: rgba(20,24,28,0.82); border: 1px solid var(--border2); color: var(--text2);
      font-size: 1.08rem; font-weight: 900; line-height: 1;
      cursor: pointer; display: flex; align-items: center; justify-content: center;
      box-shadow: 0 2px 8px rgba(0,0,0,0.45);
      font-family: inherit;
    }
    .cn-icon-btn:hover { color: #fff; border-color: var(--text2); background: rgba(32,38,44,0.95); }
    .cn-icon-btn:active { transform: scale(0.96); }
    .cn-help-btn { font-size: 1.1rem; }
    /* Format-Umschalter (#19): Handy-Symbol statt Kreispfeilen (die dem Reset ↺
       zu ähnlich sahen). Das Icon zeigt das Format, ZU dem gewechselt wird —
       aufrecht solange quer gespielt wird, quer gedreht im Hochformat. */
    .orient-ico { transition: transform 0.2s ease; }
    body.orient-hoch .orient-ico { transform: rotate(90deg); }
    /* Theme-Umschalter (#19): farbige Sonne im Darkmode (→ Lightmode) bzw.
       farbiger Halbmond im Lightmode (→ Darkmode). Die kräftige Färbung hebt
       das Icon von den grauen Werkzeug-Buttons ab, damit die Sonne nicht als
       Einstellungs-Zahnrad gelesen wird. */
    .theme-ico-sun  { color: #ffcc33; filter: drop-shadow(0 0 5px rgba(255,204,51,0.55)); }
    .theme-ico-moon { color: #5b7cff; filter: drop-shadow(0 0 5px rgba(91,124,255,0.45)); }
    .cn-theme-btn:hover .theme-ico-sun  { color: #ffdd66; }
    .cn-theme-btn:hover .theme-ico-moon { color: #7d99ff; }
    .cn-bar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
    .cn-status { font-size: 0.74rem; color: var(--text2); }
    .cn-clear-ico { display: none; }   /* icon-only NEU appears on mobile landscape */
    /* Status toast over the field (mobile: replaces the bar's status text). */
    .cn-toast {
      position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%);
      z-index: 60; padding: 6px 14px; border-radius: 8px; max-width: 80%;
      background: rgba(15,19,22,0.92); border: 1px solid var(--border2);
      font-size: 0.72rem; text-align: center; pointer-events: none;
      opacity: 0; transition: opacity 0.25s ease;
    }
    .cn-toast.show { opacity: 1; }
    .cn-layout { display: flex; flex: 1; min-height: 0; overflow: hidden; }
    /* Toolbar */
    .cn-toolbar {
      width: 158px; flex-shrink: 0; background: var(--bg2);
      border-right: 1px solid var(--border);
      padding: 12px 10px; display: flex;
      flex-direction: column; gap: 6px;
      overflow: visible;            /* let the pointer arrows spill onto the field */
      position: relative; z-index: 40;  /* … and paint above the canvas nodes */
      transition: width 0.2s ease, padding 0.2s ease;
    }
    /* Collapsed → grid reclaims the full width; toggle lives in the top bar. */
    .cn-toolbar.cn-collapsed { width: 0; padding-left: 0; padding-right: 0; border-right: 0; overflow: hidden; }
    .cn-tb-toggle {
      background: none; border: 1px solid var(--border2); color: var(--text2);
      border-radius: 6px; width: 28px; height: 22px; font-size: 0.82rem; line-height: 1;
      cursor: pointer; padding: 0; flex-shrink: 0;
    }
    .cn-tb-toggle:hover { color: var(--text); border-color: var(--text2); }
    .cntb-title {
      font-size: 1.05rem; font-weight: 900; letter-spacing: 2px;
      text-transform: uppercase; color: var(--red);
      padding-bottom: 8px; border-bottom: 1px solid var(--border);
      flex-shrink: 0;
      animation: cntbTitlePulse 2.2s ease-in-out infinite;
    }
    @keyframes cntbTitlePulse {
      0%, 100% { color: var(--red-dim); text-shadow: 0 0 2px rgba(204,0,0,0.2); }
      50%      { color: var(--red-hi);  text-shadow: 0 0 10px rgba(255,26,26,0.75); }
    }
    /* text-shadow/drop-shadow animations force a full repaint+rasterize every frame
       (unlike transform/opacity, which the compositor handles) — on touch devices we
       freeze them at their mid-pulse look instead of running them indefinitely. */
    @media (hover: none) and (pointer: coarse) {
      .cntb-title  { animation: none; color: var(--red-hi); text-shadow: 0 0 6px rgba(255,26,26,0.5); }
      .cntb-arrow  { animation: none; opacity: 0.85; }
    }
    .cntb-cards { display: flex; flex-direction: column; gap: 9px; }
    /* sidebar cards = mini IF machines (drag onto the field, infinite stack) */
    .cntb-card {
      --mc: #888;
      position: relative;
      border-radius: 5px;
      border: 2px solid #07090b;
      background: linear-gradient(180deg,
        color-mix(in srgb, var(--mc) 16%, #23282c),
        color-mix(in srgb, var(--mc) 8%, #15181b));
      box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.08),
        inset 0 0 0 1px color-mix(in srgb, var(--mc) 26%, transparent),
        0 2px 5px rgba(0,0,0,0.4);
      padding: 6px 11px 6px 15px;     /* room for the intake on the left */
      cursor: grab; user-select: none;
      display: flex; flex-direction: column; gap: 1px;
      transition: transform 0.1s, box-shadow 0.12s;
    }
    .cntb-card:hover {
      transform: translateY(-1px);
      box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.1),
        inset 0 0 0 1px color-mix(in srgb, var(--mc) 40%, transparent),
        0 0 9px color-mix(in srgb, var(--mc) 45%, transparent),
        0 3px 7px rgba(0,0,0,0.45);
    }
    .cntb-card:active { cursor: grabbing; }
    .cntb-intake {
      position: absolute; left: -2px; top: 50%; transform: translateY(-50%);
      width: 9px; height: 20px; border-radius: 2px 3px 3px 2px;
      background: radial-gradient(ellipse at 75% 50%, #2b3034, #050607 85%);
      box-shadow: inset -2px 0 4px rgba(0,0,0,0.75), inset 0 0 0 1px #000;
    }
    .cntb-tag {
      font-size: 0.46rem; font-weight: 800; letter-spacing: 2px;
      text-transform: uppercase; color: color-mix(in srgb, var(--mc) 55%, #999);
    }
    .cntb-card-label {
      font-size: 0.7rem; font-weight: 800; line-height: 1.1;
      color: #e8eef5;   /* war inline im JS — hierher gezogen, damit der Lightmode sie überschreiben kann (#21) */
      text-shadow: 0 1px 1px rgba(0,0,0,0.5);
    }
    /* red pulsing arrow that points from each card over the sidebar edge into the field */
    .cntb-arrow {
      position: absolute; right: -34px; top: 50%;
      transform: translateY(-50%);
      font-size: 1.7rem; color: var(--red);
      pointer-events: none; z-index: 1;
      filter: drop-shadow(0 0 4px rgba(204,0,0,0.45));
      animation: cntbArrowPulse 1.3s ease-in-out infinite;
    }
    @keyframes cntbArrowPulse {
      0%, 100% { opacity: 0.4; color: var(--red-dim);
                 transform: translateY(-50%) translateX(0)   scale(1); }
      50%      { opacity: 1;   color: var(--red-hi);
                 transform: translateY(-50%) translateX(7px) scale(1.18); }
    }
    .cntb-chute-yes {
      position: absolute; right: -4px; top: 50%; transform: translateY(-50%);
      width: 6px; height: 13px; border-radius: 0 2px 2px 0;
      background: linear-gradient(180deg, var(--green), #0a0c0e);
      box-shadow: 0 0 4px rgba(68,204,68,0.7);
    }
    .cntb-chute-no {
      position: absolute; bottom: -4px; left: 50%; transform: translateX(-50%);
      width: 13px; height: 6px; border-radius: 0 0 2px 2px;
      background: linear-gradient(180deg, #ff5555, #0a0c0e);
      box-shadow: 0 0 4px rgba(255,85,85,0.7);
    }
    /* the floating clone that follows the cursor while dragging from the sidebar */
    .cntb-drag-ghost {
      position: fixed; z-index: 999; pointer-events: none;
      transform: translate(-50%, -50%); opacity: 0.92;
      width: 132px; cursor: grabbing;
      box-shadow: 0 10px 24px rgba(0,0,0,0.6);
    }
    .cntb-hint {
      margin-top: auto; padding-top: 10px;
      border-top: 1px solid var(--border);
      font-size: 0.64rem; color: var(--text3); line-height: 1.65;
      flex-shrink: 0;
    }
    /* Canvas wrap */
    .cn-wrap { flex: 1; display: flex; flex-direction: row; align-items: stretch; position: relative; overflow: hidden; }
    /* Start/target now live inside the world as edge tiles → lanes collapsed */
    .cn-start-lane, .cn-target-lane { display: none; }
    .cn-grid-wrap   { flex: 1; position: relative; overflow: hidden; touch-action: none; }
    .cn-svg {
      position: absolute; top: 0; left: 0;
      width: 100%; height: 100%;
      pointer-events: none; z-index: 5; overflow: visible;
    }
    .cn-canvas {
      position: absolute; top: 0; left: 0;
      width: 1518px; height: 598px;     /* CN_COLS × CN_TILE (33 × 46), CN_ROWS × CN_TILE (13 × 46) — also set in JS */
      transform-origin: 0 0;
      will-change: transform;
      --cell-w: 46px; --cell-h: 46px;
      background-image:
        linear-gradient(to right,  rgba(255,255,255,0.06) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255,255,255,0.06) 1px, transparent 1px);
      background-size: var(--cell-w) var(--cell-h);
      background-position: 0 0;
    }
    /* Zoom / pan controls overlaid on the grid viewport */
    .cn-viewctrl {
      position: absolute; top: 8px; right: 8px; z-index: 30;
      display: none; flex-direction: column; gap: 4px;
    }
    .cn-viewctrl button {
      width: 26px; height: 26px; padding: 0;
      background: var(--bg2); color: var(--text2);
      border: 1px solid var(--border2); border-radius: 5px;
      font-size: 0.95rem; font-weight: 700; line-height: 1; cursor: pointer;
      display: flex; align-items: center; justify-content: center;
    }
    .cn-viewctrl button:hover { color: var(--text); border-color: var(--text2); }
    /* Vertical field navigation: drag the empty field (pointer tool), two-finger
       drag (always), or mouse wheel — no on-screen arrows. Handlers live in
       cnSetupCamera. Drag-to-pan cursor hint on the bare grid: */
    .cn-grid-wrap { cursor: grab; }
    /* Tool switch (Zeiger / Band) */
    .cntb-tools { display: flex; gap: 6px; margin-bottom: 4px; }
    .cntb-tool {
      flex: 1; padding: 6px 4px; font-size: 0.7rem; font-weight: 800;
      letter-spacing: 1px; text-transform: uppercase; cursor: pointer;
      background: var(--bg2); color: var(--text3);
      border: 1px solid var(--border2); border-radius: 5px;
    }
    .cntb-tool:hover { color: var(--text); }
    .cntb-tool.active {
      color: #eafff0; border-color: var(--green);
      background: linear-gradient(180deg, rgba(58,209,122,0.28), rgba(58,209,122,0.10));
      box-shadow: 0 0 8px rgba(58,209,122,0.35);
    }
    .cn-grid-wrap.cn-tool-belt { cursor: crosshair; }
    /* ─── Conveyor belt tiles (placed on the world grid) ─────────────── */
    .cn-belt-layer { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
    .cn-belt { position: absolute; }
    .cn-belt-stub {
      position: absolute;
      background: #2b322e;
    }
    .cn-stub-right { top: calc(50% - 10px); height: 20px; left: calc(50% - 10px); right: 0; }
    .cn-stub-left  { top: calc(50% - 10px); height: 20px; right: calc(50% - 10px); left: 0; }
    .cn-stub-up    { left: calc(50% - 10px); width: 20px; bottom: calc(50% - 10px); top: 0; }
    .cn-stub-down  { left: calc(50% - 10px); width: 20px; top: calc(50% - 10px); bottom: 0; }
    .cn-belt-conflict {
      background: rgba(204,0,0,0.16);
      box-shadow: inset 0 0 0 2px var(--red);
      border-radius: 4px;
      display: flex; align-items: center; justify-content: center;
    }
    .cn-belt-x { color: var(--red); font-weight: 900; font-size: 1rem; line-height: 1; }
    /* ─── Configurable blocks (color scanner / express switch / damage scanner) ── */
    .cn-block {
      position: absolute; z-index: 10; cursor: grab; --mc: #888;
      border-radius: 8px; border: 2px solid #07090b;
      background: linear-gradient(180deg,
        color-mix(in srgb, var(--mc) 20%, #23282c),
        color-mix(in srgb, var(--mc) 9%, #14171a));
      box-shadow:
        inset 0 2px 0 rgba(255,255,255,0.08),
        inset 0 0 0 1px color-mix(in srgb, var(--mc) 30%, transparent),
        0 5px 14px rgba(0,0,0,0.5);
      user-select: none; touch-action: none;
    }
    .cn-block:active { cursor: grabbing; }
    .cn-block.cn-dragging { opacity: 0.9; z-index: 25; }
    /* Flow-order badge — the check order the player follows along the belts */
    .cn-block-order {
      position: absolute; top: -11px; left: -11px; z-index: 4;
      min-width: 24px; height: 24px; padding: 0 5px; box-sizing: border-box;
      border-radius: 12px; background: #0b0e11; color: #ffd24a;
      border: 1px solid #ffd24a; box-shadow: 0 0 6px rgba(0,0,0,0.5);
      font-size: 0.85rem; font-weight: 900; line-height: 22px; text-align: center;
      pointer-events: none;
    }
    .cn-block-face {
      position: absolute; inset: 12px;
      display: flex; flex-direction: column; align-items: center; justify-content: center;
      gap: 5px; text-align: center;
      border-radius: 5px; background: rgba(0,0,0,0.22);
      box-shadow: inset 0 0 0 1px rgba(255,255,255,0.05);
    }
    /* Block tag ("WEICHE"/"EXPRESS-WEICHE") — the only text on the block now,
       so it carries the identification; colour comes from the block tint. */
    .cn-block .cn-if-tag { font-size: 1.5rem; letter-spacing: 1.5px; text-align: center; line-height: 1.15; }
    /* "EXPRESS-WEICHE" is long — one size down so it stays inside the box
       (wraps at the hyphen into two centred lines). */
    .cn-block-express .cn-if-tag { font-size: 1.2rem; }
    /* Ports on the tile edges */
    .cn-block-port {
      position: absolute; width: 42px; height: 42px; border-radius: 9px;
      display: flex; align-items: center; justify-content: center;
      font-size: 1.24rem; font-weight: 900; color: #0a0d0f; line-height: 1;
      border: 2px solid #07090b;
      box-shadow: 0 0 8px rgba(0,0,0,0.62), 0 0 10px color-mix(in srgb, var(--mc, #fff) 22%, transparent);
      z-index: 12;
    }
    .cn-bp-in    { background: radial-gradient(circle at 50% 40%, #556, #111); box-shadow: inset -1px 0 3px rgba(0,0,0,0.7); }
    .cn-bp-match { background: var(--green); }
    .cn-bp-else  { background: #ff5555; }
    .cn-bp-left  { left: -22px;   top: 50%;  transform: translateY(-50%); }
    .cn-bp-right { right: -22px;  top: 50%;  transform: translateY(-50%); }
    .cn-bp-up    { top: -22px;    left: 50%; transform: translateX(-50%); }
    .cn-bp-down  { bottom: -22px; left: 50%; transform: translateX(-50%); }
    .cn-bp-connected { box-shadow: 0 0 7px 2px rgba(255,255,255,0.55); }
    /* Output chutes on the machine — slide to whichever side match/else is set to. */
    .cn-chute {
      position: absolute; z-index: 1;
      box-shadow: 0 0 6px rgba(0,0,0,0.35), inset 0 0 0 1px rgba(0,0,0,0.4);
    }
    .cn-chute-match { --cc: var(--green); }
    .cn-chute-else  { --cc: #ff5555; }
    .cn-chute-right { right: -8px;  top: 50%;  transform: translateY(-50%); width: 12px; height: 22px; border-radius: 0 4px 4px 0; background: linear-gradient(90deg,  #0a0c0e, var(--cc)); }
    .cn-chute-left  { left: -8px;   top: 50%;  transform: translateY(-50%); width: 12px; height: 22px; border-radius: 4px 0 0 4px; background: linear-gradient(270deg, #0a0c0e, var(--cc)); }
    .cn-chute-down  { bottom: -8px; left: 50%; transform: translateX(-50%); width: 22px; height: 12px; border-radius: 0 0 4px 4px; background: linear-gradient(180deg, #0a0c0e, var(--cc)); }
    .cn-chute-up    { top: -8px;    left: 50%; transform: translateX(-50%); width: 22px; height: 12px; border-radius: 4px 4px 0 0; background: linear-gradient(0deg,   #0a0c0e, var(--cc)); }
    .cn-block-port, .cn-edge-port { cursor: pointer; }
    /* Invisible enlarged hit-area — the 16px port stays 16px visually, but taps
       land on a much bigger box. Values are world-px (they scale with the canvas).
       The box grows sideways + OUTWARD only; barely inward, so the machine body
       under the port stays grabbable for drags. */
    .cn-block-port::after, .cn-edge-port::after { content: ''; position: absolute; inset: -26px; }
    .cn-bp-left::after,  .cn-ep-left::after  { right: -4px; }   /* machine sits right of the port */
    .cn-bp-right::after, .cn-ep-right::after { left:  -4px; }
    .cn-bp-up::after,    .cn-ep-up::after    { bottom: -4px; }
    .cn-bp-down::after,  .cn-ep-down::after  { top:   -4px; }
    /* Touch: more than a belt tile (46px) of slack — tapping the tile NEXT to
       the port still connects. Inward stays tight (same reason as above). */
    @media (hover: none) and (pointer: coarse) {
      .cn-block-port::after, .cn-edge-port::after { inset: -64px; }
      .cn-bp-left::after,  .cn-ep-left::after  { right: -4px; }
      .cn-bp-right::after, .cn-ep-right::after { left:  -4px; }
      .cn-bp-up::after,    .cn-ep-up::after    { bottom: -4px; }
      .cn-bp-down::after,  .cn-ep-down::after  { top:   -4px; }
    }
    /* Picked source port waiting for a target tap. */
    .cn-pending { outline: 2px solid #ffd24a; outline-offset: 1px; z-index: 13 !important;
                  box-shadow: 0 0 10px 3px rgba(255,210,74,0.85); animation: cnPickPulse 0.9s ease-in-out infinite; }
    @keyframes cnPickPulse { 0%,100% { box-shadow: 0 0 8px 2px rgba(255,210,74,0.7); }
                             50%     { box-shadow: 0 0 13px 5px rgba(255,210,74,0.95); } }
    /* box-shadow can't be composited — the pulse repaints the node every frame.
       On touch it freezes at the bright mid-pulse look (#6). */
    @media (hover: none) and (pointer: coarse) {
      .cn-pending { animation: none; box-shadow: 0 0 12px 4px rgba(255,210,74,0.9); }
    }
    /* Block click-menu (fixed to the page so it never gets clipped) */
    .cn-blockmenu {
      position: fixed; z-index: 900; width: 264px; max-width: calc(100vw - 20px);
      background: var(--bg2); border: 1px solid var(--border2); border-radius: 12px;
      padding: 16px 16px 14px; box-shadow: 0 14px 40px rgba(0,0,0,0.7);
      font-size: 0.82rem; color: var(--text2);
    }
    .cn-bm-title { font-size: 1.02rem; font-weight: 900; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 3px; }
    .cn-bm-hint  { font-size: 0.66rem; color: var(--text3); margin-bottom: 12px; line-height: 1.4; }
    .cn-bm-row { display: flex; flex-direction: column; gap: 7px; margin: 12px 0; }
    .cn-bm-lbl { font-weight: 900; font-size: 0.78rem; letter-spacing: 0.3px; color: var(--text2); }
    .cn-bm-lbl.cn-bm-match { color: var(--green); }
    .cn-bm-lbl.cn-bm-else  { color: #ff5555; }
    .cn-bm-opts { display: flex; gap: 8px; }
    .cn-bm-side {
      flex: 1; min-height: 46px; padding: 10px 6px;
      font-size: 0.82rem; font-weight: 800;
      background: #161b1f; color: var(--text2);
      border: 2px solid var(--border2); border-radius: 8px; cursor: pointer;
      transition: background 0.1s, border-color 0.1s;
    }
    .cn-bm-side:active { transform: scale(0.96); }
    .cn-bm-opts-match .cn-bm-side.sel { color: #fff; border-color: var(--green); background: rgba(58,209,122,0.22); box-shadow: 0 0 8px rgba(58,209,122,0.4); }
    .cn-bm-opts-else  .cn-bm-side.sel { color: #fff; border-color: #ff5555;    background: rgba(255,85,85,0.22);  box-shadow: 0 0 8px rgba(255,85,85,0.4); }
    .cn-bm-side.dis { opacity: 0.28; cursor: not-allowed; }
    .cn-bm-del {
      margin-top: 14px; width: 100%; padding: 12px; cursor: pointer;
      background: rgba(204,0,0,0.15); color: #ff8888;
      border: 1px solid rgba(204,0,0,0.5); border-radius: 8px;
      font-weight: 800; font-size: 0.78rem; text-transform: uppercase;
    }
    .cn-bm-del:hover { background: rgba(204,0,0,0.3); color: #fff; }
    /* Flow arrow + powered belt (direction traced from the sources) */
    .cn-belt-arrow {
      position: absolute; left: 50%; top: 50%;
      color: #eafff0; font-size: 0.62rem; line-height: 1;
      text-shadow: 0 0 3px rgba(0,0,0,0.85); pointer-events: none; z-index: 2;
    }
    .cn-belt.cn-belt-flow .cn-belt-stub {
      background: #2c4536;
    }
    /* ─── Start / target machines (in the world, at the field borders) ── */
    .cn-edge {
      position: absolute; z-index: 9; user-select: none; --mc: #3ad17a;
      border-radius: 5px; border: 2px solid #07090b; overflow: visible;
      display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
      background: linear-gradient(180deg,
        color-mix(in srgb, var(--mc) 17%, #23282c), color-mix(in srgb, var(--mc) 8%, #15181b));
      box-shadow:
        inset 0 2px 0 rgba(255,255,255,0.09),
        inset 0 -4px 7px rgba(0,0,0,0.5),
        inset 0 0 0 1px color-mix(in srgb, var(--mc) 26%, transparent),
        0 5px 12px rgba(0,0,0,0.5);
    }
    .cn-edge-start { --mc: #3ad17a; }
    .cn-edge-start .mc-label { font-size: 1.365rem; }
    /* Machine boxes are CN_EDGE_BOX (2×2) tiles = 92px — contents sized to fit. */
    .cn-edge-icon  { font-size: 1.8rem; line-height: 1; filter: drop-shadow(0 0 3px var(--mc)); }
    /* Icon-only colour targets: the 📦 IS the label → big, with a strong glow
       in the target colour so it reads like the tinted packages. Express stacks
       a smaller ⚡ ABOVE the box; everything dead-centred in the machine. */
    .cn-tgt-shelf .cn-edge-icon {
      font-size: 2.9rem;
      filter: drop-shadow(0 0 9px var(--mc)) drop-shadow(0 0 3px var(--mc));
      display: flex; flex-direction: column; align-items: center; justify-content: center;
      gap: 1px; text-align: center;
    }
    /* Single-pass glow on touch — these sit inside the field layer that gets
       repainted by every sim flash (#6). */
    @media (hover: none) and (pointer: coarse) {
      .cn-tgt-shelf .cn-edge-icon { filter: drop-shadow(0 0 6px var(--mc)); }
    }
    .cn-tgt-shelf .cn-edge-icon .cn-ei-bolt { font-size: 0.5em; line-height: 1; }
    .cn-edge-label { font-size: 0.95rem; font-weight: 900; letter-spacing: 0.5px; text-transform: uppercase;
                     color: #eef; line-height: 1.1; text-align: center; padding: 0 4px; }
    /* Long labels sized down so they stay inside their box with a little air:
       REKLAMATION would overflow at the full 0.95rem. */
    #cn-node-tgt-reklamation .cn-edge-label { font-size: 0.68rem; letter-spacing: 0; padding: 0 2px; }
    /* Auto-sealed output: everything else is docked, so the one remaining open
       output closes itself — it simply disappears from the machine. */
    .cn-port-sealed { display: none !important; }
    .mc-label { font-size: 1.05rem; font-weight: 800; letter-spacing: 1.5px; text-transform: uppercase;
                color: var(--mc); text-shadow: 0 0 6px color-mix(in srgb, var(--mc) 55%, transparent); }
    /* express target: golden frame */
    .cn-edge-target.cn-tgt-express {
      border-color: #d9a41a;
      box-shadow: inset 0 2px 0 rgba(255,255,255,0.1), inset 0 -4px 7px rgba(0,0,0,0.5),
        inset 0 0 0 1px rgba(255,216,128,0.5), 0 0 11px rgba(212,164,26,0.5), 0 5px 12px rgba(0,0,0,0.5);
    }
    /* machine door / intake mouth — slides to the field-facing side (any edge) */
    .mc-hatch { position: absolute; z-index: 3; }
    .mc-hatch-right { right: -4px;  top: 50%;  transform: translateY(-50%); width: 24px; height: 46px; }
    .mc-hatch-left  { left: -4px;   top: 50%;  transform: translateY(-50%); width: 24px; height: 46px; }
    .mc-hatch-down  { bottom: -4px; left: 50%; transform: translateX(-50%); width: 46px; height: 24px; }
    .mc-hatch-up    { top: -4px;    left: 50%; transform: translateX(-50%); width: 46px; height: 24px; }
    .mc-hatch::before {
      content: ''; position: absolute; inset: 0; border-radius: 3px;
      background: linear-gradient(180deg, #262b2f, #15181b);
      box-shadow: inset 0 0 0 1px #07090b, 0 1px 2px rgba(0,0,0,0.5);
    }
    .mc-hatch-mouth {
      position: absolute; inset: 3px; border-radius: 2px; overflow: hidden;
      background: radial-gradient(ellipse at 50% 45%, #2b3034, #050607 82%);
      box-shadow: inset 0 2px 6px rgba(0,0,0,0.9), inset 0 0 0 1px #000;
      display: flex; align-items: center; justify-content: center;
    }
    .mc-hatch-mouth .mc-pkg { font-size: 1rem; line-height: 1; filter: drop-shadow(0 0 2px rgba(0,0,0,0.85)); }
    /* decorative machine parts never intercept clicks (drag / port taps pass through) */
    .mc-bolt, .mc-intake, .mc-face, .mc-label, .mc-hatch, .cn-chute,
    .cn-edge-icon, .cn-edge-label, .cn-block-face { pointer-events: none; }
    .cn-edge-port {
      position: absolute; width: 34px; height: 34px; border-radius: 8px;
      border: 2px solid #07090b;
      box-shadow: 0 0 8px rgba(0,0,0,0.62), 0 0 10px color-mix(in srgb, var(--mc, #fff) 20%, transparent);
      z-index: 5;
    }
    .cn-edge-out { background: var(--green); }
    .cn-edge-in  { background: #ccd; }
    /* Port nub position — always faces into the field (depends on which edge).
       −13 keeps the 24px nub's centre where the old 16px one sat. */
    .cn-ep-right { right: -18px;  top: 50%;  transform: translateY(-50%); }
    .cn-ep-left  { left: -18px;   top: 50%;  transform: translateY(-50%); }
    .cn-ep-down  { bottom: -18px; left: 50%; transform: translateX(-50%); }
    .cn-ep-up    { top: -18px;    left: 50%; transform: translateX(-50%); }
    .cn-edge-connected { box-shadow: 0 0 8px 2px rgba(255,255,255,0.6); }
    .cn-edge { cursor: grab; }
    .cn-edge.cn-dragging { z-index: 20; opacity: 0.9; }
    .cn-edge:active { cursor: grabbing; }
    /* Grip handle on the outer side — signals "drag me along this border". */
    .mc-grip {
      position: absolute; z-index: 4; opacity: 0.78; pointer-events: none; border-radius: 4px;
      background-color: rgba(255,255,255,0.035);
      background-image: radial-gradient(circle, rgba(238,246,252,0.98) 1.6px, transparent 2.3px);
      background-size: 7px 7px;
      box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08), 0 0 8px rgba(255,255,255,0.10);
    }
    .mc-grip-left   { left: 5px;   top: 50%;  transform: translateY(-50%); width: 13px; height: 58px; }
    .mc-grip-right  { right: 5px;  top: 50%;  transform: translateY(-50%); width: 13px; height: 58px; }
    .mc-grip-top    { top: 5px;    left: 50%; transform: translateX(-50%); width: 58px; height: 13px; }
    .mc-grip-bottom { bottom: 5px; left: 50%; transform: translateX(-50%); width: 58px; height: 13px; }
    /* One-time onboarding nudge: slide the block along its edge and back. */
    @keyframes cnEdgeNudgeV { 0%,100% { transform: translateY(0); } 30% { transform: translateY(11px); } 65% { transform: translateY(-11px); } }
    @keyframes cnEdgeNudgeH { 0%,100% { transform: translateX(0); } 30% { transform: translateX(11px); } 65% { transform: translateX(-11px); } }
    .cn-edge-hint-v { animation: cnEdgeNudgeV 1.15s ease-in-out 2; }
    .cn-edge-hint-h { animation: cnEdgeNudgeH 1.15s ease-in-out 2; }
    /* Permanent soft yellow field border — calm version of the drag rails
       (::before so it can't clash with the rails' ::after; no layout impact). */
    #cn-canvas::before {
      content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 8;
      border: 2px solid rgba(255,210,74,0.45);
      box-shadow: inset 0 0 18px rgba(255,210,74,0.12);
    }
    /* Glowing rails around the field while dragging a start/target block. */
    #cn-canvas.cn-rails-on::after {
      content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 8;
      border: 3px dashed rgba(255,210,74,0.85);
      box-shadow: inset 0 0 24px rgba(255,210,74,0.28);
      animation: cnRailsPulse 1s ease-in-out infinite;
    }
    @keyframes cnRailsPulse { 0%,100% { opacity: 0.5; } 50% { opacity: 1; } }
    /* Enlarged build area on desktop (mobile keeps its scaled 1080×620 box) */
    @media (min-width: 921px) {
      .game-box:has(#screen-build-chain.active) { max-width: 1240px; }
      #screen-build-chain { min-height: 760px; }
    }
    /* Nodes */
    .cn-node {
      position: absolute; cursor: grab;
      user-select: none; z-index: 10;
    }
    .cn-node:active { cursor: grabbing; }
    .cn-node.cn-dragging { z-index: 20; opacity: 0.88; }
    /* ─── Factory machine: START (source) ─────────────────────────── */
    .cn-node-start {
      --mc: #3ad17a;                 /* signature colour (green = source/go) */
      width: 96px; height: 80px;
      padding: 0; border-radius: 5px;
      border: 2px solid #07090b;
      background:
        linear-gradient(180deg, #2b3034 0%, #1c2023 55%, #141619 100%);
      box-shadow:
        inset 0 2px 0 rgba(255,255,255,0.10),
        inset 0 -4px 7px rgba(0,0,0,0.55),
        inset 0 0 0 1px rgba(255,255,255,0.04),
        0 5px 12px rgba(0,0,0,0.55);
      display: flex; flex-direction: column;
      align-items: center; justify-content: center; gap: 3px;
      padding: 4px;                   /* hatch overlaps the border; contents stay centred */
      overflow: visible;
    }
    /* corner rivets */
    .mc-bolt {
      position: absolute; width: 7px; height: 7px; border-radius: 50%;
      background: radial-gradient(circle at 35% 30%, #99a1a8, #444a50 58%, #181b1e);
      box-shadow: inset 0 0 0 1px rgba(0,0,0,0.5), 0 1px 1px rgba(0,0,0,0.6);
      z-index: 11;
    }
    .mc-bolt-tl { left: 5px;  top: 5px; }
    .mc-bolt-tr { right: 5px; top: 5px; }
    .mc-bolt-bl { left: 5px;  bottom: 5px; }
    .mc-bolt-br { right: 5px; bottom: 5px; }
    /* control face: status LED + vent slats */
    .mc-face {
      display: flex; align-items: center; gap: 5px; margin-top: 2px;
    }
    .mc-led {
      width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
      background: radial-gradient(circle at 35% 30%, #d6ffe6, var(--mc) 55%, #0c1f15);
      box-shadow: 0 0 6px var(--mc), inset 0 0 1px rgba(0,0,0,0.5);
    }
    .mc-vents { display: flex; flex-direction: column; gap: 2px; }
    .mc-vents span {
      display: block; width: 24px; height: 4px; border-radius: 2px;
      background: linear-gradient(180deg, #0a0c0e, #20262b);
      box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 1px 0 rgba(0,0,0,0.5);
    }
    /* (duplicate .mc-label removed — the edge-machine rule further up owns it) */
    /* output door / hatch on the right edge */
    .mc-door {
      position: absolute; right: -3px; top: 50%; transform: translateY(-50%);
      width: 30px; height: 48px; z-index: 12;
    }
    .mc-door::before {                 /* door frame set into the chassis */
      content: ''; position: absolute; inset: 0; border-radius: 3px;
      background: linear-gradient(180deg, #262b2f, #15181b);
      box-shadow: inset 0 0 0 1px #07090b, 0 1px 2px rgba(0,0,0,0.5);
    }
    .mc-door-panel {                   /* the slid-open door leaf (raised) */
      position: absolute; left: 2px; right: 1px; top: -2px; height: 15px;
      border-radius: 3px 3px 1px 1px;
      background: linear-gradient(180deg, var(--mc), #0f1a14);
      box-shadow: 0 0 6px var(--mc), inset 0 1px 0 rgba(255,255,255,0.30);
      border-bottom: 2px solid #07090b;
    }
    .mc-door-mouth {                   /* dark opening with the package emerging */
      position: absolute; left: 3px; right: 1px; bottom: 3px; height: 28px;
      border-radius: 2px; overflow: hidden;
      background: radial-gradient(ellipse at 65% 50%, #2b3034, #050607 82%);
      box-shadow: inset 0 2px 6px rgba(0,0,0,0.9), inset 0 0 0 1px #000;
      display: flex; align-items: center; justify-content: flex-start;
    }
    .mc-door-mouth .mc-pkg {
      font-size: 0.98rem; line-height: 1; margin-left: 1px;
      filter: drop-shadow(0 0 2px rgba(0,0,0,0.85));
    }
    /* ─── Factory machine: IF (sorter/splitter) ───────────────────── */
    .cn-node-if {
      --mc: #888;
      width: calc(var(--cell-w) - 8px); min-height: 58px;
      padding-left: 22px;            /* room for the conveyor intake on the LEFT */
      border-radius: 6px;
      border: 2px solid #07090b;
      background:
        linear-gradient(180deg,
          color-mix(in srgb, var(--mc) 16%, #23282c) 0%,
          color-mix(in srgb, var(--mc) 8%, #15181b) 100%);
      box-shadow:
        inset 0 2px 0 rgba(255,255,255,0.08),
        inset 0 -4px 7px rgba(0,0,0,0.5),
        inset 0 0 0 1px color-mix(in srgb, var(--mc) 26%, transparent),
        0 5px 12px rgba(0,0,0,0.5);
      overflow: visible;
    }
    /* dark intake slot on the left where the belt feeds in (packages vanish) */
    .mc-intake {
      position: absolute; left: -2px; top: 50%; transform: translateY(-50%);
      width: 20px; height: 32px; border-radius: 2px 3px 3px 2px;
      background: radial-gradient(ellipse at 75% 50%, #2b3034, #050607 85%);
      box-shadow:
        inset 0 2px 5px rgba(0,0,0,0.9),
        inset -3px 0 5px rgba(0,0,0,0.75),
        inset 0 0 0 1px #000;
      z-index: 11;
    }
    .cn-if-header {
      padding: 6px 9px 4px 8px; border-bottom: 1px solid rgba(0,0,0,0.45);
    }
    .cn-if-tag {
      font-size: 0.52rem; font-weight: 800;
      letter-spacing: 2px; text-transform: uppercase;
      color: color-mix(in srgb, var(--mc) 55%, #999);
    }
    .cn-if-cond {
      font-size: 0.73rem; font-weight: 800; margin-top: 1px;
      text-shadow: 0 1px 2px rgba(0,0,0,0.55);
    }
    .cn-if-footer {
      display: flex; justify-content: space-between;
      padding: 3px 9px 5px 8px;
    }
    .cn-if-yes { font-size: 0.62rem; font-weight: 800; color: var(--green); }
    .cn-if-no  { font-size: 0.62rem; font-weight: 800; color: #ff5555; }
    /* output chutes that the package is flung out of */
    .cn-if-chute-yes {
      position: absolute; right: -7px; top: 50%; transform: translateY(-50%);
      width: 10px; height: 18px; border-radius: 0 3px 3px 0;
      background: linear-gradient(180deg, var(--green), #0a0c0e);
      box-shadow: 0 0 6px rgba(68,204,68,0.7), inset 0 0 0 1px rgba(0,0,0,0.4);
      z-index: 11;
    }
    .cn-if-chute-no {
      position: absolute; bottom: -7px; left: 50%; transform: translateX(-50%);
      width: 18px; height: 10px; border-radius: 0 0 3px 3px;
      background: linear-gradient(180deg, #ff5555, #0a0c0e);
      box-shadow: 0 0 6px rgba(255,85,85,0.7), inset 0 0 0 1px rgba(0,0,0,0.4);
      z-index: 11;
    }
    .cn-node-del {
      position: absolute; top: -9px; right: -9px;
      width: 18px; height: 18px;
      background: #333; border: 1px solid #555; border-radius: 50%;
      color: var(--text2); font-size: 0.85rem; cursor: pointer;
      display: flex; align-items: center; justify-content: center;
      z-index: 30; line-height: 1; padding: 0; font-family: inherit;
    }
    .cn-node-del:hover { background: var(--red); color: #fff; border-color: var(--red); }
    /* ─── Factory machine: TARGETS (intake bins) ──────────────────── */
    .cn-node-target {
      --mc: #888;
      width: 124px; height: 62px;
      padding: 0 9px 0 30px;          /* room for the intake door on the LEFT */
      border-radius: 5px;
      border: 2px solid #07090b;
      background:
        linear-gradient(180deg,
          color-mix(in srgb, var(--mc) 17%, #23282c) 0%,
          color-mix(in srgb, var(--mc) 8%, #15181b) 100%);
      box-shadow:
        inset 0 2px 0 rgba(255,255,255,0.08),
        inset 0 -4px 7px rgba(0,0,0,0.5),
        inset 0 0 0 1px color-mix(in srgb, var(--mc) 28%, transparent),
        0 5px 12px rgba(0,0,0,0.5);
      display: flex; flex-direction: column;
      align-items: flex-start; justify-content: center; gap: 3px;
      overflow: visible;
    }
    .cn-node-target .cn-tgt-icon {
      font-size: 1.1rem; line-height: 1; flex-shrink: 0;
      filter: drop-shadow(0 0 3px var(--mc));
    }
    .cn-node-target .cn-tgt-label {
      font-size: 0.62rem; font-weight: 800; color: #fff; line-height: 1.2;
      text-shadow: 0 1px 2px rgba(0,0,0,0.6);
    }
    /* Express: matching tint + golden frame */
    .cn-node-target.cn-tgt-express {
      border-color: #d9a41a;
      box-shadow:
        inset 0 2px 0 rgba(255,255,255,0.10),
        inset 0 -4px 7px rgba(0,0,0,0.5),
        inset 0 0 0 1px rgba(255,216,128,0.5),
        0 0 11px rgba(212,164,26,0.55),
        0 5px 12px rgba(0,0,0,0.5);
    }
    .cn-tgt-express .mc-express-trim {
      position: absolute; left: 30px; right: 6px; top: 4px; height: 4px;
      border-radius: 2px;
      background: linear-gradient(90deg, #ffe089, #d9a41a);
      box-shadow: 0 0 6px rgba(212,164,26,0.6);
    }
    /* intake door variant: mirror the START door onto the LEFT edge */
    .mc-door-in { right: auto; left: -3px; }
    .mc-door-in .mc-door-mouth {
      justify-content: flex-end;
      background: radial-gradient(ellipse at 35% 50%, #2b3034, #050607 82%);
    }
    .mc-door-in .mc-door-mouth .mc-pkg { margin-left: 0; margin-right: 1px; }

    /* ─── Reklamation: rear of a 2D delivery truck ────────────────── */
    .cn-tgt-truck {
      width: 126px; height: 64px;
      padding: 0 10px 0 32px;
      border-radius: 5px 7px 7px 5px;
      border: 2px solid #2a2e31;
      background:
        repeating-linear-gradient(90deg, rgba(0,0,0,0.05) 0 6px, rgba(255,255,255,0.16) 6px 12px),
        linear-gradient(180deg, #eef1f3 0%, #cfd4d8 55%, #aeb4b9 100%);
      box-shadow:
        inset 0 2px 0 rgba(255,255,255,0.6),
        inset 0 -4px 6px rgba(0,0,0,0.2),
        0 5px 12px rgba(0,0,0,0.5);
      display: flex; flex-direction: column;
      align-items: flex-start; justify-content: center; gap: 2px;
      overflow: visible; color: #2a2e31;
    }
    .cn-tgt-truck .tk-label {
      font-size: 0.6rem; font-weight: 900; letter-spacing: 0.5px;
      text-transform: uppercase; color: #33373a; line-height: 1.15;
      text-shadow: 0 1px 0 rgba(255,255,255,0.5);
    }
    .cn-tgt-truck .tk-sub {
      font-size: 0.48rem; font-weight: 700; letter-spacing: 1px;
      text-transform: uppercase; color: #6a7075;
    }
    .tk-lights {
      position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
      display: flex; flex-direction: column; gap: 4px;
    }
    .tk-lights span { width: 7px; height: 11px; border-radius: 2px; }
    .tk-lights span.tk-red { background: #ff3b3b; box-shadow: 0 0 5px #ff3b3b; }
    .tk-lights span.tk-amber { background: #ffb13b; box-shadow: 0 0 5px #ffb13b; }
    .tk-bumper {
      position: absolute; left: 5px; right: 5px; bottom: -4px; height: 6px;
      border-radius: 2px;
      background: linear-gradient(180deg, #6a7076, #2a2e31);
      box-shadow: 0 1px 2px rgba(0,0,0,0.5);
    }
    /* open roll-up cargo door on the LEFT (where packages enter) */
    .tk-door {
      position: absolute; left: -3px; top: 50%; transform: translateY(-50%);
      width: 30px; height: 54px; z-index: 12;
    }
    .tk-door::before {
      content: ''; position: absolute; inset: 0; border-radius: 3px;
      background: linear-gradient(180deg, #9aa0a5, #6c7176);
      box-shadow: inset 0 0 0 1px #2a2e31, 0 1px 2px rgba(0,0,0,0.4);
    }
    .tk-shutter {                      /* rolled-up corrugated shutter at top */
      position: absolute; left: 2px; right: 1px; top: -2px; height: 13px;
      border-radius: 3px 3px 1px 1px;
      background: repeating-linear-gradient(180deg, #dde1e4 0 2px, #a9afb3 2px 4px);
      box-shadow: 0 1px 2px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.6);
      border-bottom: 2px solid #2a2e31;
    }
    .tk-mouth {                        /* dark cargo hold with package entering */
      position: absolute; left: 3px; right: 1px; bottom: 3px; height: 32px;
      border-radius: 2px; overflow: hidden;
      background: radial-gradient(ellipse at 35% 50%, #3a3f43, #050607 82%);
      box-shadow: inset 0 2px 6px rgba(0,0,0,0.9), inset 0 0 0 1px #000;
      display: flex; align-items: center; justify-content: flex-end;
    }
    .tk-mouth .mc-pkg {
      font-size: 0.98rem; line-height: 1; margin-right: 2px;
      filter: drop-shadow(0 0 2px rgba(0,0,0,0.85));
    }
    /* Ports */
    .cn-port {
      position: absolute; width: 13px; height: 13px;
      border-radius: 50%; background: var(--bg3); border: 2px solid #555;
      cursor: crosshair; z-index: 15;
      transition: background 0.12s, border-color 0.12s, transform 0.1s;
    }
    .cn-port:hover { transform: scale(1.5); }
    .cn-port-in  { left: -8px; top: 50%; margin-top: -6px; }
    .cn-port-out { right: -8px; top: 50%; margin-top: -6px; border-color: #888; }
    .cn-port-yes { right: -8px; top: 50%; margin-top: -6px; border-color: var(--green); }
    .cn-port-no  { bottom: -8px; left: 50%; margin-left: -6px; border-color: #ff5555; }
    .cn-port.port-active {
      background: var(--yellow); border-color: var(--yellow);
      transform: scale(1.6); box-shadow: 0 0 8px var(--yellow);
    }
    .cn-port.port-connected { background: #3a3a3a; }
    .cn-port-yes.port-connected { border-color: var(--green); background: rgba(68,204,68,0.18); }
    .cn-port-no.port-connected  { border-color: #ff5555; background: rgba(255,85,85,0.18); }
    .cn-port-in.port-connected  { border-color: #999; background: rgba(150,150,150,0.15); }
    .cn-port-out.port-connected { border-color: #aaa; background: rgba(170,170,170,0.15); }
    /* SVG connection lines */
    .cn-line { fill: none; stroke-width: 2.5; stroke-linecap: round; }
    .cn-line-yes { stroke: var(--green); }
    .cn-line-no  { stroke: #ff5555; }
    .cn-line-out { stroke: #888; }
    .cn-rubber   { fill: none; stroke: var(--yellow); stroke-width: 1.8; stroke-dasharray: 7 4; }
    /* Node flash on sim hit */
    .cn-node.cn-sim-hit { animation: cnHit 0.4s ease; }
    @keyframes cnHit {
      0%  { filter: brightness(1); }
      40% { filter: brightness(2.5); }
      100%{ filter: brightness(1); }
    }
    /* Result panel inside canvas screen */
    #screen-build-chain .result-panel { padding: 10px 18px; flex-shrink: 0; }
    /* Hand-sort target colors for new express variants */
    .sort-target[data-target="rot"]          { color: #ff5533; }
    .sort-target[data-target="blau"]         { color: var(--blue); }
    .sort-target[data-target="gruen"]        { color: #00c9a0; }
    .sort-target[data-target="express"] { color: #ffaa00; }
    .sort-target[data-target="reklamation"]      { color: var(--purple); }
    .sort-target[data-target="nicht-zustellbar"] { color: #888899; }

    /* ─── Result panel ───────────────────────────────────────────── */
    .result-panel {
      display: none; border-top: 1px solid var(--border);
      padding: 14px 0 0; gap: 16px; align-items: center;
    }
    .result-panel.show { display: flex; }
    .score-block { flex: 1; }
    .score-num { font-size: 2.8rem; font-weight: 900; color: var(--red); line-height: 1; }
    .score-num.pass { color: var(--green); }
    .score-bar-wrap { height: 5px; background: var(--border); margin: 6px 0 3px; max-width: 260px; }
    .score-bar { height: 100%; background: var(--red); transition: width 0.6s ease; }
    .score-bar.pass { background: var(--green); }
    .score-sub { font-size: 0.7rem; color: var(--text2); }
    .result-msg { font-size: 0.82rem; font-weight: 700; margin-top: 8px; letter-spacing: 0.5px; }
    .result-msg.ok   { color: var(--green); }
    .result-msg.fail { color: #ff5555; }

    /* ─── SIMULATION OVERLAY ─────────────────────────────────────── */
    /* ─── Canvas simulation animation ──────────────────────────── */
    .cn-pkg-fly {
      position: absolute; pointer-events: none; z-index: 7;  /* above belts, behind machines → vanishes inside them */
      width: 30px; height: 30px; border-radius: 3px; border: 2px solid;
      display: flex; align-items: center; justify-content: center;
      font-size: 0.95rem;
      offset-anchor: 50% 50%;
      offset-rotate: 0deg;
      will-change: transform;
    }
    .cn-pkg-fly.cn-pkg-fall { border-color: #ff5555 !important; box-shadow: 0 0 10px rgba(255,85,85,0.6); }
    /* Express package in flight: ⚡ centred on top of the colour square */
    .cn-fly-bolt {
      position: absolute; inset: 0;
      display: flex; align-items: center; justify-content: center;
      font-size: 0.8rem;
      text-shadow: 0 0 3px #000, 0 1px 4px rgba(0, 0, 0, 0.9);
    }
    .cn-node.cn-node-pulse { outline: 2px solid var(--yellow); box-shadow: 0 0 14px rgba(255,170,0,0.55); }
    .cn-node.cn-node-ok    { outline: 2px solid var(--green);  box-shadow: 0 0 22px rgba(68,204,68,0.65); }
    .cn-node.cn-node-fail  { outline: 2px solid #ff5555;       box-shadow: 0 0 22px rgba(255,85,85,0.55); }
    /* Every package flashes every block it passes (25 pkgs × blocks per run) —
       each flash repaints a blurred shadow. Touch keeps the cheap outline as
       feedback; only the final ok/fail verdict keeps a (smaller) glow (#6). */
    @media (hover: none) and (pointer: coarse) {
      .cn-node.cn-node-pulse { box-shadow: none; }
      .cn-node.cn-node-ok    { box-shadow: 0 0 10px rgba(68,204,68,0.6); }
      .cn-node.cn-node-fail  { box-shadow: 0 0 10px rgba(255,85,85,0.5); }
    }
    .cn-wrap.cn-simulating .cn-node,
    .cn-wrap.cn-simulating .cn-port { pointer-events: none; cursor: default; }
    .cn-simulating .cntb-card { opacity: 0.35; pointer-events: none; }
    /* Sim progress in cn-bar */
    .sim-progress-bar { width: 90px; height: 3px; background: var(--border); flex-shrink: 0; }
    .sim-progress-fill { height: 100%; background: var(--red); transition: width 0.25s; }
    .sim-counter { font-size: 0.7rem; color: var(--text3); }
    .sim-timer   { font-size: 0.7rem; color: var(--text2); font-variant-numeric: tabular-nums; min-width: 40px; text-align: right; }
    .result-time { font-size: 0.8rem; color: var(--text3); margin-top: 4px; }
    .hs-timer { font-size: 1.4rem; color: var(--text3); font-variant-numeric: tabular-nums; margin-left: auto; }
    .hs-result-panel { border-top: 1px solid var(--border); padding: 16px 0 0; margin-top: 20px; }
    .hs-result-inner { display: flex; align-items: center; gap: 24px; }
    .hs-result-left  { display: flex; align-items: baseline; gap: 10px; }
    .hs-result-right { margin-left: auto; text-align: right; }
    .hs-time-val           { font-size: 2.2rem; font-weight: 900; color: #f0c040; line-height: 1; }
    .hs-time-val.pass      { color: var(--green); }
    .hs-time-val.fail      { color: #ff5555; }
    .hs-pps-val            { font-size: 0.7rem; color: #f0c040; margin-top: 3px; }
    .hs-result-right.pass .hs-pps-val { color: var(--green); opacity: 0.8; }
    .hs-result-right.fail .hs-pps-val { color: #ff5555;      opacity: 0.8; }

    /* ─── TUTORIAL MODAL ─────────────────────────────────────────── */
    .tut-overlay {
      position: absolute; inset: 0;
      background: rgba(0,0,0,0.80);
      display: none; align-items: center; justify-content: center;
      z-index: 200;
    }
    .tut-overlay.show { display: flex; }
    .tut-modal {
      background: var(--bg2);
      border: 1px solid var(--border2);
      border-radius: 8px;
      padding: 28px 30px 24px;
      max-width: 400px;
      width: 90%;
      display: flex; flex-direction: column; gap: 14px;
    }
    .tut-step-ind {
      font-size: 0.65rem; font-weight: 700; letter-spacing: 2px;
      text-transform: uppercase; color: var(--text3); min-height: 1em;
    }
    .tut-title {
      font-size: 1.05rem; font-weight: 700; color: var(--text);
    }
    .tut-body {
      font-size: 0.82rem; color: var(--text2); line-height: 1.6;
    }
    .tut-footer {
      display: flex; justify-content: space-between; align-items: center; margin-top: 6px;
    }
    .tut-skip {
      background: none; border: none; color: var(--text3);
      font-size: 0.72rem; cursor: pointer; padding: 4px 0;
    }
    .tut-skip:hover { color: var(--text2); }

    /* ─── Tutorial visuals: the explained object, right of the text ────
       Miniatures built from the game's own look (switch cards, ports,
       belts, packages) so they stay true to what the player sees. */
    .tut-row { display: flex; gap: 14px; align-items: center; }
    .tut-body { flex: 1 1 auto; min-width: 0; }
    .tut-visual {
      flex: 0 0 104px; display: flex; flex-direction: column;
      align-items: center; justify-content: center; gap: 10px;
      pointer-events: none; user-select: none;
    }
    .tut-visual:empty { display: none; }
    /* with a visual, ease the side padding so text+visual sit centred */
    .tut-modal.has-visual { padding-left: 22px; padding-right: 20px; }
    .tv-card {
      position: relative; width: 96px; border-radius: 5px; border: 2px solid #07090b;
      padding: 5px 10px 5px 12px; display: flex; flex-direction: column; gap: 1px; --mc: #888;
      background: linear-gradient(180deg,
        color-mix(in srgb, var(--mc) 16%, #23282c), color-mix(in srgb, var(--mc) 8%, #15181b));
      box-shadow: inset 0 1px 0 rgba(255,255,255,0.08),
        inset 0 0 0 1px color-mix(in srgb, var(--mc) 26%, transparent), 0 2px 5px rgba(0,0,0,0.4);
    }
    .tv-tag  { font-size: 0.44rem; font-weight: 800; letter-spacing: 2px; text-transform: uppercase;
               color: color-mix(in srgb, var(--mc) 55%, #999); }
    .tv-name { font-size: 0.66rem; font-weight: 800; color: #eef; }
    .tv-port {
      width: 16px; height: 16px; border-radius: 3px; border: 1px solid #07090b; flex-shrink: 0;
      display: inline-flex; align-items: center; justify-content: center;
      font-size: 0.6rem; font-weight: 900; color: #0a0d0f; box-shadow: 0 0 4px rgba(0,0,0,0.5);
    }
    .tv-port-out { background: var(--green); }
    .tv-port-no  { background: #ff5555; }
    .tv-port-in  { background: radial-gradient(circle at 50% 40%, #556, #111); }
    .tv-strip { display: flex; align-items: center; gap: 4px; width: 100%; position: relative; }
    .tv-belt {
      flex: 1; height: 13px;
      background: linear-gradient(180deg, #2c3a30, #17211b);
      background-image: repeating-linear-gradient(90deg, rgba(255,255,255,0.09) 0 2px, transparent 2px 7px);
      box-shadow: inset 0 0 0 1px rgba(58,209,122,0.5);
    }
    .tv-menu { width: 100%; background: #161b1f; border: 1px solid var(--border2); border-radius: 8px;
               padding: 7px; display: flex; flex-direction: column; gap: 5px; }
    .tv-menu-row { display: flex; gap: 4px; }
    .tv-opt { flex: 1; border: 2px solid var(--border2); border-radius: 5px; font-size: 0.6rem; font-weight: 800;
              text-align: center; padding: 3px 0; color: var(--text2); background: #14181c; }
    .tv-opt.tv-sel-yes { border-color: var(--green); color: #fff; background: rgba(58,209,122,0.22); }
    .tv-opt.tv-sel-no  { border-color: #ff5555;    color: #fff; background: rgba(255,85,85,0.22); }
    .tv-del { border: 1px solid rgba(204,0,0,0.5); background: rgba(204,0,0,0.15); color: #ff8888;
              border-radius: 5px; font-size: 0.5rem; font-weight: 800; text-transform: uppercase;
              padding: 4px 2px; text-align: center; }
    .tv-glow { font-size: 1.9rem; line-height: 1; display: flex; flex-direction: row-reverse;
               align-items: center; justify-content: center; gap: 4px; --mc: #888;
               filter: drop-shadow(0 0 10px var(--mc)) drop-shadow(0 0 4px var(--mc)); }
    @media (hover: none) and (pointer: coarse) {
      .tv-glow { filter: drop-shadow(0 0 7px var(--mc)); }   /* single-pass glow (#6) */
    }
    .tv-glow .tv-bolt { font-size: 0.5em; line-height: 1; }
    .tv-order { position: absolute; top: -8px; left: -8px; min-width: 16px; height: 16px; padding: 0 4px;
                border-radius: 8px; background: #0b0e11; color: #ffd24a; border: 1px solid #ffd24a;
                font-size: 0.6rem; font-weight: 900; line-height: 14px; text-align: center; }
    .tv-arrows { color: #ffd24a; font-size: 1rem; font-weight: 900; letter-spacing: 4px;
                 text-shadow: 0 0 6px rgba(255,210,74,0.55); line-height: 1; }
    .tv-drop { color: var(--red-hi); font-size: 1.15rem; line-height: 1;
               filter: drop-shadow(0 0 4px rgba(204,0,0,0.45)); }
    .tv-cell { width: 42px; height: 42px; border: 2px dashed rgba(255,210,74,0.8); border-radius: 4px;
      background-image:
        linear-gradient(to right,  rgba(255,255,255,0.07) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255,255,255,0.07) 1px, transparent 1px);
      background-size: 14px 14px;
    }
    .tv-pkg { position: relative; width: 52px; height: 52px; border: 2px solid; border-radius: 2px;
              display: flex; align-items: center; justify-content: center; font-size: 1.5rem; }
    .tv-pkg .pkg-tag { font-size: 0.5rem; }

    /* Reset choice modal (reuses the tutorial overlay/card look) */
    .cn-reset-btns { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
    .cn-reset-btns .btn { width: 100%; }
    .cn-reset-danger { border-color: rgba(204,0,0,0.55); color: #ff8888; }
    .cn-reset-danger:hover { background: rgba(204,0,0,0.2); border-color: rgba(204,0,0,0.8); color: #fff; }
    .cn-reset-btns .tut-skip { align-self: center; margin-top: 2px; }

    /* ─── Level transitions (level 2+3) in tutorial-modal look ──────
       Same card, same type sizes as .tut-modal above — the screen flow and
       the button stay exactly as before. Without .intro-tut the wrapper is
       display:contents and the level-1 intro renders unchanged. */
    .intro-tut-card { display: contents; }
    .screen.intro-tut .intro-tut-card {
      display: flex; flex-direction: column; gap: 14px;
      background: var(--bg2);
      border: 1px solid var(--border2);
      border-radius: 8px;
      padding: 28px 30px 24px;
      max-width: 400px; width: min(400px, 90vw);
      text-align: left;
      /* The intro screens live inside the mobile-scaled game box (unlike the
         help/tutorial modals, which sit on the unscaled build screen). Undo
         that scale so the card renders in REAL screen pixels — same physical
         size and type size as the ?-button messages on every device. The two
         transforms cancel out, so vw/svh below behave as real screen units. */
      transform: scale(calc(1 / var(--game-scale, 1)));
      transform-origin: center;
      max-height: 88svh;
      overflow-y: auto;
    }
    .screen.intro-tut .badge {          /* → like .tut-step-ind */
      background: none; padding: 0; margin: 0;
      font-size: 0.65rem; letter-spacing: 2px; color: var(--text3);
    }
    .screen.intro-tut h2 {              /* → like .tut-title */
      font-size: 1.05rem; font-weight: 700; color: var(--text);
      letter-spacing: normal; text-transform: none; margin: 0; line-height: 1.6;
    }
    .screen.intro-tut p,
    .screen.intro-tut .hint-text {      /* → like .tut-body */
      font-size: 0.82rem; color: var(--text2); line-height: 1.6;
      margin: 0; max-width: none;
    }
    .screen.intro-tut .info-box {
      background: none; border: 0; padding: 0; margin: 0; max-width: none; width: auto;
    }
    .screen.intro-tut .mt28 {           /* → like .tut-footer */
      margin-top: 6px; display: flex; justify-content: flex-end; width: 100%;
    }
    .screen.intro-tut .btn {            /* → tut "Weiter"-button size (btn-sm) */
      padding: 8px 18px; font-size: 0.75rem;
    }
    /* Flat phone screens: tighten the card's spacing so the whole message fits
       without inner scrolling — even with the browser toolbar still visible. */
    @media (max-height: 500px) {
      .screen.intro-tut .intro-tut-card { padding: 16px 24px 14px; gap: 9px; max-height: 94svh; }
      .screen.intro-tut h2 { line-height: 1.3; }
      .screen.intro-tut p,
      .screen.intro-tut .hint-text { line-height: 1.45; }
      .screen.intro-tut .mt28 { margin-top: 0; }
    }

    /* ─── FINALE SCREEN ─────────────────────────────────────────── */
    .finale-grid {
      display: grid; grid-template-columns: repeat(3, 1fr);
      gap: 14px; width: 100%; max-width: 680px; margin: 24px 0;
    }
    .finale-card {
      background: var(--bg2); border: 1px solid var(--border);
      border-top: 2px solid var(--red); padding: 20px 14px; text-align: center;
    }
    .finale-card .fc-icon { font-size: 2.2rem; margin-bottom: 8px; }
    .finale-card .fc-title {
      font-size: 0.72rem; font-weight: 700; letter-spacing: 2px;
      text-transform: uppercase; color: var(--red); margin-bottom: 6px;
    }
    .finale-card p { font-size: 0.8rem; color: var(--text2); margin: 0; }
    .tool-chips { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin: 12px 0; }
    .tool-chip {
      background: transparent; border: 1px solid var(--red);
      color: var(--red); padding: 6px 18px;
      font-size: 0.82rem; font-weight: 700; letter-spacing: 1px;
    }

    /* ─── Game Size Tuning ──────────────────────────────────────── */
    .game-box { max-width: 1080px; }
    .screen { padding: 42px 36px; }
    .screen h2 { font-size: 1.86rem; letter-spacing: 2px; }
    .screen h3 { font-size: 1.05rem; }
    .screen p  { font-size: 0.94rem; line-height: 1.62; }
    .info-box p  { font-size: 0.82rem; }
    .hint-text   { font-size: 0.76rem; }
    .game-box .btn    { padding: 10px 22px; font-size: 0.78rem; letter-spacing: 1.4px; }
    .game-box .btn-sm { padding: 7px 15px;  font-size: 0.7rem; }
    .hs-header .title, .hs-header .counter { font-size: 1.31rem; }
    .sort-target  { font-size: 1.43rem; letter-spacing: 1.5px; }
    .pkg          { width: 78px; height: 78px; }
    .pkg-icon     { font-size: 1.72rem; }
    .pkg-name     { font-size: 1.05rem; }
    .score-num    { font-size: 2.35rem; }
    .result-msg   { font-size: 0.76rem; }
    .finale-card .fc-icon  { font-size: 1.9rem; }
    .finale-card .fc-title { font-size: 0.66rem; }
    .tool-chip    { font-size: 0.76rem; }

    /* ─── Contact ─────────────────────────────────────────────────── */
    .contact {
      position: relative;
      padding: 80px 18px;
      border-top: 1px solid var(--site-border);
      background:
        linear-gradient(180deg, rgba(21, 27, 30, 0.9), rgba(13, 18, 20, 0.95)),
        url("https://edvsupport-nbg.de/img/25_2x.jpg") center / cover no-repeat;
    }
    .contact-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 18px;
      max-width: 1200px;
      margin: 0 auto;
    }
    .contact-card {
      background: rgba(21, 27, 30, 0.82);
      border: 1px solid var(--site-border);
      border-radius: var(--site-radius);
      box-shadow: var(--site-shadow);
      padding: 22px;
    }
    .contact-card h2, .contact-card h3 {
      margin: 0 0 14px;
      color: #fff;
      font-family: "Lexend Deca", "Nunito", sans-serif;
      line-height: 1.2;
    }
    .contact-card h2 { font-size: 1.5rem; }
    .contact-card h3 { font-size: 1.17rem; }
    .contact-muted { margin: 0 0 20px; color: var(--site-muted); font-size: 1rem; line-height: 1.6; }
    .contact-muted strong { color: var(--site-text); }
    .contact-list { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
    .contact-item { display: grid; grid-template-columns: 44px 1fr; gap: 10px; align-items: center; color: #fff; line-height: 1.55; }
    .contact-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; background: rgba(255,51,0,0.2); color: var(--site-accent); font-size: 1.08rem; }
    .contact-item a { color: var(--site-accent); text-decoration: none; }
    .contact-item a:hover { color: #fff; }
    .contact-action { margin-top: 20px; }
    .contact-button {
      display: inline-flex; align-items: center; justify-content: center;
      gap: 10px; padding: 12px 18px;
      border: 1px solid var(--site-border); border-radius: 10px;
      background: rgba(255,255,255,0.02); color: var(--site-text);
      text-decoration: none; text-transform: uppercase; font-weight: 800;
    }
    .contact-button:hover { border-color: var(--site-accent); color: #fff; }
    .contact-form { display: grid; gap: 12px; }
    .contact-form input, .contact-form textarea {
      width: 100%; border: 1px solid var(--site-border); border-radius: 10px;
      background: #0f1418; color: var(--site-text); font: inherit; font-size: 1rem; padding: 12px 14px;
    }
    .contact-form textarea { min-height: 102px; resize: vertical; }
    .contact-form input:focus, .contact-form textarea:focus {
      outline: 1px solid var(--site-accent); box-shadow: 0 0 0 3px rgba(255,51,0,0.18);
    }
    .contact-submit {
      width: 100%; min-height: 44px; border: 0; border-radius: 10px;
      background: var(--site-accent); color: #050708; font-weight: 900;
      text-transform: uppercase; box-shadow: 0 16px 34px rgba(255,51,0,0.26); cursor: pointer;
    }
    .contact-submit:hover { background: #ff5530; }
    .notice { min-height: 1.4em; color: var(--site-muted); font-size: 0.95rem; }
    .hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; opacity: 0; }

    /* ─── Site Footer ─────────────────────────────────────────────── */
    .site-footer {
      text-align: center;
      padding: 22px 18px;
      border-top: 1px solid var(--site-border);
      background: #0a0d0f;
      color: var(--site-muted);
      font-size: 0.95rem;
    }
    .footer-links {
      margin-top: 8px;
      display: flex;
      justify-content: center;
      flex-wrap: wrap;
      gap: 10px 14px;
    }
    .footer-links a { color: var(--site-muted); }
    .footer-links a:hover { color: #fff; }

    @media (max-width: 820px) {
      .nav-bar { align-items: flex-start; flex-direction: column; gap: 12px; }
      .site-nav { flex-wrap: wrap; gap: 8px; }
      .site-nav a { padding: 6px 10px; }
      .nav-dropdown { width: 100%; }
      .nav-dropdown-toggle {
        width: 100%;
        justify-content: space-between;
        padding: 6px 10px;
      }
      .dropdown-menu {
        position: static;
        background: rgba(255, 255, 255, 0.05);
        border-radius: 8px;
        margin-top: 4px;
        padding: 4px;
      }
      .dropdown-menu::before { display: none; }
      .nav-dropdown:hover .dropdown-menu,
      .nav-dropdown:focus-within .dropdown-menu,
      .nav-dropdown.open .dropdown-menu {
        display: flex;
      }
      .page-intro { grid-template-columns: 1fr; }
      .game-hero { padding-top: 72px; }
      .contact-grid { grid-template-columns: 1fr; }
      .contact-card { min-height: auto; }
    }

    @media (max-width: 560px) {
      .brand img { height: 34px; }
      .site-nav { font-size: 0.9rem; }
      .game-hero { padding-left: 12px; padding-right: 12px; }
      .page-intro-text h1 { font-size: 2rem; }
      .intro-card { padding: 18px; }
      .contact { padding: 64px 16px; }
      .contact-card { padding: 22px; }
      .contact-button { width: 100%; }
    }

    @media (max-width: 920px) and (orientation: portrait) {
      body { min-height: 100svh; }
      .page-intro,
      .game-section-label,
      .game-viewport,
      .site-note,
      .contact,
      .site-footer {
        display: none;
      }
      .game-hero {
        min-height: calc(100svh - 70px);
        padding: 18px;
        display: grid;
        align-items: center;
      }
      .mobile-rotate-notice { display: grid; }
    }

    @media (max-width: 920px) and (orientation: landscape) {
      /* Deliberately NOT overflow:hidden — iOS Safari only collapses its
         toolbars when the page is scrollable. A 1px buffer beyond the dynamic
         viewport keeps the page "swipeable": the first swipe-up minimises the
         browser chrome, and the 100dvh layout grows into the freed space
         (updateGameScale listens on visualViewport for exactly this). */
      html,
      body {
        height: 100%;
      }
      body {
        overflow-x: hidden;
        min-height: calc(100dvh + 1px);
      }
      .site-header,
      .page-intro,
      .game-section-label,
      .site-note,
      .contact,
      .site-footer {
        display: none;
      }
      .page-content,
      .game-hero {
        min-height: 100dvh;
      }
      .game-hero {
        /* Fill mode: top/bottom reach the physical screen edges (the game runs
           under the iOS home indicator, like fullscreen video); only inset
           left/right where the notch can sit (viewport-fit=cover). Solid dark
           background instead of the hero photo, so the notch insets blend into
           the game frame instead of reading as bright side bars. */
        padding: 0 max(4px, env(safe-area-inset-right)) 0 max(4px, env(safe-area-inset-left));
        background: var(--bg1);
        display: flex;
        align-items: flex-start;
      }
      .game-hero .site-shell {
        max-width: none;
        width: 100%;
      }
      .game-viewport {
        /* 624 = 620px screen min-height + 4px game-box border — matches the JS.
           Bewusst KEIN max-height: 100dvh — mit korrektem --game-scale passt die
           Höhe ohnehin in den Viewport. Verpasst das JS aber mal ein Dreh-Signal
           (Scale bleibt 1), hat die Seite dank echter Layout-Höhe Scrollweg und
           der überstehende Rest bleibt erreichbar, statt hart abgeschnitten. */
        height: calc(624px * var(--game-scale));
        align-items: flex-start;
        overflow: visible;
      }
      .game-box {
        /* JS stretches --game-w so logical-width × scale spans the full screen. */
        width: var(--game-w, 1080px);
        max-width: none;
        flex: 0 0 auto;
        transform: scale(var(--game-scale));
        transform-origin: top center;
      }
      /* Build screen: fill the whole landscape viewport (no letterbox). The grid
         is elastic and absorbs the phone's aspect ratio; menus stay scaled above. */
      .game-viewport:has(#screen-build-chain.active) {
        height: 100dvh; max-height: 100dvh; align-items: stretch;
      }
      .game-box:has(#screen-build-chain.active) {
        width: 100%; height: 100dvh; min-height: 0;
        transform: none; flex: 1 1 auto;
      }
      /* Hand-sort inbox: the game box is scaled to ~63% on phones, which makes
         these small labels unreadably tiny — bump them for mobile landscape. */
      .hs-source .src-label { font-size: 2.25rem; letter-spacing: 2.5px; }
      .pkg-name             { font-size: 1.79rem; }
      .pkg-icon             { font-size: 2.4rem; }
      #screen-build-chain { min-height: 0; height: 100%; }
      /* Compact build-screen chrome (the fill mode no longer down-scales the UI):
         decorative title + BLÖCKE heading go, status moves into the field toast,
         NEU shrinks to an icon, bar + palette cards tighten up. */
      .cn-bar { padding: 4px 8px; gap: 6px; }
      .cn-bar-title, .cn-status, .cntb-title { display: none; }
      .game-box .cn-bar .btn-sm { padding: 5px 10px; font-size: 0.64rem; letter-spacing: 1px; }
      .cn-clear-ico { display: inline; }
      .cn-clear-btn span + span { display: none; }
      .cn-toolbar { width: 124px; padding: 8px; }
      .cntb-card { padding: 4px 8px 4px 12px; }
      .cntb-card-label { font-size: 0.6rem; }
      .cntb-tag { font-size: 0.4rem; letter-spacing: 1.5px; }
      /* #3: Der Füllmodus skaliert die ganze Spielbox herunter — die Tutorial-
         Karte schrumpfte auf allen Screens außer der (unskaliert dargestellten)
         Bauphase mit. Die Karte rechnet die Box-Verkleinerung hier gegen und
         ist damit überall gleich groß wie in der Bauphase. */
      .game-box:not(:has(#screen-build-chain.active)) .tut-modal {
        transform: scale(calc(1 / var(--game-scale, 1)));
      }
    }


    /* Lightmode for the complete game UI. */
    body.light-mode {
      --bg:       #f6f8fb;
      --bg1:      #ffffff;
      --bg2:      #eef2f6;
      --bg3:      #e1e7ee;
      --border:   #d7dee7;
      --border2:  #b9c4d1;
      --text:     #18212b;
      --text2:    #4f5d6b;
      --text3:    #7a8795;
      --red-dim:  #9f2d1e;
      --site-bg: #f4f7fa;
      --site-card: #ffffff;
      --site-card-strong: #eef3f7;
      --site-text: #17202a;
      --site-muted: #5f6b78;
      --site-border: #d8e0e8;
      --site-shadow: 0 14px 36px rgba(23, 32, 42, 0.14);
      background: var(--site-bg);
      color: var(--site-text);
    }
    body.light-mode .site-header { background: rgba(255,255,255,0.94); }
    body.light-mode .site-card,
    body.light-mode .intro-card,
    body.light-mode .contact-panel,
    body.light-mode .game-box {
      background: #fff;
      border-color: var(--site-border);
      color: var(--text);
      box-shadow: 0 16px 38px rgba(23,32,42,0.12);
    }
    body.light-mode #screen-hand-sort {
      background:
        radial-gradient(circle at 24% 36%, rgba(255, 85, 51, 0.13), transparent 34%),
        radial-gradient(circle at 82% 18%, rgba(68, 136, 255, 0.11), transparent 32%),
        linear-gradient(180deg, #f7fafd 0%, #edf3f8 100%);
    }
    body.light-mode .hs-header,
    body.light-mode .cn-bar {
      background: rgba(255,255,255,0.92);
      border-color: var(--border);
      box-shadow: 0 8px 20px rgba(23,32,42,0.09);
    }
    body.light-mode .cn-icon-btn {
      background: rgba(255,255,255,0.94);
      border-color: var(--border2);
      color: var(--text2);
      box-shadow: 0 2px 8px rgba(23,32,42,0.12);
    }
    body.light-mode .cn-icon-btn:hover,
    body.light-mode .cn-theme-btn[aria-pressed="true"] {
      background: #eaf1f8;
      border-color: #8da0b6;
      color: var(--text);
    }
    body.light-mode .hs-workbench,
    body.light-mode .hs-source,
    body.light-mode .hs-scan-window,
    body.light-mode .hs-route-question,
    body.light-mode .hs-data-chip,
    body.light-mode .result-panel,
    body.light-mode .tut-modal,
    body.light-mode .cn-toolbar,
    body.light-mode .cn-grid-wrap,
    body.light-mode .cn-blockmenu {
      background-color: rgba(255,255,255,0.9);
      border-color: var(--border);
      color: var(--text);
      box-shadow: 0 12px 28px rgba(23,32,42,0.10);
    }
    body.light-mode .hs-workbench {
      background:
        linear-gradient(90deg, rgba(58,120,170,0.08) 0 1px, transparent 1px),
        linear-gradient(0deg, rgba(45,61,76,0.08) 0 1px, transparent 1px),
        radial-gradient(circle at 50% 8%, rgba(255,255,255,0.85), transparent 38%),
        #f4f8fb;
      background-size: 34px 34px, 34px 34px, auto, auto;
    }
    body.light-mode .hs-source {
      background: linear-gradient(180deg, #fff, #eef4f8);
      border-color: var(--border2);
      border-top-color: rgba(255,51,0,0.55);
    }
    body.light-mode .hs-scan-window {
      background: radial-gradient(circle at 50% 45%, rgba(255,255,255,0.95), rgba(213,224,234,0.65) 62%), #edf3f8;
    }
    body.light-mode .hs-scan-window::before { color: rgba(24,33,43,0.32); }
    body.light-mode .hs-conveyor-rail {
      background:
        repeating-linear-gradient(90deg, rgba(24,33,43,0.18) 0 7px, transparent 7px 22px),
        linear-gradient(180deg, #d9e3ec, #aebbc7);
      box-shadow: inset 0 0 0 2px rgba(58,120,170,0.18), inset 0 12px 18px rgba(255,255,255,0.35), inset 0 -12px 18px rgba(23,32,42,0.12);
    }
    body.light-mode .hs-conveyor-rail::before,
    body.light-mode .hs-conveyor-rail::after { background: #f8fbfd; border-color: rgba(24,33,43,0.18); }
    body.light-mode .sort-target {
      background:
        radial-gradient(circle at 20% 20%, color-mix(in srgb, var(--mc) 16%, transparent), transparent 46%),
        linear-gradient(180deg, rgba(255,255,255,0.92), rgba(238,244,249,0.82));
      border-color: color-mix(in srgb, var(--mc) 28%, var(--border));
      box-shadow: 0 8px 20px rgba(23,32,42,0.08);
    }
    body.light-mode .sort-target::before {
      background: linear-gradient(180deg, color-mix(in srgb, var(--mc) 20%, #fff), #eef3f7);
    }
    body.light-mode .sort-target::after { color: rgba(24,33,43,0.35); }
    body.light-mode .sort-target .st-name,
    body.light-mode .hs-route-question,
    body.light-mode .hs-data-chip strong,
    body.light-mode .cn-edge-label,
    body.light-mode .cn-node-target .cn-tgt-label { color: var(--text); }
    body.light-mode .pkg[data-farbe="rot"]   { background: #fff0eb; border-color: #e25d3a; color: #b93018; }
    body.light-mode .pkg[data-farbe="blau"]  { background: #eef4ff; border-color: #3f74d8; color: #245ab6; }
    body.light-mode .pkg[data-farbe="gruen"] { background: #e9fbf5; border-color: #169b78; color: #087d60; }
    body.light-mode .cn-canvas {
      background-color: #f6f9fc;
      background-image:
        radial-gradient(circle at center, rgba(25,35,45,0.08) 0 1px, transparent 1.5px),
        linear-gradient(to right, rgba(25,35,45,0.08) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(25,35,45,0.08) 1px, transparent 1px);
    }
    body.light-mode .cn-belt-stub { background: #cfd8e2; }
    body.light-mode .cn-belt.cn-belt-flow .cn-belt-stub { background: #b9d8c8; }
    body.light-mode .cn-belt-arrow { color: rgba(18,95,55,0.74); text-shadow: none; }
    body.light-mode .cntb-card,
    body.light-mode .tv-card,
    body.light-mode .cn-block,
    body.light-mode .cn-node-if,
    body.light-mode .cn-node-target,
    body.light-mode .cn-edge {
      background: linear-gradient(180deg,
        color-mix(in srgb, var(--mc, #8899aa) 13%, #ffffff),
        color-mix(in srgb, var(--mc, #8899aa) 7%, #edf3f8));
      border-color: #9aa8b7;
      color: var(--text);
      box-shadow:
        inset 0 2px 0 rgba(255,255,255,0.85),
        inset 0 0 0 1px color-mix(in srgb, var(--mc, #8899aa) 22%, transparent),
        0 8px 18px rgba(23,32,42,0.14);
    }
    body.light-mode .cn-node-start {
      background: linear-gradient(180deg, #f9fbfd 0%, #e8eef4 55%, #d7e0e9 100%);
      border-color: #9aa8b7;
    }
    body.light-mode .mc-hatch::before,
    body.light-mode .mc-door::before,
    body.light-mode .mc-scanner-head,
    body.light-mode .hs-scanner-head { background: linear-gradient(180deg, #e7eef5, #b9c6d4); }
    body.light-mode .mc-hatch-mouth,
    body.light-mode .mc-door-mouth,
    body.light-mode .mc-intake { background: radial-gradient(ellipse at 50% 45%, #d8e1ea, #7e8d9b 82%); }
    body.light-mode .mc-vents span { background: linear-gradient(180deg, #cad5df, #edf3f8); }
    body.light-mode .cn-edge-in { background: #eef3fb; }
    body.light-mode .cn-toast { background: rgba(255,255,255,0.95); border-color: var(--border2); }
    body.light-mode .tut-overlay { background: rgba(241,246,250,0.72); }
    body.light-mode .btn-outline { background: #fff; }
    /* Hover wieder rot/weiß: die #fff-Regel oben gewann sonst gegen den
       .btn-outline:hover-Hintergrund und ließ weiße Schrift auf Weiß zurück
       (z. B. „Überspringen" in der Simulation) (#21). */
    body.light-mode .btn-outline:hover { background: var(--red); color: #fff; }
    /* Lesbare Schrift im Lightmode (#21): helle Texte, die auf den nun hellen
       Flächen unsichtbar wurden. */
    /* Sidebar-Karten: kräftigere Tönung in der Weichenfarbe + Name in einer
       dunklen, satten Variante derselben Farbe — lesbar UND identifizierend. */
    body.light-mode .cntb-card {
      background: linear-gradient(180deg,
        color-mix(in srgb, var(--mc) 30%, #ffffff),
        color-mix(in srgb, var(--mc) 16%, #eef3f8));
      border-color: color-mix(in srgb, var(--mc) 45%, #9aa8b7);
    }
    body.light-mode .cntb-tag { color: color-mix(in srgb, var(--mc) 70%, #445); }
    body.light-mode .cntb-card-label {
      color: color-mix(in srgb, var(--mc) 72%, #111);
      text-shadow: none;
    }
    body.light-mode .cn-bm-side {
      background: #eef2f6;
      color: var(--text2);
      border-color: var(--border2);
    }
    body.light-mode .cn-bm-opts-match .cn-bm-side.sel,
    body.light-mode .cn-bm-opts-else  .cn-bm-side.sel { color: var(--text); }
    /* ─── Mobile/touch polish pass ────────────────────────────────────
       Bigger endpoints, chunkier belts, fewer-but-clearer tiles and a native
       landscape phone layout. Desktop keeps the original page shell. */
    .cn-canvas {
      --belt-core: calc(var(--cell-w, 64px) * 0.52);
      background-image:
        radial-gradient(circle at center, rgba(255,255,255,0.045) 0 1px, transparent 1.5px),
        linear-gradient(to right,  rgba(255,255,255,0.055) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255,255,255,0.055) 1px, transparent 1px);
      background-size: var(--cell-w) var(--cell-h), var(--cell-w) var(--cell-h), var(--cell-w) var(--cell-h);
    }
    .cn-belt-stub {
      background: #2b322e;
    }
    .cn-stub-right { top: calc(50% - var(--belt-core) / 2); height: var(--belt-core); left: calc(50% - var(--belt-core) / 2); right: -1px; }
    .cn-stub-left  { top: calc(50% - var(--belt-core) / 2); height: var(--belt-core); right: calc(50% - var(--belt-core) / 2); left: -1px; }
    .cn-stub-up    { left: calc(50% - var(--belt-core) / 2); width: var(--belt-core); bottom: calc(50% - var(--belt-core) / 2); top: -1px; }
    .cn-stub-down  { left: calc(50% - var(--belt-core) / 2); width: var(--belt-core); top: calc(50% - var(--belt-core) / 2); bottom: -1px; }
    .cn-belt.cn-belt-flow .cn-belt-stub {
      background: #2c4536;
    }
    .cn-belt-arrow {
      font-size: calc(var(--cell-w, 64px) * 0.24);
      font-weight: 700;
      color: rgba(234,255,240,0.55);
      text-shadow: none;
    }
    .cn-pkg-fly {
      width: calc(var(--cell-w, 64px) * 0.82);
      height: calc(var(--cell-w, 64px) * 0.82);
      border-width: 3px;
      border-radius: calc(var(--cell-w, 64px) * 0.16);
      font-size: calc(var(--cell-w, 64px) * 0.36);
      box-shadow: 0 8px 16px rgba(0,0,0,0.45), 0 0 12px rgba(255,255,255,0.12);
    }
    .cn-edge {
      border-radius: calc(var(--cell-w, 64px) * 0.18);
      border-width: 3px;
      box-shadow:
        inset 0 2px 0 rgba(255,255,255,0.12),
        inset 0 -10px 18px rgba(0,0,0,0.42),
        inset 0 0 0 2px color-mix(in srgb, var(--mc) 32%, transparent),
        0 10px 24px rgba(0,0,0,0.58),
        0 0 20px color-mix(in srgb, var(--mc) 25%, transparent);
    }
    .cn-edge-icon { font-size: calc(var(--cell-w, 64px) * 1.05); }
    .cn-tgt-shelf .cn-edge-icon { font-size: calc(var(--cell-w, 64px) * 1.35); }
    .mc-label { font-size: calc(var(--cell-w, 64px) * 0.30); }
    .cn-edge-start .mc-label { font-size: calc(var(--cell-w, 64px) * 0.39); }
    .cn-edge-label { font-size: calc(var(--cell-w, 64px) * 0.23); max-width: 94%; overflow-wrap: anywhere; }
    #cn-node-tgt-reklamation .cn-edge-label { font-size: calc(var(--cell-w, 64px) * 0.18); }
    .mc-hatch-right, .mc-hatch-left { width: calc(var(--cell-w, 64px) * 0.42); height: calc(var(--cell-w, 64px) * 0.86); }
    .mc-hatch-up, .mc-hatch-down { width: calc(var(--cell-w, 64px) * 0.86); height: calc(var(--cell-w, 64px) * 0.42); }
    .cn-edge-port {
      width: calc(var(--cell-w, 64px) * 0.72);
      height: calc(var(--cell-w, 64px) * 0.72);
      border-radius: calc(var(--cell-w, 64px) * 0.18);
      border-width: 3px;
      box-shadow: 0 0 16px rgba(0,0,0,0.74), 0 0 18px color-mix(in srgb, var(--mc, #fff) 38%, transparent);
    }
    .cn-ep-right { right: calc(var(--cell-w, 64px) * -0.37); }
    .cn-ep-left  { left:  calc(var(--cell-w, 64px) * -0.37); }
    .cn-ep-down  { bottom: calc(var(--cell-w, 64px) * -0.37); }
    .cn-ep-up    { top:    calc(var(--cell-w, 64px) * -0.37); }
    .cn-block {
      border-radius: calc(var(--cell-w, 64px) * 0.16);
      border-width: 3px;
    }
    .cn-block .cn-if-tag { font-size: calc(var(--cell-w, 64px) * 0.29); letter-spacing: 1px; }
    .cn-block-express .cn-if-tag { font-size: calc(var(--cell-w, 64px) * 0.23); }
    .cn-block-port {
      width: calc(var(--cell-w, 64px) * 0.84);
      height: calc(var(--cell-w, 64px) * 0.84);
      border-radius: calc(var(--cell-w, 64px) * 0.19);
      font-size: calc(var(--cell-w, 64px) * 0.34);
      border-width: 3px;
      box-shadow: 0 0 16px rgba(0,0,0,0.74), 0 0 18px color-mix(in srgb, var(--mc, #fff) 38%, transparent);
    }
    .cn-bp-left  { left:   calc(var(--cell-w, 64px) * -0.43); }
    .cn-bp-right { right:  calc(var(--cell-w, 64px) * -0.43); }
    .cn-bp-up    { top:    calc(var(--cell-w, 64px) * -0.43); }
    .cn-bp-down  { bottom: calc(var(--cell-w, 64px) * -0.43); }
    .cn-block-order { min-width: 30px; height: 30px; border-radius: 15px; line-height: 28px; font-size: 1rem; }

    @media (max-width: 920px) and (orientation: landscape) {
      .cn-layout { flex-direction: column-reverse; }
      .cn-toolbar {
        width: 100%; height: 82px; flex-direction: row; align-items: stretch;
        border-right: 0; border-top: 1px solid var(--border);
        padding: 8px max(8px, env(safe-area-inset-right)) 8px max(8px, env(safe-area-inset-left));
        overflow-x: auto; overflow-y: hidden;
        background: linear-gradient(180deg, rgba(17,17,17,0.94), rgba(9,12,14,0.98));
      }
      .cn-toolbar.cn-collapsed { width: 100%; height: 0; padding-top: 0; padding-bottom: 0; border-top: 0; overflow: hidden; }
      .cntb-cards { flex: 1 1 auto; flex-direction: row; align-items: stretch; gap: 8px; overflow-x: auto; overflow-y: hidden; }
      .cntb-card {
        min-width: 112px; justify-content: center; border-radius: 14px;
        padding: 8px 12px 8px 16px;
        box-shadow: inset 0 1px 0 rgba(255,255,255,0.10), inset 0 0 0 1px color-mix(in srgb, var(--mc) 34%, transparent), 0 8px 18px rgba(0,0,0,0.48);
      }
      .cntb-card-label { font-size: 0.86rem; line-height: 1.05; }
      .cntb-tag { font-size: 0.52rem; }
      .cntb-arrow { display: none; }
      .cntb-hint { display: none; }
      .cn-bar {
        min-height: 46px; padding: 5px max(8px, env(safe-area-inset-right)) 5px max(8px, env(safe-area-inset-left));
        background: rgba(10,14,16,0.96);
      }
      .game-box .cn-bar .btn-sm { min-height: 40px; padding: 0 14px; border-radius: 12px; font-size: 0.72rem; }
      .cn-tb-toggle { width: 42px; height: 36px; border-radius: 10px; font-size: 1.05rem; }
      .cn-bar-tools { gap: 6px; }
      .cn-icon-btn { width: 40px; height: 40px; border-radius: 12px; font-size: 1.16rem; background: rgba(10,14,16,0.88); }
      .cn-toast { bottom: 96px; font-size: 0.86rem; padding: 8px 14px; border-radius: 12px; }
      .cn-blockmenu { width: min(380px, calc(100vw - 24px)); padding: 18px; font-size: 0.95rem; border-radius: 18px; }
      .cn-bm-side { min-height: 56px; border-radius: 12px; }
      .cn-bm-del { min-height: 50px; border-radius: 12px; }

      #screen-hand-sort { padding: 10px 12px; }
      .hs-header { margin-bottom: 10px; padding: 7px 10px; border-radius: 13px; }
      .hs-header .title { font-size: 1.61rem; letter-spacing: 1.7px; }
      .hs-header .counter, .hs-timer { font-size: 1.65rem; }
      .hs-stage { grid-template-columns: 430px 1fr; gap: 12px; min-height: 0; }
      .hs-workbench { min-height: 0; border-radius: 20px; padding: 12px; }
      .hs-conveyor-rail { height: 58px; }
      .hs-source { width: 100%; max-width: 410px; border-radius: 22px; padding: 13px; gap: 9px; }
      .hs-source .src-label { font-size: 1.91rem; letter-spacing: 2.2px; }
      .hs-scan-window { min-height: 200px; border-radius: 18px; }
      .hs-package-data { gap: 5px; }
      .hs-data-chip { padding: 5px 4px; border-radius: 10px; }
      .hs-data-chip span { font-size: 1.01rem; }
      .hs-data-chip strong { font-size: 1.5rem; }
      .hs-route-question { min-height: 48px; font-size: 1.58rem; border-radius: 12px; padding: 0 12px; }
      .hs-target-panel { gap: 9px; }
      .hs-targets { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
      .sort-target { min-height: 88px; border-radius: 18px; border-left-width: 5px; padding: 10px 28px 10px 67px; }
      .sort-target::before { left: 11px; width: 45px; height: 45px; border-radius: 14px; }
      .sort-target::after { right: 9px; font-size: 1.7rem; }
      .sort-target .st-icon { left: 16px; width: 34px; height: 42px; font-size: 2.05rem; }
      .sort-target .st-kicker { font-size: 0.93rem; }
      .sort-target .st-name { font-size: 1.8rem; }
      .sort-target .st-rule { font-size: 1.05rem; padding: 4px 7px; }
      .pkg { width: 126px; height: 126px; border-radius: 18px; border-width: 3px; }
      .pkg-icon { font-size: 3.4rem; }
      .pkg-name { font-size: 1.84rem; }
      .pkg-tag { top: -10px; right: -10px; font-size: 1.35rem; border-radius: 999px; padding: 4px 7px; }
    }

    /* ─── HOCHFORMAT-MODUS (body.orient-hoch, Umschalter im Spiel) ──────
       'quer' ist der Standard. Im Hochformat wird das Spiel eine schmale,
       gestapelte Spalte: Scanstation oben, Ziele darunter; die Weichen-
       Leiste der Bauphase wird zum Querstreifen unter dem Feld. Auf dem
       Handy ersetzt dieser Modus den "Bitte drehen"-Hinweis. */
    body.orient-hoch .game-viewport { justify-content: center; }
    body.orient-hoch .game-box { max-width: 560px; margin: 0 auto; }
    body.orient-hoch .screen { padding: 28px 16px; }

    /* Handsortieren: eine Spalte. Die Quer-Schriftgrößen sind auf die runter-
       skalierte Handy-Queransicht abgestimmt — im Hochformat (Skalierung 1:1)
       wirken sie verzerrt, darum hier eigene, kompakte Größen. */
    body.orient-hoch .hs-stage { grid-template-columns: 1fr; gap: 10px; min-height: 0; }
    body.orient-hoch .hs-workbench { min-height: 0; padding: 10px; }
    body.orient-hoch .hs-conveyor-rail { height: 44px; }
    /* Kopfzeile darf immer umbrechen (nicht nur <400px wie ursprünglich in #23):
       auch 414/430px-iPhones sind zu schmal für Titel + Zähler + Timer + drei
       Knöpfe in einer Zeile — der Format-Umschalter wurde rechts abgeschnitten.
       flex-wrap greift nur bei echtem Platzmangel, breite Geräte unverändert. */
    body.orient-hoch .hs-header { flex-wrap: wrap; row-gap: 6px; }
    body.orient-hoch .hs-header .title { font-size: 0.95rem; }
    body.orient-hoch .hs-header .counter, body.orient-hoch .hs-timer { font-size: 0.95rem; }
    /* kompakte Scanstation */
    body.orient-hoch .hs-source { width: min(100%, 330px); padding: 12px; gap: 8px; border-radius: 18px; }
    body.orient-hoch .hs-source .src-label { font-size: 0.88rem; }
    body.orient-hoch .hs-scan-window { min-height: 126px; border-radius: 14px; }
    body.orient-hoch .pkg { width: 82px; height: 82px; border-radius: 14px; }
    body.orient-hoch .pkg-icon { font-size: 1.9rem; }
    body.orient-hoch .pkg-name { font-size: 0.72rem; }
    body.orient-hoch .pkg-tag { font-size: 0.66rem; }
    body.orient-hoch .hs-package-data { gap: 5px; }
    body.orient-hoch .hs-data-chip { padding: 4px 5px; border-radius: 8px; }
    body.orient-hoch .hs-data-chip span { font-size: 0.56rem; }
    body.orient-hoch .hs-data-chip strong { font-size: 0.82rem; }
    /* kleine, unverzerrte Ziel-Karten im 2er-Raster */
    body.orient-hoch .hs-route-question { min-height: 34px; font-size: 0.9rem; padding: 0 12px; border-radius: 10px; }
    body.orient-hoch .hs-route-question::before { font-size: 1.3rem; }
    body.orient-hoch .hs-targets { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    body.orient-hoch .sort-target { min-height: 64px; gap: 8px; padding: 8px 22px 8px 56px; border-radius: 14px; border-left-width: 4px; }
    body.orient-hoch .sort-target::before { left: 9px; width: 38px; height: 38px; border-radius: 11px; }
    body.orient-hoch .sort-target::after { right: 8px; font-size: 1.3rem; }
    body.orient-hoch .sort-target .st-icon { left: 14px; width: 28px; height: 34px; font-size: 1.5rem; }
    body.orient-hoch .sort-target .st-text { gap: 2px; }
    body.orient-hoch .sort-target .st-kicker { font-size: 0.55rem; letter-spacing: 1px; }
    body.orient-hoch .sort-target .st-name { font-size: 1.02rem; }
    body.orient-hoch .sort-target .st-rule { font-size: 0.66rem; padding: 3px 7px; }
    /* Endscreen: kompakte 3er-Karten für ALLE Hochformat-Breiten (war nur
       <400px, aus #23) — die Basis-Spalten (1fr ohne minmax(0)) dürfen nicht
       unter ihre Wortbreite schrumpfen, lange Wörter wie PRIORISIEREN drückten
       das Raster auch auf 414/430px-iPhones über den rechten Rand hinaus. */
    body.orient-hoch .finale-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
    body.orient-hoch .finale-card { padding: 12px 8px; overflow-wrap: break-word; }
    body.orient-hoch .finale-card .fc-icon { font-size: 1.7rem; margin-bottom: 6px; }
    body.orient-hoch .finale-card .fc-title { font-size: 0.6rem; letter-spacing: 1.2px; }
    body.orient-hoch .finale-card p { font-size: 0.68rem; }
    /* ─── #23: Handsortieren auf schmalen Hochformat-Geräten (< 400px, iPhone-
       Klasse). Breitere Geräte (z. B. gängige Androids mit 405–430px) bleiben
       unverändert. Der Block muss NACH allen orient-hoch-Basisregeln oben
       stehen, sonst überschreiben die ihn wieder (gleiche Spezifität →
       spätere Regel gewinnt). */
    @media (max-width: 400px) {
      /* (Der Kopfzeilen-Umbruch von hier ist zu den orient-hoch-Basisregeln
         gewandert — er wird auch auf 414/430px-iPhones gebraucht.) */
      /* Eil-/Kaputt-Schildchen deutlich lesbar (wie im Handy-Querformat)
         und leicht nach innen gerückt, damit das Scan-Fenster nichts abschneidet. */
      body.orient-hoch .pkg-tag { font-size: 1.05rem; border-radius: 999px; padding: 3px 7px; top: -8px; right: -8px; }
      /* Scanstation: Vorschau-Paket sitzt etwas tiefer im Fenster — so bleibt
         über dem Paket Platz und das EIL-/KAPUTT-Schildchen verschwindet nicht
         mehr hinter dem Scannerkopf, der oben ins Fenster hineinragt. */
      body.orient-hoch .hs-scan-window { min-height: 134px; align-items: end; padding-bottom: 10px; }
      /* Keine unsichtbare Zone: Der Screen bläht sich sonst auf "Bildschirmhöhe
         - 60px" auf und Bühne/Fächer strecken sich in den Bereich unter der
         sichtbaren Kante. Stattdessen: Inhalt bestimmt die Höhe, alles dockt
         oben an, Reihen bleiben gleich hoch (Maßstab = höchstes Fach). */
      body.orient-hoch #screen-hand-sort { min-height: 0; }
      body.orient-hoch .hs-stage { align-content: start; }
      body.orient-hoch .hs-targets { align-content: start; grid-auto-rows: 1fr; gap: 6px; }
      /* Fächer kompakter, damit auch Level 4 (drei Fächer-Reihen inkl.
         Reklamation) ohne Scrollen komplett ins Sichtfenster passt. */
      body.orient-hoch .sort-target { min-height: 50px; padding: 5px 20px 5px 52px; }
      body.orient-hoch .sort-target::before { width: 34px; height: 34px; }
      body.orient-hoch .sort-target .st-icon { left: 13px; width: 26px; height: 30px; font-size: 1.35rem; }
      body.orient-hoch .sort-target .st-name { font-size: 0.92rem; }
      body.orient-hoch .sort-target .st-rule { font-size: 0.6rem; padding: 2px 6px; }
      /* (Die kompakten Abschluss-Screen-Karten von hier sind zu den
         orient-hoch-Basisregeln gewandert — auch 414/430px-iPhones
         brauchten sie.) */
    }
    /* #3: Tutorial-Overlay an den sichtbaren Bildschirm heften statt an die
       Spielbox — die ist z. B. beim Handsortieren nur inhaltshoch, wodurch
       Abdunkelung und Karten-Position dort anders wirkten als in der Bauphase.
       Gilt bewusst für ALLE Hochformat-Breiten: iPhone-Viewports reichen bis
       430px, die 400px-Grenze oben würde die breiteren Modelle verfehlen. */
    body.orient-hoch .tut-overlay { position: fixed; }

    /* Bauphase: Leiste unten als horizontale Reihe, hohes Feld darüber */
    body.orient-hoch #screen-build-chain { min-height: 900px; }
    body.orient-hoch .cn-layout { flex-direction: column-reverse; }
    body.orient-hoch .cn-toolbar {
      width: 100%; height: 82px; flex-direction: row; align-items: stretch;
      border-right: 0; border-top: 1px solid var(--border);
      padding: 8px; overflow-x: auto; overflow-y: hidden;
    }
    body.orient-hoch .cn-toolbar.cn-collapsed { width: 100%; height: 0; padding-top: 0; padding-bottom: 0; border-top: 0; overflow: hidden; }
    body.orient-hoch .cntb-cards { flex: 1 1 auto; flex-direction: row; align-items: stretch; gap: 8px; overflow-x: auto; overflow-y: hidden; }
    body.orient-hoch .cntb-card { min-width: 112px; justify-content: center; }
    body.orient-hoch .cntb-arrow, body.orient-hoch .cntb-hint { display: none; }
    body.orient-hoch .cn-bar { flex-wrap: wrap; }
    body.orient-hoch .cn-bar-title { display: none; }
    /* Die Werkzeuggruppe (enthält den Prioritäts-Hinweis) ist als Ganzes
       unshrinkbar (flex-shrink:0) — mit dem nowrap-Hinweistext lief sie
       samt ?-/Theme-/Format-Knöpfen rechts aus dem Bild. Hochkant: volle
       Breite + Umbruch; der Hinweis (flex-basis 100%, order -1) wird eine
       eigene Zeile und sein Text darf mehrzeilig laufen statt abgeschnitten
       oder ellipsiert zu enden. */
    body.orient-hoch .cn-bar-tools { flex: 1 1 auto; flex-wrap: wrap; min-width: 0; }
    body.orient-hoch .cn-hint #cn-hint-text { white-space: normal; overflow: visible; }
    /* :has-Overrides gegen die Desktop-/Landscape-Sonderbreiten der Bauphase */
    body.orient-hoch .game-box:has(#screen-build-chain.active) { max-width: 560px; width: 100%; height: auto; transform: none; }
    body.orient-hoch .game-viewport:has(#screen-build-chain.active) { height: auto; max-height: none; align-items: center; }

    /* Ergebnis-Leiste am Levelende: in der schmalen Hochkant-Spalte alles
       zentriert untereinander stapeln, statt Score links / Button rechts —
       so läuft nichts aus dem Bild und der Level-Button bleibt komplett sichtbar. */
    body.orient-hoch .result-panel {
      flex-direction: column; align-items: stretch;
      text-align: center; gap: 14px; padding: 14px 12px 4px;
    }
    body.orient-hoch .result-panel .score-block { flex: none; width: 100%; }
    body.orient-hoch .hs-result-inner { flex-direction: column; align-items: center; gap: 10px; }
    body.orient-hoch .hs-result-left { justify-content: center; }
    body.orient-hoch .hs-result-right { margin-left: 0; text-align: center; }
    body.orient-hoch .score-bar-wrap { margin-left: auto; margin-right: auto; }
    body.orient-hoch .result-msg { margin-top: 0; }
    body.orient-hoch #result-action { width: 100%; }
    body.orient-hoch #result-action .btn { width: 100%; }

    /* Handy hochkant: Spiel zeigen statt "Bitte drehen" */
    @media (max-width: 920px) and (orientation: portrait) {
      body.orient-hoch .game-viewport { display: flex; }
      body.orient-hoch .mobile-rotate-notice { display: none; }
      body.orient-hoch .game-hero { min-height: 0; padding: 8px 8px 16px; display: block; }
      body.orient-hoch .game-box { width: 100%; }
      body.orient-hoch .screen { min-height: calc(100svh - 60px); }
      body.orient-hoch #screen-build-chain { min-height: calc(100svh - 60px); }
    }

    /* Handy quer + Hochformat-Modus: Die schmale Hoch-Spalte ist höher als der
       quere Bildschirm — sie stand dann halb abgeschnitten unter der Kante.
       Stattdessen das Spiegelbild des "Bitte drehen"-Hinweises: Spielfeld
       ausblenden (Spielstand bleibt erhalten, nur unsichtbar) und dieselbe
       klare Karte zeigen wie in der Gegenrichtung, inkl. Umschalt-Knopf. */
    @media (max-width: 920px) and (orientation: landscape) {
      body.orient-hoch .game-viewport { display: none; }
      body.orient-hoch .rotate-notice-quer { display: grid; min-height: 100dvh; }
    }

    /* Knopf auf der Dreh-Hinweis-Karte */
    .rotate-portrait-btn {
      margin-top: 14px; padding: 12px 18px; border-radius: 12px; cursor: pointer;
      background: rgba(255,255,255,0.08); color: #fff; border: 1px solid rgba(255,255,255,0.3);
      font-weight: 800; font-size: 0.95rem; font-family: inherit;
    }
    .rotate-portrait-btn:active { transform: scale(0.97); }
    /* --- Priorit�ts-Hinweis in der Bauphase (Level 3/4) ---------------
       Kompakter Hinweis in der Kopfzeile, direkt vor dem ?-Button. */
    .cn-hint {
      display: flex; align-items: center; gap: 8px;
      min-height: 38px; max-width: min(420px, 42vw);
      padding: 7px 9px 7px 12px; border-radius: 12px;
      background: rgba(20,26,30,0.97); border: 1px solid var(--yellow);
      color: var(--text); font-size: 0.76rem; font-weight: 800; line-height: 1.25;
      box-shadow: 0 5px 16px rgba(0,0,0,0.38);
    }
    .cn-hint[hidden] { display: none; }
    .cn-hint #cn-hint-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .cn-hint-x {
      flex-shrink: 0; width: 24px; height: 24px; border-radius: 7px; cursor: pointer;
      background: rgba(255,255,255,0.08); color: var(--text2);
      border: 1px solid var(--border2); font-weight: 900; font-family: inherit; line-height: 1;
    }
    .cn-hint-x:hover { color: #fff; border-color: var(--text2); }
    body.light-mode .cn-hint { background: rgba(255,255,255,0.96); color: var(--text); box-shadow: 0 5px 16px rgba(23,32,42,0.12); }
    body.orient-hoch .cn-hint { max-width: 100%; flex: 1 1 100%; order: -1; font-size: 0.72rem; }

    /* ─── Browser-Vollbild zeigt nur das Spiel (#22) ─────────────────────
       Der Fullscreen läuft technisch über die ganze Seite (Overlays hängen an
       document.body) — diese Klasse blendet das Drumherum aus und lässt das
       Spielfeld den Bildschirm füllen. Gesetzt in syncGameFs (game.js). */
    /* .mobile-rotate-notice bleibt bewusst sichtbar: auf iPhone (kein
       orientation.lock) fordert die Karte im Vollbild zum Drehen auf. */
    body.game-fs .site-header,
    body.game-fs .page-intro,
    body.game-fs .game-section-label,
    body.game-fs .site-note,
    body.game-fs .contact,
    body.game-fs .site-footer { display: none !important; }
    body.game-fs .game-hero { padding: 0; border-bottom: 0; background: var(--site-bg); }
    body.game-fs .site-shell { max-width: none; }
    body.game-fs .game-box { min-height: 100svh; }

    /* #42: Der Hoch-/Querformat-Wechsel ist nur für Touch-Geräte gedacht.
       Ausgeblendet wird nach Bedienart, nicht nach Bildschirmbreite: Geräte
       mit präzisem, hover-fähigem Mauszeiger (= Desktop/Laptop) verlieren den
       Knopf — Handys UND Tablets jeder Größe behalten ihn. */
    @media (hover: hover) and (pointer: fine) {
      .game-box .cn-orient-btn { display: none; }
    }

    /* #42: Desktop-Vollbild füllt den Bildschirm — derselbe Füllmodus wie im
       Handy-Querformat (site.js setzt --game-scale/--game-w/--game-h), nur nach
       oben skaliert. Die Bauphase bleibt wie am Handy unskaliert: ihr elastisches
       Feld füllt den Bildschirm von selbst. Kriterium ist die FENSTERBREITE,
       nicht die Zeiger-Art — die (hover/pointer)-Abfrage schlägt auf manchen
       Windows-Systemen fehl. Handys bleiben unter 921px (eigener Füllmodus). */
    @media (min-width: 921px) {
      /* Ist die Breite der begrenzende Faktor, bleibt oben/unten Rest —
         dann sitzt das Spiel mittig statt am oberen Rand zu kleben. */
      body.game-fs .game-hero { display: flex; align-items: center; min-height: 100vh; }
      body.game-fs .game-hero .site-shell { width: 100%; }
      body.game-fs .game-viewport {
        height: calc((var(--game-h, 620px) + 4px) * var(--game-scale, 1));
        max-height: 100vh;
        align-items: flex-start;
        overflow: visible;
      }
      body.game-fs .game-box {
        width: var(--game-w, 1080px);
        max-width: none;
        min-height: 620px;
        flex: 0 0 auto;
        transform: scale(var(--game-scale, 1));
        transform-origin: top center;
      }
      /* Höhen-Streckung: jeder Screen füllt die volle (logische) Bildschirmhöhe,
         der Inhalt bleibt darin zentriert — keine Balken mehr, egal welches
         Monitor-Seitenverhältnis. Gilt bewusst AUCH für die Bauphase: am
         Desktop-Vollbild wird alles größer gezogen wie beim Handsortieren
         (am Handy bleibt die Bauphase elastisch, das regelt die Landscape-Media). */
      body.game-fs .screen { min-height: var(--game-h, 620px); }
      body.game-fs #screen-build-chain { min-height: var(--game-h, 620px); height: auto; }
    }

    /* ─── Scoreboard (#9): Top 100 nach Gesamtzeit ──────────────────── */
    .sb-note {
      margin: 4px 0 10px; padding: 8px 14px; border-radius: 8px;
      background: rgba(255,170,0,0.12); border: 1px solid rgba(255,170,0,0.4);
      color: var(--yellow); font-size: 0.8rem;
    }
    .sb-entry { margin-bottom: 12px; }
    .sb-qualified { color: var(--green); font-weight: 700; }
    .sb-form { display: flex; gap: 10px; align-items: center; justify-content: center; margin: 10px 0 4px; }
    .sb-form input {
      width: 7ch; padding: 10px 8px; text-align: center;
      font-family: ui-monospace, Consolas, monospace; font-size: 1.4rem; font-weight: 900;
      letter-spacing: 0.35em; text-transform: uppercase;
      background: var(--bg2); color: var(--text);
      border: 2px solid var(--border2); border-radius: 8px; outline: none;
    }
    .sb-form input:focus { border-color: var(--red); box-shadow: 0 0 8px rgba(204,0,0,0.35); }
    .sb-list {
      width: min(100%, 440px); max-height: 300px; overflow-y: auto;
      border: 1px solid var(--border); border-radius: 10px;
      background: var(--bg2); text-align: left;
    }
    .sb-row {
      display: grid; grid-template-columns: 3.2em 1fr auto 5.5em;
      gap: 8px; align-items: center; padding: 7px 14px;
      border-bottom: 1px solid var(--border); font-size: 0.92rem;
    }
    .sb-row:last-child { border-bottom: 0; }
    .sb-rank { color: var(--text3); font-weight: 700; font-variant-numeric: tabular-nums; }
    .sb-row:nth-child(1) .sb-rank { color: #ffd24a; }
    .sb-row:nth-child(2) .sb-rank { color: #c0c8d0; }
    .sb-row:nth-child(3) .sb-rank { color: #cd8a4b; }
    .sb-name { font-family: ui-monospace, Consolas, monospace; font-weight: 800; letter-spacing: 0.2em; }
    .sb-tag {
      font-size: 0.62rem; font-weight: 900; letter-spacing: 1px; color: #0b0e11;
      background: var(--yellow); border-radius: 4px; padding: 1px 6px;
    }
    .sb-tag:empty { display: none; }
    .sb-time { text-align: right; color: var(--text2); font-variant-numeric: tabular-nums; }
    .sb-row.sb-me { background: rgba(255,210,74,0.10); box-shadow: inset 2px 0 0 var(--yellow); }
    .sb-row.sb-me .sb-name, .sb-row.sb-me .sb-time { color: var(--yellow); }
    /* Geteilter Eintrag aus dem Beweis-Link (#52) – grün statt gelb */
    .sb-row.sb-shared { background: rgba(62,207,106,0.12); box-shadow: inset 2px 0 0 #3ecf6a; }
    .sb-row.sb-shared .sb-name, .sb-row.sb-shared .sb-time { color: #3ecf6a; }
    .sb-row.sb-shared .sb-tag { background: #3ecf6a; }
    .sb-row.sb-pending { border: 1px dashed var(--yellow); border-radius: 6px; }
    .sb-empty { padding: 22px 14px; text-align: center; color: var(--text3); font-size: 0.88rem; }
    body.light-mode .sb-list { background: #fff; }
    body.light-mode .sb-row.sb-me { background: rgba(192,119,20,0.10); }
    body.light-mode .sb-row.sb-me .sb-name, body.light-mode .sb-row.sb-me .sb-time { color: #9a6a10; }
    body.light-mode .sb-row.sb-shared { background: rgba(30,150,70,0.12); }
    body.light-mode .sb-row.sb-shared .sb-name, body.light-mode .sb-row.sb-shared .sb-time { color: #1e7a3c; }
    body.light-mode .sb-row.sb-shared .sb-tag { background: #1e9646; }
    body.light-mode .sb-note { color: #8a5c00; background: rgba(192,119,20,0.10); }

    /* ─── Reduced motion (#6) ────────────────────────────────────────
       System setting "Animationen reduzieren" / battery saver: freeze the
       purely decorative endless loops at a readable state. One-shot feedback
       (package flights, ok/fail flashes) stays — it carries game information. */
    @media (prefers-reduced-motion: reduce) {
      .hs-scan-line { animation: none; top: 50%; opacity: 0.8; }
      .cntb-title   { animation: none; color: var(--red-hi); text-shadow: 0 0 6px rgba(255,26,26,0.5); }
      .cntb-arrow   { animation: none; opacity: 0.85; }
      .cn-pending   { animation: none; box-shadow: 0 0 12px 4px rgba(255,210,74,0.9); }
      #cn-canvas.cn-rails-on::after { animation: none; opacity: 0.85; }
      .cn-edge-hint-v, .cn-edge-hint-h { animation: none; }
    }
