/* ============ ONG YONG QUAN — terminal portfolio · card track ============ */

/* ---------- Themes ---------- */
:root, :root[data-theme="twilight"] {
  --bg: #0b0b16;
  --bg-deep: #070710;
  --bg-panel: rgba(15, 14, 32, 0.9);
  --accent: #a78bfa;
  --accent-2: #7dd3fc;
  --accent-dim: #6d5bb8;
  --edge: #2a2b4a;
  --edge-soft: #1b1c33;
  --text: #d7d9f2;
  --text-dim: #8a8fb8;
  --warn: #fbbf24;
  --err: #fb7185;
  --glow: 0 0 8px rgba(167, 139, 250, 0.55);
  --glow-soft: rgba(167, 139, 250, 0.2);
  --sel-fg: #0b0b16;
}
:root[data-theme="moonlight"] {
  --bg: #0a0f1c;
  --bg-deep: #060a13;
  --bg-panel: rgba(12, 19, 36, 0.9);
  --accent: #9db8e8;
  --accent-2: #c3ecf6;
  --accent-dim: #5f7cad;
  --edge: #223350;
  --edge-soft: #16233a;
  --text: #dce6f5;
  --text-dim: #7f93b3;
  --warn: #e8d49d;
  --err: #f28b9b;
  --glow: 0 0 8px rgba(157, 184, 232, 0.55);
  --glow-soft: rgba(157, 184, 232, 0.2);
  --sel-fg: #0a0f1c;
}
:root[data-theme="matrix"] {
  --bg: #050a06;
  --bg-deep: #020503;
  --bg-panel: rgba(6, 16, 9, 0.9);
  --accent: #33ff66;
  --accent-2: #ffb000;
  --accent-dim: #1d8a45;
  --edge: #0e3a20;
  --edge-soft: #092614;
  --text: #c9f5d4;
  --text-dim: #7fbf93;
  --warn: #ffb000;
  --err: #ff5555;
  --glow: 0 0 6px rgba(51, 255, 102, 0.55);
  --glow-soft: rgba(51, 255, 102, 0.18);
  --sel-fg: #04120a;
}

:root { --mono: "Cascadia Code", "Consolas", "Fira Code", "JetBrains Mono", "Courier New", monospace; }

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.65;
}

.scrollable { overflow-y: auto; scrollbar-width: none; -ms-overflow-style: none; }
.scrollable::-webkit-scrollbar { display: none; }

::selection { background: var(--accent); color: var(--sel-fg); }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); text-shadow: var(--glow); }
button { font-family: var(--mono); }

/* ---------- CRT overlays ---------- */
.crt-scanlines {
  position: fixed; inset: 0; pointer-events: none; z-index: 9000;
  background: repeating-linear-gradient(to bottom,
    rgba(0,0,0,0) 0px, rgba(0,0,0,0) 2px, rgba(0,0,0,0.13) 3px);
  mix-blend-mode: multiply;
}
.crt-vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 9001;
  background: radial-gradient(ellipse at center, transparent 58%, rgba(0,0,0,0.52) 100%);
  animation: flicker 9s infinite;
}
@keyframes flicker {
  0%, 91%, 94%, 100% { opacity: 1; }
  92% { opacity: 0.9; }
  97% { opacity: 0.95; }
}

/* ---------- Boot ---------- */
#boot {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg-deep);
  padding: 6vh 6vw;
  transition: opacity 0.6s ease;
}
#boot.done { opacity: 0; pointer-events: none; }
#boot-log {
  font-family: var(--mono); font-size: 14px; color: var(--text);
  white-space: pre-wrap; text-shadow: var(--glow);
}
#boot-log .ok { color: var(--accent); }
#boot-log .warn { color: var(--warn); }
.boot-skip {
  position: absolute; bottom: 4vh; left: 0; right: 0;
  text-align: center; color: var(--text-dim); font-size: 12px;
  animation: blink 1.4s step-end infinite;
}

/* ---------- three.js city background ---------- */
#bg3d { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
#bg3d canvas { display: block; opacity: 0.9; }

#mrain {
  position: fixed; inset: 0; z-index: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  mix-blend-mode: screen;      /* black becomes transparent over the city */
  opacity: 0.5;
}

