:root {
  color-scheme: dark;
  --bg: #101010;
  --panel: #171717;
  --muted: #929292;
  --line: #2a2a2a;
  --accent: #fff;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif; }
body { color: #fff; }
button { font: inherit; color: inherit; cursor: pointer; }

.app-shell { min-height: 100svh; display: grid; grid-template-columns: minmax(0, 1fr) 360px; background: var(--bg); }
.stage-wrap { position: relative; min-height: 100svh; background: #fff; overflow: hidden; }
#stage { display: block; width: 100%; height: 100%; min-height: 100svh; touch-action: none; }
.stage-hint { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); color: #fff; background: rgba(0,0,0,.72); border-radius: 999px; padding: 12px 20px; font-size: 14px; letter-spacing: .04em; pointer-events: none; transition: opacity .3s; }
.stage-hint.hidden { opacity: 0; }
.exit-button { display: none; position: absolute; top: 20px; right: 20px; width: 40px; height: 40px; border: 0; border-radius: 50%; background: rgba(0,0,0,.6); font-size: 26px; }
.control-panel { padding: 34px 26px 24px; background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: 24px; }
.brand-row { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.eyebrow { margin: 0 0 10px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .16em; }
h1 { max-width: 210px; margin: 0; font-size: 27px; line-height: 1.05; letter-spacing: -.04em; }
.scene-count { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; margin-top: 5px; }
.scene-picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.scene-button { aspect-ratio: 1; position: relative; border: 1px solid #444; border-radius: 12px; background: #fff; overflow: hidden; padding: 0; opacity: .55; transition: opacity .2s, transform .2s, border-color .2s; }
.scene-button.active { opacity: 1; border: 2px solid #fff; transform: translateY(-2px); }
.scene-button span { position: absolute; left: 7px; bottom: 5px; font-size: 10px; color: #777; mix-blend-mode: difference; }
.thumb { position: absolute; inset: 0; }
.thumb.circle { background: radial-gradient(circle at 50% 50%, #111 0 28%, transparent 29%); }
.thumb.stripes { background: repeating-linear-gradient(90deg, #111 0 10px, #fff 10px 20px); }
.thumb.rings { background: repeating-radial-gradient(circle, #111 0 7px, #fff 8px 15px); }
.thumb.dots { background: radial-gradient(circle, #111 0 4px, transparent 5px); background-size: 18px 18px; }
.thumb.diagonal { background: repeating-linear-gradient(135deg, #111 0 11px, #fff 11px 22px); }
.thumb.square { background: repeating-conic-gradient(#111 0 25%, #fff 0 50%) 50% / 22px 22px; }
.thumb.wave { background: repeating-radial-gradient(ellipse at 50% 100%, #111 0 5px, #fff 6px 13px); }
.thumb.cross { background: linear-gradient(#111 0 0) center / 26% 100% no-repeat, linear-gradient(90deg, #111 0 0) center / 100% 26% no-repeat, #fff; }
.thumb.star { background: #ed1118; clip-path: polygon(50% 8%, 61% 38%, 95% 38%, 68% 58%, 78% 92%, 50% 70%, 22% 92%, 32% 58%, 5% 38%, 39% 38%); }
.thumb.triangle { background: #ed1118; clip-path: polygon(50% 8%, 92% 90%, 8% 90%); }
.thumb.pentagon { background: #050505; clip-path: polygon(50% 5%, 95% 38%, 78% 92%, 22% 92%, 5% 38%); }
.thumb.diamond { background: #ed1118; clip-path: polygon(50% 5%, 95% 50%, 50% 95%, 5% 50%); }
.thumb.bars { background: repeating-linear-gradient(90deg, #050505 0 12%, #ed1118 12% 24%, #fff 24% 36%); }
.thumb.ring { background: repeating-radial-gradient(circle, #ed1118 0 5px, #fff 6px 10px); }
.thumb.star2 { background: #ed1118; clip-path: polygon(50% 3%, 60% 35%, 94% 35%, 67% 56%, 78% 94%, 50% 70%, 22% 94%, 33% 56%, 6% 35%, 40% 35%); }
.thumb.hexagon { background: #ed1118; clip-path: polygon(25% 8%, 75% 8%, 96% 50%, 75% 92%, 25% 92%, 4% 50%); }
.thumb.bars2 { background: repeating-linear-gradient(0deg, #050505 0 12%, #ed1118 12% 24%, #fff 24% 36%); }
.thumb.triangle2 { background: #050505; clip-path: polygon(8% 10%, 92% 10%, 50% 92%); }
.thumb.diamond2 { background: #050505; clip-path: polygon(50% 5%, 95% 50%, 50% 95%, 5% 50%); }
.thumb.dots2 { background: radial-gradient(circle, #ed1118 0 3px, transparent 4px); background-size: 13px 13px; }
.thumb.square2 { background: repeating-conic-gradient(#050505 0 25%, #ed1118 0 50%) 50% / 18px 18px; }
.toolbar { display: flex; gap: 8px; margin-top: auto; }
.toolbar button { height: 48px; border: 1px solid #333; background: #222; border-radius: 12px; }
.primary { flex: 1; background: #fff !important; color: #111; border-color: #fff !important; font-weight: 700; }
.icon-button { width: 48px; font-size: 20px; }
.icon-button.active { background: #fff; color: #111; }
.safety-note { margin: 0; color: #6f6f6f; font-size: 11px; line-height: 1.45; }

@media (max-width: 760px) {
  .app-shell { display: block; }
  .stage-wrap { min-height: 68svh; height: 68svh; }
  #stage { min-height: 68svh; }
  .control-panel { border-left: 0; border-top: 1px solid var(--line); padding: 20px 18px max(18px, env(safe-area-inset-bottom)); gap: 16px; }
  h1 { font-size: 22px; }
  .scene-picker { grid-template-columns: repeat(8, 1fr); gap: 5px; }
  .scene-button { border-radius: 7px; }
  .scene-button span { font-size: 8px; left: 4px; bottom: 2px; }
}

body.inverted { filter: invert(1); }
body.inverted .control-panel { filter: invert(1); }
.scene-picker { grid-template-columns: repeat(2, 1fr); }
.scene-button { aspect-ratio: auto; height: 44px; background: #222; opacity: .7; }
.scene-button.active { background: #fff; }
.scene-button span { position: static; display: block; font-size: 13px; color: #aaa; mix-blend-mode: normal; }
.scene-button.active span { color: #111; font-weight: 600; }
.scene-picker { grid-template-columns: repeat(3, 1fr); gap: 6px; }
.scene-button { height: 36px; border-radius: 9px; }
.scene-button span { font-size: 12px; }

/* Fullscreen fallback for iPhone Safari, which has no element fullscreen API */
body.immersive { overflow: hidden; height: 100vh; height: 100dvh; }
body.immersive .app-shell { display: block; min-height: 0; height: 100%; }
body.immersive .control-panel { display: none; }
body.immersive .stage-wrap { position: fixed; inset: 0; height: 100vh; height: 100dvh; min-height: 0; }
body.immersive #stage { height: 100%; min-height: 0; }
