/* ============================================================
   XMB Portfolio · Tokens
   ============================================================ */
:root {
  /* Background stack */
  --bg:           #161412;
  --bg-deep:      #0E0C0B;
  --surface:      #1C1916;
  --elevated:     #1E1B18;
  --border:       #2A2520;
  --border-subtle:#3D3020;

  /* Text */
  --text-primary:   #E8D9C0;
  --text-secondary: #7A7068;
  --text-tertiary:  #5A5248;

  /* Active focus colour — driven by JS as the focused category changes */
  --tint-active:    #97BCB7;
  --focus-glow:     color-mix(in oklab, var(--tint-active) 18%, transparent);

  /* Spacing / sizing */
  --icon-size-focus:    72px;
  --icon-size-rest:     54px;
  --cat-gap:            96px;
  --sub-gap:            44px;
  --infobar-h:          44px;
  --page-pad-x:         clamp(20px, 4vw, 56px);

  /* Anchor of the focused icon — fraction of viewport (0 = left, 0.5 = centre) */
  --anchor-x:           0.22;
  --anchor-y:           0.32;

  /* Timing */
  --t-cat:    300ms cubic-bezier(.25,0,0,1);
  --t-icon:   200ms cubic-bezier(.25,0,0,1);
  --t-sub:    250ms cubic-bezier(.25,0,0,1);
  --t-tint:   500ms ease;
}

/* ============================================================
   Reset
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: 'DM Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-weight: 400;
  color: var(--text-primary);
  background: var(--bg-deep);
  overflow: hidden;
  min-height: 100vh;
  letter-spacing: 0.02em;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

ul { list-style: none; }

/* ============================================================
   Background layers
   ============================================================ */
.bg-photo,
#wave-bg,
#particles,
.bg-vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.bg-photo {
  z-index: 0;
  background-image: url('/aurora_2.jpg');
  background-size: cover;
  background-position: center 30%;
  background-repeat: no-repeat;
  filter: saturate(0.7) brightness(0.55);
}

#wave-bg    { z-index: 1; opacity: 0.35; }
#particles  { z-index: 2; opacity: 0.5; }

.bg-vignette {
  z-index: 3;
  background:
    linear-gradient(180deg,
      rgba(14,12,11,0.65) 0%,
      rgba(14,12,11,0.1)  20%,
      rgba(14,12,11,0.1)  68%,
      rgba(14,12,11,0.80) 100%),
    radial-gradient(ellipse 90% 70% at 50% 50%,
      transparent 35%,
      rgba(14,12,11,0.5) 100%);
}

/* ============================================================
   Info bar
   ============================================================ */
#infobar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--infobar-h);
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 var(--page-pad-x);
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 0.5px solid var(--border);
  font-size: 11px;
  letter-spacing: 0.14em;
}

#infobar .brand {
  color: var(--text-primary);
  opacity: 0.85;
}

#infobar .cat-name {
  color: var(--tint-active);
  text-align: center;
  transition: color var(--t-tint);
}

#infobar .meta {
  color: var(--text-tertiary);
  text-align: right;
}

/* ============================================================
   XMB main
   ============================================================ */
#xmb {
  position: relative;
  z-index: 10;
  height: 100vh;
  padding-top: calc(var(--infobar-h) + var(--anchor-y) * 100vh - var(--icon-size-focus));
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
}

/* ─── Category bar (horizontal) ─── */
#categories {
  width: 100%;
  overflow: hidden;
  position: relative;
}

.cat-list {
  display: flex;
  align-items: flex-end;
  gap: var(--cat-gap);
  padding: 24px var(--page-pad-x);
  /* The focused item is centred — JS translates the strip */
  transform: translateX(0);
  transition: transform var(--t-cat);
  will-change: transform;
}

.cat {
  flex: 0 0 auto;
  --tint: var(--text-primary);
  color: var(--tint);
}

