:root {
  /* The app's one chevron (Feather proportions, like Around's chevron icons). It points to the inline
     end; disclosures and menu rows rotate it and paint it in currentColor through a mask. */
  --orbit-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M5.5 2.5 11 8l-5.5 5.5' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--ds-ink);
  background: var(--ds-canvas);
  color-scheme: dark;
  /* Older names for design-system.css tokens. Prefer the --ds-* names in new rules. */
  --text: var(--ds-ink);
  --muted: var(--ds-ink-muted);
  --border: var(--ds-border);
  --purple: var(--ds-accent);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 280px; min-height: 100dvh; }
[hidden] { display: none !important; }
.symbols { position: absolute; width: 0; height: 0; overflow: hidden; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
body :is(button, input, select, textarea, a[href], [tabindex], [contenteditable]):focus-visible { outline: var(--ds-focus-width) solid var(--ds-focus-color); outline-offset: var(--ds-focus-offset); }
button svg, .participant-mute, .participant-count svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }

.topbar { height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 clamp(18px, 4vw, 56px); border-bottom: 1px solid #292633; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 720; letter-spacing: -.055em; }
.brand-mark { width: 25px; height: 25px; border-radius: 50%; background: #ad94ff; position: relative; }
.brand-mark::before { content: ''; position: absolute; inset: 5px; border: 1.5px solid #21163d; border-radius: 50%; transform: rotate(-36deg) scaleY(.64); }
.brand-mark::after { content: ''; position: absolute; width: 5px; height: 5px; top: 10px; left: 10px; border-radius: 50%; background: #21163d; }
.header-actions { display: flex; align-items: center; gap: 13px; }
.connection { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.connection > span:first-child { width: 7px; height: 7px; border-radius: 50%; background: #a6a0b4; }
.connection[data-state="live"] > span:first-child { background: #8ee9ba; box-shadow: 0 0 10px #8ee9ba60; }
.connection[data-state="connecting"] > span:first-child { background: #eacf8b; }

.lobby { width: min(100% - 48px, 1000px); margin: clamp(32px, 11vh, 130px) auto 40px; display: grid; grid-template-columns: 1.18fr 1fr; align-items: stretch; gap: 16px; }
.lobby[inert] { visibility: hidden; }
.room-startup-failed .topbar { display: none; }
.room-startup-error { --ds-empty-min-height: 100dvh; }
.room-startup-error a { text-decoration: none; }
.instance-directory { width: min(100% - 2 * var(--ds-space-4), 42rem); margin: var(--ds-space-6) auto; }
.instance-directory ul { display: grid; gap: var(--ds-space-2); padding: 0; list-style: none; }
.instance-directory button { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.preview, .join-card { border-radius: 26px; border: 1px solid var(--border); }
.preview { position: relative; isolation: isolate; overflow: hidden; min-height: 490px; display: grid; justify-items: center; align-content: center; gap: 25px; background: radial-gradient(ellipse at 49% 40%, #3e2d60 0%, #261d37 48%, #201b2b 73%); }
.preview::before { content: ''; position: absolute; inset: 0; z-index: -2; background: radial-gradient(#a18ac770 1px, transparent 1.5px) center / 24px 24px; opacity: .22; mask-image: radial-gradient(ellipse at center, #000 10%, transparent 82%); }
.preview-caption { position: absolute; top: 23px; left: 25px; color: #d9cdef; font-size: 13px; }
.orbit-line { position: absolute; z-index: -1; width: 70%; height: 39%; top: 27%; border-radius: 50%; border: 1px solid #b89aee41; transform: rotate(-24deg); }
.orbit-line-inner { width: 55%; height: 30%; top: 31%; border-color: #b89aee2c; }
.orbit-star { position: absolute; width: 6px; height: 6px; border-radius: 50%; background: #c3a0ff; box-shadow: 0 0 13px #c3a0ff9c; }
.orbit-star-a { left: 18%; top: 53%; }
.orbit-star-b { left: 78%; top: 29%; }
.orbit-star-c { left: 84%; top: 64%; width: 3px; height: 3px; }
.preview-avatar, .face { display: grid; place-items: center; aspect-ratio: 1; position: relative; overflow: hidden; border-radius: 50%; }
.preview-avatar { width: 148px; border: 1px solid #d5bfff55; box-shadow: 0 0 0 8px #ac86e61a, 0 12px 34px #0b061d44; background: radial-gradient(circle at 35% 22%, #b08be5, #6b48a4 85%); font-size: 49px; font-weight: 630; color: #fff6ff; }
.preview-avatar video, .face video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.preview-avatar video, .participant[data-self="true"] .face video { transform: scaleX(-1); }
.preview-controls { display: flex; align-items: center; gap: 10px; }
.preview-status { position: absolute; padding-inline: 16px; bottom: 18px; margin: 0; text-align: center; font-size: 13px; color: #f4c3ca; }
.join-card { padding: clamp(22px, 4.5vw, 46px); display: grid; align-content: center; gap: 28px; background: #201e29; }
h1 { margin: 0; font-size: clamp(30px, 4vw, 43px); line-height: 1.075; font-weight: 720; letter-spacing: -.058em; }
.muted { color: var(--muted); }
.intro-copy { margin: 9px 0 0; line-height: 1.5; font-size: 14px; }
#join-form { display: grid; grid-template-columns: minmax(0, 1fr); }
#join-form label { color: #eeebf5; font-size: 13px; font-weight: 600; margin-bottom: 7px; }
#join-form input { width: 100%; min-height: 44px; margin-bottom: 14px; color: var(--text); background: #191721; border: 1px solid #3b3648; border-radius: 9px; padding: 10px 12px; font-size: 14px; }
#join-form input::placeholder { color: #827b93; }
.join-button { display: flex; align-items: center; justify-content: center; gap: 9px; min-height: 46px; margin-top: 6px; color: #22183c; background: #bdabff; border: 0; border-radius: 10px; font-size: 14px; font-weight: 700; }
.join-button:hover { background: #d0c2ff; }
.join-button svg { width: 17px; height: 17px; }
.form-error { margin: 12px 0 0; color: #ffb6c3; font-size: 13px; overflow-wrap: anywhere; }

.icon-button { width: 43px; height: 43px; display: inline-grid; place-items: center; padding: 0; flex: 0 0 auto; border: 1px solid #494052; border-radius: 12px; color: #e4dfef; background: #2c2738; }
.icon-button:hover { background: #3c334d; }
.icon-button[aria-pressed="true"] { color: #e8deff; border-color: #8063c1; background: #4a3672; }
.compact-button { width: 36px; height: 36px; background: #201e29; border-color: var(--border); }
.compact-button svg { width: 17px; height: 17px; }

.room { width: min(100% - 48px, 1150px); min-height: calc(100dvh - 76px); padding: 38px 0 24px; margin: 0 auto; display: flex; flex-direction: column; }
.room-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.room-heading h1 { word-break: break-word; }
.participant-count { display: flex; align-items: center; gap: 7px; color: var(--muted); margin: 9px 0 0; font-size: 13px; }
.participant-count svg { width: 16px; height: 16px; }
.invite-button { flex: 0 0 auto; display: flex; align-items: center; gap: 7px; padding: 9px 12px; border-radius: 9px; background: #25212e; border: 1px solid var(--border); color: #e2daef; font-size: 13px; }
.invite-button:hover { background: #3c334d; }
.invite-button svg { width: 16px; height: 16px; }
.invite-url { width: 100%; margin-top: 12px; padding: 9px 11px; color: var(--text); background: #191721; border: 1px solid var(--border); border-radius: 9px; font-size: 13px; }
.room-status { margin: 18px 0 0; padding: 10px 12px; border: 1px solid #4b3d59; border-radius: 9px; background: #28212f; color: #ead8f5; font-size: 13px; }
/* The mute notice card shows this sentence; the line stays for assistive technology only. */
.room-status.room-status-carded { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.stage { display: grid; justify-items: center; align-content: center; flex: 1; gap: 24px; min-height: 240px; padding: 30px 0; }
.participants { display: flex; align-items: flex-start; justify-content: center; flex-wrap: wrap; gap: 24px; }
.participant { display: grid; justify-items: center; gap: 12px; width: 142px; }
.face { width: 128px; border: 1px solid #ffffff38; box-shadow: 0 0 0 4px #fff1; background:var(--avatar-color, #C597FF); }
.face-photo { position:absolute; inset:0; width:100%; height:100%; object-fit:cover; }
.face:has(.face-photo:not([hidden])) orbit-avatar-name { visibility:hidden; }
.participant-label { display: flex; justify-content: center; align-items: center; gap: 6px; width: 100%; }
.participant-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #e8e4f0; font-size: 13px; }
.participant-mute { flex: 0 0 auto; width: 14px; height: 14px; color: #bbb0d0; }
.share-stage { display: grid; width: 100%; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 14px; }

body.compact .topbar { height: 54px; padding-inline: 14px; }
body.compact .room { width: calc(100% - 28px); padding: 12px 0; min-height: calc(100dvh - 54px); }
body.compact .room-heading h1 { font-size: 22px; }
body.compact .participants { gap: 13px; }
body.compact .participant { width: 76px; gap: 6px; }
body.compact .face { width: 63px; }
body.compact .participant-name { font-size: 11px; }
body.compact .stage { min-height: 100px; padding: 15px 0; gap: 12px; }

@media (max-width: 730px) {
  .lobby { grid-template-columns: 1fr; width: min(100% - 30px, 490px); margin-top: 24px; }
  .preview { min-height: 245px; gap: 16px; }
  .preview-avatar { width: 94px; font-size: 32px; }
  .preview-caption { left: 16px; top: 15px; }
  .preview-status { bottom: 8px; }
  .join-card { gap: 21px; }
  .room { width: calc(100% - 30px); padding-top: 24px; }
  .participant { width: 108px; }
  .face { width: 91px; }
  .participants { gap: 16px; }
}

@media (max-width: 550px) and (max-height: 450px) {
  .topbar { height: 54px; padding-inline: 14px; }
  .room { min-height: calc(100dvh - 54px); padding: 12px 0; }
  .room-heading h1 { font-size: 22px; }
  .stage { min-height: 100px; padding: 15px 0; gap: 12px; }
}

#open-in-orbit { color: inherit; justify-self: start; font-size: 14px; }
#return-to-instance { color: var(--ds-ink); justify-self: start; }
.orbit-desktop #return-to-instance { display: none; }
.orbit-desktop #open-in-orbit { display: none; }

/* Dice tray: built from design-system.css components (see docs/design-system.md, "Dice tray"). */
.orbit-dice-tray form { display: grid; gap: var(--ds-space-4); }
.orbit-dice-tray fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.orbit-dice-tray legend { margin-bottom: var(--ds-space-1); padding: 0; }
.dice-header { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--ds-space-1) var(--ds-space-3); }
/* The readout is an <output> (a polite status), so screen readers hear the expression as it changes. */
.dice-readout { min-height: 1.3em; color: var(--ds-accent); font: 700 var(--ds-text-lg)/1.3 var(--ds-font-sans); font-variant-numeric: tabular-nums; }
.dice-shapes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--ds-space-2); }
.dice-shapes label {
  position: relative; display: grid; justify-items: center; gap: var(--ds-space-1); padding: var(--ds-space-2) var(--ds-space-1);
  border-radius: var(--ds-radius-lg); color: var(--ds-ink-muted); background: var(--ds-fill);
  box-shadow: inset 0 0 0 1px var(--ds-hairline), var(--ds-lip); cursor: pointer;
  transition: background-color var(--ds-duration-fast) var(--ds-ease-standard), box-shadow var(--ds-duration-fast) var(--ds-ease-standard),
    color var(--ds-duration-fast) var(--ds-ease-standard), transform var(--ds-duration-instant) var(--ds-ease-standard);
}
.dice-shapes label:hover { color: var(--ds-ink); background: var(--ds-fill-hover); }
.dice-shapes label:active { transform: scale(.95); }
.dice-shapes label:has(:checked) { color: var(--ds-ink); background: var(--ds-accent-wash); box-shadow: inset 0 0 0 1.5px var(--ds-accent), 0 0 0 4px var(--ds-accent-glow); }
.dice-shapes label:has(:focus-visible) { outline: var(--ds-focus-width) solid var(--ds-focus-color); outline-offset: var(--ds-focus-offset); }
.dice-shapes .die-shape { width: 44px; height: 44px; filter: drop-shadow(0 2px 3px rgb(0 0 0 / 45%)); transition: transform var(--ds-duration-slow) var(--ds-ease-spring); }
.dice-shapes label:hover .die-shape { transform: rotate(-10deg) scale(1.06); }
.dice-shapes label:has(:checked) .die-shape { transform: translateY(-2px) rotate(8deg) scale(1.08); }
.die-name { font: 700 var(--ds-text-md)/1 var(--ds-font-sans); font-variant-numeric: tabular-nums; }
.dice-shapes input, .dice-announcement { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
/* The live region is a direct child of body. Anchor it so its static position
   after the content cannot extend a fixed-size window such as Floating. */
.dice-announcement { top: 0; left: 0; }
.dice-numbers, .dice-sharing { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--ds-space-3); align-items: end; }
.dice-mode { container-type: inline-size; }
.dice-mode .ds-hint { margin-top: var(--ds-space-1); }
@container (max-width: 20rem) {
  .dice-mode .ds-segmented { grid-auto-flow: row; }
}
/* One hint per state; the hidden one drops out of the fieldset description. */
.dice-mode:enabled .ds-hint > :last-child, .dice-mode:disabled .ds-hint > :first-child { display: none; }
.dice-roll { min-width: 112px; }
.dice-roll .die-shape { width: 22px; height: 22px; transition: transform var(--ds-duration-slow) var(--ds-ease-spring); }
.dice-roll:hover:enabled .die-shape { transform: rotate(200deg) scale(1.1); }
.dice-roll:active:enabled .die-shape { transform: rotate(320deg) scale(.9); }

.die-shape { display:inline-grid; place-items:center; width:38px; height:38px; color:white; background:center/contain no-repeat; font:bold 13px var(--ds-font-sans); font-variant-numeric:tabular-nums; text-shadow:0 1px 3px #20142d,0 0 3px #20142d; }
.die-4 { background-image:url('/dice/d4.svg'); }
.die-6 { background-image:url('/dice/d6.svg'); }
.die-8 { background-image:url('/dice/d8.svg'); }
.die-10 { background-image:url('/dice/d10.svg'); }
.die-12 { background-image:url('/dice/d12.svg'); }
.die-20 { background-image:url('/dice/d20.svg'); }
.die-100 { background-image:url('/dice/d100.svg'); }

/* Results sit over live video, so they use tinted translucency without backdrop blur (docs/design-system.md, "Glass"). */
.orbit-roll-button,.orbit-die-overlay,.offpage-dice { position:absolute; z-index:12; color:var(--ds-ink); background:var(--ds-call-scrim); border:1px solid var(--ds-hairline); box-shadow:var(--ds-lip), 0 2px 8px rgb(0 0 0 / 40%); font:600 var(--ds-text-sm)/1.25 var(--ds-font-sans); }
.orbit-roll-button { bottom:-10px; left:50%; display:inline-flex; align-items:center; gap:var(--ds-space-1); min-height:var(--ds-target-compact); padding:0 var(--ds-space-2) 0 var(--ds-space-1); border-radius:var(--ds-radius-pill); transform:translateX(-50%); white-space:nowrap; transition:background-color var(--ds-duration-fast) var(--ds-ease-standard); }
.orbit-roll-button::before { content:''; width:20px; height:20px; background:center/contain no-repeat url('/dice/d20.svg'); transition:transform var(--ds-duration-slow) var(--ds-ease-spring); }
.orbit-roll-button:hover { background:var(--ds-fill-hover); }
.orbit-roll-button:hover::before { transform:rotate(-20deg) scale(1.1); }
.orbit-die-overlay { top:0; left:90%; display:grid; grid-template-columns:auto minmax(0, 1fr) auto; grid-template-areas:'die caption close'; align-items:center; column-gap:var(--ds-space-1); width:max-content; max-width:min(190px,45vw); padding:var(--ds-space-1) var(--ds-space-1) var(--ds-space-1) var(--ds-space-0); border-radius:var(--ds-radius-lg); overflow-wrap:anywhere; }
.orbit-die-overlay .die-shape { grid-area:die; }
.orbit-die-overlay small { grid-area:caption; color:var(--ds-ink-muted); font-size:var(--ds-text-sm); font-variant-numeric:tabular-nums; }
.orbit-die-overlay button { grid-area:close; align-self:start; min-width:24px; min-height:24px; padding:0; color:var(--ds-ink-muted); background:none; border:0; border-radius:var(--ds-radius-sm); font-size:16px; line-height:1; }
.orbit-die-overlay button:hover { color:var(--ds-ink); background:var(--ds-hairline); }
.orbit-die-overlay[data-natural=high] { border-color:var(--ds-gold); box-shadow:var(--ds-lip), 0 0 0 3px rgb(255 210 122 / 25%), 0 2px 12px rgb(255 210 122 / 35%); }
.orbit-die-overlay[data-natural=high] small { color:var(--ds-gold); }
.orbit-die-overlay[data-natural=low] { border-color:var(--ds-danger-edge); }
.orbit-die-overlay[data-natural=low] small { color:var(--ds-danger-ink); }
.offpage-dice { bottom:0; left:0; padding:var(--ds-space-1) var(--ds-space-2); border-radius:var(--ds-radius-md); pointer-events:none; }
@media (prefers-reduced-motion:no-preference) {
  .orbit-die-overlay.tumble .die-shape { animation:orbit-die-tumble .55s var(--ds-ease-out); }
  .orbit-die-overlay.tumble small { animation:orbit-die-reveal .55s var(--ds-ease-out) both; }
  .orbit-die-overlay.tumble[data-natural=high] { animation:orbit-die-glint 1.1s .45s var(--ds-ease-out) both; }
  .orbit-die-overlay.tumble[data-natural=low] .die-shape { animation:orbit-die-tumble .55s var(--ds-ease-out), orbit-die-wobble .5s .55s var(--ds-ease-standard); }
}
@media (prefers-reduced-motion:reduce) {
  .dice-shapes .die-shape, .dice-roll .die-shape, .orbit-roll-button::before { transition:none; }
  .dice-shapes label:hover .die-shape, .dice-shapes label:has(:checked) .die-shape, .dice-roll:is(:hover, :active) .die-shape, .orbit-roll-button:hover::before { transform:none; }
}
@media (forced-colors:active) {
  .dice-shapes label:has(:checked):not(:has(:focus-visible)) { outline:2px solid Highlight; }
  .dice-shapes label:has(:checked:focus-visible) .die-name { text-decoration:underline; }
  .orbit-roll-button,.orbit-die-overlay,.offpage-dice { border-color:CanvasText; }
}
@keyframes orbit-die-tumble { 0% { transform:scale(.3) rotate(-170deg); } 75% { transform:scale(1.05) rotate(12deg); } 100% { transform:none; } }
@keyframes orbit-die-reveal { 0%, 55% { opacity:0; transform:translateX(-4px); } 100% { opacity:1; transform:none; } }
@keyframes orbit-die-glint { 0% { box-shadow:var(--ds-lip), 0 0 0 0 rgb(255 210 122 / 70%); } 100% { box-shadow:var(--ds-lip), 0 0 0 3px rgb(255 210 122 / 25%), 0 2px 12px rgb(255 210 122 / 35%); } }
@keyframes orbit-die-wobble { 25% { transform:rotate(-9deg); } 50% { transform:rotate(7deg); } 75% { transform:rotate(-4deg); } }

orbit-avatar-name {
  position: absolute;
  inset: 15%;
  display: grid;
  place-items: center;
  grid-template-columns: minmax(0, 1fr);
  text-align: center;
  color: white;
  font-weight: bold;
  line-height: 1.1;
  text-shadow: 0 .5px 1px #0008;
}
/* Break names only between words (spaces), not between CJK ideographs, and balance the lines;
   avatar.js falls back to breaking inside words only at the 10px minimum. */
orbit-avatar-name bdi { text-transform: uppercase; display: block; width: 100%; word-break: keep-all; text-wrap: balance; }

/* A titled section revealed by its button (the app does not use the browser's details element). */
.orbit-disclosure-toggle { display:inline-flex; align-items:center; gap:8px; margin:4px 0; margin-inline-start:-8px; padding:4px 8px;
  border:0; border-radius:6px; background:transparent; color:inherit; font:inherit; font-weight:600; cursor:pointer; }
.orbit-disclosure-toggle:hover { background:color-mix(in srgb, currentColor 10%, transparent); }
.orbit-disclosure-toggle:active { background:color-mix(in srgb, currentColor 16%, transparent); }
.orbit-disclosure-chevron { flex:none; width:12px; height:12px; background:currentColor; opacity:.7;
  -webkit-mask:var(--orbit-chevron) center / contain no-repeat; mask:var(--orbit-chevron) center / contain no-repeat;
  transition:transform .15s, opacity .15s; }
.orbit-disclosure-chevron:dir(rtl) { transform:rotate(180deg); }
[aria-expanded="true"] > .orbit-disclosure-chevron { transform:rotate(90deg); }
.orbit-disclosure-toggle:is(:hover, :focus-visible) > .orbit-disclosure-chevron { opacity:1; }
@media (prefers-reduced-motion:reduce) { .orbit-disclosure-chevron { transition:none; } }
/* The body lines up with the toggle's text: chevron plus gap, less the toggle's outdent. */
.orbit-disclosure-body { padding-inline-start:20px; }
/* Text sits right under its toggle; a first paragraph's own margin would leave a blank line. */
.orbit-disclosure-body > :first-child { margin-block-start:4px; }
.setup-device-access { padding-top: 16px; border-top: 1px solid var(--border); }
.setup-device-access h2, .setup-device-access p { margin: 0 0 8px; font-size: 13px; line-height: 1.45; }
.setup-device-access p { color: var(--muted); }
.setup-device-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.setup-device-actions button { min-height: 32px; padding: 5px 10px; border: 1px solid var(--border); border-radius: 6px; color: var(--text); background: #303030; font: inherit; font-size: 13px; }
.setup-device-actions button:hover:enabled { background: #414141; }
