/* ==========================================================================
   Volutus — cloud-suite aesthetic: atmospheric themes + frosted glass.
   Shared by the host (index.html, body.host) and the phone pad (play.html, body.pad).
   ========================================================================== */

/* ---------- Theme tokens ---------- */
:root,
html.night {
  --ink: #f1f5f9;
  --ink-soft: #cbd5e1;
  --ink-faint: #94a3b8;
  --glass: rgba(10, 16, 32, 0.55);
  --glass-strong: rgba(10, 16, 32, 0.88);
  --glass-border: rgba(255, 255, 255, 0.14);
  --shadow: 0 18px 50px -20px rgba(0, 0, 0, 0.8);
  --accent: #7dd3fc;
  --accent-ink: #04121c;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --line: rgba(255, 255, 255, 0.12);
  --input: rgba(2, 6, 23, 0.45);
  --btn: rgba(255, 255, 255, 0.08);
  --btn-hover: rgba(255, 255, 255, 0.14);
  --sky-top: #040814;
  --sky-mid: #0c1730;
  --sky-horizon: #22355c;
  --me: #7dd3fc;
  --radius: 14px;
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

html.twilight {
  --ink: #fbf7ff;
  --ink-soft: #e2dcf0;
  --ink-faint: #b4abc9;
  --glass: rgba(34, 28, 62, 0.5);
  --glass-strong: rgba(34, 28, 62, 0.88);
  --glass-border: rgba(255, 255, 255, 0.18);
  --accent: #fbbf91;
  --accent-ink: #2a1408;
  --btn: rgba(255, 255, 255, 0.1);
  --btn-hover: rgba(255, 255, 255, 0.16);
  --input: rgba(20, 14, 40, 0.45);
  --sky-top: #251f52;
  --sky-mid: #8a4c8c;
  --sky-horizon: #ffb27a;
}

html.day {
  --ink: #0f172a;
  --ink-soft: #334155;
  --ink-faint: #64748b;
  --glass: rgba(255, 255, 255, 0.62);
  --glass-strong: rgba(255, 255, 255, 0.92);
  --glass-border: rgba(255, 255, 255, 0.75);
  --shadow: 0 18px 50px -24px rgba(15, 40, 80, 0.55);
  --accent: #0284c7;
  --accent-ink: #ffffff;
  --line: rgba(15, 23, 42, 0.12);
  --input: rgba(255, 255, 255, 0.75);
  --btn: rgba(15, 23, 42, 0.06);
  --btn-hover: rgba(15, 23, 42, 0.12);
  --sky-top: #3b82d6;
  --sky-mid: #7dbcef;
  --sky-horizon: #d8eefb;
}

/* ---------- Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--sky-top);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: -0.01em;
}

.mono {
  font-family: var(--font-mono);
}

.muted {
  color: var(--ink-faint);
  font-size: 0.9rem;
  line-height: 1.45;
}

.center {
  text-align: center;
}

.error {
  color: var(--bad);
  font-size: 0.9rem;
  margin: 0;
}

kbd {
  font-family: var(--font-mono);
  font-size: 0.8em;
  padding: 1px 6px;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: var(--btn);
}

.glass {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border-radius: var(--radius);
}

/* ---------- Buttons ---------- */
.btn {
  font: 600 0.95rem var(--font-ui);
  color: var(--ink);
  background: var(--btn);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn:hover {
  background: var(--btn-hover);
}

.btn:active {
  transform: scale(0.97);
}

.btn--primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}

.btn--primary:hover {
  background: var(--accent);
  filter: brightness(1.08);
}

.btn--ghost {
  background: transparent;
}

.btn--small {
  padding: 5px 10px;
  font-size: 0.85rem;
}

.btn--big {
  padding: 14px 18px;
  font-size: 1.1rem;
  width: 100%;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  color: var(--ink);
  cursor: pointer;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

.icon-btn:hover {
  background: var(--glass-strong);
}

.icon-btn.is-active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}

/* ---------- Brand ---------- */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand__emblem {
  width: 46px;
  height: 30px;
  color: var(--ink);
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.2));
}