.cat-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 12px;
  transition:
    transform   var(--t-icon),
    opacity     var(--t-icon),
    background  var(--t-icon);
}

.cat-icon {
  width: var(--icon-size-rest);
  height: var(--icon-size-rest);
  display: block;
  color: rgba(255, 255, 255, 0.55);
  transition:
    width      var(--t-icon),
    height     var(--t-icon),
    color      var(--t-icon),
    filter     var(--t-icon),
    transform  var(--t-icon);
}

.cat-label {
  font-size: 11px;
  letter-spacing: 0.16em;
  color: rgba(255, 255, 255, 0.5);
  opacity: 0;
  transform: translateY(-4px);
  transition:
    opacity   var(--t-icon),
    transform var(--t-icon),
    color     var(--t-icon);
}

/* States */
.cat.is-focused .cat-icon {
  width: var(--icon-size-focus);
  height: var(--icon-size-focus);
  color: var(--tint);
  filter: drop-shadow(0 0 14px color-mix(in oklab, var(--tint) 60%, transparent));
}
.cat.is-focused .cat-btn {
  background: color-mix(in oklab, var(--tint) 10%, transparent);
}
.cat.is-focused .cat-label {
  opacity: 1;
  color: var(--tint);
  transform: translateY(0);
}

.cat.is-adjacent .cat-icon { color: rgba(255,255,255,0.55); }
.cat.is-distant  .cat-icon { color: rgba(255,255,255,0.30); transform: scale(0.92); }

/* ─── Profile prose panel ─── */
.sub-prose {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 460px;
  font-size: 13px;
  line-height: 1.65;
  color: rgba(255,255,255,0.78);
  letter-spacing: 0.02em;
  text-wrap: pretty;
}
.sub-prose p { margin: 0; }
.sub-prose .resume-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--tint-active);
  text-decoration: none;
  border-bottom: 0.5px dashed color-mix(in oklab, var(--tint-active) 60%, transparent);
  align-self: flex-start;
  padding-bottom: 1px;
  transition: color var(--t-icon), border-color var(--t-icon), transform var(--t-icon);
}
.sub-prose .resume-link::before { content: '['; opacity: 0.55; }
.sub-prose .resume-link::after  { content: ']'; opacity: 0.55; }
.sub-prose .resume-link:hover {
  color: #fff;
  border-color: #fff;
  transform: translateX(2px);
}
.sub-list.is-prose {
  align-items: stretch;
  padding: 8px 4px;
  min-width: 380px;
  max-width: min(540px, 92vw);
  background: none;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-radius: 0;
}
.prose-logo {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.prose-logo-bubble {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 8px;
  border-radius: 6px;
  background: color-mix(in oklab, var(--tint-active) 14%, transparent);
  flex-shrink: 0;
}
.prose-logo-img {
  width: var(--icon-size-rest);
  height: var(--icon-size-rest);
  border-radius: 6px;
  display: block;
}
.prose-logo-content {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.sub-list.is-prose::before,
.sub-list.is-prose::after { display: none; }

/* ─── Profile vertical axis ─── */
.sub-list.is-profile {
  position: fixed;
  inset: 0;
  display: block;
  background: none;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  padding: 0;
  min-width: unset;
  gap: 0;
  pointer-events: none;
}
.sub-list.is-profile > .sub {
  position: absolute;
  pointer-events: auto;
  transition: top var(--t-sub);
  will-change: top;
}
.sub-list.is-profile .sub-icon {
  border-radius: 8px;
}
.profile-detail {
  position: absolute;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(460px, 90vw);
  font-size: 13px;
  line-height: 1.65;
  color: rgba(255,255,255,0.78);
  letter-spacing: 0.02em;
  text-wrap: pretty;
}
.profile-detail p { margin: 0; }
.profile-detail .profile-year {
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--tint-active);
  transition: color var(--t-icon);
  margin-right: 4px;
}
.profile-entry-icon {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-left: 6px;
  vertical-align: middle;
  opacity: 0.75;
}
.profile-entry-icon svg { width: 100%; height: 100%; display: block; }
.profile-detail.is-swap {
  animation: detail-in 320ms cubic-bezier(.25,0,0,1);
}
.profile-detail .resume-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--tint-active);
  text-decoration: none;
  border-bottom: 0.5px dashed color-mix(in oklab, var(--tint-active) 60%, transparent);
  align-self: flex-start;
  padding-bottom: 1px;
  transition: color var(--t-icon), border-color var(--t-icon), transform var(--t-icon);
}
.profile-detail .resume-link::before { content: '['; opacity: 0.55; }
.profile-detail .resume-link::after  { content: ']'; opacity: 0.55; }
.profile-detail .resume-link:hover {
  color: #fff;
  border-color: #fff;
  transform: translateX(2px);
}