/* ---------- Cursor black hole ---------- */
#bhole {
  position: fixed; left: 0; top: 0; z-index: 9500;
  pointer-events: none;
  will-change: transform;
}
@media (prefers-reduced-motion: reduce) { #bhole { display: none; } }

/* ---------- Nav ---------- */
#nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 8000;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px 26px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.5), transparent);
}
.nav-logo {
  background: none; border: none; cursor: pointer;
  color: var(--accent); font-weight: bold; font-size: 15px;
  text-shadow: var(--glow); letter-spacing: 1px;
}
.nav-links { display: flex; gap: 4px; flex-wrap: wrap; }
.nav-links button {
  background: none; border: none; cursor: pointer;
  color: var(--text-dim); font-size: 13.5px; padding: 4px 10px;
  transition: color .2s;
}
.nav-links button::before { content: "./"; opacity: .55; }
.nav-links button.nav-term::before { content: ""; }
.nav-links button:hover, .nav-links button.active { color: var(--accent); text-shadow: var(--glow); }
.nav-links .nav-term { color: var(--accent-2); }
.theme-switch { display: flex; gap: 6px; }
.theme-switch button {
  width: 30px; height: 30px; cursor: pointer;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--edge);
  color: var(--text-dim); font-size: 14px; line-height: 1;
  transition: all .2s;
}
.theme-switch button:hover { color: var(--accent); border-color: var(--accent-dim); }
.theme-switch button.active {
  color: var(--accent); border-color: var(--accent);
  box-shadow: 0 0 10px var(--glow-soft);
}

/* ---------- HUD ---------- */
#hud-rail {
  position: fixed; right: 22px; top: 50%; transform: translateY(-50%);
  z-index: 8000; display: flex; flex-direction: column; gap: 14px;
}
#hud-rail .rail-dot {
  width: 9px; height: 9px; border-radius: 50%;
  border: 1px solid var(--accent-dim);
  background: transparent; cursor: pointer; padding: 0;
  transition: all .3s;
}
#hud-rail .rail-dot:hover { border-color: var(--accent); }
#hud-rail .rail-dot.active {
  background: var(--accent); border-color: var(--accent);
  box-shadow: 0 0 10px var(--glow-soft), var(--glow);
  transform: scale(1.25);
}
#hud-counter {
  position: fixed; left: 26px; bottom: 22px; z-index: 8000;
  color: var(--text-dim); font-size: 12.5px; letter-spacing: 2px;
}
#hud-counter #hud-num { color: var(--accent); text-shadow: var(--glow); }
#hud-counter #hud-name { color: var(--text); }
#hud-hint {
  position: fixed; right: 48px; bottom: 22px; z-index: 8000;
  color: var(--text-dim); font-size: 12px; letter-spacing: 1px;
  animation: hintpulse 2.6s ease-in-out infinite;
}
@keyframes hintpulse { 50% { opacity: 0.35; } }

/* ---------- Card track ---------- */
#dimmer {
  position: fixed; inset: 0; z-index: 1;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 52%, rgba(0, 0, 0, 0.58) 0%, rgba(0, 0, 0, 0.30) 60%, rgba(0, 0, 0, 0.14) 100%);
}

#deck { position: fixed; inset: 0; z-index: 2; }
.scene {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 72px 40px 52px;
  perspective: 1400px;
  pointer-events: none;
  will-change: transform, opacity;
  visibility: hidden;
}
.scene.shown { visibility: visible; }
.scene.front { pointer-events: auto; }

.scene-card {
  width: min(92vw, 1000px);
  max-height: 76vh;
  display: flex; flex-direction: column;
  border: 1px solid var(--edge);
  background: var(--bg-panel);
  backdrop-filter: blur(10px);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6), 0 0 28px var(--glow-soft);
  transform: translate(var(--tx, 0px), var(--ty, 0px)) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform .3s ease-out, box-shadow .3s ease;
  cursor: pointer;
}
.scene-card:hover { box-shadow: 0 28px 80px rgba(0,0,0,.65), 0 0 40px var(--glow-soft); }
.scene-card.card-bare {
  border: none; background: transparent;
  backdrop-filter: none; box-shadow: none; cursor: default;
}
.scene-card.term-live, .scene-card[data-no-click-expand] { cursor: default; }

