
  /* ─── DESIGN TOKENS ──────────────────────────────────────────────
     All colours live here. Change these to retheme the whole UI.
     jade       = garden / nature tones
     amethyst   = architectural / mystical tones
     papa/mama  = custody guardian colours (blue / terracotta)
     accent     = warm highlight (used for current-event borders etc)
  ─────────────────────────────────────────────────────────────── */
  :root {
    --jade: #6ead8f; --jade-dark: #31483d;
    --amethyst: #8f77c7; --amethyst-deep: #463564;
    --papa: #6B93AD; --papa-bg: rgba(107,147,173,0.18);
    --mama: #C07050; --mama-bg: rgba(192,112,80,0.18);
    --accent: #c97a50;
    --header-line: rgba(91, 72, 58, 0.2);
    --header-track: rgba(74, 61, 112, 0.18);
  }

  /* ─── PAGE BASE ──────────────────────────────────────────────────
     Background is a CSS radial gradient — NOT a Three.js scene background.
     alpha:true on the renderer lets this show through.
     To change background: edit the radial-gradient below.
  ─────────────────────────────────────────────────────────────── */
  body, html {
    margin: 0; padding: 0; width: 100vw; height: 100vh; overflow: hidden;
    background: radial-gradient(circle at 50% 44%, #eef2f4 0%, #bfd0de 100%);
    font-family: 'Outfit', sans-serif;
  }

  /* Three.js canvas sits at z-index 1; the HTML UI overlay sits at z-index 10 above it */
  #canvas-container { position: absolute; top: 0; left: 0; width: 100vw; height: 100vh; z-index: 1; }
  #ui-layer { position: absolute; top: 0; left: 0; width: 100vw; height: 100vh; z-index: 10; pointer-events: none; display: flex; flex-direction: column; }

  /* ─── HEADER (top-centre overlay) ───────────────────────────────
     Shows: "Currently Occupying" label → big activity name → countdown + guardian badge
     To resize the activity name: edit the clamp() in .header-activity font-size
  ─────────────────────────────────────────────────────────────── */
  .header { position: absolute; top: 2.8vh; right: clamp(1rem, 4vw, 2.75rem); width: min(23rem, 42vw); display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; text-align: left; }
  .header-label { margin: 0; font-size: 0.68rem; letter-spacing: 6px; text-transform: uppercase; color: var(--jade-dark); font-weight: 800; opacity: 0.78; }
  .header-activity { margin: 0.1rem 0 0; font-size: clamp(2.5rem, 7vw, 4.65rem); font-weight: 200; color: var(--amethyst-deep); letter-spacing: -1.4px; line-height: 0.98; }
  .header-meta { display: flex; align-items: flex-start; gap: 14px; margin-top: 0.55rem; }
  .header-countdown-wrap { display: flex; flex-direction: column; align-items: flex-start; gap: 7px; min-width: 158px; padding: 0; border: none; background: transparent; box-shadow: none; }
  .header-countdown { font-size: 0.86rem; font-weight: 700; color: var(--amethyst); letter-spacing: 0.6px; line-height: 1; min-height: 0.95rem; }
  .header-progress { width: 100%; height: 4px; background: var(--header-track); overflow: hidden; }
  .header-progress-fill { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, rgba(201, 122, 80, 0.95) 0%, rgba(240, 191, 117, 0.95) 100%); transform-origin: left center; transition: width 0.35s ease; }

  /* Guardian badge — automatically gets class "papa" or "mama" via JS */
  .header-guardian { font-size: 0.7rem; font-weight: 800; letter-spacing: 2px; text-transform: uppercase; padding: 5px 10px; border-radius: 20px; }
  .header-guardian.papa { background: var(--papa-bg); color: var(--papa); }
  .header-guardian.mama { background: var(--mama-bg); color: var(--mama); }
  .header-guardian.neutral { background: rgba(138,138,147,0.18); color: #8a8a93; }

  @media (max-width: 760px) {
    .header {
      width: min(17.5rem, calc(100vw - 2rem));
      right: 1rem;
    }
  }

  /* ─── EVENTS PANEL (right side) ─────────────────────────────────
     CSS is ready; cards are not yet populated by JS (known gap B2).
     To enable: build card HTML in updateHeader() and append to #events-panel
  ─────────────────────────────────────────────────────────────── */
  #events-panel { position: absolute; top: 18vh; right: 16px; max-width: 200px; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
  .evt-card { background: rgba(255,255,255,0.75); backdrop-filter: blur(10px); border-radius: 10px; padding: 7px 11px; border: 1px solid rgba(200,189,223,0.3); display: flex; flex-direction: column; gap: 2px; }
  .evt-card.now { border-color: var(--accent); background: rgba(212,132,90,0.1); }
  .evt-time { font-size: 0.65rem; font-weight: 800; color: var(--amethyst); letter-spacing: 1px; }
  .evt-title { font-size: 0.78rem; font-weight: 600; color: var(--amethyst-deep); }

  .timetable-tablet {
    display: none;
    position: absolute;
    left: clamp(0.9rem, 3vw, 2.1rem);
    top: clamp(5.8rem, 15vh, 8.8rem);
    width: min(18.5rem, 30vw);
    max-height: min(23rem, 48vh);
    box-sizing: border-box;
    overflow: hidden;
    padding: 1.05rem 1rem 1.15rem;
    color: rgba(43, 36, 30, 0.72);
    background:
      linear-gradient(90deg, rgba(55,45,37,0.18), transparent 10%, transparent 90%, rgba(55,45,37,0.13)),
      linear-gradient(180deg, #B5AAA0 0%, #9B9289 42%, #81786E 100%);
    border-top: 2px solid rgba(44, 36, 30, 0.22);
    border-bottom: 2px solid rgba(44, 36, 30, 0.3);
    clip-path: polygon(3% 0, 100% 0, 98% 9%, 100% 21%, 97% 100%, 0 100%, 2% 78%, 0 59%, 2% 31%, 0 12%);
    pointer-events: none;
  }
  .timetable-tablet::before {
    content: '';
    position: absolute;
    left: 11%;
    right: 18%;
    top: 0.55rem;
    height: 2px;
    background: rgba(226, 216, 199, 0.22);
  }
  .timetable-kicker {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.58rem;
    letter-spacing: 0.08em;
    color: rgba(43, 36, 30, 0.45);
    text-transform: lowercase;
  }
  .timetable-title-main {
    margin-top: 0.28rem;
    font-size: 1.12rem;
    line-height: 1;
    color: rgba(42, 35, 30, 0.74);
    font-weight: 800;
    text-transform: lowercase;
  }
  .timetable-list {
    list-style: none;
    margin: 0.75rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    max-height: calc(min(23rem, 48vh) - 4.1rem);
    overflow: hidden;
  }
  .timetable-row {
    display: grid;
    grid-template-columns: 5.45rem minmax(0, 1fr);
    gap: 0.65rem;
    align-items: baseline;
    padding: 0.46rem 0;
    border-top: 1px solid rgba(43, 36, 30, 0.16);
  }
  .timetable-time {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.58rem;
    color: rgba(43, 36, 30, 0.48);
    white-space: nowrap;
  }
  .timetable-title {
    min-width: 0;
    font-size: 0.78rem;
    line-height: 1.14;
    font-weight: 600;
    color: rgba(37, 31, 27, 0.68);
    overflow-wrap: anywhere;
    text-transform: lowercase;
  }
  .timetable-empty {
    padding-top: 0.75rem;
    border-top: 1px solid rgba(43, 36, 30, 0.16);
    font-size: 0.72rem;
    line-height: 1.25;
    color: rgba(43, 36, 30, 0.45);
  }

  @media (max-width: 760px) {
    .timetable-tablet {
      top: auto;
      left: 1rem;
      bottom: clamp(8.5rem, 22vh, 11rem);
      width: min(17.5rem, calc(100vw - 2rem));
      max-height: 24vh;
      padding: 0.85rem 0.85rem 0.95rem;
    }
    .timetable-title-main {
      font-size: 0.96rem;
    }
    .timetable-row {
      grid-template-columns: 4.85rem minmax(0, 1fr);
      gap: 0.45rem;
      padding: 0.36rem 0;
    }
  }

  #week-hotspots {
    position: absolute;
    left: 0;
    bottom: clamp(2.5rem, 7vh, 5.5rem);
    width: min(23rem, 58vw);
    height: clamp(5rem, 17vh, 7.5rem);
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    pointer-events: auto;
  }
  .week-hotspot {
    appearance: none;
    border: none;
    background: transparent;
    margin: 0;
    padding: 0;
    cursor: pointer;
  }

  #rewards-panel { display: none; }

  /* ─── SETTINGS GEAR (bottom-right) ──────────────────────────────
     Carved stone disc. Click opens the settings tablet.
  ─────────────────────────────────────────────────────────────── */
  .settings-gear { position: fixed; bottom: 16px; right: 16px; width: 42px; height: 42px; border-radius: 50%; background: linear-gradient(160deg, #B8B0A4, #9A9490); border: 1.5px solid rgba(80,70,62,0.25); box-shadow: 0 4px 12px rgba(40,30,25,0.25), inset 0 1px 0 rgba(220,210,200,0.4); font-size: 17px; color: rgba(60,50,45,0.7); cursor: pointer; display: flex; align-items: center; justify-content: center; z-index: 100; pointer-events: auto; transition: transform 0.15s; }
  .settings-gear:active { transform: scale(0.92); }

  /* ─── STONE TABLET SETTINGS ─────────────────────────────────── */
  .modal-bg { position: fixed; inset: 0; background: rgba(12,10,8,0.4); display: none; align-items: center; justify-content: center; z-index: 5000; }
  .modal-bg.open { display: flex; }

  .modal { position: relative; background: linear-gradient(178deg, #A89E94 0%, #8E857C 40%, #7A7268 100%); border-radius: 0; padding: 0; width: min(420px, calc(100vw - 40px)); max-height: 80vh; overflow-y: auto; box-shadow: 0 8px 40px rgba(20,15,10,0.4), inset 0 1px 0 rgba(200,190,178,0.35); border: 1px solid rgba(60,52,45,0.2); pointer-events: auto; }

  /* Top edge — chiselled line */
  .modal::after { content: ''; position: absolute; left: 30%; right: 30%; top: 10px; height: 3px; border-radius: 2px; background: rgba(200,190,175,0.35); pointer-events: none; }

  .tablet-header { padding: 24px 24px 8px; text-align: center; }
  .tablet-title { margin: 0; font-size: 0.65rem; font-weight: 800; letter-spacing: 5px; text-transform: uppercase; color: rgba(50,42,36,0.5); }

  .tablet-section { padding: 6px 20px; }
  .tablet-divider { height: 1px; margin: 4px 20px 8px; background: rgba(60,52,45,0.12); }

  .tablet-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 4px; }
  .tablet-label { font-size: 0.72rem; font-weight: 600; letter-spacing: 1.2px; text-transform: uppercase; color: rgba(40,34,28,0.65); }
  .tablet-hint { font-size: 0.62rem; color: rgba(40,34,28,0.4); margin-top: 2px; letter-spacing: 0.5px; }
  .tablet-note { padding: 0 4px 10px; font-size: 0.62rem; color: rgba(40,34,28,0.46); letter-spacing: 0.4px; }
  .tablet-inline-btn { flex: 0; padding: 6px 14px; font-size: 0.6rem; min-width: 88px; }

  /* Stone toggle */
  .stone-toggle { width: 44px; height: 24px; appearance: none; border-radius: 12px; background: rgba(60,52,45,0.2); border: 1px solid rgba(60,52,45,0.15); position: relative; cursor: pointer; transition: background 0.2s; flex-shrink: 0; }
  .stone-toggle::before { content: ''; position: absolute; width: 18px; height: 18px; top: 2px; left: 2px; border-radius: 50%; background: linear-gradient(160deg, #C8C0B4, #A89E94); box-shadow: 0 1px 4px rgba(40,30,20,0.25); transition: transform 0.15s ease; }
  .stone-toggle:checked { background: rgba(123,196,160,0.4); }
  .stone-toggle:checked::before { transform: translateX(20px); }

  /* Stone slider */
  .stone-slider { width: 120px; padding: 0; background: transparent; border: none; box-shadow: none; flex-shrink: 0; }
  .stone-slider::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: rgba(60,52,45,0.18); }
  .stone-slider::-webkit-slider-thumb { appearance: none; margin-top: -7px; width: 20px; height: 20px; border-radius: 50%; background: linear-gradient(160deg, #C8C0B4, #A89E94); border: 1px solid rgba(60,52,45,0.2); box-shadow: 0 2px 6px rgba(40,30,20,0.2); }
  .tablet-slider-wrap { display: flex; align-items: center; gap: 10px; }
  .tablet-value { min-width: 42px; text-align: right; font-size: 0.66rem; font-weight: 700; letter-spacing: 0.8px; color: rgba(40,34,28,0.52); }

  /* Stone select */
  .stone-select { padding: 6px 10px; border-radius: 8px; background: rgba(60,52,45,0.1); border: 1px solid rgba(60,52,45,0.15); font-family: Outfit, sans-serif; font-size: 0.72rem; font-weight: 600; color: rgba(40,34,28,0.7); letter-spacing: 0.8px; appearance: none; cursor: pointer; }
  .role-select { width: 100%; min-height: 86px; margin-top: 6px; border-radius: 0; letter-spacing: 0.2px; }
  .role-select option { padding: 4px 2px; }
  .role-select:disabled { color: rgba(40,34,28,0.36); cursor: default; }
  .tablet-role-hint { margin-top: 4px; font-size: 0.58rem; line-height: 1.35; color: rgba(40,34,28,0.42); letter-spacing: 0.2px; }

  /* Stone date input */
  .stone-input { padding: 6px 10px; border-radius: 8px; background: rgba(60,52,45,0.1); border: 1px solid rgba(60,52,45,0.15); font-family: Outfit, sans-serif; font-size: 0.72rem; font-weight: 600; color: rgba(40,34,28,0.7); }

  /* Stone textarea */
  .stone-textarea { width: 100%; box-sizing: border-box; padding: 8px 10px; border-radius: 8px; background: rgba(60,52,45,0.08); border: 1px solid rgba(60,52,45,0.12); font-family: Outfit, sans-serif; font-size: 0.7rem; color: rgba(40,34,28,0.65); min-height: 40px; resize: vertical; margin-top: 6px; }

  /* Expandable advanced section */
  .tablet-advanced-toggle { display: block; width: 100%; padding: 10px 4px; background: none; border: none; font-family: Outfit, sans-serif; font-size: 0.62rem; font-weight: 800; letter-spacing: 3px; text-transform: uppercase; color: rgba(40,34,28,0.35); cursor: pointer; text-align: left; }
  .tablet-advanced-toggle::after { content: ' +'; }
  .tablet-advanced-toggle.open::after { content: ' −'; }
  .tablet-advanced-body { display: none; padding: 4px 0 8px; }
  .tablet-advanced-body.open { display: block; }
  .tablet-advanced-row { padding: 6px 4px; }
  .tablet-advanced-label { font-size: 0.62rem; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: rgba(40,34,28,0.45); }

  /* Bottom actions */
  .tablet-actions { display: flex; gap: 8px; padding: 14px 20px 20px; }
  .tablet-btn { flex: 1; padding: 10px 0; border-radius: 10px; font-family: Outfit, sans-serif; font-size: 0.7rem; font-weight: 800; letter-spacing: 1.5px; text-transform: uppercase; cursor: pointer; text-align: center; }
  .tablet-btn-primary { background: rgba(60,52,45,0.15); border: 1px solid rgba(60,52,45,0.2); color: rgba(40,34,28,0.7); }
  .tablet-btn-primary:active { background: rgba(60,52,45,0.25); }
  .tablet-btn-close { background: none; border: 1px solid rgba(60,52,45,0.1); color: rgba(40,34,28,0.4); }
  .tablet-status { padding: 0 20px 8px; font-size: 0.65rem; font-weight: 600; color: rgba(90,106,77,0.8); min-height: 1.2em; }

  .modal::-webkit-scrollbar { width: 6px; }
  .modal::-webkit-scrollbar-thumb { background: rgba(60,52,45,0.2); border-radius: 3px; }