/* ─── Projects view ─── */
.sub-list.is-projects {
  position: fixed;
  inset: 0;
  display: block;
  pointer-events: none;
  z-index: 15;
  padding: 0;
  min-width: unset;
  gap: 0;
}

.sub-list.is-projects > .projects-list {
  position: absolute;
  inset: 0;
  display: block;
  list-style: none;
  margin: 0;
  padding: 0;
  pointer-events: none;
}

.sub-list.is-projects > .projects-list > .proj-row {
  position: absolute;
  pointer-events: auto;
  width: 260px;
  transition: color var(--t-icon), background var(--t-icon), transform var(--t-icon), top var(--t-sub);
  will-change: top;
}

.sub-list.is-projects > .proj-detail {
  position: absolute;
  pointer-events: auto;
  width: 320px;
}
.projects-wrap {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(220px, 320px);
  gap: 36px;
  align-items: start;
}
.projects-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.proj-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  color: rgba(255,255,255,0.55);
  transition: color var(--t-icon), background var(--t-icon), transform var(--t-icon);
  opacity: 0;
  transform: translateX(-8px);
  animation: sub-in 250ms ease-out forwards;
}
.proj-row .proj-thumb {
  width: 56px;
  height: 38px;
  border-radius: 3px;
  flex-shrink: 0;
  background: var(--surface);
  border: 0.5px solid var(--border);
  overflow: hidden;
  display: block;
  filter: saturate(0.4) brightness(0.85);
  transition: filter var(--t-icon), border-color var(--t-icon), transform var(--t-icon);
}
.proj-row .proj-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.proj-row .proj-title {
  font-size: 13px;
  letter-spacing: 0.06em;
}
.proj-row .proj-sub {
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--text-tertiary);
}
.proj-row.is-focused {
  color: #fff;
  background: color-mix(in oklab, var(--tint-active) 12%, transparent);
}
.proj-row.is-focused .proj-thumb {
  filter: saturate(1) brightness(1);
  border-color: color-mix(in oklab, var(--tint-active) 60%, transparent);
  transform: scale(1.02);
}
.proj-row.is-focused .proj-sub {
  color: var(--tint-active);
}