.card-inner {
  padding: 24px 30px 28px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none; -ms-overflow-style: none;
  position: relative;
  flex: 1; min-height: 0;
}
.card-inner::-webkit-scrollbar { display: none; }
.card-bare .card-inner { overflow: visible; }
#term-in { pointer-events: auto; }

/* clipped-content fade at card bottom */
.scene-card:not(.card-bare):not(.expanded) .card-inner::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: 0; height: 26px;
  background: linear-gradient(to bottom, transparent, var(--bg));
  pointer-events: none;
  opacity: .5;
}

/* ---------- Expanded preview ---------- */
#backdrop {
  position: fixed; inset: 0; z-index: 8400;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(7px);
  opacity: 0; pointer-events: none;
  transition: opacity .35s ease;
}
#backdrop.show { opacity: 1; pointer-events: auto; }

.scene-card.expanded {
  position: fixed;
  inset: 5vh 5vw;
  width: auto; max-height: none;
  z-index: 8600;
  transform: none !important;
  cursor: default;
  animation: cardin .4s cubic-bezier(.16,1,.3,1);
}
@keyframes cardin {
  from { transform: translateY(50px) scale(.94); opacity: 0; }
  to   { transform: none; opacity: 1; }
}
.scene-card.expanded .card-inner {
  overflow-y: auto;
  scrollbar-width: none; -ms-overflow-style: none;
}
.scene-card.expanded .card-inner::-webkit-scrollbar { display: none; }

