:root { color-scheme: dark; }
  * { box-sizing: border-box; }
  html, body { width: 100%; min-height: 100%; margin: 0; }
  body { background: #070809; display: grid; place-items: center; min-height: 100vh; }
  main { width: min(100%, 1288px); display: grid; place-items: center; padding: 125px 24px; overflow: visible; perspective: 1100px; position: relative; visibility: hidden; translate: 0 18px; }
  .cover { width: min(430px, 84vw, 75vh); aspect-ratio: 959 / 1209; cursor: grab; touch-action: none; user-select: none; will-change: transform; position: relative; overflow: visible; background: transparent; border: 0; border-radius: 0; box-shadow: none; outline: 0; isolation: isolate; }
  #draggable-cover { position: relative; z-index: 2; }
  .cover-side { position: absolute; z-index: 1; pointer-events: none; opacity: .5; transform-origin: center; filter: brightness(.77); }
  .cover:active { cursor: grabbing; }
  .cover img { display: block; width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; border-radius: 3px 3px 0 0; pointer-events: none; -webkit-user-drag: none; }
  /* On narrow viewports reserve room for dragging, instead of filling the
     screen with one giant cover. Desktop geometry remains unchanged. */
  @media (max-width: 899px) {
    main { padding: 125px 16px; }
    .cover { width: min(360px, 50vw); }
  }
  @media (max-width: 480px) {
    main { padding: 125px 12px; }
    .cover { width: 52vw; }
  }
  /* Portrait phones: preserve the desktop five-cover composition exactly.
     The phone viewport is a centered crop, NOT a resized gallery. */
  @media (max-width: 600px) and (orientation: portrait) {
    html, body { width: 100%; overflow-x: clip; }
    body { position: relative; min-height: 100dvh; display: block; overflow: hidden; }
    main {
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
      width: 180vw;
      translate: 0 0;
      max-width: none;
      padding: 125px 12px;
    }
    /* Optical correction: side cards were slightly right-heavy at viewport edges on iPhone. */
    .pomexa-scene .cover-side { translate: -3px 0; }
    /* Center fits entirely at its 105% scale; near neighbours peek in. */
    .cover { width: min(60vw, 280px, 60vh); }
  }
  /* Original Stitch editorial footer, adapted as a radio-only dock. */
  .live-controls{
    position:fixed;left:50%;bottom:12px;transform:translateX(-50%);z-index:3000;
    width:50%;max-width:760px;min-height:70px;padding:12px clamp(12px,2vw,24px);
    display:flex;align-items:center;gap:clamp(16px,2.6vw,32px);
    background:rgba(8,9,11,.70);border:0;border-top:1px solid #2e2f32;
    border-radius:0;color:#edeae2;box-shadow:0 -8px 40px #0007;
    backdrop-filter:blur(14px);font-family:Inter,system-ui,sans-serif;
  }
  .stitch-playgroup{display:flex;align-items:center;gap:16px;flex:none}
  .live-controls button{
    width:46px;height:46px;flex:none;display:grid;place-items:center;
    padding:0;background:#edeae2;color:#0b0b0c;border:0;border-radius:50%;
    cursor:pointer;box-shadow:0 0 20px #edeae21f;transition:transform .18s,background .18s;
  }
  .live-controls button:hover{transform:scale(1.06);background:#fff}
  .live-controls button:focus-visible{outline:2px solid #ba2c3e;outline-offset:4px}
  .live-controls button svg{width:19px;height:19px;fill:currentColor}
  .stitch-clock{display:flex;gap:7px;white-space:nowrap;color:#777980;font:12px/1.2 ui-monospace,SFMono-Regular,Consolas,monospace}
  .stitch-clock .elapsed{color:#edeae2}
  .stitch-progress{flex:1;min-width:20px;height:20px;display:flex;align-items:center}
  .stitch-progress-rail{height:2px;width:100%;background:#34363a;overflow:hidden;border-radius:3px}
  .stitch-progress-fill{height:100%;width:0;background:#9d232d;transition:width .15s linear}
  .stitch-info{display:flex;align-items:center;gap:10px;min-width:0;flex:0 1 260px}
  .stitch-dot{width:7px;height:7px;flex:none;border-radius:50%;background:#6b6e72}
  .live-controls.is-live .stitch-dot{background:#9d232d;box-shadow:0 0 8px #9d232d88}
  .live-controls .track{min-width:0;flex:1;font:11px/1.4 ui-monospace,SFMono-Regular,Consolas,monospace}
  .live-controls .track strong,.live-controls .track span{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .live-controls .track strong{font-weight:500;color:#e2dfda}
  .live-controls .track span{font-size:10px;color:#888b91;margin-top:2px}
  @media(max-width:650px){
    .live-controls{width:92vw;max-width:380px;min-height:66px;padding:10px 12px;gap:10px}
    .stitch-clock{font-size:11px}
    .stitch-info{flex:0 1 115px}
  }
  @media(max-width:390px){.stitch-clock{display:none}.stitch-info{flex:0 1 94px}}
  main.live-ready { visibility:visible; }
  .cover .cover-caption {
    position:absolute;left:9%;right:7%;top:77%;width:auto;min-height:0;padding:0;
    background:transparent;color:#f3f3f3;font:600 15px/1.25 'Inter',sans-serif;
    text-align:left;pointer-events:none;border:0;border-radius:0;z-index:3;text-shadow:0 1px 3px #000;
  }
  .cover .cover-caption .track-artist,.cover .cover-caption .track-title {display:block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;}
  @media(max-width:600px) and (orientation:portrait) {.cover .cover-caption {font-size:11px;}}

  /* Artwork inside the approved grunge frame. */
  .cover > img, .cover .card-reflection img {
    position: absolute;
    /* Match the ACTUAL inner window of the v2 grunge frame, rather than
       positioning a smaller square over it.  The image is clipped to that
       window; object-fit handles cover variations without stretching. */
    left: 4%; top: 3%;
    width: 92%; height: 69%;
    aspect-ratio: auto;
    object-fit: cover;
    border-radius: 2px;
  }
  .cover::after {
    content: '';
    position: absolute;
    inset: 0;
    background: url('../assets/pomexa-card-frame-v2.webp') center / 100% 100% no-repeat;
    pointer-events: none;
    z-index: 2;
  }
  .cover .cover-caption .track-artist {
    font-family: 'Anton', Impact, sans-serif;
    font-size: clamp(13px, 2.8vw, 38px);
    line-height: 1.05;
    font-weight: 400;
    letter-spacing: .5px;
    color: #ebe9e4;
  }
  .cover .cover-caption .track-title {
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: clamp(10px, 1.4vw, 19px);
    line-height: 1.25;
    color: #a5a5a5;
    margin-top: 6px;
  }
  @media(max-width:600px) and (orientation:portrait) {
    .cover .cover-caption .track-artist {font-size:clamp(12px, 4.1vw, 20px)}
    .cover .cover-caption .track-title {font-size:clamp(10px, 2.8vw, 14px)}
  }


  /* Real mirrored artwork layer, not box-reflect (unreliable on rotated 3D elements).
     Positioned absolutely: it never affects the gallery's centering/geometry. */
  .cover .card-reflection {
    position:absolute; left:0; top:calc(100% + 18px); width:100%; height:100%;
    pointer-events:none; z-index:-2;
    filter:blur(2px);
    transform:scaleY(-1); transform-origin:center;
    -webkit-mask-image:linear-gradient(to top, rgba(0,0,0,.58) 0%, rgba(0,0,0,.35) 18%, transparent 39%);
    mask-image:linear-gradient(to top, rgba(0,0,0,.58) 0%, rgba(0,0,0,.35) 18%, transparent 39%);
  }
  .cover .card-reflection::after {
    content:''; position:absolute; inset:0;
    background:url('../assets/pomexa-card-frame-v2.webp') center/100% 100% no-repeat;
  }
  /* Center cover casts a directional soft shadow across the adjacent cards. */
  .cover::before {
    content: '';
    position: absolute;
    inset: 4% -15% -5%;
    z-index: -1;
    pointer-events: none;
    background: rgba(0,0,0,.72);
    filter: blur(31px);
    transform: translate(18px, 11px) scale(.96);
    border-radius: 8px;
  }
  /* Directional surface lighting follows each card's actual Y rotation.
     Separate layer leaves frame, cover, caption, and reflections intact. */
  /* Fixed light from upper left: rotation creates an asymmetric moving
     penumbra across the face, not just a uniform brightness reduction. */
  .cover .card-surface-light {
    position:absolute;inset:0;z-index:4;pointer-events:none;
    background:
      linear-gradient(90deg,
        rgba(0,0,0,var(--shadow-strong,0)) 0%,
        rgba(0,0,0,var(--shadow-mid,0)) var(--shadow-knee,48%),
        rgba(0,0,0,var(--shadow-soft,0)) 100%);
  }
  .cover .card-surface-light::after {
    content:'';position:absolute;inset:0;pointer-events:none;
    background:radial-gradient(ellipse 18% 100% at var(--glint-x,20%) 46%,
       rgba(255,248,229,.32),rgba(255,248,229,.08) 42%,transparent 100%);
    opacity:var(--glint-alpha,0);
  }
  /* A detachable live indicator mounted opposite the artist label. */
  .cover .cover-caption .artist-line {display:flex;align-items:center;justify-content:space-between;gap:8px;min-width:0;}
  .cover .cover-caption .artist-line .track-artist {min-width:0;flex:1;}
  .cover .cover-caption .live-lamp {display:block;width:clamp(25px, 3.1vw, 40px);height:auto;aspect-ratio:271/301;object-fit:contain;flex:none;filter:grayscale(1) brightness(1.35) contrast(.92) drop-shadow(0 0 4px rgba(235,233,228,.38));opacity:.9;}
  #draggable-cover .cover-caption .live-lamp {filter:contrast(1.12) saturate(1.1);opacity:1;}
  @media(max-width:600px) and (orientation:portrait){.cover .cover-caption .live-lamp {width:clamp(20px, 6vw, 29px)}}

  /* Flowing, vertically striated aurora curtains—not blurred color blobs. */
  .pomexa-aurora {position:fixed;inset:0;z-index:0;pointer-events:none;overflow:hidden;}
  .pomexa-aurora canvas {display:block;width:100%;height:100%;opacity:.88;}
  .pomexa-scene > main {z-index:1;}
  /* Alternating brand marks, transparent PNGs supplied separately in assets/. */
  .pomexa-header-layout{
    position:fixed;top:clamp(26px,4vh,44px);left:50%;transform:translateX(-50%) scale(.9);
    z-index:2100;width:min(75vw,520px);height:clamp(70px,13vh,122px);opacity:.8;
    pointer-events:none; margin:0; font:inherit;
  }
  /* Render branding once at its final viewport size, outside the scaled scene. */
  .pomexa-header-brand{
    position:fixed;left:var(--brand-left,50%);top:var(--brand-top,0px);
    width:var(--brand-width,0px);height:var(--brand-height,0px);
    z-index:2100;pointer-events:none;margin:0;font:inherit;
    opacity:0;transition:opacity .7s ease;
  }
  html.is-ready .pomexa-header-brand{opacity:.8}
  /* Codrops CSSGlitchEffect-inspired clip-path image strips:
     two PNGs remain still between brief signal-loss transitions. */
  .pomexa-header-brand img{
    position:absolute;inset:0;width:100%;height:100%;object-fit:contain;
    opacity:0; /* Keep the original logo detail; avoid filtered raster layers. */
  }
  .pomexa-header-brand img.is-visible{opacity:1}
  .pomexa-header-brand > img:nth-child(2),
  .pomexa-header-brand .glitch-strip.is-slogan{width:81%;height:81%;left:9.5%;top:9.5%}
  .pomexa-header-brand .glitch-strips{
    position:absolute;inset:0;pointer-events:none;overflow:visible;opacity:0;
  }
  .pomexa-header-brand.is-glitching .glitch-strips{opacity:1}
  .pomexa-header-brand.is-glitching .glitch-strip{
    opacity:1;will-change:transform,clip-path;
    animation:pomexa-signal-strip .56s steps(1,end) both;
    animation-delay:var(--delay,0ms);
  }
  .pomexa-header-brand .glitch-strip:nth-child(2){animation-direction:reverse}
  .pomexa-header-brand .glitch-strip:nth-child(3){animation-duration:.47s}
  .pomexa-header-brand .glitch-strip:nth-child(4){animation-duration:.63s}
  /* Keep the main mark centered; only the overlay strips move during glitches. */
  @keyframes pomexa-signal-strip{
    0%,100%{opacity:0;transform:translateX(0);clip-path:inset(0 0 100% 0)}
    9%{opacity:.95;transform:translateX(-17px) skewX(-4deg);clip-path:inset(12% 0 85% 0)}
    17%{opacity:.8;transform:translateX(9px) scaleX(1.04);clip-path:inset(32% 0 65% 0)}
    27%{opacity:1;transform:translateX(-23px) skewX(5deg);clip-path:inset(63% 0 33% 0)}
    39%{opacity:.9;transform:translateX(13px);clip-path:inset(19% 0 79% 0)}
    52%{opacity:1;transform:translateX(-19px) scaleX(.98);clip-path:inset(47% 0 49% 0)}
    64%{opacity:.9;transform:translateX(26px) skewX(-3deg);clip-path:inset(76% 0 21% 0)}
    76%{opacity:.85;transform:translateX(-11px) scaleX(1.03);clip-path:inset(29% 0 68% 0)}
    89%{opacity:.9;transform:translateX(10px);clip-path:inset(58% 0 39% 0)}
  }
  @media(max-width:600px){
    .pomexa-header-layout{top:26px;width:79vw;height:76px}
  }
  @media(max-width:600px) and (orientation:portrait){
    .pomexa-header-layout{top:54px}
  }
  @media(prefers-reduced-motion:reduce){
    .pomexa-header-brand .glitch-strips{display:none}
  }

  /* Desktop composition uses one coordinate system. Fit it to both window
     dimensions so browser zoom cannot push the card under the player. */
  .pomexa-scene { display: grid; place-items: center; width: 100%; opacity: 0; transition: opacity .7s ease; }
  @media (min-width: 900px), (min-width: 601px) and (min-height: 600px) and (max-width: 1440px) and (max-aspect-ratio: 31/20) {
    html, body { height: 100%; min-height: 100%; overflow: hidden; }
    .pomexa-scene {
      position: fixed; left: 50%; top: 50%; width: 1900px; height: 846px;
      display: grid; place-items: center; isolation: isolate; z-index: 1;
      transform: translate(-50%, -50%) scale(var(--scene-scale, .8));
      transform-origin: center;
    }
    .pomexa-scene main { width: 1288px; padding: 125px 24px; }
    .pomexa-scene .cover { width: 430px; }
    .pomexa-scene .pomexa-header-layout { top: 34px; width: 520px; height: 110px; }
    .pomexa-scene .live-controls {
      width: 760px; max-width: none; bottom: 12px; min-height: 70px;
      padding: 12px 24px; gap: 32px;
    }
    .pomexa-scene .cover .track-artist { font-size: 38px; }
    .pomexa-scene .cover .track-title { font-size: 19px; }
    .pomexa-scene .cover .live-lamp { width: 40px; }
  }

  /* Tablet elements fit independently; the scene itself fills the viewport. */
  @media (min-width: 601px) and (min-height: 600px) and (max-width: 1440px) and (max-aspect-ratio: 31/20) {
    .pomexa-scene {
      left: 0; top: 0; width: 100%; height: 100dvh; transform: none;
    }
    .pomexa-scene main {
      position: absolute; left: 50%; top: 50%; translate: 0 0;
      transform: translate(-50%, -50%) scale(var(--scene-scale));
    }
    .pomexa-scene .pomexa-header-layout { top: 16px; height: 90px; }
    .pomexa-scene .live-controls { width: min(760px, calc(100vw - 32px)); }
  }
  @media (min-width: 601px) and (min-height: 600px) and (max-width: 1440px) and (max-aspect-ratio: 31/20) and (orientation: portrait) {
    .pomexa-scene .pomexa-header-layout {
      top: calc(50% - var(--tablet-card-half) - 110px);
    }
    .pomexa-scene .live-controls {
      top: calc(50% + var(--tablet-card-half) + 24px); bottom: auto;
    }
  }

  @media (min-width: 601px) and (max-width: 800px) and (orientation: portrait) {
    .pomexa-scene .live-controls { width: min(600px, 80vw); }
  }

  /* Short landscape phones use a compact, centered composition. */
  @media (max-width: 1000px) and (max-height: 599px) and (orientation: landscape) {
    html, body { height: 100%; min-height: 0; overflow: hidden; }
    .pomexa-scene {
      position: fixed; inset: 0; width: 100%; height: 100dvh; transform: none;
    }
    .pomexa-scene main {
      position: absolute; left: 50%; top: 50%; width: 1288px;
      padding: 125px 24px; translate: 0 0;
      transform: translate(-50%, -50%) scale(var(--scene-scale));
    }
    .pomexa-scene .cover { width: 430px; }
    .pomexa-scene .cover .track-artist { font-size: 38px; }
    .pomexa-scene .cover .track-title { font-size: 19px; }
    .pomexa-scene .cover .live-lamp { width: 40px; }
    .pomexa-scene .pomexa-header-layout { top: 8px; width: min(60vw, 360px); height: 60px; }
    .pomexa-scene .live-controls {
      bottom: 8px; width: min(680px, 90vw); max-width: none;
      min-height: 58px; padding: 6px 16px; gap: 16px;
    }
  }

  /* The viewport clips the composition; the gallery must not clip reflections. */
  html, body { height:100%;min-height:0;overflow:hidden;overscroll-behavior:none; }
  body { position:fixed;inset:0;width:100%;height:100dvh;touch-action:none; }
  [hidden] { display: none !important; }
  .pomexa-aurora { opacity: 0; transition: opacity .7s ease; }
  html.is-ready .pomexa-scene, html.is-ready .pomexa-aurora { opacity: 1; }
  html.is-ready .startup-loader { opacity: 0; pointer-events: none; }
  html.is-booting .pomexa-scene,
  html.is-booting .pomexa-aurora,
  html.is-booting .pomexa-header-brand { visibility: hidden; }
  .startup-loader {
    position: fixed; inset: 0; z-index: 10000; background: transparent;
    opacity: 1; transition: opacity .7s ease;
    display: grid; place-content: center; justify-items: center; gap: 22px;
    padding: 24px; text-align: center; color: #edeae2; font-family: Inter,system-ui,sans-serif;
  }
  .startup-loader > img { width: min(320px,68vw); height: auto; display: block; }
  .startup-label { margin: 0; font-size: 14px; letter-spacing: .08em; animation: startup-pulse 2s ease-in-out infinite; }
  @keyframes startup-pulse { 0%,100% { opacity: .45; } 50% { opacity: 1; } }
  .startup-loader.has-error .startup-label { animation: none; }
  .startup-loader button {
    border: 1px solid #7c2931; background: #17191c; color: #edeae2;
    border-radius: 4px; padding: 12px 22px; font: 14px/1.3 Inter,system-ui,sans-serif; cursor: pointer;
  }
  .startup-loader button:focus-visible { outline: 2px solid #edeae2; outline-offset: 4px; }
  @media(prefers-reduced-motion:reduce) {
    .startup-label { animation: none; opacity: .8; }
    .pomexa-scene,.pomexa-aurora,.pomexa-header-brand,.startup-loader { transition: none; }
  }