.proj-detail {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 320px;
  padding-top: 4px;
}
.proj-detail.is-swap {
  animation: detail-in 320ms cubic-bezier(.25,0,0,1);
}
.proj-detail .hero {
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 4px;
  border: 0.5px solid var(--border);
  background: var(--surface);
  overflow: hidden;
  display: block;
  position: relative;
}
.proj-detail .hero svg,
.proj-detail .hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.proj-detail .hero.hero-interactive {
  cursor: pointer;
}
.proj-detail .hero.hero-interactive::after {
  content: '↵ launch';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  letter-spacing: 0.18em;
  color: #fff;
  background: rgba(14,12,11,0.55);
  opacity: 0;
  transition: opacity 180ms ease;
}
.proj-detail .hero.hero-interactive:hover::after {
  opacity: 1;
}
.proj-detail .det-title {
  font-size: 14px;
  letter-spacing: 0.04em;
  color: #fff;
}
.proj-detail .det-meta {
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--tint-active);
  margin-top: -8px;
  transition: color var(--t-tint);
}
.proj-detail .det-desc {
  font-size: 12px;
  line-height: 1.65;
  color: rgba(255,255,255,0.72);
  letter-spacing: 0.02em;
  text-wrap: pretty;
}
.proj-detail .det-launch {
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--tint-active);
  opacity: 0.7;
  transition: opacity var(--t-icon), color var(--t-tint);
}
@keyframes detail-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0);   }
}
@media (max-width: 820px) {
  .projects-wrap {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .proj-detail { max-width: 100%; }
}

/* ─── Sub-item panel (vertical) ─── */
#subitems {
  width: 100%;
  display: flex;
  justify-content: flex-start;
  margin-top: 8px;
  min-height: 280px;
  /* Push the panel under the focused icon (set via JS) */
  padding-left: var(--sub-anchor-x, calc(var(--anchor-x) * 100vw - 36px));
}

.sub-list {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
  padding: 8px 4px;
  min-width: 320px;
  max-width: min(480px, 90vw);
  position: relative;
}

.sub {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  letter-spacing: 0.06em;
  color: rgba(255,255,255,0.5);
  padding: 6px 8px;
  border-radius: 6px;
  transition: color var(--t-icon), background var(--t-icon), transform var(--t-icon);
  cursor: pointer;
  width: fit-content;
  opacity: 0;
  transform: translateX(-8px);
  animation: sub-in 250ms ease-out forwards;
}

.sub::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  flex-shrink: 0;
  transition: background var(--t-icon), box-shadow var(--t-icon), transform var(--t-icon);
}

.sub.is-focused {
  color: #fff;
  background: color-mix(in oklab, var(--tint-active) 14%, transparent);
}
.sub.is-focused::before {
  background: var(--tint-active);
  box-shadow: 0 0 10px var(--tint-active);
  transform: scale(1.4);
}

.sub:hover { color: rgba(255,255,255,0.85); }

/* Brand-icon glyph (skills list) */
.sub-icon {
  width: var(--icon-size-rest);
  height: var(--icon-size-rest);
  flex-shrink: 0;
  display: inline-block;
  opacity: 0.75;
  filter: saturate(0.55);
  transition: opacity var(--t-icon), filter var(--t-icon), transform var(--t-icon);
}
.sub.is-focused .sub-icon {
  opacity: 1;
  filter: saturate(1) drop-shadow(0 0 12px color-mix(in oklab, var(--tint-active) 50%, transparent));
  transform: scale(1.05);
}
.sub.has-icon::before { display: none; }
.sub.has-icon { gap: 12px; }
.sub-icon svg { width: 100%; height: 100%; display: block; }

@keyframes sub-in {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ─── Skills / Connect / About column: XMB-style vertical axis ─── */
.sub-list.is-skills,
.sub-list.is-connect,
.sub-list.is-about {
  position: fixed;
  inset: 0;
  display: block;
  pointer-events: none;
  z-index: 15;
  padding: 0;
  min-width: unset;
  gap: 0;
}

.sub-list.is-skills > .sub,
.sub-list.is-connect > .sub {
  position: absolute;
  pointer-events: auto;
  transition: top var(--t-sub);
  will-change: top;
}

/* ============================================================
   Hint bar (footer)
   ============================================================ */
#hint-bar {
  position: fixed;
  bottom: 16px; left: 0; right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--text-tertiary);
}

#hint-bar .key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border: 0.5px solid var(--border-subtle);
  border-radius: 4px;
  color: var(--text-secondary);
  background: rgba(0,0,0,0.35);
  font-size: 10px;
}

#hint-bar .hint-label { padding: 0 4px; }
#hint-bar .dot        { opacity: 0.4; padding: 0 4px; }