.term-bar {
  display: flex; align-items: center; gap: 7px;
  padding: 9px 14px;
  background: rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid var(--edge-soft);
  flex-shrink: 0;
}
.dot { width: 11px; height: 11px; border-radius: 50%; opacity: .85; }
.dot.r { background: #ff5f56; } .dot.y { background: #ffbd2e; } .dot.g { background: #27c93f; }
.term-title { margin-left: 10px; color: var(--text-dim); font-size: 12.5px; }
.expand-btn {
  margin-left: auto;
  background: none; border: 1px solid var(--edge);
  color: var(--text-dim); font-size: 13px; line-height: 1;
  width: 24px; height: 24px; cursor: pointer;
  transition: all .2s;
}
.expand-btn:hover { color: var(--accent); border-color: var(--accent); box-shadow: 0 0 8px var(--glow-soft); }
.expanded .expand-btn { color: var(--accent); }

.cmd { color: var(--text-dim); margin-bottom: 12px; font-size: 14px; }

h2 {
  font-size: 25px; letter-spacing: 4px;
  color: var(--accent); text-shadow: var(--glow);
  margin-bottom: 14px;
}
h3 { color: var(--text); font-size: 16px; }

.glitch { position: relative; display: inline-block; }
.glitch::before, .glitch::after {
  content: attr(data-text);
  position: absolute; top: 0; left: 0; width: 100%;
  opacity: 0; pointer-events: none;
}
.glitch:hover { animation: glitch-base .6s steps(1) infinite; }
.glitch:hover::before {
  opacity: .85; color: var(--accent-2);
  text-shadow: 2px 0 currentColor;
  animation: glitch-a .34s steps(1) infinite;
}
.glitch:hover::after {
  opacity: .85; color: var(--accent);
  text-shadow: -2px 0 currentColor;
  animation: glitch-b .27s steps(1) infinite;
}
@keyframes glitch-a {
  0%   { transform: translate(-3px, -1px); clip-path: inset(8% 0 64% 0); }
  20%  { transform: translate(3px, 1px); clip-path: inset(56% 0 14% 0); }
  40%  { transform: translate(-2px, 2px) skewX(4deg); clip-path: inset(28% 0 46% 0); }
  60%  { transform: translate(3px, -2px); clip-path: inset(78% 0 3% 0); }
  80%  { transform: translate(-3px, 1px); clip-path: inset(2% 0 82% 0); }
  100% { transform: translate(2px, -1px) skewX(-3deg); clip-path: inset(40% 0 36% 0); }
}
@keyframes glitch-b {
  0%   { transform: translate(3px, 1px); clip-path: inset(62% 0 10% 0); }
  20%  { transform: translate(-3px, -1px) skewX(-4deg); clip-path: inset(12% 0 70% 0); }
  40%  { transform: translate(2px, -2px); clip-path: inset(48% 0 22% 0); }
  60%  { transform: translate(-2px, 2px); clip-path: inset(6% 0 86% 0); }
  80%  { transform: translate(3px, -1px) skewX(3deg); clip-path: inset(70% 0 8% 0); }
  100% { transform: translate(-2px, 1px); clip-path: inset(24% 0 58% 0); }
}
@keyframes glitch-base {
  0%, 100% { transform: none; opacity: 1; }
  28% { transform: skewX(1deg); }
  30% { transform: skewX(-1.4deg) translateX(1px); opacity: .82; }
  33% { transform: none; opacity: 1; }
  64% { transform: translateX(-2px); opacity: .9; }
  66% { transform: translateX(2px); }
  68% { transform: none; opacity: 1; }
}

/* ---------- Hero ---------- */
.hero-content { text-align: center; }
.banner {
  font-size: clamp(4px, 1.25vw, 14px);
  line-height: 1.12;
  color: var(--accent);
  text-shadow: 0 0 12px var(--glow-soft), 0 0 34px var(--glow-soft);
  margin-bottom: 20px;
  user-select: none;
  display: inline-block; text-align: left;
}
.banner-mini { display: none; font-size: 11px; }
.hero-type { font-size: clamp(15px, 2.2vw, 21px); margin-bottom: 8px; }
.prompt { color: var(--accent-2); }
.cursor { animation: blink 1s step-end infinite; color: var(--accent); }
@keyframes blink { 50% { opacity: 0; } }
.hero-sub { color: var(--text-dim); font-size: 14px; margin-bottom: 30px; }
.hero-cta { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.btn {
  display: inline-block; cursor: pointer;
  border: 1px solid var(--edge);
  padding: 9px 18px;
  color: var(--accent); font-size: 14px;
  background: rgba(0, 0, 0, 0.35);
  transition: all 0.22s ease;
}
.btn:hover {
  background: var(--accent); border-color: var(--accent);
  color: var(--sel-fg);
  box-shadow: 0 0 20px var(--glow-soft), 0 0 40px var(--glow-soft);
  text-shadow: none;
}
.btn-primary { border-color: var(--accent); }

/* ---------- About ---------- */
.about-grid {
  display: grid; grid-template-columns: auto 1fr; gap: 30px;
  align-items: center;
}
.portrait-wrap { text-align: center; }
.portrait {
  font-size: clamp(4px, 0.72vw, 7.5px);
  line-height: 1.02;
  color: var(--text-dim);
  display: inline-block; text-align: left;
  user-select: none;
  text-shadow: 0 0 4px rgba(0,0,0,.4);
  mask-image: radial-gradient(ellipse 72% 64% at 50% 44%, black 52%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 72% 64% at 50% 44%, black 52%, transparent 100%);
}
.portrait i { font-style: normal; }
.portrait-cap { color: var(--text-dim); font-size: 11.5px; margin-top: 8px; }
.facts { list-style: none; margin-top: 14px; }
.facts li { padding: 2px 0; font-size: 13.5px; color: var(--text); }
.facts .k, .contact-list .k { color: var(--text-dim); }
.ok { color: var(--accent); text-shadow: var(--glow); }

/* ---------- Skills ---------- */
.skills-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 26px; }
.skill-col h3 { color: var(--accent-2); margin-bottom: 12px; font-size: 14.5px; }
.skill { margin-bottom: 11px; }
.skill-name { display: block; font-size: 13.5px; margin-bottom: 3px; }
.bar {
  display: block; height: 10px;
  border: 1px solid var(--edge);
  position: relative; overflow: hidden;
  background: rgba(0, 0, 0, 0.3);
}
.bar::after {
  content: "";
  position: absolute; inset: 1px auto 1px 1px;
  width: 0;
  background: repeating-linear-gradient(90deg, var(--accent) 0 6px, var(--glow-soft) 6px 8px);
  box-shadow: 0 0 8px var(--glow-soft);
  transition: width 1.2s cubic-bezier(.2,.7,.3,1) .35s;
}
.scene.active .skill[data-level="85"] .bar::after { width: 85%; }
.scene.active .skill[data-level="80"] .bar::after { width: 80%; }
.scene.active .skill[data-level="75"] .bar::after { width: 75%; }
.scene.active .skill[data-level="70"] .bar::after { width: 70%; }
.scene.active .skill[data-level="65"] .bar::after { width: 65%; }

/* ---------- Projects ---------- */
.proj-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.proj-card {
  border: 1px solid var(--edge);
  padding: 16px 18px 13px;
  background: rgba(0, 0, 0, 0.28);
  position: relative;
  transition: transform .22s ease, border-color .22s ease, box-shadow .22s ease;
}
.proj-card::before {
  content: "▮"; position: absolute; top: 12px; right: 14px;
  color: var(--edge); transition: color .22s;
}
.proj-card:hover {
  transform: translateY(-5px);
  border-color: var(--accent);
  box-shadow: 0 12px 30px rgba(0,0,0,.5), 0 0 16px var(--glow-soft);
}
.proj-card:hover::before { color: var(--accent); animation: blink 1s step-end infinite; }
.proj-card h3 { margin-bottom: 3px; color: var(--accent); font-size: 15px; }
.proj-tag { color: var(--accent-2); font-size: 11.5px; margin-bottom: 8px; }
.proj-card p { font-size: 12.5px; color: var(--text); }
.proj-stack { margin-top: 10px; color: var(--text-dim); font-size: 11.5px !important; }

/* ---------- Experience ---------- */
.timeline { border-left: 1px dashed var(--accent-dim); margin: 6px 0 20px 6px; padding-left: 26px; }
.tl-item { position: relative; margin-bottom: 18px; }
.tl-item::before {
  content: "◆"; position: absolute; left: -34px; top: 1px;
  color: var(--accent); text-shadow: var(--glow); font-size: 13px;
}
.tl-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.tl-date { color: var(--accent-2); font-size: 13px; white-space: nowrap; }
.tl-role { color: var(--text-dim); font-size: 13px; font-style: italic; margin: 1px 0 6px; }
.tl-item ul { margin-left: 20px; }
.tl-item li { font-size: 13px; margin-bottom: 3px; }
.timeline.edu .tl-item { margin-bottom: 12px; }

/* ---------- Contact ---------- */
.contact-card { width: min(92vw, 660px); }
.contact-list { list-style: none; margin: 14px 0; }
.contact-list li { padding: 3px 0; }
.pong { color: var(--text-dim); font-size: 13px; margin-top: 12px; }
.foot-note { color: var(--text-dim); font-size: 11.5px; margin-top: 20px; border-top: 1px solid var(--edge-soft); padding-top: 12px; }

/* ---------- Interactive terminal ---------- */
.term-live { width: min(92vw, 900px); }
.term-live .card-inner {
  height: min(60vh, 540px);
  cursor: text; font-size: 14px;
}
.term-live .card-inner::after { display: none; }
#term-out { white-space: pre-wrap; word-break: break-word; }
#term-out .t-cmd { color: var(--text); }
#term-out .t-dim { color: var(--text-dim); }
#term-out .t-ok { color: var(--accent); }
#term-out .t-warn { color: var(--warn); }
#term-out .t-err { color: var(--err); }
#term-out a { text-decoration: underline; }
.term-input-line { display: flex; gap: 8px; margin-top: 4px; }
.term-input-wrap { position: relative; flex: 1; display: flex; }
#term-ghost {
  position: absolute; left: 0; top: 0;
  color: var(--text-dim); opacity: 0.45;
  font-family: var(--mono); font-size: 14px; line-height: inherit;
  pointer-events: none; white-space: pre;
}
#term-in {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--accent); font-family: var(--mono); font-size: 14px;
  caret-color: var(--accent);
}
#term-in::placeholder { color: var(--text-dim); opacity: .5; }

