/* The shell: one world filling the window, a curtain between worlds, and the cluster of controls.
   The cluster sits on twenty-one worlds that look nothing alike, so it carries its own near-opaque dark fill,
   a light hairline and a shadow: it reads on parchment, on black, and on everything between. No backdrop blur:
   over a game that animates every frame it costs a phone a blur per frame and buys nothing at this opacity. */
:root {
  --glass: rgb(17 17 20 / 0.96);
  --line: rgb(255 255 255 / 0.16);
  --ink: #f4f4f5;
  --ink-soft: #d4d4d8;
  --ink-faint: #a1a1aa;
  --fill: rgb(255 255 255 / 0.09);
  --fill-hover: rgb(255 255 255 / 0.17);
  --picked: #f4f4f5;
  --picked-ink: #111114;
  --gold: #e8c840;
  --tile: 44px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: #000; }
[hidden] { display: none !important; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.stage { position: fixed; inset: 0; }
.frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; }
.frame.is-incoming { opacity: 0; pointer-events: none; }

.curtain {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  background: #101014;
  pointer-events: none;
  --curtain-ink: rgb(255 255 255 / 0.72);
}
.curtain-label {
  margin: 0;
  color: var(--curtain-ink);
  font: 500 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  letter-spacing: 0.01em;
  visibility: hidden;
}
.curtain.is-slow .curtain-label { visibility: visible; }

/* The cluster. Closed, it is the handle alone: a 44px disc, 12px from the window's edges. */
.cluster {
  position: fixed;
  z-index: 2;
  bottom: calc(max(12px, env(safe-area-inset-bottom)) + var(--clearance, 0px));
  right: max(12px, env(safe-area-inset-right));
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-end;
  gap: 8px;
  max-width: calc(100vw - 24px);
  color: var(--ink);
  font: 500 14px/1.3 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.cluster[data-corner="left"] {
  right: auto;
  left: max(12px, env(safe-area-inset-left));
  align-items: flex-start;
}

.handle, .panel {
  background: var(--glass);
  border: 1px solid var(--line);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 24px rgb(0 0 0 / 0.28);
}

button { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }
.cluster button, .cluster a { cursor: pointer; touch-action: manipulation; }
.cluster :focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
  box-shadow: 0 0 0 5px #111114;
}

.handle {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  transition: background-color 120ms;
}
.handle:hover, .handle[aria-expanded="true"] { background: rgb(38 38 44 / 0.95); }
.handle-mark { fill: currentColor; opacity: 0.9; transition: transform 200ms var(--ease); }
.handle[aria-expanded="true"] .handle-mark { transform: rotate(45deg); }

/* The panel opens upward from the handle. Its first group sits nearest the handle, under the thumb. */
.panel {
  display: flex;
  flex-direction: column-reverse;
  gap: 12px;
  padding: 12px;
  border-radius: 18px;
  max-height: calc(100dvh - 88px - var(--clearance, 0px));
  overflow-y: auto;
  overscroll-behavior: contain;
  transform-origin: bottom right;
  animation: panel-in 160ms var(--ease);
}
.cluster[data-corner="left"] .panel { transform-origin: bottom left; }
@keyframes panel-in { from { opacity: 0; transform: translateY(6px) scale(0.98); } }

.credit {
  max-width: 38ch;
  margin: 0 4px;
  color: var(--ink-faint);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.45;
}

.settings { display: flex; gap: 8px; margin: 0 2px; }
.setting {
  display: grid;
  place-items: center;
  min-width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: var(--fill);
}
.setting:hover { background: var(--fill-hover); }
.setting svg { fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
/* The way to Aero: its word, and a small glossy orb in Aero's own blue and green. */
.aero {
  display: flex;
  gap: 8px;
  margin-right: auto;
  padding: 0 16px 0 12px;
  color: var(--ink);
  font-weight: 600;
  letter-spacing: 0.01em;
  text-decoration: none;
}
.aero::before {
  content: "";
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 28%, #fff 0 12%, #9fe3ff 30%, #2f9df0 62%, #35c98a);
  box-shadow: inset 0 -2px 3px rgb(0 60 90 / 0.35);
}
.sound .mute, .sound[aria-checked="false"] .waves { display: none; }
.sound[aria-checked="false"] { color: var(--ink-faint); }
.sound[aria-checked="false"] .mute { display: inline; }
.cluster[data-corner="left"] .move svg { transform: scaleX(-1); }

/* The picker. Tiles touch, so seven fit a 360px phone at 44px each; the face drawn in each is 40px. */
.caption {
  min-height: 1.3em;
  margin: 0 4px 6px;
  color: var(--ink-soft);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.picker-row { display: flex; gap: 10px; align-items: stretch; }
.picker { display: flex; flex-wrap: wrap; }
.picker[data-kind="grid"] {
  display: grid;
  grid-template-columns: repeat(7, var(--tile));
  grid-auto-rows: var(--tile);
}
.tile, .slot {
  display: grid;
  place-items: center;
  width: var(--tile);
  height: var(--tile);
  padding: 0;
  border-radius: 12px;
}
.tile { border: 0; background: none; color: var(--ink); }
.tile svg, .slot::before {
  box-sizing: border-box;
  width: 40px;
  height: 40px;
  border-radius: 10px;
}
.tile svg {
  padding: 8px;
  background: var(--fill);
  transition: background-color 120ms, color 120ms;
}
.tile:hover svg { background: var(--fill-hover); }
.tile[aria-current] svg { background: var(--picked); color: var(--picked-ink); }
.tile[aria-disabled="true"] { cursor: not-allowed; }
.tile[aria-disabled="true"] svg { color: var(--ink-faint); background: transparent; box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.14); }
.tile[data-world="fair"]:not([aria-disabled]) svg { box-shadow: inset 0 0 0 1.5px var(--gold); color: var(--gold); }
.tile[data-world="fair"][aria-current] svg { color: var(--picked-ink); }
.slot::before { content: ""; border: 1px dashed rgb(255 255 255 / 0.13); }

.die {
  flex: none;
  display: grid;
  place-items: center;
  width: calc(var(--tile) * 3);
  margin: 2px;
  border: 0;
  border-radius: 14px;
  background: var(--fill);
}
.die:hover { background: var(--fill-hover); }
.pips {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10%;
  width: 62%;
  aspect-ratio: 1;
  padding: 9%;
  border-radius: 20%;
  box-shadow: inset 0 0 0 1.75px var(--ink);
}
.pips i { border-radius: 50%; background: var(--ink); opacity: 0; transition: opacity 80ms; }
.pips i.on { opacity: 1; }
.die.is-rolling .pips { animation: tumble 420ms var(--ease); }
@keyframes tumble {
  0% { transform: rotate(0); }
  60% { transform: rotate(200deg) scale(0.9); }
  100% { transform: rotate(360deg); }
}

@media (max-width: 560px) {
  .picker-row { flex-direction: column; gap: 6px; }
  .die { width: auto; height: 52px; }
  .pips { width: 34px; gap: 3px; padding: 6px; border-radius: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after { animation: none !important; transition: none !important; }
}