/* ============================================================
   Mini-map (mobile only)
   ============================================================ */
#mini-map {
  display: none;
}

@media (max-width: 700px) {
  #mini-map {
    display: flex;
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    gap: 9px;
    align-items: flex-start;
    pointer-events: none;
  }

  .mm-col {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .mm-dot {
    width: 6px;
    height: 6px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.18);
    transition: background 0.25s, transform 0.25s, box-shadow 0.25s;
  }

  .mm-col--active .mm-dot {
    background: rgba(255, 255, 255, 0.35);
  }

  .mm-dot--active {
    background: var(--tint-active) !important;
    transform: scale(1.6);
    box-shadow: 0 0 5px var(--tint-active);
  }
}

/* ============================================================
   Reduced motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration:  0.01ms !important;
  }
  #wave-bg { display: none; }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 700px) {
  :root {
    --icon-size-focus: 56px;
    --icon-size-rest:  42px;
    --cat-gap:         60px;
  }

  .sub-list { min-width: 280px; }
  #hint-bar { display: none; }
}

/* ── Mobile phones (≤ 480 px) ───────────────────────────── */
@media (max-width: 480px) {
  :root {
    --icon-size-focus: 24px;
    --icon-size-rest:  12px;
    --cat-gap:         18px;
    --sub-gap:         28px;
    /* Top-left vertex: focused icon anchored near top-left corner.
       The strip slides around this fixed point on swipe — it never moves. */
    --anchor-x:        0.10;
    --anchor-y:        0.05;
  }

  /* Labels always visible — text becomes the primary navigation cue */
  .cat-label {
    opacity: 0.50;
    transform: translateY(0);
    font-size: 8px;
    letter-spacing: 0.08em;
  }
  .cat.is-focused .cat-label {
    opacity: 1;
    font-size: 10px;
    letter-spacing: 0.12em;
  }

  /* Sub-list: no forced min-width on phone */
  .sub-list { min-width: 0; }

  /*
   * Detail panels (profile bio, about desc, project info) are positioned by JS
   * to the RIGHT of the vertical list — on a narrow phone this overflows off-screen.
   * Override to a bottom-sheet sitting above the hint bar instead.
   */
  #profile-detail,
  #about-detail,
  #proj-detail {
    position: fixed !important;
    left: 16px !important;
    right: 16px !important;
    bottom: 112px !important;
    top: auto !important;
    width: auto !important;
    max-width: none !important;
    background: rgba(14, 12, 11, 0.90);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 0.5px solid var(--border-subtle);
    border-radius: 10px;
    padding: 14px 16px;
    max-height: 34vh;
    overflow-y: auto;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.45);
    z-index: 16;
  }

  /* About items: wider label so "University of Melbourne" wraps to 2 lines
     instead of 3, keeping actual row height close to the JS-calculated pitch.
     The 40 px right padding is only needed for the desktop side-panel — remove it. */
  .sub-list.is-about > .sub {
    padding-right: 8px;
  }
  .sub-list.is-about .sub-btn {
    width: 160px !important;
  }
}

/* ============================================================
   About vertical column + detail panel
   ============================================================ */
.sub-list.is-about > .sub {
  position: absolute;
  pointer-events: auto;
  transition: top var(--t-sub);
  will-change: top;
  padding-right: 40px;
}
.sub-list.is-about > .sub .sub-btn {
  white-space: normal;
  width: 80px;
  line-height: 1.4;
}
.about-detail {
  position: absolute;
  pointer-events: auto;
  max-width: unset;
  font-size: 13px;
  line-height: 1.65;
  color: rgba(255,255,255,0.78);
  letter-spacing: 0.02em;
  text-wrap: pretty;
}
.about-detail.is-swap {
  animation: detail-in 320ms cubic-bezier(.25,0,0,1);
}
.about-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.about-year {
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--tint-active);
  opacity: 0.8;
  transition: color var(--t-tint);
}

