/* =====================================================================
   NXE-style dashboard
   Everything inside .frame is laid out in "design units" (u). JS sets
   --u to the px size of one unit so the 1710×900 landscape frame (or
   the narrow portrait frame) scales to fit any viewport.
   ===================================================================== */

:root {
  --u: 1px;
  --fw: 1710; --fh: 900;
  --tx: 128; --ty: 310; --tw: 562; --th: 426;
  --persp: 1000; --ox: 855; --oy: 523;
  --cy: 750; --hy: 826; --lx: 128; --lbase: 50;

  --h: 74;
  --sat: 74%;
  --tile-top: hsl(var(--h) var(--sat) 56%);
  --tile-mid: hsl(calc(var(--h) + 3) var(--sat) 44%);
  --tile-bot: hsl(calc(var(--h) + 12) var(--sat) 27%);
  --accent-ink: hsl(calc(var(--h) + 8) 60% 24%);

  --font: "Segoe UI", "Selawik", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --t: 420ms;
}

[data-theme="blue"]   { --h: 200; --sat: 78%; }
[data-theme="orange"] { --h: 26;  --sat: 88%; }
[data-theme="purple"] { --h: 272; --sat: 52%; }
[data-theme="pink"]   { --h: 328; --sat: 68%; }
[data-theme="silver"] { --h: 90;  --sat: 5%; }

@media (prefers-reduced-motion: reduce) {
  :root { --t: 1ms; }
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  position: fixed;
  inset: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: #b9c49d;
  color: #fff;
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; text-align: inherit; }
button:focus { outline: none; }

.sr-only, .defs {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

.stage { position: fixed; inset: 0; overflow: clip; touch-action: none; }

/* ---------------------------------------------------------------------
   Background: sky, drifting light, curved floor
   --------------------------------------------------------------------- */
.bg { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }

.sky {
  position: absolute; inset: 0;
  background:
    radial-gradient(55% 45% at 36% 26%, hsl(calc(var(--h) - 4) calc(var(--sat) - 10%) 68% / .55), transparent 72%),
    radial-gradient(40% 30% at 0% 60%, rgba(255,255,255,.55), transparent 70%),
    linear-gradient(90deg, transparent 40%, hsl(var(--h) 6% 64% / .6) 100%),
    linear-gradient(180deg,
      hsl(calc(var(--h) + 5) var(--sat) 33%) 0%,
      hsl(var(--h) calc(var(--sat) - 18%) 48%) 24%,
      hsl(var(--h) calc(var(--sat) - 38%) 68%) 46%,
      hsl(var(--h) 14% 88%) 60%,
      #eef0ec 64%);
}

.bokeh { position: absolute; inset: 0; }
.bokeh i {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.22) 0%, rgba(255,255,255,.1) 55%, rgba(255,255,255,0) 70%);
  animation: drift var(--dur, 30s) ease-in-out var(--delay, 0s) infinite alternate;
}
.bokeh i.ring {
  background: none;
  box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.18), 0 0 0 6px rgba(255,255,255,.05);
}
@keyframes drift {
  from { transform: translate3d(0, 0, 0); }
  to   { transform: translate3d(var(--dx, 40px), var(--dy, -20px), 0); }
}

