/* Layout: portrait = stage on top, pill controls in a dark sheet below;
   landscape = stage on the left, controls in a side panel. Single dark look by design. */
:root {
  --night: #0d1524;        /* stage background */
  --sheet: #0a101c;        /* control area */
  --pill: #1e2633;
  --pill-edge: #3a4252;
  --pill-hover: #283246;
  --gold: #d1aa5b;
  --ink-dark: #14171d;
  --ink: #e9ebef;
  --title: #f1eee7;
  --muted: #a3abbe;
  --label: #8a96ad;
  --display: 'Marcellus', 'Optima', 'Candara', Georgia, serif;
  --ui: 'Figtree', -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}
html { height: 100%; box-sizing: border-box; background: var(--sheet); }
*, *::before, *::after { box-sizing: inherit; }
body { height: 100%; margin: 0; background: var(--sheet); color: var(--ink); font-family: var(--ui);
  -webkit-font-smoothing: antialiased; overflow: hidden; -webkit-user-select: none; user-select: none; }
[hidden] { display: none !important; }

.app { height: 100%; display: grid; grid-template-rows: minmax(0, 1fr) auto; }

.stage { position: relative; min-height: 0; background: var(--night); overflow: hidden; }
.stage canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.stage.dragging canvas { cursor: grabbing; }

.header { position: absolute; top: 0; left: 0; right: 0; pointer-events: none;
  padding: 18px max(20px, env(safe-area-inset-right, 0px)) 0 max(20px, env(safe-area-inset-left, 0px)); }
.title { margin: 0; font-family: var(--display); font-weight: 400; font-size: 2.6rem; line-height: 1; color: var(--title); letter-spacing: 0.01em; }
.subtitle { margin: 0.35rem 0 0; font-family: var(--display); font-size: 1.12rem; color: var(--gold); }
.hint { margin: 0.9rem 0 0; font-size: 0.92rem; color: var(--muted); }

.loading { position: absolute; inset: 0; display: grid; place-content: center; gap: 12px; text-align: center;
  background: var(--night); color: var(--muted); font-size: 0.95rem; padding: 0 24px; }
.loading-track { width: min(220px, 60vw); height: 3px; border-radius: 2px; background: var(--pill); margin: 0 auto; overflow: hidden; }
.loading-bar { height: 100%; width: 0; background: var(--gold); transition: width 0.2s; }
.loading.error .loading-track { display: none; }
.loading.error { color: var(--ink); }

.controls { background: var(--sheet); overflow-y: auto;
  padding: 12px max(16px, env(safe-area-inset-right, 0px)) max(12px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
.group { max-width: 520px; margin: 0 auto; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 7px 7px; }
.group + .group { margin-top: 7px; }
.label { color: var(--label); font-size: 0.85rem; padding-right: 6px; }

.pill { appearance: none; border: 1px solid var(--pill-edge); background: var(--pill); color: var(--ink);
  font: 500 0.9rem/1 var(--ui); height: 34px; padding: 0 14px; border-radius: 17px; cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s; -webkit-tap-highlight-color: transparent; }
.pill:hover { background: var(--pill-hover); }
.pill:active { transform: scale(0.97); }
.pill.on { background: var(--gold); border-color: var(--gold); color: var(--ink-dark); }
.pill:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

@media (orientation: landscape) {
  .app { grid-template-rows: none; grid-template-columns: minmax(0, 1fr) minmax(300px, 42%); }
  .controls { display: flex; flex-direction: column; justify-content: center;
    padding-top: max(16px, env(safe-area-inset-top, 0px)); }
}
@media (orientation: landscape) and (max-height: 520px) {
  .title { font-size: 2rem; }
  .subtitle { font-size: 1rem; }
  .hint { margin-top: 0.5rem; font-size: 0.85rem; }
  .pill { height: 38px; padding: 0 15px; font-size: 0.92rem; }
  .group { gap: 8px 8px; }
  .group + .group { margin-top: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .pill, .loading-bar { transition: none; }
}