/* ============================================================
   Project detail — tech tags
   ============================================================ */
.det-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: -6px;
}
.det-tag {
  font-size: 9px;
  letter-spacing: 0.12em;
  padding: 2px 7px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--tint-active) 10%, transparent);
  border: 0.5px solid color-mix(in oklab, var(--tint-active) 30%, transparent);
  color: color-mix(in oklab, var(--tint-active) 85%, #fff);
  transition: background var(--t-tint), border-color var(--t-tint), color var(--t-tint);
}

/* ============================================================
   Project overlay
   ============================================================ */
#proj-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(14,12,11,0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 280ms ease;
}
#proj-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}
.po-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--infobar-h);
  padding: 0 var(--page-pad-x);
  border-bottom: 0.5px solid var(--border);
  background: rgba(0,0,0,0.30);
}
.po-title {
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--tint-active);
}
.po-close {
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--text-secondary);
  padding: 3px 8px;
  border-radius: 4px;
  border: 0.5px solid var(--border-subtle);
  transition: color var(--t-icon), background var(--t-icon);
}
.po-close:hover { color: var(--text-primary); background: rgba(255,255,255,0.06); }
.po-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 32px var(--page-pad-x);
}
.po-pane {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
  max-width: 640px;
}
.po-pane.is-active { display: flex; }
#tg-root { width: 100%; }
.po-note {
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
}

/* ── Ray Tracer (in overlay) ── */
.rt-wrap {
  position: relative;
  display: inline-block;
  border: 0.5px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
#rt-canvas {
  display: block;
  background: var(--bg-deep);
  max-width: min(400px, 90vw);
  height: auto;
}
.rt-loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(14,12,11,0.88);
  color: var(--text-secondary);
  pointer-events: none;
}
.rt-loading-overlay svg {
  width: 2.5rem;
  height: 2.5rem;
  color: var(--tint-active);
}
.rt-loading-overlay span { font-size: 10px; letter-spacing: 0.14em; }
.rt-loading-overlay.rendering svg { display: none; }
.rt-hint {
  font-size: 10px;
  letter-spacing: 0.10em;
  color: var(--text-tertiary);
  text-align: center;
}