.floor {
  position: absolute;
  left: -130%; width: 400%;
  top: 59%; height: 160%;
  border-radius: 50%;
  background:
    radial-gradient(28% 22% at 47% 6%, rgba(255,255,255,.95), rgba(255,255,255,0) 70%),
    radial-gradient(40% 30% at 40% 0%, #e8eae6 0%, #cfd2ce 35%, #a8aca8 70%, #8b8f8b 100%);
  box-shadow: 0 -6px 50px 18px rgba(255,255,255,.65);
}

/* ---------------------------------------------------------------------
   Frame: the scaled design surface
   --------------------------------------------------------------------- */
.frame {
  position: absolute;
  left: calc(50% - var(--fw) * var(--u) / 2);
  top: calc(50% - var(--fh) * var(--u) / 2);
  width: calc(var(--fw) * var(--u));
  height: calc(var(--fh) * var(--u));
}

.decor { position: absolute; inset: 0; pointer-events: none; }
.ripple {
  position: absolute; border-radius: 50%;
  background: repeating-radial-gradient(circle, rgba(255,255,255,.12) 0 1.5px, transparent 2px calc(9 * var(--u)));
  -webkit-mask: radial-gradient(circle, #000 30%, transparent 70%);
          mask: radial-gradient(circle, #000 30%, transparent 70%);
}
.ripple.r1 { left: calc(1270 * var(--u)); top: calc(300 * var(--u)); width: calc(100 * var(--u)); height: calc(100 * var(--u)); }
.ripple.r2 { left: calc(1580 * var(--u)); top: calc(200 * var(--u)); width: calc(170 * var(--u)); height: calc(170 * var(--u)); }
.ripple.r3 { left: calc(640 * var(--u)); top: calc(250 * var(--u)); width: calc(90 * var(--u)); height: calc(90 * var(--u)); opacity: .6; }

/* ---------------------------------------------------------------------
   Channel list (top-left)
   --------------------------------------------------------------------- */
.channels { position: absolute; inset: 0; pointer-events: none; z-index: 1; }

.ch-label {
  position: absolute;
  left: calc(var(--lx) * var(--u));
  top: 0;
  font-size: calc(var(--lbase) * var(--u));
  font-weight: 400;
  line-height: 1;
  white-space: nowrap;
  transform-origin: 0 0;
  pointer-events: auto;
  text-shadow: 0 1px 2px rgba(0, 40, 0, .25);
  transition: transform var(--t) var(--ease), opacity var(--t) var(--ease), filter var(--t) var(--ease), visibility var(--t);
}
.ch-label.is-current { text-shadow: 0 0 .35em rgba(255,255,255,.35), 0 1px 2px rgba(0, 40, 0, .3); }
.ch-label::before {
  content: "";
  position: absolute;
  left: -.3em; top: .48em;
  width: .16em; height: .16em;
  background: #fff;
  opacity: var(--bullet, 0);
}

/* ---------------------------------------------------------------------
   Tile rows
   --------------------------------------------------------------------- */
.rows { position: absolute; inset: 0; z-index: 2; pointer-events: none; }

.row {
  position: absolute; inset: 0;
  perspective: calc(var(--persp) * var(--u));
  perspective-origin: calc(var(--ox) * var(--u)) calc(var(--oy) * var(--u));
  transform-origin: calc(var(--tx) * var(--u)) calc(var(--ty) * var(--u));
  transition: transform var(--t) var(--ease), opacity var(--t) var(--ease), visibility var(--t);
}
.row.is-current { z-index: 2; }

.track { position: absolute; inset: 0; transform-style: preserve-3d; }
.track.nudge-next { animation: nudge-next .28s var(--ease); }
.track.nudge-prev { animation: nudge-prev .28s var(--ease); }
.track.nudge-up   { animation: nudge-up .28s var(--ease); }
.track.nudge-down { animation: nudge-down .28s var(--ease); }
@keyframes nudge-next { 40% { transform: translateX(calc(-18 * var(--u))); } }
@keyframes nudge-prev { 40% { transform: translateX(calc(18 * var(--u))); } }
@keyframes nudge-up   { 40% { transform: translateY(calc(14 * var(--u))); } }
@keyframes nudge-down { 40% { transform: translateY(calc(-14 * var(--u))); } }

.tile {
  position: absolute;
  left: calc(var(--tx) * var(--u));
  top: calc(var(--ty) * var(--u));
  width: calc(var(--tw) * var(--u));
  height: calc(var(--th) * var(--u));
  pointer-events: none;
  transition: transform var(--t) var(--ease), opacity var(--t) var(--ease), visibility var(--t);
  will-change: transform;
}
.row.is-current .tile { pointer-events: auto; }

.tile-face {
  position: absolute; inset: 0;
  overflow: hidden;
  border-radius: calc(6 * var(--u));
  container-type: size;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 560 420' preserveAspectRatio='xMidYMid slice'%3E%3Cg fill='none' stroke='white' stroke-opacity='.11' stroke-width='3'%3E%3Ccircle cx='68' cy='140' r='24'/%3E%3Ccircle cx='68' cy='140' r='38'/%3E%3Ccircle cx='68' cy='140' r='52'/%3E%3Ccircle cx='520' cy='78' r='20'/%3E%3Ccircle cx='520' cy='78' r='32'/%3E%3Ccircle cx='120' cy='340' r='50'/%3E%3Ccircle cx='120' cy='340' r='70'/%3E%3Ccircle cx='470' cy='300' r='14'/%3E%3Ccircle cx='470' cy='300' r='26'/%3E%3Ccircle cx='330' cy='40' r='10'/%3E%3C/g%3E%3Cg fill='white' fill-opacity='.08'%3E%3Ccircle cx='430' cy='190' r='11'/%3E%3Ccircle cx='36' cy='260' r='15'/%3E%3Ccircle cx='250' cy='385' r='8'/%3E%3Ccircle cx='545' cy='220' r='18'/%3E%3C/g%3E%3C/svg%3E") center / cover,
    linear-gradient(180deg, rgba(255,255,255,.34) 0%, rgba(255,255,255,.08) 34%, rgba(255,255,255,0) 58%),
    linear-gradient(180deg, var(--tile-top) 0%, var(--tile-mid) 56%, var(--tile-bot) 100%);
  box-shadow:
    inset 0 calc(1.5 * var(--u)) 0 rgba(255,255,255,.7),
    inset 0 0 0 calc(1 * var(--u)) rgba(255,255,255,.22),
    0 calc(10 * var(--u)) calc(26 * var(--u)) rgba(20, 40, 0, .22);
  -webkit-box-reflect: below calc(3 * var(--u)) linear-gradient(transparent 78%, rgba(255,255,255,.13));
  text-shadow: 0 1px 2px rgba(0, 30, 0, .35);
  transition: filter .2s;
}
/* distance haze */
.tile-face::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: hsl(var(--h) 15% 86%);
  opacity: calc(var(--depth, 0) * .32);
}
.tile.is-focus .tile-face {
  box-shadow:
    inset 0 calc(1.5 * var(--u)) 0 rgba(255,255,255,.8),
    inset 0 0 0 calc(1.5 * var(--u)) rgba(255,255,255,.3),
    0 0 calc(34 * var(--u)) hsl(var(--h) 90% 75% / .45),
    0 calc(12 * var(--u)) calc(28 * var(--u)) rgba(20, 40, 0, .25);
}
.tile:focus-visible .tile-face { outline: calc(2 * var(--u)) solid rgba(255,255,255,.6); outline-offset: calc(3 * var(--u)); }
@media (hover: hover) {
  .row.is-current .tile:hover .tile-face { filter: brightness(1.06) saturate(1.05); }
}

.tile { --ts: 1; }
[data-layout="portrait"] .tile { --ts: 1.3; }

.t-label {
  position: absolute;
  left: 4.5cqw; bottom: 9cqh;
  font-size: calc(6cqw * var(--ts));
  line-height: 1.1;
  white-space: nowrap;
}

.t-icon {
  position: absolute;
  left: 50%; top: 43%;
  width: 52cqmin; height: 52cqmin;
  transform: translate(-50%, -50%);
}
.ico { width: 100%; height: 100%; display: block; fill: url(#gloss); overflow: visible; }
.t-icon .ico, .t-corner, .p-hero .ico, .toast-badge .ico { filter: drop-shadow(0 .4cqmin .8cqmin rgba(0, 45, 0, .35)); }
.ico .s { fill: none; stroke: url(#gloss); stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; }
.ico .shade { fill: rgba(0, 40, 0, .22); }
.gloss-0 { stop-color: #fff; }
.gloss-1 { stop-color: #f5f8ee; }
.gloss-2 { stop-color: hsl(var(--h) 35% 80%); }

.ico-flat { width: 1.25em; height: 1.25em; flex: none; fill: currentColor; }
.ico-flat .s { fill: none; stroke: currentColor; stroke-width: 8; stroke-linecap: round; stroke-linejoin: round; }
.ico-flat .shade { fill: rgba(0,0,0,.2); }

/* info tiles (projects, jobs) */
.t-info { position: absolute; left: 4.5cqw; right: 24cqw; top: 8cqh; }
.t-eyebrow { font-size: calc(3.3cqw * var(--ts)); letter-spacing: .06em; text-transform: uppercase; opacity: .85; }
.t-title {
  /* Leave room for descenders inside the two-line clipping box. */
  font-size: calc(7.2cqw * var(--ts)); line-height: 1.25; margin-top: 2cqh;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.t-text {
  font-size: calc(3.8cqw * var(--ts)); line-height: 1.3; margin-top: 3cqh; opacity: .92;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.t-corner { position: absolute; right: 4.5cqw; top: 7cqh; width: 20cqmin; height: 20cqmin; }
[data-layout="portrait"] .t-info { right: 4.5cqw; top: 30cqh; }
[data-layout="portrait"] .t-corner { left: 4.5cqw; top: 6cqh; width: 18cqmin; height: 18cqmin; }

/* image tiles */
.t-img { position: absolute; inset: 0; background-size: cover; background-position: center; }
.tile--image .tile-face::before {
  content: ""; position: absolute; inset: 0; z-index: 0;
  background: linear-gradient(180deg, transparent 45%, rgba(0,0,0,.55));
}
.tile--image .t-label, .tile--image .t-info { z-index: 1; }

/* profile tile */
.t-profile { position: absolute; left: 4cqw; top: 8cqh; right: 32cqw; }
.t-tag { font-size: calc(6.4cqw * var(--ts)); line-height: 1.1; }
.t-score { font-size: calc(5.4cqw * var(--ts)); margin-top: 1cqh; display: flex; align-items: center; gap: .25em; }
.t-caption { font-size: calc(4cqw * var(--ts)); margin-top: 22cqh; opacity: .85; }

.g {
  display: inline-grid; place-items: center;
  width: 1.05em; height: 1.05em;
  border-radius: 50%;
  border: .09em solid currentColor;
  font-size: .8em; font-weight: 700; line-height: 1;
}

/* avatar, stands in front of its tile */
.avatar {
  position: absolute;
  left: 70%; top: -6%;
  width: 31%; height: 120%;
  pointer-events: none;
  animation: breathe 4.5s ease-in-out infinite;
  transform-origin: 50% 100%;
}
/* 3D avatar canvas: twice the box wide so raised arms have room */
.avatar .av3d { position: absolute; left: -50%; top: 0; width: 200%; height: 100%; display: block; }
/* Portrait tiles are taller: leave room for the helmet and waving arms. */
[data-layout="portrait"] .avatar .av3d { left: -100%; width: 300%; }
.avatar [hidden] { display: none; }
.avatar.is-3d { animation: none; }
.avatar svg, .avatar img { width: 100%; height: 100%; object-fit: contain; object-position: bottom; display: block; overflow: visible; }
.avatar-shadow {
  position: absolute; left: 12%; right: 12%; bottom: -1.5%; height: 4%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(0,0,0,.35), transparent);
}
@keyframes breathe { 50% { transform: scaleY(1.008) translateY(-.3%); } }

/* built-in avatar (js/avatar.js): colours, then shading mixed from them */
.av {
  --av-skin: #f1c6a2; --av-hair: #4e3423; --av-eyes: #4f86c6;
  --av-shirt: #34404e; --av-pants: #46699c; --av-shoes: #f3f3f0;
}
.av .sk0 { stop-color: color-mix(in srgb, var(--av-skin) 70%, #fff); }
.av .sk1 { stop-color: var(--av-skin); }
.av .sk2 { stop-color: color-mix(in srgb, var(--av-skin) 76%, #5a2a14); }
.av .hr0 { stop-color: color-mix(in srgb, var(--av-hair) 80%, #fff); }
.av .hr1 { stop-color: var(--av-hair); }
.av .hr2 { stop-color: color-mix(in srgb, var(--av-hair) 70%, #000); }
.av .sh0 { stop-color: color-mix(in srgb, var(--av-shirt) 72%, #fff); }
.av .sh1 { stop-color: var(--av-shirt); }
.av .sh2 { stop-color: color-mix(in srgb, var(--av-shirt) 68%, #000); }
.av .pa0 { stop-color: color-mix(in srgb, var(--av-pants) 80%, #fff); }
.av .pa1 { stop-color: var(--av-pants); }
.av .pa2 { stop-color: color-mix(in srgb, var(--av-pants) 65%, #000); }
.av .so0 { stop-color: color-mix(in srgb, var(--av-shoes) 60%, #fff); }
.av .so1 { stop-color: var(--av-shoes); }
.av .so2 { stop-color: color-mix(in srgb, var(--av-shoes) 72%, #000); }
.av .ey0 { stop-color: color-mix(in srgb, var(--av-eyes) 70%, #fff); }
.av .ey1 { stop-color: color-mix(in srgb, var(--av-eyes) 75%, #000); }
.av-brow { fill: none; stroke: color-mix(in srgb, var(--av-hair) 80%, #000); stroke-width: 3.6; stroke-linecap: round; }
.av-lid { fill: none; stroke: #2b1d16; stroke-width: 2; stroke-linecap: round; }
.av-nose { fill: none; stroke: color-mix(in srgb, var(--av-skin) 65%, #7a3b22); stroke-width: 2.4; stroke-linecap: round; }
.av-smile { fill: none; stroke: #9b4a3a; stroke-width: 3; stroke-linecap: round; }
.av-grin { opacity: 0; }

/* idle: weight shift, head bob, arm swing, blink. Origins are viewBox units. */
.avatar .av-body  { transform-origin: 80px 392px; animation: av-sway 7s ease-in-out infinite; }
.avatar .av-head  { transform-origin: 80px 136px; animation: av-nod 9s ease-in-out infinite; }
.avatar .av-arm-l { transform-origin: 41px 160px; animation: av-swing 7s ease-in-out infinite; }
.avatar .av-arm-r { transform-origin: 119px 160px; animation: av-swing 7s ease-in-out infinite reverse; }
.avatar .av-eye   { transform-box: fill-box; transform-origin: center; animation: av-blink 5.2s infinite; }
@keyframes av-sway  { 30% { transform: rotate(.9deg); } 70% { transform: rotate(-.7deg); } }
@keyframes av-nod   { 25% { transform: rotate(2.5deg); } 60% { transform: rotate(-1.5deg); } }
@keyframes av-swing { 50% { transform: rotate(1.6deg); } }
@keyframes av-blink { 0%, 93%, 98%, 100% { transform: none; } 95.5% { transform: scaleY(.08); } }

/* emotes, toggled from dashboard.js */
.avatar.emote-wave .av-arm-r { animation: av-wave 2.2s cubic-bezier(.3, .7, .3, 1); }
.avatar.emote-wave .av-head  { animation: av-tilt 2.2s ease-in-out; }
.avatar.emote-look .av-look  { animation: av-look 3s ease-in-out; }
.avatar.emote-look .av-head  { animation: av-look-head 3s ease-in-out; }
.avatar.emote-cheer .av-body  { animation: av-jump 1.5s ease-in-out; }
.avatar.emote-cheer .av-arm-l { animation: av-cheer-l 1.5s ease-in-out; }
.avatar.emote-cheer .av-arm-r { animation: av-cheer-r 1.5s ease-in-out; }
.avatar.emote-cheer .avatar-shadow { animation: av-shadow 1.5s ease-in-out; }
.avatar.emote-wave .av-grin, .avatar.emote-cheer .av-grin { opacity: 1; }
.avatar.emote-wave .av-smile, .avatar.emote-cheer .av-smile { opacity: 0; }

@keyframes av-wave {
  18% { transform: rotate(-148deg); } 30% { transform: rotate(-126deg); }
  42% { transform: rotate(-152deg); } 54% { transform: rotate(-126deg); }
  66% { transform: rotate(-150deg); } 80% { transform: rotate(-140deg); }
}
@keyframes av-tilt { 20%, 78% { transform: rotate(5deg); } }
@keyframes av-look { 15%, 40% { transform: translate(-2.6px, 0); } 55%, 80% { transform: translate(2.6px, -.5px); } }
@keyframes av-look-head { 15%, 40% { transform: translateX(-2px) rotate(-3deg); } 55%, 80% { transform: translateX(2px) rotate(3deg); } }
@keyframes av-jump {
  10% { transform: translateY(4px) scale(1.03, .96); }
  25% { transform: translateY(-34px); }
  40% { transform: translateY(2px) scale(1.03, .96); }
  52% { transform: translateY(-26px); }
  66% { transform: translateY(2px) scale(1.02, .97); }
  78% { transform: none; }
}
@keyframes av-cheer-l { 15%, 75% { transform: rotate(155deg); } 30%, 60% { transform: rotate(138deg); } }
@keyframes av-cheer-r { 15%, 75% { transform: rotate(-155deg); } 30%, 60% { transform: rotate(-138deg); } }
@keyframes av-shadow { 25%, 52% { transform: scale(.7); opacity: .6; } }

@media (prefers-reduced-motion: reduce) {
  .avatar, .avatar * { animation: none !important; }
}

/* ---------------------------------------------------------------------
   Counter, gamercard, hints, portrait
   --------------------------------------------------------------------- */
.counter {
  position: absolute; z-index: 3;
  left: calc(var(--tx) * var(--u));
  top: calc(var(--cy) * var(--u));
  font-size: calc(22 * var(--u));
  opacity: .7;
  text-shadow: 0 1px 2px rgba(0,0,0,.2);
}

.gamercard {
  position: absolute; z-index: 3;
  right: calc(130 * var(--u)); top: calc(64 * var(--u));
  display: flex; align-items: flex-start; gap: calc(12 * var(--u));
  text-align: right;
  text-shadow: 0 1px 3px rgba(0, 30, 0, .35);
}
.gc-tag { font-size: calc(36 * var(--u)); line-height: 1.12; }
.gc-score { font-size: calc(31 * var(--u)); line-height: 1.2; display: flex; justify-content: flex-end; align-items: center; gap: calc(6 * var(--u)); }
.gc-pic {
  width: calc(83 * var(--u)); height: calc(83 * var(--u));
  border-radius: calc(4 * var(--u));
  overflow: hidden; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(160deg, #6a6f68, #2d302c);
  box-shadow: 0 0 0 calc(2 * var(--u)) rgba(255,255,255,.55), 0 calc(4 * var(--u)) calc(12 * var(--u)) rgba(0,0,0,.25);
  font-size: calc(34 * var(--u)); font-weight: 600; letter-spacing: -.02em;
}
.gc-pic img, .gc-pic svg { width: 100%; height: 100%; object-fit: cover; display: block; }
.gc-pic--avatar { background: radial-gradient(circle at 50% 30%, hsl(var(--h) 45% 82%), hsl(var(--h) 35% 52%) 90%); }

.hints {
  position: absolute; z-index: 3;
  left: calc((var(--tx) + 4) * var(--u));
  top: calc(var(--hy) * var(--u));
  font-size: calc(24 * var(--u));
  display: flex; gap: calc(28 * var(--u));
}
.hint { display: inline-flex; align-items: center; text-shadow: 0 1px 2px rgba(0,0,0,.25); }
.btn {
  display: inline-grid; place-items: center;
  width: 1.3em; height: 1.3em;
  margin-right: .4em;
  border-radius: 50%;
  font-size: .9em; font-weight: 700; color: #fff;
  text-shadow: 0 1px 1px rgba(0,0,0,.4);
  box-shadow: inset 0 -.08em .12em rgba(0,0,0,.35), inset 0 .06em .08em rgba(255,255,255,.6), 0 .04em .12em rgba(0,0,0,.35);
}
.btn-a { background: radial-gradient(circle at 38% 28%, #d5ff8a 0%, #6cc021 38%, #2f7a0c 100%); }
.btn-b { background: radial-gradient(circle at 38% 28%, #ffb3a6 0%, #e0301f 40%, #8f1106 100%); }

.coach {
  position: absolute; z-index: 4;
  left: calc(var(--tx) * var(--u));
  top: calc((var(--hy) - 56) * var(--u));
  padding: .5em 1em;
  border-radius: 999px;
  background: rgba(20, 30, 15, .55);
  font-size: calc(19 * var(--u));
  backdrop-filter: blur(6px);
  animation: coach-in .5s var(--ease) 1.2s both;
  transition: opacity .4s;
}
.coach.gone { opacity: 0; }
@keyframes coach-in { from { opacity: 0; transform: translateY(8px); } }

/* Home shortcut and native modal photo viewer. */
.home-button {
  position: absolute; z-index: 3;
  right: calc(130 * var(--u)); bottom: calc(42 * var(--u));
  width: max(56px, calc(88 * var(--u))); aspect-ratio: 1;
  display: grid; place-items: center;
  border: 2px solid rgba(255,255,255,.85); border-radius: 50%;
  background: radial-gradient(circle at 35% 25%, var(--tile-top), var(--tile-bot));
  box-shadow: inset 0 2px 5px rgba(255,255,255,.45), 0 4px 16px rgba(0,0,0,.3);
}
.home-icon { display: block; width: 54%; height: 54%; fill: #fff; filter: drop-shadow(0 2px 2px rgba(0,0,0,.2)); }
.home-button:hover { box-shadow: inset 0 2px 5px rgba(255,255,255,.45), 0 4px 20px rgba(0,0,0,.45); }
.home-button:focus-visible, .hint:focus-visible, .gc-info:focus-visible, .gc-pic:focus-visible {
  outline: 3px solid #fff; outline-offset: 4px;
}
.photo-dialog {
  width: min(424px, calc(100vw - 32px), calc(100dvh - 130px));
  max-width: none; max-height: calc(100dvh - 32px);
  margin: auto; padding: 12px; overflow: auto;
  border: 1px solid rgba(255,255,255,.8); border-radius: 14px;
  background: #f7f8f5; color: #272b25;
  box-shadow: 0 24px 80px rgba(0,0,0,.4); text-align: center;
}
.photo-dialog::backdrop { background: rgba(8,16,4,.72); backdrop-filter: blur(6px); }
.photo-dialog img { display: block; width: 100%; height: auto; border-radius: 7px; }
.photo-dialog #photo-title { margin: 14px 0 4px; font-size: 21px; font-weight: 600; }
.photo-hint { margin: 0 0 4px; font-size: 13px; color: #52604e; }
.photo-close {
  position: absolute; top: 20px; right: 20px; width: 44px; height: 44px;
  display: grid; place-items: center; border-radius: 50%;
  color: #fff; background: rgba(20,25,20,.85); font-size: 30px; line-height: 1;
}
.photo-close:hover { background: #202b1c; }
.photo-close:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

/* ---------------------------------------------------------------------
   Portrait (phones): narrower frame, chrome repositioned
   --------------------------------------------------------------------- */
[data-layout="portrait"] .gamercard { right: calc(20 * var(--u)); top: calc(34 * var(--u)); gap: calc(10 * var(--u)); }
[data-layout="portrait"] .gc-tag { font-size: calc(24 * var(--u)); }
[data-layout="portrait"] .gc-score { font-size: calc(21 * var(--u)); }
[data-layout="portrait"] .gc-pic { width: calc(58 * var(--u)); height: calc(58 * var(--u)); font-size: calc(24 * var(--u)); }
[data-layout="portrait"] .counter { font-size: calc(19 * var(--u)); }
[data-layout="portrait"] .hints { font-size: calc(22 * var(--u)); }
[data-layout="portrait"] .coach { font-size: calc(16 * var(--u)); top: calc((var(--hy) - 50) * var(--u)); }
[data-layout="portrait"] .home-button { right: calc(26 * var(--u)); bottom: calc(66 * var(--u)); width: max(56px, calc(66 * var(--u))); }
[data-layout="portrait"] .ripple.r1 { left: calc(var(--fw) * var(--u) - 90 * var(--u)); top: calc(140 * var(--u)); }
[data-layout="portrait"] .ripple.r2, [data-layout="portrait"] .ripple.r3 { display: none; }

/* ---------------------------------------------------------------------
   State helpers
   --------------------------------------------------------------------- */
.dragging .row, .dragging .tile, .dragging .ch-label,
.no-anim .row, .no-anim .tile, .no-anim .ch-label { transition: none !important; }

/* NXE "fly-through": opening a tile zooms the dashboard past the camera
   (origin = the tile, set in JS); closing pulls it back into place. */
.frame { transition: transform .44s cubic-bezier(.16, .84, .24, 1), filter .44s ease, opacity .44s ease; }
.panel-open .frame { transform: scale(1.1); filter: blur(3px); opacity: .75; }
.intro .gamercard, .intro .channels, .intro .hints, .intro .counter, .intro .home-button { opacity: 0; }
.gamercard, .channels, .hints, .counter, .home-button { transition: opacity .6s ease .15s; }

/* ---------------------------------------------------------------------
   Detail panel
   --------------------------------------------------------------------- */
.panel-layer {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  padding: max(20px, 5vh) max(16px, 5vw);
}
.panel-layer[hidden] { display: none; }
.panel-scrim {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 40%, hsl(var(--h) 30% 30% / .25), rgba(8, 16, 4, .55));
  opacity: 0;
  transition: opacity .3s;
}
.panel-layer.open .panel-scrim { opacity: 1; }

.panel {
  position: relative;
  width: min(1120px, 100%);
  height: min(760px, 100%);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border-radius: 10px;
  background: linear-gradient(180deg, #f7f8f5 0%, #e4e7e1 100%);
  color: #272b25;
  box-shadow: 0 30px 90px rgba(0,0,0,.45), inset 0 0 0 1px rgba(255,255,255,.6);
  /* --from (set in JS) lays the panel exactly over the tile it opens from */
  transform: var(--from, scale(.6));
  opacity: 0;
  transition: transform .34s cubic-bezier(.45, 0, .2, 1), opacity .14s ease .22s;
}
.panel-layer.open .panel {
  transform: none; opacity: 1;
  transition: transform .44s cubic-bezier(.16, .84, .24, 1), opacity .08s ease;
}
/* tile skin over the panel: the tile appears to grow into it, and back */
.panel::after {
  content: ""; position: absolute; inset: 0; z-index: 10;
  border-radius: inherit; pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255,255,255,.34) 0%, rgba(255,255,255,.08) 34%, rgba(255,255,255,0) 58%),
    linear-gradient(180deg, var(--tile-top) 0%, var(--tile-mid) 56%, var(--tile-bot) 100%);
  transition: opacity .2s ease;
}
.panel-layer.open .panel::after { opacity: 0; transition: opacity .3s ease .14s; }
@media (prefers-reduced-motion: reduce) {
  .panel, .panel-layer.open .panel { transform: none; }
  .panel-open .frame { transform: none; }
}

.panel-head {
  position: relative;
  padding: 22px 32px 18px;
  color: #fff;
  background:
    linear-gradient(180deg, rgba(255,255,255,.3), rgba(255,255,255,0) 60%),
    linear-gradient(180deg, var(--tile-top), var(--tile-mid) 70%, var(--tile-bot));
  text-shadow: 0 1px 2px rgba(0,30,0,.35);
  box-shadow: inset 0 -1px 0 rgba(0,0,0,.12);
}
.panel-eyebrow { font-size: 14px; letter-spacing: .08em; text-transform: uppercase; opacity: .88; }
.panel-title { font-size: clamp(28px, 4.2vw, 46px); font-weight: 400; line-height: 1.08; margin: 2px 0 0; }
.panel-sub { font-size: clamp(16px, 1.6vw, 19px); opacity: .92; margin-top: 4px; }
.panel-sub:empty { display: none; }

.panel-body {
  overflow: auto;
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  gap: 32px;
  align-content: start;
  padding: 28px 32px 36px;
  touch-action: pan-x pan-y;
  overscroll-behavior: contain;
  user-select: text;
  -webkit-user-select: text;
}
.panel-foot {
  display: flex; gap: 26px; align-items: center;
  padding: 12px 32px;
  font-size: 18px;
  color: #394035;
  background: rgba(0,0,0,.04);
  border-top: 1px solid rgba(0,0,0,.07);
}
.panel-foot .hint { text-shadow: none; }

.p-hero {
  aspect-ratio: 4 / 3;
  border-radius: 6px;
  overflow: hidden;
  display: grid; place-items: center;
  container-type: size;
  background:
    linear-gradient(180deg, rgba(255,255,255,.3), rgba(255,255,255,0) 55%),
    linear-gradient(180deg, var(--tile-top), var(--tile-mid) 60%, var(--tile-bot));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7), 0 6px 18px rgba(0,40,0,.2);
}
.p-hero .ico { width: 55cqmin; height: 55cqmin; }
.p-hero img { width: 100%; height: 100%; object-fit: cover; }
.p-hero--avatar img { object-fit: contain; min-width: 0; min-height: 0; }
.p-hero--avatar svg { width: 100%; height: 100%; display: block; }

.p-actions { display: flex; flex-direction: column; gap: 6px; margin-top: 18px; }
.p-btn {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  border-radius: 5px;
  font-size: 17px;
  text-decoration: none;
  color: #2a3027;
  background: linear-gradient(180deg, #ffffff, #e6e9e3);
  border: 1px solid rgba(0,0,0,.13);
  box-shadow: inset 0 1px 0 #fff, 0 1px 2px rgba(0,0,0,.06);
  transition: background .12s, color .12s;
}
.p-btn:hover, .p-btn:focus-visible, .p-btn:focus {
  outline: none;
  color: #fff;
  border-color: hsl(var(--h) 60% 30% / .5);
  background: linear-gradient(180deg, var(--tile-top), var(--tile-bot));
  text-shadow: 0 1px 1px rgba(0,30,0,.4);
}
.p-btn[aria-pressed="true"]::after { content: "✓"; margin-left: auto; font-weight: 700; }

.p-main { min-width: 0; font-size: 17px; line-height: 1.6; }
.p-main > :first-child { margin-top: 0; }
.p-main p { margin: 0 0 14px; }
.p-main h2 {
  font-size: 19px; font-weight: 600;
  color: var(--accent-ink);
  margin: 26px 0 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid hsl(var(--h) 45% 45% / .25);
}
.p-main ul { margin: 0 0 12px; padding-left: 1.2em; }
.p-main li { margin: 4px 0; }
.p-main li::marker { color: hsl(var(--h) 60% 38%); }

.p-meta { display: flex; flex-wrap: wrap; gap: 10px 30px; margin-bottom: 18px; }
.p-meta div { font-size: 16px; }
.p-meta b { display: block; font-size: 12px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: #6a7165; }

.tag {
  display: inline-block;
  margin: 0 6px 8px 0;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 14px;
  color: var(--accent-ink);
  background: hsl(var(--h) 55% 45% / .15);
  box-shadow: inset 0 0 0 1px hsl(var(--h) 55% 35% / .15);
}

.p-item { padding: 12px 0; border-bottom: 1px solid rgba(0,0,0,.08); }
.p-item:last-child { border-bottom: 0; }
.p-item-head { display: flex; justify-content: space-between; gap: 6px 16px; flex-wrap: wrap; align-items: baseline; }
.p-item-title { font-weight: 600; }
.p-item-date { font-size: 14px; color: #666d62; white-space: nowrap; }
.p-item-sub { color: #4c5348; }
.p-item > a { display: inline-block; margin-top: 4px; color: var(--accent-ink); text-underline-offset: 3px; }
.p-item > a:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 3px; border-radius: 2px; }

.p-roles { margin: 10px 0 2px; padding-left: 14px; border-left: 2px solid hsl(var(--h) 50% 42% / .35); }
.p-role { padding: 6px 0; }
.p-role-title { font-weight: 600; color: var(--accent-ink); }
.p-role ul { margin: 4px 0 0; }

.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.swatch {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: 6px;
  padding: 10px 12px;
  display: flex; align-items: flex-end;
  color: #fff; font-size: 16px;
  text-shadow: 0 1px 2px rgba(0,0,0,.35);
  background:
    linear-gradient(180deg, rgba(255,255,255,.3), rgba(255,255,255,0) 55%),
    linear-gradient(180deg, var(--tile-top), var(--tile-mid) 60%, var(--tile-bot));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7), 0 3px 10px rgba(0,0,0,.15);
}
.swatch:focus-visible, .swatch:hover { outline: 3px solid hsl(var(--h) 70% 40%); outline-offset: 3px; }
.swatch[aria-pressed="true"]::after {
  content: "✓"; position: absolute; top: 8px; right: 10px;
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255,255,255,.9); color: #2a3a1a; font-weight: 700; text-shadow: none;
}

/* achievements panel */
.ach-summary { margin-bottom: 8px; }
.ach-stats { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 20px; font-size: 17px; }
.ach-stats b { font-size: 24px; font-weight: 600; color: var(--accent-ink); }
.ach-bar {
  height: 12px; margin-top: 10px; border-radius: 6px; overflow: hidden;
  background: rgba(0,0,0,.09); box-shadow: inset 0 1px 2px rgba(0,0,0,.15);
}
.ach-bar i {
  display: block; height: 100%; border-radius: inherit;
  background: linear-gradient(180deg, rgba(255,255,255,.35), rgba(255,255,255,0) 60%), linear-gradient(180deg, var(--tile-top), var(--tile-bot));
  transition: width .6s var(--ease);
}
.ach {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 0; border-bottom: 1px solid rgba(0,0,0,.08);
}
.ach-badge {
  flex: none; width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center; container-type: size;
  background: radial-gradient(circle at 40% 30%, #c9ccc6, #7d827a 75%);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.4), 0 2px 5px rgba(0,0,0,.15);
}
.ach.is-on .ach-badge { background: radial-gradient(circle at 40% 30%, hsl(var(--h) 90% 70%), hsl(calc(var(--h) + 8) var(--sat) 32%) 75%); }
.ach-badge .ico { width: 56%; height: 56%; }
.ach-text { flex: 1; min-width: 0; line-height: 1.35; }
.ach-name { display: block; font-weight: 600; }
.ach-desc, .ach-date { display: block; font-size: 15px; color: #5c6358; }
.ach-date { font-size: 13px; color: #7a8175; }
.ach:not(.is-on) .ach-name { color: #5c6358; }
.ach-g { flex: none; display: flex; align-items: center; gap: 4px; font-size: 17px; white-space: nowrap; }
.ach:not(.is-on) .ach-g { opacity: .55; }
.ach-done { margin-top: 18px; font-weight: 600; color: var(--accent-ink); }
.ach-reset { display: inline-flex; margin-top: 22px; font-size: 15px; }

.controls-scroll { max-width: 100%; overflow-x: auto; }
.controls-scroll:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; }
.controls-table { width: 100%; min-width: 600px; border-collapse: collapse; font-size: 16px; }
.controls-table th, .controls-table td { text-align: left; padding: 9px 8px; border-bottom: 1px solid rgba(0,0,0,.08); vertical-align: top; }
.controls-table th { font-size: 12px; letter-spacing: .07em; text-transform: uppercase; color: #6a7165; font-weight: 600; }
kbd {
  display: inline-block; min-width: 1.6em; padding: 1px 6px; margin: 1px 2px;
  border-radius: 4px; font: 600 13px/1.5 var(--font); text-align: center;
  background: #fff; border: 1px solid rgba(0,0,0,.18); box-shadow: 0 1px 0 rgba(0,0,0,.15);
}

@media (max-width: 760px) {
  .panel-layer { padding: 0; }
  .panel { width: 100%; height: 100%; border-radius: 0; }
  .panel-head { padding: calc(18px + env(safe-area-inset-top)) 20px 14px; }
  .panel-body { grid-template-columns: 1fr; gap: 20px; padding: 20px 20px 32px; }
  .p-hero { aspect-ratio: 16 / 7; }
  .panel-foot { padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); }
}

/* ---------------------------------------------------------------------
   Achievement toast
   --------------------------------------------------------------------- */
.toast-wrap {
  position: fixed; z-index: 80;
  left: 50%; bottom: 8vh;
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  display: flex; align-items: center;
  height: 68px;
  max-width: 68px;
  padding: 8px;
  border-radius: 34px;
  overflow: hidden;
  white-space: nowrap;
  color: #fff;
  background: linear-gradient(180deg, #484c46 0%, #262825 55%, #1a1b19 100%);
  box-shadow: 0 10px 30px rgba(0,0,0,.4), inset 0 1px 0 rgba(255,255,255,.25), inset 0 0 0 1px rgba(255,255,255,.08);
  opacity: 0;
  transform: scale(.4);
  transition: max-width .45s var(--ease), transform .3s cubic-bezier(.5, 0, .75, 0), opacity .2s ease .1s;
}
/* 360 order: circle pops in, badge spins, pill opens; reverse to leave */
.toast.show {
  opacity: 1; transform: none;
  transition: max-width .5s var(--ease), transform .45s cubic-bezier(.34, 1.56, .64, 1), opacity .12s;
}
.toast.expand { max-width: 560px; }
.toast.show .toast-badge .ico { animation: badge-spin 1s cubic-bezier(.2, .8, .2, 1) .1s both; }
@keyframes badge-spin { from { transform: perspective(200px) rotateY(-540deg) scale(.6); } }
.toast-text { opacity: 0; transform: translateX(-12px); transition: opacity .18s, transform .18s; }
.toast.expand .toast-text { opacity: 1; transform: none; transition: opacity .3s ease .2s, transform .4s var(--ease) .2s; }
.toast-badge {
  flex: none;
  width: 52px; height: 52px;
  border-radius: 50%;
  display: grid; place-items: center;
  container-type: size;
  background: radial-gradient(circle at 40% 30%, hsl(var(--h) 90% 70%), hsl(calc(var(--h) + 8) var(--sat) 32%) 75%);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.4);
}
.toast-badge .ico { width: 58%; height: 58%; }
.toast-text { padding: 0 24px 0 14px; line-height: 1.25; }
.toast-l1 { font-size: 14px; opacity: .8; }
.toast-l2 { font-size: 19px; }

/* ---------------------------------------------------------------------
   No-JS fallback
   --------------------------------------------------------------------- */
.noscript {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-content: center; text-align: center;
  background: #8fb33a; color: #fff; padding: 24px; user-select: text;
}
.noscript a { color: #fff; }

/* Captioned evidence stays in the reading column rather than a cropped tile. */
.p-figure { margin: 0 0 24px; }
.p-figure img { display: block; width: 100%; height: auto; border-radius: 6px; background: #101f27; }
.p-figure figcaption { margin-top: 8px; font-size: .85em; line-height: 1.45; color: #536052; }
.reading-link { position: fixed; right: 24px; bottom: 20px; z-index: 2; color: #193315; font: 14px/1.4 sans-serif; background: rgba(255,255,255,.88); padding: 8px 12px; border-radius: 6px; }
.reading-link:focus-visible { outline: 3px solid #193315; outline-offset: 3px; }
@media (max-width: 600px) { .reading-link { bottom: 12px; right: 12px; font-size: 12px; } }

.panel-open .reading-link { visibility: hidden; }

/* Keep portrait game captures visible as a complete frame. */
.media-portrait img { width: auto; max-width: 100%; max-height: min(55vh, 480px); margin-inline: auto; }
