  * { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
  /* the page itself must NEVER scroll or rubber-band on a phone — the game is the page */
  html { overflow: hidden; height: 100%; overscroll-behavior: none; }
  body { background: #1a1a2e; overflow: hidden; font-family: 'Georgia', serif; overscroll-behavior: none; touch-action: none; }
  /* …but panels with lists still scroll INSIDE themselves */
  .modal-card, #shelter, #cat-grid, #customise-rows, #catmaker-rows, #politics-body, #business-body,
  #homestore-grid, #rescue-grid, #inbox-body, #school-body, #map-wrap {
    touch-action: pan-y; -webkit-overflow-scrolling: touch;
  }
  #plan-palette { touch-action: pan-x; }
  /* buttons: tap = tap, never a double-tap zoom */
  button, input { touch-action: manipulation; }
  #canvas { display: block; width: 100vw; height: 100vh; touch-action: none; }

  /* HUD */
  #hud {
    position: fixed; top: 0; left: 0; right: 0;
    padding: calc(14px + env(safe-area-inset-top)) calc(18px + env(safe-area-inset-right)) 14px calc(18px + env(safe-area-inset-left));
    display: flex; justify-content: space-between; align-items: flex-start;
    pointer-events: none; z-index: 10;
  }
  #coin-display {
    background: rgba(20,12,5,0.82);
    border: 2px solid #c8922a;
    border-radius: 12px;
    padding: 8px 16px;
    color: #f0d080;
    font-size: 1.1rem;
    letter-spacing: 0.04em;
    display: flex; align-items: center; gap: 8px;
  }
  #coin-display .coin-icon { font-size: 1.3rem; }
  #family-panel {
    background: rgba(20,12,5,0.82);
    border: 2px solid #7a6a5a;
    border-radius: 12px;
    padding: 8px 14px;
    color: #d4b896;
    font-size: 0.78rem;
    text-align: right;
    line-height: 1.6;
  }
  #family-panel .fam-title { color: #f0d080; font-size: 0.88rem; margin-bottom: 2px; }
  .rent-line { display: none; margin-top: 6px; }
  .rent-text { color: #f0c090; font-size: 0.72rem; letter-spacing: 0.02em; }
  .rent-line.urgent .rent-text { color: #f0876a; }
  .rent-barwrap { height: 5px; margin-top: 3px; background: rgba(0,0,0,0.45); border-radius: 4px; overflow: hidden; }
  .rent-bar { height: 100%; width: 0%; background: linear-gradient(90deg, #c8922a, #f0d080); transition: width 0.4s; }

  /* Dialogue bubble */
  #dialogue {
    position: fixed; bottom: calc(24px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
    pointer-events: none;   /* subtitles sit between the d-pad and action buttons — never block taps */
    width: min(320px, 46vw);
    background: rgba(20,12,5,0.9);
    border: 2px solid #c8922a;
    border-radius: 16px;
    padding: 12px 20px;
    color: #f0e8d0;
    font-size: 0.95rem;
    max-width: 320px;
    text-align: center;
    pointer-events: none;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.3s;
    line-height: 1.5;
  }
  #dialogue.show { opacity: 1; }
  #dialogue .speaker { color: #f0d080; font-size: 0.8rem; margin-bottom: 4px; letter-spacing: 0.06em; text-transform: uppercase; }

  /* Controls — 360° joystick (drag past the ring to sprint) + Jump */
  #controls {
    position: fixed; bottom: calc(18px + env(safe-area-inset-bottom)); left: calc(16px + env(safe-area-inset-left));
    display: flex; align-items: flex-end; gap: 14px; z-index: 10;
  }
  #move-cluster { display: flex; flex-direction: column; align-items: center; gap: 6px; }
  #joystick {
    position: relative; width: 124px; height: 124px; border-radius: 50%;
    background: radial-gradient(circle, rgba(20,12,5,0.28) 55%, rgba(20,12,5,0.55) 100%);
    border: 2.5px solid #5a4a3a;
    touch-action: none; user-select: none; -webkit-user-select: none;
  }
  #joy-knob {
    position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; margin: -29px 0 0 -29px;
    border-radius: 50%;
    background: rgba(200,146,42,0.88); border: 2px solid #f0d080;
    box-shadow: 0 3px 10px rgba(0,0,0,0.45);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem; pointer-events: none; will-change: transform;
  }
  #joystick.sprint { border-color: #4ad06a; box-shadow: 0 0 16px rgba(74,208,106,0.55); }
  #joystick.sprint #joy-knob { background: rgba(74,208,106,0.85); border-color: #bff0c8; }
  #joystick.cooldown { border-color: #d0564a; }
  #joystick.cooldown #joy-knob { background: rgba(150,90,60,0.8); border-color: #f0b0a0; }
  .action-btn {
    background: rgba(200,146,42,0.22);
    border: 2px solid #c8922a;
    border-radius: 50%;
    width: 54px; height: 54px;
    color: #f0d080;
    font-size: 0.7rem;
    font-family: Georgia, serif;
    display: flex; align-items: center; justify-content: center;
    flex-direction: column;
    cursor: pointer; user-select: none;
    text-align: center; line-height: 1.2;
    transition: background 0.1s;
    margin-bottom: 34px;   /* jump floats beside the upper half of the joystick */
  }
  .action-btn:active, .action-btn.active { background: rgba(200,146,42,0.5); }
  .action-btn .btn-icon { font-size: 1.4rem; }
  #stamina {
    width: 100px; height: 7px;
    background: rgba(20,12,5,0.7); border: 1px solid #5a4a3a;
    border-radius: 5px; overflow: hidden;
  }
  #stamina-fill {
    height: 100%; width: 100%;
    background: linear-gradient(90deg, #4ad06a, #a8f0b0);
    transition: width 0.08s linear;
  }
  #stamina-fill.cooldown { background: linear-gradient(90deg, #d0564a, #f0a86a); }

  /* Minimap */
  #minimap {
    position: fixed; top: calc(132px + env(safe-area-inset-top)); right: calc(18px + env(safe-area-inset-right));
    width: 118px; height: 118px;
    background: #a9d787;
    border: 3px solid #fbf6ea;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 4px 14px rgba(0,0,0,0.4);
    z-index: 10;
  }
  #minimap canvas { width: 100%; height: 100%; }

  /* Intro screen */
  #intro {
    position: fixed; inset: 0;
    background: linear-gradient(160deg, #0d0d1a 0%, #1a1000 60%, #0d0700 100%);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    z-index: 100; gap: 18px;
    padding: 30px;
  }
  #intro h1 {
    color: #f0d080;
    font-size: 2.2rem;
    letter-spacing: 0.06em;
    text-shadow: 0 2px 24px #c8922a88;
    text-align: center;
  }
  #intro .subtitle {
    color: #b8906a;
    font-size: 0.95rem;
    text-align: center;
    max-width: 280px;
    line-height: 1.6;
  }
  #intro .cat-emoji { font-size: 4rem; filter: drop-shadow(0 0 18px #c8922a); }
  #start-btn {
    background: #c8922a;
    color: #1a0800;
    border: none;
    border-radius: 14px;
    padding: 14px 40px;
    font-size: 1.1rem;
    font-family: Georgia, serif;
    font-weight: bold;
    cursor: pointer;
    letter-spacing: 0.06em;
    margin-top: 10px;
    box-shadow: 0 4px 24px #c8922a55;
  }
  #start-btn:active { background: #a87020; }

  /* Notification pop */
  #notif {
    position: fixed; top: 70px; left: 50%; transform: translateX(-50%);
    pointer-events: none;   /* informational — never block a button underneath */
    background: rgba(20,12,5,0.92);
    border: 2px solid #f0d080;
    border-radius: 12px;
    padding: 10px 22px;
    color: #f0d080;
    font-size: 1rem;
    z-index: 20;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.4s;
    white-space: nowrap;
  }
  #notif.show { opacity: 1; }

  /* Shelter selection screen */
  #shelter {
    position: fixed; inset: 0;
    background: linear-gradient(160deg, #0d0d1a 0%, #1a1000 60%, #0d0700 100%);
    display: flex; flex-direction: column; align-items: center;
    z-index: 200; padding: 22px 14px 0; overflow-y: auto;
  }
  #shelter h1 {
    color: #f0d080; font-size: 1.6rem; text-align: center;
    letter-spacing: 0.04em; text-shadow: 0 2px 20px #c8922a88;
  }
  #shelter .subtitle {
    color: #b8906a; font-size: 0.84rem; text-align: center;
    max-width: 360px; line-height: 1.5; margin: 8px 0 16px;
  }
  #cat-grid {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 11px;
    width: 100%; max-width: 460px; padding-bottom: 10px;
  }
  @media (min-width: 540px) { #cat-grid { grid-template-columns: repeat(3, 1fr); max-width: 660px; } }
  .cat-card {
    background: rgba(20,12,5,0.55);
    border: 2px solid #5a4a3a; border-radius: 14px;
    padding: 8px 6px 10px;
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    cursor: pointer; user-select: none;
    transition: transform 0.12s, border-color 0.12s, background 0.12s;
  }
  .cat-card:active { transform: scale(0.96); }
  .cat-card.selected, .cat-card:hover { border-color: #c8922a; background: rgba(200,146,42,0.18); }
  .cat-card svg { width: 76px; height: 76px; }
  .cat-card .cat-name { color: #f0d080; font-size: 0.92rem; letter-spacing: 0.03em; }
  .cat-card .cat-hello { color: #cbb091; font-size: 0.64rem; text-align: center; line-height: 1.3; min-height: 2.5em; font-style: italic; }
  #shelter-footer {
    position: sticky; bottom: 0; width: 100%;
    display: flex; justify-content: center; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 12px 0 14px;
    background: linear-gradient(to top, #0d0700 30%, rgba(13,7,0,0) 100%);
  }
  #cat-name-input, #catmaker-name {
    background: rgba(20,12,5,0.85); color: #f0e6c8; border: 2px solid #7a6a4a; border-radius: 12px;
    padding: 11px 14px; font-family: Georgia, serif; font-size: 1rem; text-align: center; width: 200px; max-width: 60vw;
  }
  #cat-name-input:focus, #catmaker-name:focus { outline: none; border-color: #f0d080; }
  #catmaker-name { display: block; margin: 0 auto 12px; }
  .cat-card.create-card { justify-content: center; border-style: dashed; border-color: #7a6a4a; background: rgba(90,74,58,0.18); }
  .cat-card.create-card .create-icon { font-size: 2.4rem; line-height: 1.1; }
  #catmaker { z-index: 260; }   /* above the #shelter intro screen (z 200) */
  #adopt-btn {
    background: #c8922a; color: #1a0800; border: none; border-radius: 14px;
    padding: 13px 38px; font-size: 1.05rem; font-family: Georgia, serif; font-weight: bold;
    cursor: pointer; letter-spacing: 0.05em; box-shadow: 0 4px 24px #c8922a55;
    transition: background 0.12s;
  }
  #adopt-btn:active { background: #a87020; }
  #adopt-btn:disabled { background: #4a4036; color: #8a7a66; cursor: default; box-shadow: none; }

  .intro-portrait { width: 120px; height: 120px; filter: drop-shadow(0 0 18px #c8922a); }
  .intro-portrait svg { width: 100%; height: 100%; }

  /* ☰ menu button — the ONLY utility button always on screen */
  #menu-toggle {
    position: fixed; top: calc(152px + env(safe-area-inset-top)); left: calc(18px + env(safe-area-inset-left)); z-index: 12;
    width: 40px; height: 40px; border-radius: 10px;
    background: rgba(20,12,5,0.82); border: 2px solid #7a6a5a;
    color: #f0d080; font-size: 1.15rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
  }
  #menu-toggle.open { border-color: #c8922a; background: rgba(200,146,42,0.25); }
  #menu-badge {
    position: absolute; top: -7px; right: -7px; min-width: 19px; height: 19px; border-radius: 10px;
    background: #c8443a; color: #fff; font-size: 0.66rem; font-weight: bold; font-family: Georgia, serif;
    display: none; align-items: center; justify-content: center; padding: 0 4px; border: 2px solid #1a0d05;
  }
  /* Toolbar tray — every utility button lives here; hidden until ☰ slides it out */
  #toolbar {
    position: fixed; top: calc(152px + env(safe-area-inset-top)); left: calc(66px + env(safe-area-inset-left)); z-index: 11;
    display: flex; flex-wrap: wrap; gap: 6px; width: 190px;
    opacity: 0; pointer-events: none; transform: translateX(-10px);
    transition: opacity 0.18s, transform 0.18s;
  }
  #toolbar.open { opacity: 1; pointer-events: auto; transform: translateX(0); }
  #toolbar button {
    position: relative;
    width: 40px; height: 40px; border-radius: 10px;
    background: rgba(20,12,5,0.82); border: 2px solid #7a6a5a;
    color: #f0d080; font-size: 1.05rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex: 0 0 auto;
  }

  /* Enter / leave house button */
  #enter-btn {
    position: fixed; bottom: calc(220px + env(safe-area-inset-bottom)); left: 50%;
    transform: translateX(-50%); z-index: 12; display: none;
    background: rgba(200,146,42,0.92); color: #1a0800;
    border: 2px solid #f0d080; border-radius: 14px;
    padding: 10px 22px; font-family: Georgia, serif; font-weight: bold; font-size: 0.95rem;
    cursor: pointer; box-shadow: 0 4px 18px #00000066; white-space: nowrap;
  }
  #enter-btn.show { display: block; }
  #enter-btn:active { background: #a87020; }

  /* Go upstairs / downstairs button (sits just above the enter button) */
  #stairs-btn {
    position: fixed; bottom: calc(270px + env(safe-area-inset-bottom)); left: 50%;
    transform: translateX(-50%); z-index: 12; display: none;
    background: rgba(120,90,180,0.92); color: #fff;
    border: 2px solid #e0d0f0; border-radius: 14px;
    padding: 10px 22px; font-family: Georgia, serif; font-weight: bold; font-size: 0.95rem;
    cursor: pointer; box-shadow: 0 4px 18px #00000066; white-space: nowrap;
  }
  #stairs-btn.show { display: block; }
  #stairs-btn:active { background: #5a4090; }

  /* Give / Shelter buttons */
  #give-btn, #shelter-btn {
    position: fixed; left: 50%; transform: translateX(-50%); z-index: 12; display: none;
    border-radius: 14px; padding: 10px 22px; font-family: Georgia, serif; font-weight: bold; font-size: 0.95rem;
    cursor: pointer; box-shadow: 0 4px 18px #00000066; white-space: nowrap; color: #fff;
  }
  #give-btn { bottom: calc(320px + env(safe-area-inset-bottom)); background: rgba(200,90,140,0.92); border: 2px solid #f0c0d8; }
  #give-btn.show { display: block; } #give-btn:active { background: #a04068; }
  #shelter-btn { bottom: calc(270px + env(safe-area-inset-bottom)); background: rgba(90,150,160,0.92); border: 2px solid #c0e8f0; }
  #shelter-btn.show { display: block; } #shelter-btn:active { background: #3a7a88; }

  /* Needs (hunger / thirst / energy) — starts BELOW the coin box (iOS renders it tall) */
  #needs {
    position: fixed; top: calc(72px + env(safe-area-inset-top)); left: calc(18px + env(safe-area-inset-left));
    display: flex; flex-direction: column; gap: 4px; z-index: 10;
  }
  .need { display: flex; align-items: center; gap: 5px; }
  .need-icon { font-size: 0.8rem; width: 16px; text-align: center; filter: drop-shadow(0 1px 1px #000); }
  .need-bar { width: 62px; height: 7px; background: rgba(20,12,5,0.72); border: 1px solid #5a4a3a; border-radius: 5px; overflow: hidden; }
  .need-fill { height: 100%; width: 100%; background: #6ac06a; transition: width 0.3s linear, background 0.4s; }
  .need-fill.low { background: #e0a83a; }
  .need-fill.critical { background: #d0463a; }
  /* one tight centre-top stack — pills pack under each other, no overlaps ever */
  #status-stack {
    position: fixed; top: calc(12px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
    z-index: 10; display: flex; flex-direction: column; align-items: center; gap: 5px;
    pointer-events: none;
  }
  #status-stack > * { pointer-events: auto; }
  #clock {
    font-size: 0.92rem; color: #f0e6cc; background: rgba(20,12,5,0.82);
    border: 1px solid #5a4a3a; border-radius: 12px; padding: 5px 12px; white-space: nowrap; letter-spacing: 0.03em;
  }
  #population {
    display: none; align-items: center; gap: 8px; font-size: 0.82rem; color: #f0e0c0;
    background: rgba(20,12,5,0.7); border: 1px solid #5a4a3a; border-radius: 12px; padding: 4px 12px; white-space: nowrap;
  }

  /* Context action button (eat / drink / sleep / pet) */
  #context-btn {
    position: fixed; bottom: calc(370px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
    z-index: 12; display: none; color: #1a0800; background: rgba(240,208,128,0.95); border: 2px solid #fff0d0;
    border-radius: 14px; padding: 10px 22px; font-family: Georgia, serif; font-weight: bold; font-size: 0.95rem;
    cursor: pointer; box-shadow: 0 4px 18px #00000066; white-space: nowrap;
  }
  #context-btn.show { display: block; } #context-btn:active { background: #d0b060; }

  /* 🛍️ Buy button — its own button at the shop counter, never hidden behind the job offer */
  #buy-btn {
    position: fixed; bottom: calc(320px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
    z-index: 12; display: none; color: #1a0800; background: rgba(120,200,150,0.95); border: 2px solid #e0f8e8;
    border-radius: 14px; padding: 10px 22px; font-family: Georgia, serif; font-weight: bold; font-size: 0.95rem;
    cursor: pointer; box-shadow: 0 4px 18px #00000066; white-space: nowrap;
  }
  #buy-btn.show { display: block; } #buy-btn:active { background: #58a878; }

  /* For-sale property button */
  #property-btn {
    position: fixed; bottom: calc(420px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
    z-index: 12; display: none; color: #fff; background: rgba(180,80,80,0.94); border: 2px solid #f0c0c0;
    border-radius: 14px; padding: 10px 22px; font-family: Georgia, serif; font-weight: bold; font-size: 0.9rem;
    cursor: pointer; box-shadow: 0 4px 18px #00000066; white-space: nowrap;
  }
  #property-btn.show { display: block; } #property-btn:active { background: #904040; }

  /* Store cards (Home Store) */
  #homestore-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; max-height: 56vh; overflow-y: auto; }
  .store-card { background: rgba(20,12,5,0.55); border: 2px solid #5a4a3a; border-radius: 12px; padding: 8px 6px 10px; display: flex; flex-direction: column; align-items: center; gap: 5px; }
  .store-icon { font-size: 2rem; }
  .store-name { color: #f0d080; font-size: 0.72rem; text-align: center; min-height: 2.2em; }
  .store-buy { background: #4aa06a; color: #06140c; border: none; border-radius: 10px; padding: 7px 6px; font-family: Georgia, serif; font-weight: bold; font-size: 0.72rem; cursor: pointer; width: 100%; }
  .store-buy:active { background: #3a8050; }
  .store-owned { color: #7adf8a; font-size: 0.68rem; font-weight: bold; padding: 6px 0; }

  /* Cat customisation */
  .cust-portrait { width: 108px; height: 108px; margin: 0 auto 12px; }
  .cust-portrait svg { width: 100%; height: 100%; }
  #customise-rows { max-height: 46vh; overflow-y: auto; }
  .cust-row { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }
  .cust-label { color: #d4b896; font-size: 0.76rem; width: 66px; text-align: right; flex-shrink: 0; }
  .cust-sw-wrap { display: flex; gap: 6px; flex-wrap: wrap; }
  .cust-sw { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #5a4a3a; cursor: pointer; padding: 0; }
  .cust-sw.sel { border-color: #f0d080; box-shadow: 0 0 0 2px #f0d08066; }
  .cust-pat { background: rgba(90,74,58,0.4); color: #f0e0c0; border: 1px solid #7a6a5a; border-radius: 8px; padding: 4px 9px; font-family: Georgia, serif; font-size: 0.72rem; cursor: pointer; }
  .cust-pat.sel { background: #c8922a; color: #1a0800; border-color: #f0d080; }
  .cust-pat.locked { color: #c8a878; border-style: dashed; opacity: 0.85; }
  .cust-pat.locked.sel { color: #1a0800; }

  /* Presidency arc */
  #politics-body { max-height: 56vh; overflow-y: auto; text-align: left; }
  .pol-lead { color: #e8d4b0; font-size: 0.86rem; line-height: 1.5; margin-bottom: 12px; }
  .pol-stat { color: #d4b896; font-size: 0.8rem; margin: 5px 0; }
  .pol-stat b, .pol-lead b { color: #f0d080; }
  .pol-note { color: #b8906a; font-size: 0.74rem; font-style: italic; margin-top: 8px; }
  .pol-q { color: #f5e8cc; font-size: 0.92rem; font-weight: bold; line-height: 1.4; margin-bottom: 10px; }
  .pol-rival { color: #cdb79a; font-size: 0.78rem; line-height: 1.4; margin: 4px 0; }
  .pol-rival b { color: #e8d4b0; }
  .pol-you { color: #9ad0a0; font-size: 0.8rem; font-weight: bold; margin: 12px 0 6px; }
  .pol-opt {
    display: block; width: 100%; text-align: left; margin: 7px 0; padding: 11px 13px;
    background: rgba(90,74,58,0.35); color: #f0e6d2; border: 1px solid #7a6a5a; border-radius: 10px;
    font-family: Georgia, serif; font-size: 0.82rem; line-height: 1.35; cursor: pointer;
  }
  .pol-opt:active { background: #c8922a; color: #1a0800; }
  .pol-primary {
    display: block; width: 100%; margin: 14px 0 4px; padding: 13px; border: none; border-radius: 12px;
    background: linear-gradient(#e8b84a, #c8922a); color: #1a0800; font-family: Georgia, serif;
    font-size: 0.92rem; font-weight: bold; cursor: pointer;
  }
  .pol-primary:disabled { background: #5a4a3a; color: #9a8a78; cursor: default; }

  /* Business & reputation dashboard */
  #business-body { text-align: left; max-height: 62vh; overflow-y: auto; }
  .biz-rep { text-align: center; font-size: 0.95rem; color: #e8d4b0; margin-bottom: 10px; padding: 6px; border-radius: 10px; }
  .biz-rep.good { background: rgba(60,120,70,0.35); }
  .biz-rep.neutral { background: rgba(90,74,58,0.35); }
  .biz-rep.bad { background: rgba(150,60,50,0.4); }
  .biz-stats { display: flex; gap: 8px; text-align: center; margin-bottom: 10px; }
  .biz-stats > div { flex: 1; background: rgba(90,74,58,0.3); border-radius: 10px; padding: 8px 4px; color: #d4b896; font-size: 0.72rem; }
  .biz-stats b { color: #f0d080; font-size: 1.15rem; }
  .biz-wallet { color: #d4b896; font-size: 0.85rem; margin-bottom: 8px; }
  .biz-wallet b { color: #f0d080; }
  .biz-econ { color: #cdb79a; font-size: 0.78rem; line-height: 1.5; margin-bottom: 10px; }
  .biz-econ .pos { color: #7adf8a; } .biz-econ .neg { color: #e88a7a; }
  .biz-workers { color: #cdb79a; font-size: 0.74rem; line-height: 1.4; margin-bottom: 12px; }
  .biz-wbtns { display: flex; gap: 8px; margin-top: 8px; }
  .biz-wbtns button { flex: 1; background: linear-gradient(#e8b84a, #c8922a); color: #1a0800; border: none; border-radius: 10px; padding: 9px; font-family: Georgia, serif; font-weight: bold; font-size: 0.82rem; cursor: pointer; }
  .biz-list { display: flex; flex-direction: column; gap: 7px; }
  .biz-card { display: flex; align-items: center; gap: 10px; background: rgba(90,74,58,0.3); border: 1px solid #5a4a3a; border-radius: 10px; padding: 8px 10px; }
  .biz-card.owned { border-color: #7adf8a; }
  .biz-ic { font-size: 1.5rem; }
  .biz-nm { flex: 1; color: #f0e6d2; font-size: 0.84rem; } .biz-nm small { color: #b8906a; }
  .biz-own { color: #7adf8a; font-size: 0.74rem; font-weight: bold; }
  .biz-buy { background: #c8922a; color: #1a0800; border: none; border-radius: 10px; padding: 8px 12px; font-family: Georgia, serif; font-weight: bold; font-size: 0.78rem; cursor: pointer; white-space: nowrap; }
  .biz-note { color: #cdb79a; font-size: 0.73rem; line-height: 1.45; margin-bottom: 12px; }
  .biz-jobs { background: rgba(90,74,58,0.28); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; }
  .jobs-title { color: #f0d080; font-size: 0.86rem; font-weight: bold; margin-bottom: 8px; }
  .job-row { margin-bottom: 8px; }
  .job-head { color: #e8d4b0; font-size: 0.78rem; margin-bottom: 4px; }
  .job-head b { color: #f0d080; }
  .job-pct { color: #b8906a; font-size: 0.72rem; }
  .job-bar { height: 8px; background: rgba(30,20,10,0.6); border-radius: 5px; overflow: hidden; }
  .job-fill { height: 100%; background: linear-gradient(90deg, #4a9a6a, #7adf8a); border-radius: 5px; transition: width 0.3s; }
  .jobs-note { color: #b8906a; font-size: 0.7rem; font-style: italic; line-height: 1.4; margin-top: 6px; }
  .biz-staff { color: #e8d4b0; font-size: 0.8rem; white-space: nowrap; }
  .biz-hire { display: flex; gap: 6px; margin: -3px 0 4px; }
  .biz-hire button { flex: 1; background: rgba(90,74,58,0.5); color: #f0e6d2; border: 1px solid #7a6a5a; border-radius: 9px; padding: 7px 4px; font-family: Georgia, serif; font-size: 0.74rem; cursor: pointer; }
  .biz-hire button:active { background: #c8922a; color: #1a0800; }

  /* Town map */
  #dark-toggle.on { border-color: #8a9ac8; color: #bcd0f0; background: rgba(10,12,22,0.88); }
  #inbox-count {
    position: absolute; top: -7px; right: -7px; min-width: 19px; height: 19px; border-radius: 10px;
    background: #c8443a; color: #fff; font-size: 0.66rem; font-weight: bold; font-family: Georgia, serif;
    display: none; align-items: center; justify-content: center; padding: 0 4px; border: 2px solid #1a0d05;
  }
  .mail-item { background: rgba(90,74,58,0.22); border: 1px solid #5a4a3a; border-radius: 10px; padding: 9px 12px; margin-bottom: 8px; cursor: pointer; text-align: left; }
  .mail-item.unread { border-color: #c8922a; background: rgba(200,146,42,0.14); }
  .mail-head { display: flex; justify-content: space-between; color: #cdb79a; font-size: 0.68rem; margin-bottom: 2px; }
  .mail-subject { color: #f0e6c8; font-size: 0.86rem; }
  .mail-item.unread .mail-subject { color: #f0d080; font-weight: bold; }
  .mail-body { color: #e0d4b8; font-size: 0.8rem; line-height: 1.55; margin-top: 8px; border-top: 1px dashed #6a5a3a; padding-top: 8px; }
  /* Tutorial cards + button glow */
  #tutorial {
    position: fixed; top: calc(64px + env(safe-area-inset-top)); right: calc(14px + env(safe-area-inset-right)); z-index: 210;
    width: min(250px, 58vw); display: none; background: rgba(16,22,32,0.95); border: 2px solid #6ab0e0; border-radius: 14px; padding: 12px 14px;
    box-shadow: 0 6px 24px #00000088;
  }
  #tut-text { color: #d8ecff; font-size: 0.82rem; line-height: 1.5; margin-bottom: 10px; }
  #tut-btns { display: flex; gap: 8px; }
  #tut-next { flex: 1; background: #4a90c8; color: #fff; border: none; border-radius: 9px; padding: 8px; font-family: Georgia, serif; font-weight: bold; font-size: 0.78rem; cursor: pointer; }
  #tut-skip { background: none; color: #8aa8c0; border: 1px solid #4a6a8a; border-radius: 9px; padding: 8px 12px; font-family: Georgia, serif; font-size: 0.74rem; cursor: pointer; }
  .tut-glow { animation: tutPulse 1s ease-in-out infinite; }
  @keyframes tutPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(106,176,224,0.0); } 50% { box-shadow: 0 0 14px 5px rgba(106,176,224,0.85); } }
  /* CV cards */
  .cv-card { background: rgba(246,238,220,0.07); border: 1px solid #7a6a4a; border-radius: 12px; padding: 12px 15px; margin-bottom: 12px; text-align: left; }
  .cv-title { color: #cdb79a; font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; }
  .cv-name { color: #f0d080; font-size: 1.15rem; font-weight: bold; margin: 3px 0; }
  .cv-sec { color: #cdb79a; font-size: 0.72rem; margin-top: 9px; border-bottom: 1px dashed #5a4a3a; padding-bottom: 2px; }
  .cv-sec-big { color: #cdb79a; font-size: 0.82rem; margin: 12px 0 6px; }
  .cv-line { color: #e8dcc0; font-size: 0.8rem; padding: 2px 0; }
  .cv-dim { color: #9a8a6c; font-style: italic; }
  .cv-bad { color: #d88a7a; }
  .cv-note { color: #9a8a6c; font-size: 0.66rem; font-style: italic; margin-top: 8px; }
  .staff-block { background: rgba(90,74,58,0.18); border-radius: 10px; padding: 8px 11px; margin-bottom: 8px; text-align: left; }
  .staff-biz { color: #f0d080; font-size: 0.8rem; margin-bottom: 4px; }
  .staff-row { color: #e8dcc0; font-size: 0.8rem; padding: 4px 2px; cursor: pointer; display: flex; justify-content: space-between; flex-wrap: wrap; border-top: 1px solid rgba(90,74,58,0.4); }
  .staff-cv { width: 100%; color: #d4c8a8; font-size: 0.74rem; line-height: 1.55; background: rgba(246,238,220,0.06); border-radius: 8px; padding: 8px 10px; margin-top: 6px; }
  #minimap { cursor: pointer; }
  .mm-hint { position: absolute; bottom: 1px; right: 3px; font-size: 0.72rem; opacity: 0.85; pointer-events: none; }
  #map-wrap { width: 100%; display: flex; justify-content: center; margin-bottom: 14px; }
  #map .modal-card { max-width: 620px; }
  #map-canvas { width: 100%; max-width: 560px; aspect-ratio: 1 / 1; border-radius: 16px; background: #a9d787; box-shadow: 0 8px 30px rgba(0,0,0,0.5), inset 0 0 0 1px rgba(0,0,0,0.15); image-rendering: auto; }

  /* ── SimCity-style build mode (top-down overlay over the real 3D world) ── */
  #plan-ui { position: fixed; inset: 0; z-index: 150; display: none; pointer-events: none; }
  #plan-ui.show { display: block; }
  /* while planning, hide the walk-around HUD so the map is clear */
  body.planning #controls, body.planning #minimap, body.planning #needs,
  body.planning #enter-btn, body.planning #give-btn, body.planning #shelter-btn,
  body.planning #context-btn, body.planning #property-btn, body.planning #decorate-move-btn,
  body.planning #toolbar, body.planning #menu-toggle { display: none !important; }

  #plan-top { position: fixed; top: calc(14px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
    display: flex; gap: 12px; align-items: center; background: rgba(20,12,5,0.8); border: 1px solid #7a6a5a;
    border-radius: 12px; padding: 7px 14px; pointer-events: none; max-width: 92vw; }
  #plan-hint { color: #e8d4b0; font-size: 0.72rem; }
  #plan-bal { color: #f0d080; font-size: 0.86rem; font-weight: bold; white-space: nowrap; }
  #plan-reticle { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 151;
    color: #ffe89a; font-size: 2rem; text-shadow: 0 0 4px #000, 0 0 8px #000; pointer-events: none; opacity: 0.9; }

  #plan-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 152; pointer-events: auto;
    background: linear-gradient(rgba(20,12,5,0) , rgba(16,10,4,0.94) 22%);
    padding: 24px 10px calc(12px + env(safe-area-inset-bottom)); }
  #plan-palette { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
  #plan-palette::-webkit-scrollbar { display: none; }
  .plan-item { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 1px; width: 60px;
    padding: 6px 2px; font-size: 1.35rem; background: rgba(120,90,60,0.3); border: 1.5px solid #6a5a48;
    border-radius: 10px; color: #f0e0c0; cursor: pointer; line-height: 1.05; }
  .plan-item small { font-size: 0.54rem; color: #cbb894; }
  .plan-item.sel { background: rgba(200,146,42,0.4); border-color: #f0c060; box-shadow: 0 0 0 1px #f0c060 inset; }
  .plan-item:active { transform: scale(0.94); }
  #plan-actions { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
  #plan-actions button { background: rgba(120,90,60,0.5); color: #f0e0c0; border: 1px solid #7a6a5a;
    border-radius: 10px; padding: 9px 12px; font-family: Georgia, serif; font-size: 0.86rem; cursor: pointer; }
  #plan-actions button:active { background: rgba(200,146,42,0.5); }
  #plan-place { background: linear-gradient(#e8b84a, #c8922a) !important; color: #1a0800 !important; font-weight: bold; border: none !important; }
  #plan-done { background: rgba(90,74,58,0.6) !important; }
  #plan-move.on { background: linear-gradient(#4aa0d8, #2a70b0) !important; color: #f0f8ff !important; border-color: #7ac0f0 !important; }
  #plan-demolish.on { background: linear-gradient(#e05a3a, #b83020) !important; color: #fff0ec !important; border-color: #ff9a7a !important; }
  #plan-pay { background: linear-gradient(#6a8a5a, #4a6a3a) !important; color: #f0f8e8 !important; border-color: #8aca7a !important; font-weight: bold; }
  #plan-pay.tax { background: linear-gradient(#c8922a, #a06a1a) !important; color: #1a0800 !important; border-color: #f0c060 !important; }
  /* Road extend pad — appears when the Road piece is selected */
  #plan-roadpad { position: fixed; left: calc(14px + env(safe-area-inset-left)); bottom: 150px; z-index: 153;
    display: none; flex-direction: column; align-items: center; gap: 6px; pointer-events: auto;
    background: rgba(16,10,4,0.82); border: 1.5px solid #7a6a5a; border-radius: 14px; padding: 8px 10px; }
  #plan-roadpad.show { display: flex; }
  #plan-roadpad .rp-label { color: #f0d080; font-size: 0.72rem; font-weight: bold; white-space: nowrap; }
  #plan-roadpad .rp-grid { display: grid; grid-template-columns: repeat(3, 42px); grid-auto-rows: 42px; gap: 4px; }
  #plan-roadpad button { background: rgba(20,12,5,0.9); color: #f0d080; border: 1.5px solid #8a7a5a; border-radius: 9px; font-size: 1.2rem; cursor: pointer; }
  #plan-roadpad button:active { background: rgba(200,146,42,0.7); color: #1a0800; }
  #plan-roadpad .rp-mid { display: flex; align-items: center; justify-content: center; font-size: 1.2rem; color: #c8b890; opacity: 0.7; }

  /* Presidency: happiness HUD, governance dashboard, jail */
  #happy {
    display: none; align-items: center; gap: 6px; background: rgba(20,12,5,0.72); border: 1px solid #5a4a3a; border-radius: 12px; padding: 3px 10px;
  }
  .happy-face { font-size: 0.95rem; }
  .happy-bar { width: 96px; height: 8px; background: #3a2e22; border-radius: 5px; overflow: hidden; }
  .happy-fill { height: 100%; width: 60%; background: #5fbf6a; transition: width 0.4s, background 0.4s; }
  #anger {
    display: none; align-items: center; gap: 6px; background: rgba(20,12,5,0.72); border: 1px solid #5a4a3a; border-radius: 12px; padding: 3px 10px;
  }
  .anger-face { font-size: 0.95rem; }
  .anger-fill { height: 100%; width: 0%; background: #7a8a5a; transition: width 0.4s, background 0.4s; }
  #anger.danger { border-color: #c8443a; animation: angerPulse 1s ease-in-out infinite; }
  @keyframes angerPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(200,68,58,0); } 50% { box-shadow: 0 0 10px 2px rgba(200,68,58,0.6); } }
  #winback {
    display: none; align-items: center; gap: 6px; background: rgba(30,14,20,0.78); border: 1px solid #a05a6a; border-radius: 12px; padding: 3px 10px;
  }
  .winback-face { font-size: 0.95rem; }
  .winback-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #c85a7a, #f090a8); transition: width 0.4s; }
  .winback-pct { color: #f0c0cc; font-size: 0.72rem; min-width: 30px; text-align: right; }
  #jobhud {
    display: none; align-items: center; gap: 6px; background: rgba(14,22,30,0.82); border: 1px solid #3a6a8a; border-radius: 12px; padding: 4px 12px; cursor: pointer;
  }
  .jobhud-text { color: #bfe0f0; font-size: 0.74rem; white-space: nowrap; }
  .job-letter { text-align: left; color: #e8dcc0; font-size: 0.85rem; line-height: 1.5; background: rgba(240,232,205,0.06); border: 1px solid #6a5a3a; border-radius: 10px; padding: 13px 15px; margin-bottom: 14px; }
  .job-letter .jl-head { color: #f0d080; font-weight: bold; margin-bottom: 8px; }
  .job-letter p { margin: 5px 0; }
  .job-letter ul { margin: 6px 0 6px 18px; line-height: 1.75; }
  .job-letter .jl-sign { text-align: right; margin-top: 8px; color: #cbb091; font-style: italic; }
  .co-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 10px 0 14px; }
  .co-grid button { background: rgba(90,74,58,0.4); color: #f0e6c8; border: 1px solid #7a6a5a; border-radius: 12px; padding: 12px 8px; font-family: Georgia, serif; font-size: 1.15rem; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; }
  .co-grid button small { font-size: 0.68rem; color: #cdb79a; }
  .co-grid button:active { background: rgba(200,146,42,0.35); border-color: #c8922a; }
  .co-receipt { background: rgba(246,236,212,0.08); border: 1px dashed #7a6a4a; border-radius: 10px; padding: 10px 13px; margin-bottom: 10px; }
  .co-line { display: flex; justify-content: space-between; color: #e8dcc0; font-size: 0.85rem; padding: 2px 0; }
  .co-line.co-total { border-top: 1px solid #6a5a3a; margin-top: 5px; padding-top: 6px; color: #f0d080; font-weight: bold; }
  .co-line.co-paid { color: #a8d0a0; font-weight: bold; }
  /* Town School */
  .school-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 10px; }
  .school-card { background: rgba(20,12,5,0.55); border: 2px solid #5a4a3a; border-radius: 14px; padding: 12px 8px; display: flex; flex-direction: column; align-items: center; gap: 5px; }
  .school-icon { font-size: 2rem; }
  .school-blurb { color: #cbb091; font-size: 0.66rem; text-align: center; line-height: 1.4; min-height: 3.4em; }
  .school-locked { color: #9a8468; font-size: 0.7rem; font-style: italic; }
  /* The debate stage + mayor goals */
  #debate-stage { width: 100%; height: auto; display: block; border-radius: 12px; border: 1px solid #5a4a3a; margin-bottom: 10px; }
  .mayor-goal { color: #e8dcc0; font-size: 0.84rem; padding: 5px 8px; border-radius: 8px; margin-bottom: 4px; background: rgba(90,74,58,0.22); display: flex; justify-content: space-between; gap: 8px; }
  .mayor-goal.ok { background: rgba(70,120,80,0.25); color: #cfe8c8; }
  .mayor-count { color: #f0d080; }
  #jobhud.alert { border-color: #f0c040; animation: jobPulse 1.1s ease-in-out infinite; }
  #jobhud.alert .jobhud-text { color: #ffe08a; }
  @keyframes jobPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(240,192,64,0); } 50% { box-shadow: 0 0 10px 2px rgba(240,192,64,0.55); } }
  .gov-top { display: flex; gap: 8px; margin-bottom: 10px; }
  .gov-treasury, .gov-happy { flex: 1; background: rgba(90,74,58,0.3); border-radius: 10px; padding: 8px; color: #d4b896; font-size: 0.75rem; text-align: center; }
  .gov-treasury b { color: #f0d080; font-size: 1.0rem; } .gov-happy b { color: #f0e6c8; }
  .gov-bar { height: 8px; background: #3a2e22; border-radius: 5px; overflow: hidden; margin-top: 6px; }
  .gov-fill { height: 100%; }
  .gov-corrupt { color: #e0a090; font-size: 0.78rem; margin-bottom: 8px; }
  .gov-corrupt b { color: #f0c0b0; }
  .gov-anger { color: #e8b090; font-size: 0.78rem; margin-bottom: 8px; }
  .gov-anger b { color: #f4c8a8; }
  .gov-hint { opacity: 0.65; font-size: 0.7rem; }
  .gov-repay { width: 100%; margin: 0 0 10px; background: rgba(70,120,80,0.28); color: #d8f0d0; border: 1px solid #5a9a6a; border-radius: 9px; padding: 9px; font-family: Georgia, serif; font-size: 0.76rem; cursor: pointer; }
  .gov-repay:disabled { opacity: 0.45; cursor: default; }
  .gov-repay b { color: #f0e6c8; }
  .gov-mail { background: rgba(120,90,40,0.3); border: 1px solid #7a6a4a; border-radius: 10px; padding: 8px 10px; margin-bottom: 10px; color: #e8d4b0; font-size: 0.8rem; }
  .gov-mailbtns { display: flex; gap: 8px; margin-top: 8px; }
  .gov-mailbtns button { flex: 1; background: linear-gradient(#e8b84a, #c8922a); color: #1a0800; border: none; border-radius: 9px; padding: 8px; font-family: Georgia, serif; font-weight: bold; font-size: 0.76rem; cursor: pointer; }
  .gov-mailbtns button.ghost { background: rgba(90,74,58,0.5); color: #f0e0c0; }
  .gov-section { color: #cdb79a; font-size: 0.78rem; margin: 10px 0 6px; }
  .gov-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .gov-actions button { background: rgba(60,110,70,0.32); color: #f0e6d2; border: 1px solid #5a7a5a; border-radius: 9px; padding: 8px 6px; font-family: Georgia, serif; font-size: 0.74rem; cursor: pointer; display: flex; flex-direction: column; gap: 2px; text-align: left; }
  .gov-actions button small { color: #a6c6a6; font-size: 0.66rem; }
  .gov-actions button:disabled, .gov-lux:disabled { opacity: 0.45; cursor: default; }
  .gov-actions button.gov-owned { opacity: 1; background: rgba(80,140,90,0.45); border-color: #7adf8a; color: #eafce8; }
  .gov-actions button.gov-owned small { color: #bfe8c0; }
  .gov-lux { width: 100%; margin-top: 6px; background: rgba(150,60,50,0.32); color: #f0d0c0; border: 1px solid #9a5a4a; border-radius: 9px; padding: 9px; font-family: Georgia, serif; font-size: 0.74rem; cursor: pointer; }
  #jail-hud {
    position: fixed; top: calc(60px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 150;
    display: none; flex-direction: column; align-items: center; gap: 4px; padding: 10px 18px;
    background: rgba(14,10,8,0.9); border: 2px solid #7a5a4a; border-radius: 14px; text-align: center;
  }
  #jail-hud .jail-count { color: #f0d080; font-size: 1.15rem; font-weight: bold; }
  #jail-hud .jail-note { color: #c89a7a; font-size: 0.72rem; margin-bottom: 6px; }
  #jail-hud button { background: linear-gradient(#e8b84a, #c8922a); color: #1a0800; border: none; border-radius: 10px; padding: 9px 16px; font-family: Georgia, serif; font-weight: bold; font-size: 0.82rem; cursor: pointer; }
  #gloom { position: fixed; inset: 0; z-index: 5; background: #2a2620; opacity: 0; pointer-events: none; transition: opacity 1.2s; }
  #pay-body .pay-label { color: #e8d4b0; font-size: 0.9rem; text-align: center; }
  #pay-body .pay-amt { color: #f0d080; font-size: 1.6rem; font-weight: bold; text-align: center; margin: 2px 0 8px; }
  #pay-body .pay-note { color: #b8906a; font-size: 0.72rem; font-style: italic; text-align: center; line-height: 1.4; margin-bottom: 14px; }
  #pay-body .pol-primary { margin-bottom: 8px; }

  /* Furniture editor (Sims-style placement) — bottom-right corner, clear of the minimap */
  #decorate-move-btn {
    position: fixed; bottom: calc(90px + env(safe-area-inset-bottom)); right: calc(18px + env(safe-area-inset-right)); z-index: 12;
    width: 44px; height: 44px; border-radius: 10px; background: rgba(20,12,5,0.82); border: 2px solid #7a6a5a;
    color: #f0d080; font-size: 1.25rem; cursor: pointer; display: none; align-items: center; justify-content: center;
  }
  #decorate-move-btn.show { display: flex; }
  #decorate-move-btn.active { background: #c8922a; color: #1a0800; border-color: #f0d080; }
  #decor-tools, #build-tools {
    position: fixed; left: 50%; transform: translateX(-50%); top: calc(150px + env(safe-area-inset-top)); z-index: 120;
    display: none; align-items: center; gap: 7px; padding: 8px 10px; max-width: 94vw;
    background: rgba(20,12,5,0.88); border: 2px solid #7a6a5a; border-radius: 14px;
  }
  #decor-tools.show, #build-tools.show { display: flex; }
  #decor-tools { flex-wrap: wrap; justify-content: center; }
  #decor-tools .hint, #build-tools .hint { color: #e8d4b0; font-size: 0.72rem; white-space: nowrap; }
  #decor-tools button, #build-tools button {
    background: linear-gradient(#e8b84a, #c8922a); color: #1a0800; border: none; border-radius: 10px;
    padding: 9px 11px; font-family: Georgia, serif; font-weight: bold; font-size: 0.78rem; cursor: pointer; white-space: nowrap;
  }
  /* 🛠️ while decorating: a CLEAR view — only the coins, the tool bar and the exit remain */
  body.editing #status-stack, body.editing #needs, body.editing #menu-toggle, body.editing #toolbar,
  body.editing #controls, body.editing #enter-btn, body.editing #stairs-btn, body.editing #context-btn,
  body.editing #give-btn, body.editing #buy-btn, body.editing #family-panel { display: none !important; }
  body.editing #decor-tools { top: calc(10px + env(safe-area-inset-top)); }
  /* 🎬 during any cutscene the HUD leaves the frame — just the scene, the caption, and Skip */
  body.cine #hud, body.cine #needs, body.cine #status-stack, body.cine #menu-toggle, body.cine #toolbar,
  body.cine #controls, body.cine #minimap, body.cine #enter-btn, body.cine #stairs-btn, body.cine #context-btn,
  body.cine #give-btn, body.cine #shelter-btn, body.cine #buy-btn, body.cine #property-btn,
  body.cine #decorate-move-btn, body.cine #tutorial { display: none !important; }

  /* Park catch tally */
  #park-tally {
    display: none; background: rgba(20,12,5,0.82); border: 2px solid #5a8a3a; border-radius: 12px;
    padding: 6px 16px; color: #cfe8b0; font-size: 0.95rem; letter-spacing: 0.04em; white-space: nowrap;
  }
  #park-tally.show { display: block; }

  /* Sleep / night fade */
  #fade {
    position: fixed; inset: 0; z-index: 300; background: #050810; opacity: 0;
    pointer-events: none; transition: opacity 0.6s;
  }
  #fade.show { opacity: 1; }

  /* Dog-scare red flash */
  #flash {
    position: fixed; inset: 0; z-index: 290; background: #c83030; opacity: 0;
    pointer-events: none; transition: opacity 0.18s;
  }
  #flash.show { opacity: 0.4; }

  /* Cutscenes (painted-panel story moments) */
  #cutscene { position: fixed; inset: 0; z-index: 400; display: none; background: #000; }
  #cutscene.show { display: block; }
  #cs-canvas { width: 100%; height: 100%; display: block; }
  #cs-caption {
    position: absolute; left: 50%; bottom: 9%; transform: translateX(-50%); width: 84%; max-width: 760px;
    text-align: center; color: #f6ecd6; font-family: Georgia, serif; font-size: clamp(1rem, 2.7vw, 1.55rem);
    line-height: 1.45; text-shadow: 0 2px 14px #000, 0 0 4px #000; opacity: 0; transition: opacity 0.45s; pointer-events: none;
  }
  #cs-skip {
    position: absolute; top: calc(14px + env(safe-area-inset-top)); right: calc(16px + env(safe-area-inset-right));
    background: rgba(0,0,0,0.45); color: #f0e0c0; border: 1px solid #8a7a5a; border-radius: 20px;
    padding: 8px 18px; font-family: Georgia, serif; font-size: 0.9rem; cursor: pointer; letter-spacing: 0.5px;
  }
  #cs-skip:active { background: rgba(200,146,42,0.5); color: #1a0800; }
  #cs-bars { position: absolute; inset: 0; display: none; pointer-events: none; }
  #cs-bars .cs-bar-top, #cs-bars .cs-bar-bottom { position: absolute; left: 0; right: 0; height: 11%; background: #000; }
  #cs-bars .cs-bar-top { top: 0; } #cs-bars .cs-bar-bottom { bottom: 0; }

  /* Give / Rescue modals */
  .modal { position: fixed; inset: 0; z-index: 160; display: none; align-items: center; justify-content: center; background: rgba(10,6,2,0.8); padding: 20px; }
  .modal.show { display: flex; }
  .modal-card { background: rgba(20,12,5,0.97); border: 2px solid #c8922a; border-radius: 18px; padding: 22px 24px; text-align: center; max-width: 340px; width: 100%; max-height: calc(100% - 8px); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
  .modal-card.wide { max-width: 480px; }
  .modal-title { color: #f0d080; font-size: 1.3rem; margin-bottom: 8px; }
  .modal-sub { color: #d4b896; font-size: 0.85rem; line-height: 1.5; margin-bottom: 16px; }
  .modal-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 16px; }
  .modal-row button { background: #c8922a; color: #1a0800; border: none; border-radius: 12px; padding: 12px 18px; font-family: Georgia, serif; font-weight: bold; font-size: 1rem; cursor: pointer; }
  .modal-row button:active { background: #a87020; }
  .modal-close { background: rgba(120,90,60,0.4); color: #f0e0c0; border: 1px solid #7a6a5a; border-radius: 12px; padding: 10px 28px; font-family: Georgia, serif; cursor: pointer; }
  .scandal-choices { display: flex; flex-direction: column; gap: 10px; }
  .scandal-choices button { display: flex; flex-direction: column; align-items: center; gap: 2px; border: none; border-radius: 12px; padding: 12px 14px; font-family: Georgia, serif; font-weight: bold; font-size: 0.95rem; cursor: pointer; }
  .scandal-choices button small { font-weight: normal; font-size: 0.68rem; opacity: 0.85; }
  .scandal-choices button:disabled { opacity: 0.45; cursor: default; }
  .scandal-bribe { background: rgba(150,110,40,0.4); color: #f0dca0; border: 1px solid #b89040 !important; }
  .scandal-deny { background: rgba(150,60,50,0.38); color: #f0c8bc; border: 1px solid #a05a4a !important; }
  .scandal-confess { background: rgba(70,120,80,0.32); color: #d8f0d0; border: 1px solid #5a9a6a !important; }
  #rescue-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; max-height: 56vh; overflow-y: auto; }
  .rescue-buy { background: #4aa06a; color: #06140c; border: none; border-radius: 10px; padding: 7px 4px; font-family: Georgia, serif; font-weight: bold; font-size: 0.66rem; cursor: pointer; width: 100%; }
  .rescue-buy:active { background: #3a8050; }
  .rescue-tag { font-size: 0.72rem; padding: 6px 0; color: #d4b896; }
  .rescue-tag.freed { color: #7adf8a; font-weight: bold; }

  /* 🏘️ Neighbors & the town postcard */
  .nb-mycode { background: rgba(200,146,42,0.14); border: 1.5px dashed #c8922a; border-radius: 12px; padding: 9px; color: #d4b896; font-size: 0.74rem; margin-bottom: 10px; }
  .nb-mycode b { color: #f0d080; font-size: 1.15rem; letter-spacing: 0.08em; }
  .nb-addrow { display: flex; gap: 7px; margin: 4px 0 12px; }
  .nb-addrow input { flex: 1; background: rgba(20,12,5,0.85); color: #f0e6c8; border: 2px solid #7a6a4a; border-radius: 10px; padding: 9px 12px; font-family: Georgia, serif; font-size: 0.85rem; min-width: 0; }
  .nb-addrow input:focus { outline: none; border-color: #f0d080; }
  .nb-addrow .rescue-buy { width: auto; flex: 0 0 auto; padding: 9px 16px; font-size: 0.8rem; }
  .nb-row { display: flex; align-items: center; gap: 8px; background: rgba(90,74,58,0.22); border: 1px solid #5a4a3a; border-radius: 10px; padding: 8px 10px; margin-bottom: 7px; }
  .nb-row .nb-name { flex: 1; color: #f0e6c8; font-size: 0.85rem; text-align: left; }
  .nb-row .nb-code { color: #b8a078; font-size: 0.68rem; letter-spacing: 0.05em; }
  .nb-note { color: #b8906a; font-size: 0.74rem; font-style: italic; margin: 6px 0 10px; }
  .nb-townname { color: #f0d080; font-size: 1.15rem; margin-bottom: 4px; }
  .zoo-want { font-size: 3.4rem; line-height: 1.1; margin-bottom: 4px; }
  .nb-stats { color: #d4b896; font-size: 0.78rem; line-height: 1.5; margin-bottom: 10px; }
  #townview-wrap { width: 100%; display: flex; justify-content: center; margin-bottom: 12px; }
  /* the postcard fits WHOLE on screen — sized by the smaller of width / viewport height */
  #townview-canvas { width: min(100%, 560px, 58vh); aspect-ratio: 1 / 1; border-radius: 16px; background: #a9d787; box-shadow: 0 8px 30px rgba(0,0,0,0.5); }
  #townview .modal-card { max-width: 620px; }

  /* Mouse-catching minigame */
  #minigame {
    position: fixed; inset: 0; z-index: 150;
    display: none; flex-direction: column;
    background: #2a1d12; touch-action: none;
  }
  #minigame.show { display: flex; }
  /* the HUD clears the phone notch (safe-area) — the title, hearts & CLOCK BAR always visible */
  #mg-top {
    display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: calc(10px + env(safe-area-inset-top)) calc(18px + env(safe-area-inset-right)) 6px calc(18px + env(safe-area-inset-left));
    color: #f0d080;
  }
  #mg-title { font-size: 1.05rem; font-weight: bold; letter-spacing: 0.03em; }
  #mg-stats { color: #f0e8d0; font-size: 0.95rem; white-space: nowrap; }
  #mg-barwrap {
    /* flex: none is THE fix — the canvas's intrinsic size was squeezing this bar to ~2px
       (worst on short phone screens: "the timer doesn't show") */
    flex: 0 0 auto;
    height: 14px; margin: 0 calc(18px + env(safe-area-inset-right)) 6px calc(18px + env(safe-area-inset-left));
    background: rgba(0,0,0,0.5); border: 1px solid rgba(240,208,128,0.35); border-radius: 8px; overflow: hidden;
  }
  #mg-bar { height: 100%; width: 100%; background: linear-gradient(90deg, #c8922a, #f0d080); transition: background 0.3s; }
  #mg-canvas { flex: 1; min-height: 0; width: 100%; display: block; touch-action: none; cursor: pointer; }
  #mg-top { flex: 0 0 auto; }
  #mg-hint { position: absolute; bottom: 16px; left: 0; right: 0; text-align: center; color: #d4b896; font-size: 0.8rem; pointer-events: none; }
  #mg-result {
    position: absolute; inset: 0; display: none; align-items: center; justify-content: center;
    background: rgba(10,6,2,0.82); z-index: 5;
  }
  #mg-result.show { display: flex; }
  .mg-card {
    background: rgba(20,12,5,0.96); border: 2px solid #c8922a; border-radius: 18px;
    padding: 26px 30px; text-align: center; max-width: 300px;
  }
  #mg-res-emoji { font-size: 3rem; }
  #mg-res-title { color: #f0d080; font-size: 1.4rem; margin: 6px 0; }
  #mg-res-text { color: #f0e8d0; font-size: 0.95rem; line-height: 1.4; }
  #mg-res-coins { color: #f0d080; font-size: 1.7rem; margin: 12px 0 16px; }
  #mg-collect {
    background: #c8922a; color: #1a0800; border: none; border-radius: 12px;
    padding: 12px 30px; font-size: 1rem; font-family: Georgia, serif; font-weight: bold; cursor: pointer;
  }
  #mg-collect:active { background: #a87020; }

  /* ── Phone screens: refit the stacked contextual buttons & modals.
     (Portrait phones run the game rotated 90° — physical WIDTH is the game's height.) ── */
  @media (orientation: landscape) and (max-height: 560px), (orientation: portrait) and (max-width: 560px) {
    #enter-btn          { bottom: calc(18px  + env(safe-area-inset-bottom)); }
    #context-btn        { bottom: calc(76px  + env(safe-area-inset-bottom)); }
    #stairs-btn         { bottom: calc(134px + env(safe-area-inset-bottom)); }
    #shelter-btn        { bottom: calc(134px + env(safe-area-inset-bottom)); }
    #give-btn           { bottom: calc(192px + env(safe-area-inset-bottom)); }
    #buy-btn            { bottom: calc(134px + env(safe-area-inset-bottom)); }
    #property-btn       { bottom: calc(250px + env(safe-area-inset-bottom)); }
    /* tighter joystick + toolbar so nothing can touch on a phone screen */
    #joystick { width: 110px; height: 110px; }
    #joy-knob { width: 50px; height: 50px; margin: -25px 0 0 -25px; }
    #stamina  { width: 90px; }
    #menu-toggle { width: 36px; height: 36px; font-size: 1.05rem; }
    #toolbar  { width: 174px; left: calc(60px + env(safe-area-inset-left)); }
    #toolbar button { width: 36px; height: 36px; font-size: 0.95rem; }
    #minimap  { width: 100px; height: 100px; }
    /* modals sized for a phone: tight frame, small headings, ONE scroll area (the card) */
    .modal { padding: 8px; }
    .modal-card { padding: 12px 12px; max-height: calc(100% - 12px); overflow-y: auto; }
    .modal-title { font-size: 1.05rem; margin-bottom: 5px; }
    .modal-sub { font-size: 0.74rem; margin-bottom: 10px; }
    .modal-row button { padding: 9px 13px; font-size: 0.88rem; }
    .modal-close { padding: 8px 20px; font-size: 0.85rem; }
    #cat-grid { max-height: 46vh; overflow-y: auto; }
    #rescue-grid, #homestore-grid, #customise-rows, #catmaker-rows { max-height: none; overflow: visible; }   /* no scroll-inside-scroll */
    .cat-card svg { width: 58px; height: 58px; }
    .store-icon, .school-icon { font-size: 1.5rem; }
    #shelter { padding-top: 10px; }
    #shelter h1 { font-size: 1.25rem; }
    #shelter .subtitle { margin: 4px 0 10px; }
    /* the 🛠️ furniture bar: compact buttons, no hint text stealing width */
    #decor-tools { max-width: 98vw; gap: 5px; padding: 6px 8px; }
    #decor-tools button, #build-tools button { padding: 8px 9px; font-size: 0.72rem; }
    #decor-tools .hint { display: none; }
  }

/* ── 🚗 driving controls: wheel left, pedals right — dressed like the rest of the game ── */
#drive-ui { display: none; }
body.driving #drive-ui { display: block; }
body.driving #joystick, body.driving #btn-stack { display: none !important; }
body.planning #drive-ui, body.cine #drive-ui, body.editing #drive-ui { display: none !important; }   /* the cockpit clears out for planner, cutscenes & editing */
body.driving #minimap {   /* bottom-centre while driving: clear of panels, pedals and thumbs */
  width: 88px; height: 88px;
  top: auto; right: auto; left: 50%;
  bottom: calc(12px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  border-width: 2px;
}
#wheel-zone { position: fixed; left: calc(12px + env(safe-area-inset-left)); bottom: calc(12px + env(safe-area-inset-bottom)); width: 148px; height: 148px; z-index: 40; touch-action: none; }
#wheel {
  width: 124px; height: 124px; margin: 12px; border-radius: 50%;
  border: 12px solid #2e2438;
  background: radial-gradient(circle at 50% 36%, #4a3c58, #241c30 72%);
  box-shadow: 0 6px 18px rgba(0,0,0,.55), 0 0 0 2px rgba(200,146,42,.55), inset 0 2px 8px rgba(255,255,255,.10);
  position: relative; will-change: transform;
}
.wheel-ring { position: absolute; inset: 6px; border-radius: 50%; border: 3px solid rgba(200,146,42,.35); pointer-events: none; }
.wheel-spoke { position: absolute; left: 50%; top: 50%; width: 9px; height: 100px; margin: -50px 0 0 -4.5px; background: linear-gradient(#463a56, #302640); border-radius: 5px; box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.wheel-spoke.s2 { transform: rotate(90deg); }
.wheel-spoke.s3 { transform: rotate(45deg); }
.wheel-spoke.s4 { transform: rotate(135deg); }
.wheel-hub {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  width: 46px; height: 46px; border-radius: 50%;
  background: radial-gradient(circle at 42% 32%, #e8c060, #a06818);
  border: 2px solid #7a5210;
  display: flex; align-items: center; justify-content: center; font-size: 1.25rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.45), inset 0 1px 2px rgba(255,255,255,.35);
}
#pedals { position: fixed; right: calc(12px + env(safe-area-inset-right)); bottom: calc(12px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 9px; z-index: 40; align-items: flex-end; }
#pedals button {
  border-radius: 16px; font-family: Georgia, serif; font-weight: 700;
  background: linear-gradient(rgba(44,30,16,0.92), rgba(26,17,8,0.94));
  border: 2px solid #c8922a; color: #f0d080;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  box-shadow: 0 4px 12px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.14);
  touch-action: none; -webkit-user-select: none; user-select: none;
}
#pedals button small { font-size: .6rem; letter-spacing: .14em; opacity: .9; }
#pedal-gas { width: 94px; height: 78px; font-size: 1.6rem; border-color: #6ac06a; color: #c8f0b0; }
#pedal-brake { width: 94px; height: 64px; font-size: 1.3rem; border-color: #d0584a; color: #f0b8a8; }
#park-btn { width: 94px; height: 42px; font-size: .85rem; flex-direction: row !important; gap: 5px; border-color: #7aa8d8; color: #c8e0f8; }
#horn-btn { width: 94px; height: 42px; font-size: 1.15rem; border-color: #e8c040; }
#pedal-gas:active, #pedal-brake:active, #park-btn:active, #horn-btn:active { transform: scale(.94); filter: brightness(1.3); }
@media (orientation: landscape) and (max-height: 560px), (orientation: portrait) and (max-width: 560px) {
  #wheel-zone { width: 128px; height: 128px; }
  #wheel { width: 104px; height: 104px; margin: 12px; border-width: 10px; }
  .wheel-spoke { height: 84px; margin-top: -42px; }
  .wheel-hub { width: 40px; height: 40px; font-size: 1.05rem; }
  #pedal-gas { width: 86px; height: 66px; font-size: 1.35rem; }
  #pedal-brake { width: 86px; height: 54px; font-size: 1.15rem; }
  #park-btn, #horn-btn { width: 86px; height: 36px; }

}

/* ── 🦘🤫🐾 the action stack: joystick LEFT thumb, these under the RIGHT thumb ── */
#btn-stack {
  position: fixed; right: calc(14px + env(safe-area-inset-right)); bottom: calc(14px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column-reverse; gap: 10px; z-index: 30;
}
#btn-stack .action-btn { margin-bottom: 0; }
#btn-jump.charging { background: rgba(232,192,64,0.45); border-color: #ffd040; transition: none; }
body.indoors #btn-sneak, body.indoors #btn-attack { display: none; }   /* inside, only Jump — clears the 🛠️ decorate button */
#btn-sneak.on { background: rgba(106,90,170,0.55); border-color: #b8a8f0; color: #e8e0ff; }
@media (orientation: landscape) and (max-height: 560px), (orientation: portrait) and (max-width: 560px) {
  #btn-stack { gap: 7px; }
  #btn-stack .action-btn { width: 50px; height: 50px; font-size: 0.6rem; }
  #btn-stack .action-btn .btn-icon { font-size: 1.15rem; }
}

/* ── 🔍 map zoom controls ── */
#map-wrap { position: relative; }
#map-canvas { touch-action: none; }
#map-zoom { position: absolute; right: 10px; bottom: 10px; display: flex; flex-direction: column; gap: 6px; }
#map-zoom button {
  width: 42px; height: 42px; border-radius: 10px; font-size: 1.1rem; cursor: pointer;
  background: rgba(20,12,5,0.82); border: 2px solid #c8922a; color: #f0d080;
  display: flex; align-items: center; justify-content: center;
}
#map-zoom button:active { background: rgba(200,146,42,0.5); }

/* ── ⚙️ settings rows ── */
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 4px; border-bottom: 1px solid rgba(200,146,42,0.25); }
.set-row:last-child { border-bottom: none; }
.set-info { display: flex; align-items: center; gap: 10px; text-align: left; }
.set-icon { font-size: 1.4rem; }
.set-info small { display: block; opacity: 0.75; font-size: 0.72rem; }
.set-pill {
  min-width: 64px; padding: 8px 0; border-radius: 999px; font-family: inherit; font-weight: 700; cursor: pointer;
  background: rgba(90,70,50,0.5); border: 2px solid #7a6a5a; color: #c8b8a0;
}
.set-pill.on { background: rgba(106,160,80,0.45); border-color: #8ac858; color: #d8f0c0; }

/* ── 💬 dialogue lives top-centre, clear of every button (cutscenes keep it low) ── */
#dialogue { top: calc(122px + env(safe-area-inset-top)); bottom: auto !important; }
body.cine #dialogue { top: auto; bottom: calc(24px + env(safe-area-inset-bottom)) !important; }
@media (orientation: landscape) and (max-height: 560px), (orientation: portrait) and (max-width: 560px) {
  #dialogue { top: calc(100px + env(safe-area-inset-top)); width: min(340px, 58vw); }
}

/* ── indoors: park tally & population are outdoor business ── */
body.indoors #park-tally, body.indoors #population { display: none !important; }

/* ── 🤝 hiring CVs — little paper résumés you can actually read ── */
.hire-list { display: flex; flex-direction: column; gap: 12px; margin: 10px 0; color: #f2e4c8; }
.hire-card {
  text-align: left; border: 2px solid rgba(200,146,42,0.55); border-radius: 14px;
  padding: 12px 14px; color: #f2e4c8;
  background: linear-gradient(rgba(255,240,210,0.10), rgba(255,240,210,0.04));
  box-shadow: 0 2px 8px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.07);
}
.hire-card.busy { opacity: 0.55; }
.hire-head { font-size: 1rem; display: flex; align-items: center; gap: 9px; color: #ffe9c0; border-bottom: 1px dashed rgba(200,146,42,0.4); padding-bottom: 6px; }
.hire-chip { width: 22px; height: 22px; border-radius: 50%; border: 3px solid; display: inline-block; box-shadow: 0 1px 3px rgba(0,0,0,0.4); }
.hire-det { font-size: 0.8rem; color: #e2d2b2; line-height: 1.6; margin: 7px 0; }
.hire-busy { font-size: 0.76rem; color: #d8a860; font-style: italic; }
.hire-btn { width: 100%; padding: 9px; border-radius: 10px; border: 2px solid #8ac858; background: rgba(106,160,80,0.32); color: #d8f0c0; font-family: inherit; font-weight: 700; cursor: pointer; }
.hire-btn:active { background: rgba(106,160,80,0.55); }

/* ── ✕ every panel closes from the top corner ── */
.modal-card { position: relative; }
.modal-x {
  position: absolute; top: 8px; right: 8px; z-index: 5;
  width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid #c8922a; background: rgba(20,12,5,0.85); color: #f0d080;
  font-size: 1rem; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.modal-x:active { background: rgba(200,146,42,0.5); }