/* ── Thirteen Card Game (in overlay) ── */
.tg-wrap {
  position: relative;
  width: 100%;
  max-width: 620px;
  min-height: 480px;
  background: rgba(14,12,11,0.70);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 0.5px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.tg-screen {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: absolute;
  inset: 0;
  padding: 1.5rem;
}
.tg-screen.tg-active { display: flex; }
.tg-board { justify-content: space-between; padding: 1rem; }
.tg-board.tg-active { display: flex; }
.tg-center-block { display: flex; flex-direction: column; align-items: center; gap: 0.75rem; }
.tg-big-title { font-size: 2.4rem; font-weight: 500; color: var(--text-primary); letter-spacing: 0.04em; }
.tg-sub-title  { font-size: 10px; color: var(--text-secondary); letter-spacing: 0.12em; margin-bottom: 0.5rem; }
.tg-tr-name    { font-size: 1.8rem; font-weight: 500; color: var(--tint-active); transition: color var(--t-tint); }
.tg-tr-hint    { font-size: 11px; color: var(--text-secondary); text-align: center; max-width: 28ch; line-height: 1.5; letter-spacing: 0.04em; }
.tg-win-crown  { font-size: 3rem; color: var(--tint-active); line-height: 1; transition: color var(--t-tint); }
.tg-win-name   { font-size: 1.8rem; font-weight: 500; color: var(--text-primary); }
.tg-win-sub    { font-size: 12px; color: var(--text-secondary); margin-bottom: 0.5rem; letter-spacing: 0.06em; }
.tg-muted      { color: var(--text-tertiary); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; }
.tg-btn {
  padding: 0.5rem 1.3rem;
  border-radius: 4px;
  border: 0.5px solid var(--border-subtle);
  background: rgba(255,255,255,0.04);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.tg-btn:hover { background: rgba(255,255,255,0.08); color: var(--text-primary); }
.tg-btn-primary { border-color: color-mix(in oklab, var(--tint-active) 55%, transparent); color: var(--tint-active); }
.tg-btn-primary:hover { background: color-mix(in oklab, var(--tint-active) 10%, transparent); color: var(--text-primary); }
.tg-btn-sort { font-size: 10px; padding: 0.45rem 0.85rem; }
.tg-opponents { display: flex; justify-content: center; gap: 1rem; flex-wrap: wrap; width: 100%; }
.tg-opponent  { display: flex; flex-direction: column; align-items: center; gap: 0.25rem; }
.tg-opp-name  { font-size: 10px; color: var(--text-secondary); letter-spacing: 0.06em; }
.tg-opp-hand  { display: flex; position: relative; }
.tg-opp-count { font-size: 9px; color: var(--text-tertiary); }
.tg-more      { font-size: 9px; color: var(--text-tertiary); align-self: center; padding-left: 4px; }
.tg-mid { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; flex: 1; justify-content: center; }
.tg-play-label { font-size: 9px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--text-tertiary); }
.tg-play-area  { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; min-height: 78px; align-items: center; }
.tg-no-play    { color: var(--text-tertiary); font-size: 1.2rem; }
.tg-status     { font-size: 11px; color: var(--text-secondary); min-height: 1.2em; text-align: center; max-width: 38ch; letter-spacing: 0.04em; }
.tg-bottom     { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; width: 100%; }
.tg-hand-label { font-size: 10px; color: var(--tint-active); letter-spacing: 0.08em; align-self: flex-start; padding-left: 2px; transition: color var(--t-tint); }
.tg-hand-scroll { width: 100%; overflow-x: auto; padding-bottom: 4px; }
.tg-hand { display: flex; flex-direction: row; padding: 10px 0 4px; }
.tg-hand .tg-card { margin-right: -18px; }
.tg-hand .tg-card:last-child { margin-right: 0; }
.tg-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: center; }
.tg-card {
  width: 48px; height: 68px;
  background: #fafafa;
  border-radius: 5px;
  border: 1px solid #ccc;
  box-shadow: 1px 2px 5px rgba(0,0,0,0.4);
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 3px 4px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  flex-shrink: 0; user-select: none;
  position: relative; z-index: 0;
}
.tg-card:hover:not(.tg-inert):not(.tg-back) { transform: translateY(-6px); z-index: 10; }
.tg-card.tg-selected { transform: translateY(-16px); box-shadow: 2px 6px 12px rgba(0,0,0,0.5); z-index: 10; border-color: #C8A882; }
.tg-card.tg-inert { cursor: default; }
.tg-cr { font-size: 14px; font-weight: 700; line-height: 1; }
.tg-cs { font-size: 16px; line-height: 1; align-self: flex-end; }
.tg-card.tg-red   .tg-cr, .tg-card.tg-red   .tg-cs { color: #c0392b; }
.tg-card.tg-black .tg-cr, .tg-card.tg-black .tg-cs { color: #1a1a2e; }
.tg-card.tg-small { width: 22px; height: 32px; margin-right: -10px; border-radius: 3px; cursor: default; }
.tg-card.tg-small:last-child { margin-right: 0; }
.tg-card.tg-back {
  background: repeating-linear-gradient(45deg, #1e3a5f 0px, #1e3a5f 4px, #16304f 4px, #16304f 8px);
  border-color: #2a4a6f; cursor: default;
}
@media (max-width: 600px) {
  .tg-wrap  { min-height: 440px; }
  .tg-card  { width: 42px; height: 60px; }
  .tg-cr    { font-size: 12px; }
  .tg-cs    { font-size: 14px; }
  .tg-hand .tg-card { margin-right: -16px; }
}