/* ---------- Hire pricing tiers ---------- */
.tier-note { color: var(--text-dim); font-size: 13.5px; margin-bottom: 16px; }
.tier-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(205px, 1fr)); gap: 14px; }
.tier {
  position: relative;
  border: 1px solid var(--edge);
  background: rgba(0, 0, 0, 0.28);
  padding: 16px 16px 14px;
  display: flex; flex-direction: column;
  transition: transform .22s ease, border-color .22s ease, box-shadow .22s ease;
}
.tier:hover {
  transform: translateY(-5px);
  border-color: var(--accent);
  box-shadow: 0 12px 30px rgba(0,0,0,.5), 0 0 16px var(--glow-soft);
}
.tier.hot { border-color: var(--accent); box-shadow: 0 0 18px var(--glow-soft); }
.tier.best { border-color: var(--accent-2); }
.tier-badge {
  position: absolute; top: -9px; right: 10px;
  font-size: 9.5px; letter-spacing: 1px;
  padding: 2px 8px;
  background: var(--accent); color: var(--sel-fg);
  box-shadow: 0 0 10px var(--glow-soft);
}
.tier.best .tier-badge { background: var(--accent-2); }
.tier h3 { color: var(--accent); font-size: 14.5px; letter-spacing: 2px; margin-bottom: 2px; }
.tier.best h3 { color: var(--accent-2); }
.tier-price { font-size: 17px; color: var(--text); margin-bottom: 10px; }
.tier-price span { font-size: 11.5px; color: var(--text-dim); }
.tier ul { list-style: none; margin: 0 0 14px; flex: 1; }
.tier li { font-size: 12px; padding: 2.5px 0 2.5px 18px; position: relative; }
.tier li.y::before { content: "✓"; position: absolute; left: 0; color: var(--accent); }
.tier li.n { color: var(--text-dim); opacity: .55; }
.tier li.n::before { content: "🔒"; position: absolute; left: 0; font-size: 10px; }
.tier-cta {
  display: block; text-align: center;
  border: 1px solid var(--edge);
  padding: 7px 10px;
  font-size: 12.5px;
  color: var(--accent);
  background: rgba(0, 0, 0, 0.3);
  transition: all .2s ease;
}
a.tier-cta:hover {
  background: var(--accent); border-color: var(--accent);
  color: var(--sel-fg); text-shadow: none;
  box-shadow: 0 0 16px var(--glow-soft);
}
.tier-cta.primary { border-color: var(--accent-2); color: var(--accent-2); }
a.tier-cta.primary:hover { background: var(--accent-2); border-color: var(--accent-2); color: var(--sel-fg); }
.tier-cta.current { color: var(--text-dim); border-style: dashed; cursor: default; }
.tier-fine { color: var(--text-dim); font-size: 10.5px; margin-top: 14px; opacity: .8; }