.brand__name {
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

.brand__tag {
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.brand--center {
  justify-content: center;
}

/* ---------- Status ---------- */
.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  font-size: 0.85rem;
  font-weight: 600;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.status__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.2);
}

.status[data-state="open"] .status__dot {
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.22);
}

.status[data-state="error"] .status__dot,
.status[data-state="closed"] .status__dot,
.status[data-state="replaced"] .status__dot,
.status[data-state="no-host"] .status__dot,
.status[data-state="full"] .status__dot {
  background: var(--bad);
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.22);
}

.status--compact {
  padding: 10px;
}

/* ==========================================================================
   Host (Mac)
   ========================================================================== */
body.host {
  overflow: hidden;
}

.sky-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  pointer-events: none;
}

.topbar > * {
  pointer-events: auto;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.banner {
  position: fixed;
  top: 76px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
  font-size: 0.92rem;
  z-index: 5;
}

.join-card {
  position: fixed;
  top: 50%;
  right: clamp(16px, 4vw, 56px);
  transform: translateY(-50%);
  width: min(340px, 34vw);
  max-height: calc(100vh - 92px);
  overflow-y: auto;
  padding: 22px 22px 18px;
  text-align: center;
  z-index: 3;
}

.join-card__close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  background: transparent;
  border-color: transparent;
}

.join-card__title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 14px;
}

.join-card__qr {
  display: block;
  width: min(100%, max(132px, 100vh - 390px));
  margin: 0 auto;
  background: #fff;
  border-radius: 12px;
  padding: 6px;
  line-height: 0;
}

.join-card__qr svg {
  display: block;
  width: 100%;
  height: auto;
}

.join-card__code {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.join-card__label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-faint);
}

.room-code {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 2.6rem;
  letter-spacing: 0.22em;
  margin-right: -0.22em;
}

.room-code--small {
  font-size: 1.25rem;
  letter-spacing: 0.16em;
}

.join-card__hint {
  margin: 12px 0 0;
  font-size: 0.85rem;
  color: var(--ink-soft);
  line-height: 1.45;
  word-break: break-word;
}

.join-card__hint--soft {
  color: var(--ink-faint);
}

.join-mini {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px 8px 8px;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  z-index: 3;
}

.join-mini__qr {
  width: 64px;
  height: 64px;
  background: #fff;
  border-radius: 8px;
  padding: 3px;
  line-height: 0;
}

.join-mini__qr svg {
  width: 100%;
  height: 100%;
}

.roster {
  position: fixed;
  left: 18px;
  bottom: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 60vw;
  margin: 0;
  padding: 0;
  list-style: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  font-size: 0.9rem;
  font-weight: 600;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.chip__dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
}

.chip.is-away {
  opacity: 0.6;
}

.chip em {
  font-weight: 500;
  color: var(--ink-faint);
}

/* ---------- Modal ---------- */
.modal {
  width: min(480px, calc(100vw - 32px));
  padding: 20px 22px;
  color: var(--ink);
  background: var(--glass-strong);
}

.modal::backdrop {
  background: rgba(2, 6, 23, 0.4);
  backdrop-filter: blur(3px);
}

.modal__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.modal__section {
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.modal__section h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
  margin-bottom: 10px;
}

.modal__section .muted {
  margin: 0 0 10px;
}

.modal__foot {
  margin: 6px 0 0;
  font-size: 0.8rem;
}

.theme-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.theme-chip {
  font: 600 0.9rem var(--font-ui);
  color: var(--ink);
  background: var(--btn);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 12px;
  cursor: pointer;
}

.theme-chip.is-active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}

.field-row {
  display: flex;
  gap: 8px;
}

.field-row input {
  flex: 1;
  min-width: 0;
}

input {
  font: 500 0.95rem var(--font-ui);
  color: var(--ink);
  background: var(--input);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  outline: none;
}

