/* Figuregot Arcade — Teenage-Engineering-ish: warm grey, black mono, one orange */
:root {
  --bg: #e4e3df;
  --bg-2: #d9d8d3;
  --ink: #141414;
  --ink-2: #5b5a56;
  --line: rgba(20, 20, 20, .14);
  --accent: #ff5b1f;
  --red: #e5352b;
  --orange: #f08a24;
  --green: #7fb03a;
  --screen: #17150e;
  --phosphor: #f2e8cf;
  --world-bg: #121210;
  --world-ink: #e9e6dc;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --sans: "Inter Tight", system-ui, -apple-system, "Segoe UI", sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 500 14px/1.4 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
.noscript { padding: 40px; font-family: var(--mono); }

/* ---------- home: the Higgsfield console plate with live overlays ---------- */
.home {
  position: fixed; inset: 0; overflow: hidden;
  display: grid; place-items: center;
  /* seamless 4K-sourced plastic tile, one cell = one console width so the grain matches */
  background: #cac4b7 url("../img/ui/panel_tile.webp") center bottom / calc(min(100vw, 100vh * 1200 / 904) * 2) auto repeat;
}
.plate {
  --u: calc(100cqw / 1200);
  align-self: end;
  position: relative; container-type: size;
  width: min(100vw, 100vh * 1200 / 904); aspect-ratio: 1200 / 904;
  background: url("../img/ui/plate.webp") center / 100% 100% no-repeat;
  /* fade into the page on the sides and top; the bottom runs off the window so the cable exits */
  mask-image: linear-gradient(90deg, transparent, #000 5%, #000 95%, transparent), linear-gradient(180deg, transparent, #000 4%);
  mask-composite: intersect; -webkit-mask-composite: source-in;
  transform-origin: 50% 50%; will-change: transform;
}
@media (max-width: 899px) { .plate { background-image: url("../img/ui/plate_1600.webp"); } }
.plate > * {
  position: absolute; margin: 0;
  left: calc(var(--x) / 12 * 1%); top: calc(var(--y) / 9.04 * 1%);
  width: calc(var(--w) / 12 * 1%); height: calc(var(--h) / 9.04 * 1%);
}

/* engraved labels */
.lbl { display: flex; align-items: center; justify-content: center; font: 600 calc(var(--u) * 9.5) / 1 var(--mono); letter-spacing: .14em; color: #57534b; white-space: nowrap; }
.lbl-head { font-size: calc(var(--u) * 11.5); letter-spacing: .2em; color: #4b4842; }
.lbl-head b { color: #2a2824; margin-left: .5em; }
.lbl-tiny { font-size: calc(var(--u) * 7.5); letter-spacing: .1em; }
.lbl-side { justify-content: flex-start; font-size: calc(var(--u) * 9); font-weight: 500; }
.lbl-right { justify-content: flex-end; }
.lbl-left { justify-content: flex-start; }
.lbl-group span { padding: 0 .7em; background: #dcd8cd; box-shadow: 0 0 calc(var(--u) * 4) calc(var(--u) * 3) #dcd8cd; border-radius: 2px; }

/* buttons: invisible hit areas over the plate's real keys; text printed on top */
.hit { padding: 0; border: 0; background: transparent; cursor: pointer; -webkit-tap-highlight-color: transparent; border-radius: calc(var(--u) * 7); }
/* .cut = the button's own pixels from the plate, so the real key can move. Hover sinks it into
   its socket (the shadow above it fills the gap it leaves); pressing sinks it further. */
.cut, .dpad-img {
  background-image: url("../img/ui/plate.webp");
  background-size: calc(1200 / var(--w) * 100%) calc(904 / var(--h) * 100%);
  background-position: calc(var(--x) / (1200 - var(--w)) * 100%) calc(var(--y) / (904 - var(--h)) * 100%);
  background-repeat: no-repeat;
}
.cut { transition: transform .08s ease-out, box-shadow .08s ease-out, filter .08s; }
.cut:hover { transform: translateY(calc(var(--u) * 1.8)); box-shadow: 0 calc(var(--u) * -1.8) 0 0 rgba(48,44,38,.55); filter: brightness(.97); }
.cut:active, .cut.pressed { transform: translateY(calc(var(--u) * 3.2)); box-shadow: 0 calc(var(--u) * -3.2) 0 0 rgba(40,36,30,.62); filter: brightness(.9); transition-duration: .04s; }
@media (max-width: 899px) { .cut, .dpad-img { background-image: url("../img/ui/plate_1600.webp"); } }
/* d-pad: the cross rocks toward the arrow you hover / press */
.dpad-img {
  pointer-events: none; transform-origin: 50% 50%; transition: transform .1s ease-out, filter .1s;
  clip-path: polygon(34.8% 0, 65.2% 0, 65.2% 28.7%, 100% 28.7%, 100% 68.7%, 65.2% 68.7%, 65.2% 100%, 34.8% 100%, 34.8% 68.7%, 0 68.7%, 0 28.7%, 34.8% 28.7%);
}
.dpad-img[data-tilt="up"] { transform: perspective(400px) rotateX(11deg) translateY(1px); filter: brightness(.96); }
.dpad-img[data-tilt="down"] { transform: perspective(400px) rotateX(-11deg) translateY(1px); filter: brightness(.96); }
.dpad-img[data-tilt="left"] { transform: perspective(400px) rotateY(-11deg) translateY(1px); filter: brightness(.96); }
.dpad-img[data-tilt="right"] { transform: perspective(400px) rotateY(11deg) translateY(1px); filter: brightness(.96); }
.dpad-img.pressed { filter: brightness(.88); }
.hit:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.key3 { display: flex; align-items: center; justify-content: center; gap: .45em; font: 600 calc(var(--u) * 9.5) / 1 var(--mono); letter-spacing: .06em; color: #2f2d29; padding-bottom: calc(var(--u) * 3); }
.tkey[aria-checked="false"]::before { content: ""; position: absolute; inset: 0; border-radius: inherit; background: rgba(226,222,212,.3); pointer-events: none; }
.tkey[aria-checked="true"] { color: #141310; text-shadow: 0 1px 0 rgba(255,255,255,.35); }
.tkey[aria-checked="true"]::before { content: ""; position: absolute; left: 50%; top: 14%; width: calc(var(--u) * 5); height: calc(var(--u) * 5); translate: -50% 0; border-radius: 50%; background: #fff8d0; box-shadow: 0 0 calc(var(--u) * 6) #fff3b0; }
.key3 .led { width: calc(var(--u) * 6); height: calc(var(--u) * 6); border-radius: 50%; background: #7fbf3f; box-shadow: 0 0 calc(var(--u) * 6) #8fd24d; }
#soundBtn[aria-pressed="false"] .led { background: #8c8a84; box-shadow: none; }
.hit-pwr { border-radius: 50%; }
.hit-round { border-radius: 50%; }
.hit-dpad { border-radius: calc(var(--u) * 4); }
.hit-explore { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: calc(var(--u) * 5); color: #ece8de; text-shadow: 0 -1px 0 rgba(0,0,0,.35); border-radius: calc(var(--u) * 4); }
.hit-explore b { font: 700 calc(var(--u) * 15) / 1 var(--sans); letter-spacing: .08em; }
.hit-explore small { font: 600 calc(var(--u) * 6.5) / 1 var(--mono); letter-spacing: .16em; opacity: .8; }

.readout { display: flex; align-items: center; padding: 0 calc(var(--u) * 8); overflow: hidden; white-space: nowrap; font: 500 calc(var(--u) * 9) / 1 var(--mono); letter-spacing: .12em; color: #a6d36a; text-shadow: 0 0 calc(var(--u) * 5) rgba(166,211,106,.6); }
.stat { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: calc(var(--u) * 2); font: 600 calc(var(--u) * 5.5) / 1 var(--mono); letter-spacing: .1em; color: #5d5951; }
.stat b { font: 700 calc(var(--u) * 11) / 1 var(--sans); letter-spacing: 0; color: #2a2824; }

/* the live screen, blended into the plate's own glass */
.screen {
  padding: 0; border: 0; border-radius: 8% / 12%; overflow: hidden; cursor: zoom-in; background: transparent;
}
.screen canvas { width: 100%; height: 100%; display: block; image-rendering: pixelated; image-rendering: crisp-edges; mix-blend-mode: screen; opacity: .96; }
.screen-glass {
  position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  background:
    linear-gradient(162deg, rgba(255,255,255,.10) 0%, rgba(255,255,255,.02) 30%, transparent 42%),
    repeating-linear-gradient(0deg, rgba(0,0,0,.18) 0 1px, transparent 1px 3px);
}
.screen:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

/* slider: the plate's own handle, moved over a patch of empty track */
.slider { cursor: grab; touch-action: none; border-radius: calc(var(--u) * 3); overflow: hidden; }
.slider-cover { position: absolute; left: calc(1.5 / 226 * 100%); top: 0; width: calc(74 / 226 * 100%); height: 100%; background: url("../img/ui/track.webp") center / 100% 100%; }
.slider-thumb { position: absolute; left: calc(1.5 / 226 * 100%); top: 0; width: calc(74 / 226 * 100%); height: 100%; background: url("../img/ui/thumb.webp") center / 100% 100%; border-radius: calc(var(--u) * 2); box-shadow: 0 1px 3px rgba(0,0,0,.35); }
.slider-text { position: absolute; left: 36%; right: 0; top: 0; bottom: 0; display: flex; align-items: center; justify-content: center; font: 600 calc(var(--u) * 7.5) / 1 var(--mono); letter-spacing: .2em; color: #a8a396; pointer-events: none; }
.slider.dragging { cursor: grabbing; }
.slider:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.mobile-pad { display: none; }

/* zoom-into-screen flash */
.flash { position: fixed; inset: 0; background: var(--screen); opacity: 0; pointer-events: none; z-index: 20; transition: opacity .25s; }

/* ---------- explorer: one Got in focus, the collection blurred behind ---------- */
.explorer {
  position: fixed; inset: 0; z-index: 10; overflow: hidden; overflow: clip; color: var(--world-ink);
  background: radial-gradient(70% 70% at 50% 50%, #1c1b18 0%, #0c0c0b 70%, #080807 100%);
  touch-action: none; user-select: none; -webkit-user-select: none;
  --px: 0; --py: 0;
}
.explorer canvas#world {
  position: absolute; inset: 0; width: 100%; height: 100%; display: block;
  filter: blur(22px) brightness(.5) saturate(1.15); transform: scale(1.06);
  transition: filter .45s var(--ease), transform .45s var(--ease);
}
.explorer.browsing canvas#world { filter: none; transform: none; }
.explorer.browsing { cursor: grab; }
.explorer.browsing:active { cursor: grabbing; }
.vignette { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(closest-side, transparent 60%, rgba(0,0,0,.55)); }

.orb, .sats, .tags, .leaders { transition: opacity .35s var(--ease), transform .45s var(--ease); }
.explorer.browsing .orb, .explorer.browsing .sats, .explorer.browsing .tags, .explorer.browsing .leaders { opacity: 0; pointer-events: none; }
.explorer.browsing .orb { transform: scale(.55); }

.orb {
  position: absolute; padding: 0; border: 0; border-radius: 50%; overflow: hidden; cursor: pointer;
  background: #151412;
  box-shadow: 0 40px 120px rgba(0,0,0,.65), 0 0 0 1px rgba(255,255,255,.06);
  translate: calc(var(--px) * -14px) calc(var(--py) * -14px);
}
.orb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .35s; }
.orb img.on { opacity: 1; }
.orb:focus-visible { outline: 2px solid var(--accent); outline-offset: 6px; }

/* the three tiers orbit the orb */
.sats { position: absolute; width: 0; height: 0; translate: calc(var(--px) * -6px) calc(var(--py) * -6px); }
.sat {
  
  position: absolute; left: 0; top: 0; width: 64px; height: 64px; margin: -32px 0 0 -32px; padding: 0;
  border: 0; border-radius: 50%; background: #000; overflow: hidden; cursor: pointer;
  box-shadow: 0 10px 30px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,.08);
  transform: rotate(var(--a)) translateX(var(--r)) rotate(calc(-1 * var(--a)));
  animation: bob 5s ease-in-out infinite; animation-delay: calc(var(--i) * -1.6s);
}
.sat img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s; }
.sat:hover img { transform: scale(1.08); }
.sat span { position: absolute; left: 50%; bottom: 5px; translate: -50% 0; padding: 2px 6px; border-radius: 999px; background: rgba(0,0,0,.65); font: 600 9px/1.2 var(--mono); letter-spacing: .08em; color: #fff; }
.sat.on { box-shadow: 0 0 0 2px var(--accent), 0 10px 30px rgba(0,0,0,.6); }
@keyframes bob { 0%, 100% { translate: 0 0; } 50% { translate: 0 -5px; } }

/* leader lines + labels */
.leaders { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.leaders line { stroke: rgba(242,232,207,.62); stroke-width: 1.2; stroke-dasharray: 600; stroke-dashoffset: 600; animation: draw .8s var(--ease) forwards; animation-delay: var(--d); }
.leaders circle { fill: var(--phosphor); opacity: 0; animation: fadein .3s forwards; animation-delay: var(--d); }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fadein { to { opacity: 1; } }
.tags { position: absolute; inset: 0; pointer-events: none; }
.tag {
  position: absolute; translate: 0 -50%; display: flex; align-items: baseline; gap: 8px; white-space: nowrap;
  font: 500 12px/1.2 var(--mono); letter-spacing: .02em; color: #9c978b;
  opacity: 0; animation: fadein .45s var(--ease) forwards; animation-delay: var(--d);
}
.tag::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); translate: 0 -1px; flex: none; }
.tag b { color: var(--phosphor); font-weight: 600; font-family: var(--sans); font-size: 14px; letter-spacing: 0; }
.tag.right { translate: -100% -50%; flex-direction: row-reverse; text-align: right; }

/* HUD */
.hud { position: absolute; left: 0; right: 0; z-index: 3; display: flex; align-items: center; gap: 12px; padding: 16px 18px; pointer-events: none; font: 500 11px/1 var(--mono); letter-spacing: .08em; }
.hud > * { pointer-events: auto; }
.hud-top { top: 0; padding-top: max(16px, env(safe-area-inset-top)); }
.hud-bottom { bottom: 0; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
.chip-dark { background: rgba(255,255,255,.06); color: var(--world-ink); border-color: rgba(255,255,255,.12); text-decoration: none; backdrop-filter: blur(10px); }
.chip-dark:hover { background: rgba(255,255,255,.14); }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 999px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); backdrop-filter: blur(10px); }
.seg button { height: 24px; min-width: 38px; padding: 0 10px; border: 0; border-radius: 999px; background: transparent; color: #a9a69d; font: 600 11px/1 var(--mono); letter-spacing: .08em; }
.seg button[aria-checked="true"] { background: var(--phosphor); color: #141414; }
.find { margin-left: auto; display: flex; align-items: center; height: 30px; padding: 0 4px 0 12px; border-radius: 999px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); backdrop-filter: blur(10px); }
.find label { color: #8f8b80; }
.find input { width: 96px; height: 100%; border: 0; outline: 0; background: transparent; color: var(--world-ink); font: 500 11px/1 var(--mono); letter-spacing: .08em; padding: 0 6px; }
.find input::placeholder { color: #6f6c63; }
.now { flex: 1; text-align: center; min-width: 0; transition: opacity .3s; }
.explorer.browsing .now, .explorer.browsing .now-actions { opacity: .35; }
.now-title { margin: 0 0 4px; font: 700 18px/1 var(--sans); letter-spacing: -.01em; color: var(--phosphor); }
.now-sub { margin: 0; font: 500 10.5px/1 var(--mono); letter-spacing: .12em; color: #8f8b80; }
.now-actions { display: flex; gap: 6px; }
.hint { position: absolute; left: 50%; top: 64px; translate: -50% 0; margin: 0; z-index: 3; font: 500 10.5px/1 var(--mono); letter-spacing: .14em; color: #6f6c63; pointer-events: none; transition: opacity .8s; white-space: nowrap; }
.hint.gone { opacity: 0; }

/* all-traits drawer */
.drawer {
  position: absolute; top: 12px; right: 12px; bottom: 12px; z-index: 5; width: min(380px, calc(100vw - 24px)); overflow: auto;
  padding: 26px 24px; border-radius: 16px; background: rgba(20,20,18,.92); border: 1px solid rgba(255,255,255,.1);
  backdrop-filter: blur(16px); color: var(--world-ink); animation: slidein .35s var(--ease);
}
@keyframes slidein { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes slideup { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: none; } }
.drawer-close { position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; border-radius: 50%; border: 1px solid rgba(255,255,255,.14); background: transparent; color: var(--world-ink); font-size: 18px; line-height: 1; }
.drawer h2 { margin: 0 0 8px; font: 700 26px/1.05 var(--sans); letter-spacing: -.02em; color: var(--phosphor); }
.drank { margin: 0 0 18px; font: 500 11px/1 var(--mono); letter-spacing: .08em; color: #8f8b80; text-transform: uppercase; }
.drank b { color: var(--accent); font-size: 16px; margin-right: 4px; }
.dtraits { margin: 0 0 18px; border-top: 1px solid rgba(255,255,255,.08); }
.dtraits > div { position: relative; display: grid; grid-template-columns: 104px 1fr auto; gap: 10px; align-items: center; padding: 10px 0 12px; border-bottom: 1px solid rgba(255,255,255,.08); }
.dtraits dt { font: 500 10px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: #8f8b80; }
.dtraits dd { margin: 0; font-weight: 600; color: var(--phosphor); }
.dtraits span { font: 500 11px/1 var(--mono); color: #8f8b80; }
.dtraits i { position: absolute; left: 114px; right: 0; bottom: 5px; height: 2px; background: rgba(255,255,255,.07); }
.dtraits i::after { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--w); background: #8f8b80; }
.dtraits .rare i::after { background: var(--accent); }
.dlabel { margin: 0 0 8px; font: 500 10px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: #8f8b80; }
.devo { margin-bottom: 20px; }
.devo table { width: 100%; border-collapse: collapse; font: 500 11.5px/1.3 var(--mono); }
.devo th, .devo td { text-align: left; padding: 5px 6px 5px 0; font-weight: 500; }
.devo th { color: #8f8b80; font-weight: 400; }
.devo .same { color: var(--accent); }
.btn { display: inline-flex; align-items: center; height: 40px; padding: 0 18px; border-radius: 999px; background: var(--phosphor); color: #141414; text-decoration: none; font: 600 11px/1 var(--mono); letter-spacing: .08em; }
.btn:hover { background: var(--accent); color: #fff; }

/* ---------- small screens ---------- */
@media (max-width: 760px), (max-aspect-ratio: 4/5) {
  /* phones: zoom the console onto the screen, controls in a strip below */
  .home { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; overflow: hidden; }
  .plate {
    flex: none; width: calc(100vw * 1200 / 640); margin-top: max(8px, env(safe-area-inset-top));
    margin-left: calc(100vw * -1200 / 640 * (604 / 1200) + 50vw); align-self: flex-start;
    mask-image: none;
  }
  .mobile-pad { display: flex; flex-direction: column; gap: 10px; width: 100%; padding: 14px 16px max(18px, env(safe-area-inset-bottom)); margin-top: auto; }
  .mrow { display: flex; gap: 8px; }
  .mkey {
    flex: 1; height: 48px; border: 0; border-radius: 9px;
    background: linear-gradient(180deg, #f6f3ec, #dcd6c9); color: #2f2d29;
    font: 600 11px/1 var(--mono); letter-spacing: .08em;
    box-shadow: 0 0 0 1px #c5bfb1, 0 3px 0 #b9b2a2, 0 6px 10px rgba(60,48,26,.18), inset 0 1px 0 #fff;
  }
  .mkey:active { transform: translateY(2px); }
  .mkey[aria-checked="true"] { background: linear-gradient(180deg, #a9d27c, #79aa4c); box-shadow: 0 0 0 1px #6e9a45, 0 3px 0 #5f8a3b, inset 0 1px 0 rgba(255,255,255,.5); }
  .mkey-explore { flex: 1.4; background: linear-gradient(180deg, #8d8a84, #6b6862); color: #f1ede3; box-shadow: 0 0 0 1px #5e5b55, 0 3px 0 #4e4b46, inset 0 1px 0 rgba(255,255,255,.25); }
  .hud { padding-left: 12px; padding-right: 12px; gap: 8px; }
  .hud-bottom { flex-wrap: wrap; justify-content: center; }
  .now { order: -1; flex-basis: 100%; margin-bottom: 6px; }
  .tag { font-size: 10.5px; }
  .tag b { font-size: 12.5px; }
  .sat { width: 48px; height: 48px; margin: -24px 0 0 -24px; }
  .hint { top: 58px; font-size: 9.5px; }
  .drawer { top: auto; left: 0; right: 0; bottom: 0; width: 100%; max-height: 78vh; border-radius: 18px 18px 0 0; animation-name: slideup; padding-bottom: max(24px, env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) {
  .key, .bigkey, .round { transition: none; }
}