/* ---------- Responsive ---------- */
@media (max-width: 920px) {
  .about-grid { grid-template-columns: 1fr; gap: 16px; justify-items: center; }
  .portrait { font-size: 5px; }
}
@media (max-width: 760px) {
  .banner-full { display: none; }
  .banner-mini { display: block; }

  /* nav: logo + theme on row 1, links as one swipeable row below */
  #nav {
    padding: 8px 12px 6px;
    flex-wrap: wrap;
    background: linear-gradient(to bottom, rgba(0,0,0,0.72), rgba(0,0,0,0.35) 70%, transparent);
  }
  .nav-logo { order: 1; font-size: 14px; }
  .theme-switch { order: 2; }
  .nav-links {
    order: 3;
    flex: 1 1 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none; -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
    justify-content: flex-start;
    margin-top: 2px;
    mask-image: linear-gradient(to right, black 88%, transparent);
    -webkit-mask-image: linear-gradient(to right, black 88%, transparent);
  }
  .nav-links::-webkit-scrollbar { display: none; }
  .nav-links button { padding: 6px 7px; font-size: 12.5px; white-space: nowrap; flex-shrink: 0; }
  .theme-switch button { width: 28px; height: 28px; }

  #hud-rail { right: 6px; gap: 11px; }
  #hud-rail .rail-dot { width: 8px; height: 8px; }
  #hud-hint { display: none; }
  #hud-counter { left: 14px; bottom: 12px; font-size: 11px; }

  .scene { padding: 92px 12px 40px; }
  .scene-card { max-height: calc(100vh - 140px); max-height: calc(100dvh - 140px); width: min(94vw, 1000px); }
  .card-inner { padding: 16px 14px 20px; }
  .scene-card.expanded { inset: 2vh 2vw; }
  .term-live .card-inner { height: min(52dvh, 540px); }
  .tl-head { flex-direction: column; gap: 0; }
  h2 { font-size: 21px; letter-spacing: 3px; }
  #term-in, #term-ghost, .term-live .card-inner { font-size: 16px; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .crt-vignette, #hud-hint { animation: none; }
  .cursor, .boot-skip { animation: none; }
  .glitch:hover { animation: none; }
  .glitch:hover::before, .glitch:hover::after { animation: none; opacity: 0; }
  .scene-card { transition: none; }
  .scene-card.expanded { animation: none; }
}