input:focus {
  border-color: var(--accent);
}

/* ==========================================================================
   Phone pad
   ========================================================================== */
body.pad {
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.pad-sky {
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 62%, var(--sky-horizon) 100%);
}

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
}

.join-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
}

.join-form input {
  -webkit-user-select: text;
  user-select: text;
  font-size: 1.05rem;
  padding: 12px 14px;
  width: 100%;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.room-input {
  font-family: var(--font-mono) !important;
  font-weight: 700;
  font-size: 1.6rem !important;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  text-align: center;
}

.screen--play {
  justify-content: stretch;
  gap: 14px;
}

.pad-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.me {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  min-width: 0;
}

.me__swatch {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--line);
  box-shadow: inset 0 -6px 10px rgba(0, 0, 0, 0.15), 0 0 0 3px rgba(255, 255, 255, 0.35);
}

.me__name {
  font-weight: 700;
  font-size: 1.05rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.me__sub {
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.gauge {
  margin-top: 6px;
  height: 6px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
}

.gauge__fill {
  height: 100%;
  width: 60%;
  border-radius: 3px;
  background: var(--me);
  transition: width 0.25s ease-out;
}

.gauge.is-soaking .gauge__fill {
  animation: soak 0.9s ease-in-out infinite alternate;
}

.gauge.is-empty {
  background: rgba(248, 113, 113, 0.35);
}

@keyframes soak {
  to {
    filter: brightness(1.35);
  }
}

.stick-area {
  position: relative;
  flex: 1;
  border-radius: 22px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  touch-action: none;
  overflow: hidden;
}

.stick-base {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 180px;
  height: 180px;
  margin: -90px 0 0 -90px;
  border-radius: 50%;
  border: 2px dashed var(--glass-border);
  background: radial-gradient(circle, rgba(255, 255, 255, 0.08), transparent 70%);
  display: grid;
  place-items: center;
  pointer-events: none;
  transition: opacity 0.2s;
}

.stick-area.is-dragging .stick-base {
  border-style: solid;
  border-color: var(--me);
}

.stick-knob {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffffff, var(--me) 140%);
  box-shadow: 0 10px 24px -8px rgba(0, 0, 0, 0.5), 0 0 0 4px rgba(255, 255, 255, 0.25);
  transition: transform 0.06s linear;
}

.stick-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 14px;
  margin: 0;
  text-align: center;
  font-size: 0.85rem;
  color: var(--ink-soft);
  pointer-events: none;
  padding: 0 16px;
}

.stick-hint.is-flash {
  color: var(--ink);
  font-weight: 600;
}

.pad-bottom {
  display: flex;
  gap: 12px;
  align-items: stretch;
}

.tilt-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 96px;
  border-radius: 18px;
  background: var(--glass);
  border-color: var(--glass-border);
}

.tilt-btn svg {
  width: 26px;
  height: 26px;
}

.tilt-btn.is-active {
  background: var(--accent);
  color: var(--accent-ink);
}

.rain-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 96px;
  border-radius: 18px;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  color: var(--ink);
  font: 700 1.1rem var(--font-ui);
  touch-action: none;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: transform 0.08s, background 0.15s;
}

.rain-btn svg {
  width: 42px;
  height: 42px;
}

.rain-btn.is-active {
  background: var(--me);
  color: #0f172a;
  transform: scale(0.97);
}

.rain-btn.is-empty {
  opacity: 0.6;
  font-size: 0.95rem;
}

.rain-btn.is-empty.is-active {
  background: var(--glass);
  color: var(--ink);
}

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(2, 6, 23, 0.35);
  z-index: 10;
}

.overlay__card {
  padding: 20px;
  text-align: center;
  max-width: 320px;
}

.overlay__card p {
  margin: 0 0 12px;
  font-weight: 600;
  line-height: 1.45;
}

.overlay__card p:last-child {
  margin-bottom: 0;
}
