:root {
  --ink: #2b2620; --paper: #fbf7ef; --card: rgba(251, 247, 239, .97); --accent: #c8452c; --muted: #6f655a;
  --panel-w: min(460px, 40vw);
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #cfe3f2; color: var(--ink); }
body { overflow: hidden; }
html:not(.no-gl), html:not(.no-gl) body { overscroll-behavior: none; }   /* one fixed screen: no pull to refresh, no rubber band */
#world { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
#world { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; cursor: grab; }
#world.drag { cursor: grabbing; }
#world.hot { cursor: pointer; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.sr:focus-within { position: fixed; left: 12px; top: 12px; width: auto; height: auto; clip: auto; z-index: 30; background: var(--card); padding: 8px 12px; border-radius: 12px; list-style: none; margin: 0; }

#labels { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
.tw-label {
  position: absolute; left: 0; top: 0; pointer-events: auto; cursor: pointer; white-space: nowrap;
  font: 700 15px/1 ui-rounded, "SF Pro Rounded", system-ui, sans-serif; letter-spacing: .01em;
  color: var(--ink); background: var(--card); border: 0; border-radius: 999px; padding: 8px 14px 9px;
  box-shadow: 0 2px 0 rgba(60, 40, 20, .18), 0 8px 20px rgba(40, 30, 20, .16);
  transform-origin: 50% 0; opacity: 0; touch-action: none; transition: opacity .25s, background .2s, color .2s; will-change: transform;
}
.tw-label.on { opacity: 1; }
.tw-label.focus { background: var(--ink); color: var(--paper); }
.tw-label:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

#onward {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 6;
  width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--card); color: var(--ink);
  box-shadow: 0 6px 18px rgba(40, 30, 20, .18); cursor: pointer; display: grid; place-items: center;
  animation: nudge 1.8s ease-in-out infinite; transition: opacity .4s;
}
#onward.gone { opacity: 0; pointer-events: none; }
@keyframes nudge { 0%, 100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, 6px); } }

#bar { position: fixed; top: calc(14px + env(safe-area-inset-top)); right: 14px; z-index: 8; display: flex; gap: 8px; }
#bar button {
  height: 38px; min-width: 38px; padding: 0 14px; border-radius: 999px; border: 0; background: var(--card); color: var(--ink);
  font: 700 14px/1 ui-rounded, "SF Pro Rounded", system-ui, sans-serif; cursor: pointer; display: grid; place-items: center;
  box-shadow: 0 4px 14px rgba(40, 30, 20, .14);
}
#bar #planet { padding: 0; }
#bar button:focus-visible, #panel button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

#panel {
  position: fixed; z-index: 10; top: 0; right: 0; bottom: 0; width: var(--panel-w); background: var(--card);
  box-shadow: -10px 0 40px rgba(40, 30, 20, .18); display: flex; flex-direction: column;
  transform: translateX(105%); transition: transform .55s cubic-bezier(.2, .8, .2, 1);
  border-radius: 22px 0 0 22px;
}
#panel.open { transform: none; }
#panel[hidden] { display: flex; visibility: hidden; }
#panel.open[hidden] { visibility: visible; }
.p-head { position: relative; padding: 26px 64px 10px 28px; }
.p-client { margin: 0 0 6px; font: 700 12px/1 ui-rounded, system-ui, sans-serif; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); min-height: 12px; }
#p-title { margin: 0; font: 800 30px/1.05 ui-rounded, "SF Pro Rounded", system-ui, sans-serif; letter-spacing: -.01em; outline: none; }
.p-close { position: absolute; top: 18px; right: 18px; width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(43, 38, 32, .08); color: var(--ink); font-size: 26px; line-height: 1; cursor: pointer; }
.p-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; padding: 6px 28px 24px; -webkit-overflow-scrolling: touch; }
.p-body p { font-size: 16px; line-height: 1.5; margin: 0 0 14px; }
.p-body h2 { font: 800 17px/1.2 ui-rounded, system-ui, sans-serif; margin: 26px 0 10px; }
.p-body img { display: block; width: 100%; height: auto; border-radius: 12px; margin: 0 0 10px; background: #e9e2d4; }
.p-body .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.p-body .row img { margin: 0; }
.p-body .credits { font-size: 13px; color: var(--muted); margin-top: 26px; }
.film { position: relative; margin: 0 0 12px; border-radius: 12px; overflow: hidden; background: #1d1a17; aspect-ratio: 16 / 9; }
.film.vertical { aspect-ratio: 9 / 16; max-width: 62%; }
.film button { all: unset; position: absolute; inset: 0; cursor: pointer; display: grid; place-items: center; }
.film button img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; margin: 0; border-radius: 0; }
.film button span { position: relative; width: 64px; height: 64px; border-radius: 50%; background: var(--card); display: grid; place-items: center; box-shadow: 0 6px 18px rgba(0, 0, 0, .3); }
.film button span::before { content: ""; border-left: 18px solid var(--ink); border-top: 11px solid transparent; border-bottom: 11px solid transparent; margin-left: 5px; }
.film button:focus-visible span { outline: 3px solid var(--accent); }
.film iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.film-title { font-size: 13px; color: var(--muted); margin: -6px 0 16px; }
.audio { display: block; margin: 0 0 12px; font-size: 14px; font-weight: 700; }
.audio audio { display: block; width: 100%; margin-top: 6px; }
.p-nav { display: flex; gap: 8px; padding: 12px 20px calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid rgba(43, 38, 32, .08); }
.p-nav button { flex: 1; min-height: 44px; border-radius: 14px; border: 0; background: rgba(43, 38, 32, .07); color: var(--ink); font: 700 14px/1.15 ui-rounded, system-ui, sans-serif; cursor: pointer; padding: 6px 10px; }
.p-nav button:last-child { text-align: right; }
.p-nav button:first-child { text-align: left; }

#loading { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 4; pointer-events: none; transition: opacity .6s; }
#loading span { display: block; width: 44px; height: 44px; border-radius: 50%; border: 5px solid rgba(255, 255, 255, .6); border-top-color: #4e8a2a; animation: spin 1s linear infinite; }
#loading.done { opacity: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 760px), (max-aspect-ratio: 4/5) {
  #panel { top: auto; left: 0; width: 100%; height: 60%; border-radius: 22px 22px 0 0; transform: translateY(105%); box-shadow: 0 -10px 40px rgba(40, 30, 20, .2); }
  .p-head { padding: 20px 60px 6px 20px; }
  #p-title { font-size: 24px; }
  .p-body { padding: 4px 20px 20px; }
  .tw-label { font-size: 14px; padding: 7px 12px 8px; }
}
@media (prefers-reduced-motion: reduce) {
  #onward { animation: none; }
  #panel { transition: none; }
}

/* without WebGL: a plain list of the work */
html.no-gl body { overflow: auto; }
#plain { max-width: 980px; margin: 0 auto; padding: 72px 16px 40px; }
#plain h1 { font: 800 34px/1.1 ui-rounded, "SF Pro Rounded", system-ui, sans-serif; margin: 0 0 20px; }
#plain ol { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
#plain button { all: unset; cursor: pointer; display: block; background: var(--card); border-radius: 14px; overflow: hidden; box-shadow: 0 4px 14px rgba(40, 30, 20, .12); width: 100%; }
#plain button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
#plain img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: #e9e2d4; }
#plain span { display: block; padding: 10px 12px 12px; }
#plain strong { display: block; font: 800 16px/1.2 ui-rounded, system-ui, sans-serif; }
#plain small { display: block; margin-top: 3px; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
