  /* ── trex view (offline runner) ────────────────────────── */
  body.view-trex { overflow: hidden; }
  #view-trex {
    position: fixed;
    inset: 0;
    overflow: hidden;
    background: var(--bg);
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
  }
  #view-trex:not(.active) { display: none; }
  .trex-stage {
    position: absolute;
    inset: 0;
    cursor: pointer;
  }
  .trex-ground {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 22%;
    height: 1px;
    background: var(--ink);
  }
  .trex-ground::before {
    content: "";
    position: absolute;
    left: 0; right: 0;
    top: 1px;
    height: 14px;
    background-image:
      radial-gradient(circle, rgba(26,26,26,.35) 1px, transparent 1.4px),
      radial-gradient(circle, rgba(26,26,26,.25) 1px, transparent 1.4px);
    background-size: 22px 14px, 38px 14px;
    background-position: 0 4px, 14px 10px;
    opacity: .55;
  }
  .trex-actor {
    position: absolute;
    left: 80px;
    bottom: 22%;
    width: 64px;
    height: 64px;
    color: var(--ink);
    transform-origin: bottom center;
    will-change: transform;
  }
  .trex-actor svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    fill: currentColor;
    shape-rendering: crispEdges;
  }
  .trex-actor .leg-a { display: block; }
  .trex-actor .leg-b { display: none; }
  .trex-actor.step  .leg-a { display: none; }
  .trex-actor.step  .leg-b { display: block; }
  .trex-actor.jumping .leg-a,
  .trex-actor.jumping .leg-b { display: none; }
  .trex-actor.jumping .leg-jump { display: block; }
  .trex-actor .leg-jump { display: none; }
  .trex-actor.dead .eye { fill: var(--bg); }
  .trex-actor.dead .eye-x { display: block; }
  .trex-actor .eye-x { display: none; }

  .trex-party-hat {
    position: absolute;
    top: -32px;
    left: 36px;
    width: 36px;
    height: 44px;
    pointer-events: none;
    opacity: 0;
    transform: scale(0) rotate(-30deg);
    transform-origin: bottom center;
    transition: opacity .2s;
  }
  .trex-actor.party .trex-party-hat {
    opacity: 1;
    animation: trex-hat-pop .9s cubic-bezier(.2,1.4,.4,1) both,
               trex-hat-wobble 2.2s ease-in-out .9s infinite;
  }
  .trex-party-hat svg {
    position: static;
    width: 100%;
    height: 100%;
    overflow: visible;
    shape-rendering: geometricPrecision;
  }
  @keyframes trex-hat-pop {
    0%   { transform: scale(0) rotate(-180deg) translateY(20px); }
    50%  { transform: scale(1.25) rotate(15deg) translateY(0); }
    72%  { transform: scale(.9) rotate(-8deg); }
    100% { transform: scale(1) rotate(-12deg); }
  }
  @keyframes trex-hat-wobble {
    0%, 100% { transform: scale(1) rotate(-12deg); }
    50%      { transform: scale(1) rotate(-4deg); }
  }
  /* Little confetti bursts around the rex when partying */
  .trex-confetti {
    position: absolute;
    inset: -40px -20px 0 -20px;
    pointer-events: none;
    opacity: 0;
  }
  .trex-actor.party .trex-confetti { opacity: 1; }
  .trex-confetti span {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 1px;
    opacity: 0;
  }
  .trex-actor.party .trex-confetti span {
    animation: trex-confetti 1.6s ease-out infinite;
  }
  .trex-confetti span:nth-child(1) { left: 10%; background: #c6efb1; animation-delay: 0s; }
  .trex-confetti span:nth-child(2) { left: 30%; background: #d97757; animation-delay: .2s; }
  .trex-confetti span:nth-child(3) { left: 50%; background: #c6efb1; animation-delay: .4s; }
  .trex-confetti span:nth-child(4) { left: 70%; background: #d97757; animation-delay: .6s; }
  .trex-confetti span:nth-child(5) { left: 90%; background: #c6efb1; animation-delay: .8s; }
  @keyframes trex-confetti {
    0%   { transform: translateY(20px) rotate(0); opacity: 0; }
    10%  { opacity: 1; }
    100% { transform: translateY(-90px) rotate(360deg); opacity: 0; }
  }

  .trex-world {
    position: absolute;
    inset: 0;
    pointer-events: none;
  }
  .trex-obstacle,
  .trex-coin {
    position: absolute;
    left: 0;
    will-change: transform;
  }
  .trex-obstacle {
    bottom: 22%;
    color: var(--ink);
  }
  .trex-obstacle svg {
    display: block;
    fill: currentColor;
    shape-rendering: crispEdges;
  }
  .trex-stack-coin {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    padding: 0;
    /* mint default */
    background: linear-gradient(180deg, #e7f6d6 0%, #c6efb1 55%, #95d278 100%);
    box-shadow:
      inset 0 0 0 1.5px #6fb049,
      inset 0 0 0 3px #defaca,
      inset 0 -7px 12px -8px rgba(60,100,40,.45),
      0 10px 18px -6px rgba(120,180,90,.45);
    color: #2f5d1f;
  }
  /* alternate to orange */
  .trex-stack-coin:nth-child(even) {
    background: linear-gradient(180deg, #fbdccc 0%, #e9b5a0 45%, #d97757 100%);
    box-shadow:
      inset 0 0 0 1.5px #a85339,
      inset 0 0 0 3px #f6cdbb,
      inset 0 -7px 12px -8px rgba(120,40,20,.45),
      0 10px 18px -6px rgba(217,119,87,.45);
    color: #5c2812;
  }
  .trex-coin-illu {
    width: 56%;
    height: 56%;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .trex-coin-illu svg {
    width: 100%;
    height: 100%;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  /* Full-page confetti burst when all 8 projects are collected */
  .trex-bigconfetti {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 6;
  }
  .trex-bigconfetti-piece {
    position: absolute;
    top: -10%;
    display: inline-block;
    border-radius: 1px;
    will-change: transform, opacity;
  }
  /* Fall stops above the rex (~65vh) and fades out before reaching him,
     so the playfield stays clear for keep-playing. */
  @keyframes trex-bigconfetti-fall {
    0%   { transform: translate(0, 0) rotate(var(--rot-start, 0deg)); opacity: 1; }
    55%  { opacity: 1; }
    100% { transform: translate(var(--x-drift, 0), 65vh) rotate(var(--rot-end, 720deg)); opacity: 0; }
  }

  /* Standalone pause button in the top-right corner */
  .trex-pause-btn {
    position: absolute;
    top: 90px;
    right: 22px;
    width: 30px;
    height: 30px;
    border: 1px solid var(--line);
    background: var(--card);
    border-radius: 6px;
    color: var(--ink-soft);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: color .2s, background .2s, border-color .2s;
    z-index: 5;
  }
  .trex-pause-btn:hover { color: var(--ink); border-color: var(--ink); }
  .trex-pause-btn svg { width: 14px; height: 14px; fill: currentColor; }

  /* Centered status column: big count → stack → action */
  .trex-center {
    position: absolute;
    left: 50%;
    top: 28%;
    transform: translateX(-50%);
    width: min(640px, calc(100vw - 40px));
    text-align: center;
    z-index: 4;
    pointer-events: none;
  }
  .trex-status { margin-bottom: 18px; }
  .trex-bigcount {
    font-family: var(--serif);
    font-size: 64px;
    font-weight: 600;
    line-height: 1;
    color: var(--ink-mute);
    letter-spacing: -.02em;
    margin-bottom: 8px;
  }
  .trex-bigcount em {
    font-style: normal;
    color: var(--ink);
  }
  .trex-bigcount-label {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: .22em;
    text-transform: uppercase;
    color: var(--ink-mute);
  }
  /* Prompt content (replaces big-count during pause / game-over) */
  .trex-prompt-content { display: none; }
  .trex-center.is-prompt .trex-bigcount-wrap { display: none; }
  .trex-center.is-prompt .trex-prompt-content { display: block; }
  .trex-center.is-prompt .trex-prompt-action { display: block; }
  .trex-prompt-action { display: none; margin-top: 14px; }
  .trex-stack {
    display: flex;
    flex-direction: row-reverse;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    max-width: 100%;
    pointer-events: auto;
    margin: 0 auto;
  }
  .trex-stack-coin {
    cursor: pointer;
    transition: transform .15s cubic-bezier(.2,.8,.2,1),
                background .25s, box-shadow .25s, color .25s;
    transform-origin: center;
    animation: trex-coin-pop .55s cubic-bezier(.2,1.3,.35,1) both;
  }
  .trex-stack-coin:hover {
    transform: translateY(-3px) scale(1.08) rotate(-2deg);
    z-index: 2;
  }
  /* On hover, deepen the chip's own color (darker variant of the same hue) */
  .trex-stack-coin:hover {
    background: linear-gradient(180deg, #c6efb1 0%, #95d278 55%, #5a9a3a 100%);
    box-shadow:
      inset 0 0 0 1.5px #3f7820,
      inset 0 0 0 3px #b8e399,
      inset 0 -7px 12px -8px rgba(30,70,15,.6),
      0 16px 26px -8px rgba(80,140,60,.55);
    color: #1d3c0f;
  }
  .trex-stack-coin:nth-child(even):hover {
    background: linear-gradient(180deg, #e9b5a0 0%, #d97757 45%, #9a4a2e 100%);
    box-shadow:
      inset 0 0 0 1.5px #6f3018,
      inset 0 0 0 3px #e0a08a,
      inset 0 -7px 12px -8px rgba(80,25,8,.6),
      0 16px 26px -8px rgba(190,90,60,.55);
    color: #3a1607;
  }
  /* Game-y spawn: pops in big with a small bounce-back wobble */
  @keyframes trex-coin-pop {
    0%   { transform: scale(.3) rotate(-22deg) translateY(-8px); opacity: 0; }
    40%  { transform: scale(1.25) rotate(10deg) translateY(2px); opacity: 1; }
    65%  { transform: scale(.9)  rotate(-5deg); }
    85%  { transform: scale(1.06) rotate(2deg); }
    100% { transform: scale(1)   rotate(0); opacity: 1; }
  }
  /* Hint + game over overlay */
  .trex-hint {
    position: absolute;
    left: 50%;
    top: 18%;
    transform: translateX(-50%);
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: .22em;
    text-transform: uppercase;
    color: var(--ink-mute);
    pointer-events: none;
    transition: opacity .25s;
    text-align: center;
  }
  .trex-hint.hide { opacity: 0; }
  .trex-hint .key {
    display: inline-block;
    padding: 2px 8px;
    border: 1px solid var(--line);
    border-radius: 4px;
    color: var(--ink-soft);
    margin: 0 3px;
  }

  /* Chip hover preview: compact card anchored under the hovered chip */
  .trex-chip-hover {
    position: absolute;
    /* top + left are set inline by showTrexChipHover() relative to the chip */
    top: 0;
    left: 0;
    width: 300px;
    max-width: calc(100vw - 40px);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
    opacity: 0;
    transform: translate(-50%, 8px);
    transition: opacity .25s, transform .25s cubic-bezier(.2,.8,.2,1);
    pointer-events: none;
    z-index: 4;
    box-shadow: 0 22px 50px -22px rgba(26,26,26,.4);
  }
  .trex-chip-hover.show {
    opacity: 1;
    transform: translate(-50%, 0);
  }
  .trex-chip-hover .tch-cover {
    aspect-ratio: 16 / 10;
    background: var(--bg-tint);
    overflow: hidden;
    position: relative;
  }
  .trex-chip-hover .tch-cover::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(26,26,26,0) 55%, rgba(26,26,26,.45) 100%);
    pointer-events: none;
  }
  .trex-chip-hover .tch-cover video,
  .trex-chip-hover .tch-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }
  .trex-chip-hover .tch-body { padding: 12px 14px 14px; }
  .trex-chip-hover .tch-meta {
    font-family: var(--mono);
    font-size: 9px;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--ink-mute);
    margin-bottom: 4px;
  }
  .trex-chip-hover .tch-title {
    font-family: var(--serif);
    font-size: 19px;
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: -.01em;
    color: var(--ink);
    margin: 0 0 6px;
  }
  .trex-chip-hover .tch-summary {
    font-family: var(--serif);
    font-size: 13px;
    line-height: 1.45;
    color: var(--ink-soft);
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .trex-prompt-eyebrow {
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: .24em;
    text-transform: uppercase;
    color: var(--ink-mute);
  }
  .trex-prompt-title {
    font-family: var(--serif);
    font-size: 24px;
    font-weight: 600;
    margin: 4px 0 6px;
    color: var(--ink);
  }
  .trex-prompt-sub {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--ink-mute);
    line-height: 1.6;
  }
  .trex-prompt-sub em {
    font-style: normal;
    color: var(--ink-soft);
    font-weight: 600;
  }
  .trex-prompt-action button {
    pointer-events: auto;
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: .22em;
    text-transform: uppercase;
    color: var(--ink-soft);
    background: transparent;
    border: none;
    padding: 6px 10px;
    cursor: pointer;
    transition: color .2s;
  }
  .trex-prompt-action button:hover { color: var(--ink); }
  .trex-prompt-action .key {
    display: inline-block;
    padding: 2px 8px;
    border: 1px solid var(--line);
    border-radius: 4px;
    color: var(--ink-soft);
    margin: 0 3px;
  }

  @media (max-width: 820px) {
    .trex-actor { width: 52px; height: 52px; left: 40px; }
    .trex-pause-btn { top: 76px; right: 12px; }
    .trex-stack-coin { width: 44px; height: 44px; border-radius: 10px; }
    .trex-stack { gap: 6px; }
    .trex-hint { font-size: 10px; top: 18%; }
    .trex-hint-desktop { display: none; }
    .trex-prompt-action .key { display: none; }
    .trex-center { top: 24%; }
    .trex-bigcount { font-size: 48px; }
    .trex-bigcount-label { font-size: 10px; }
    .trex-chip-hover { width: 240px; }
    .trex-chip-hover .tch-title { font-size: 16px; }
    .trex-chip-hover .tch-summary { font-size: 12px; -webkit-line-clamp: 2; }
  }

