/* Moonshine Web. One deliberate look: the stream is a dark room, so the page
   is dark in every theme. Palette = the native apps' Theme.swift tokens. */
:root {
  --ink0: #0b0d10;
  --ink1: #16191e;
  --ink2: #1f242b;
  --line: rgba(255, 255, 255, 0.12);
  --text: rgba(255, 255, 255, 0.92);
  --text2: rgba(255, 255, 255, 0.6);
  --glow: #9ec7db; /* moonGlow */
  --ok: #4dd973;
  --warn: #f2bf40;
  --bad: #f25940;
  --radius: 12px; /* deckRadius */
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --sans:
    -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI",
    system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
}

* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
  margin: 0;
  background: var(--ink0);
  color: var(--text);
  font: 15px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
}
[hidden] {
  display: none !important;
}

#stage {
  position: fixed;
  inset: 0;
  background: #000;
  display: grid;
  place-items: center;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
#screen {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain; /* never stretched; letterboxed to the PC's aspect */
  background: #000;
  outline: none;
}

/* ---- sheets (landing / connecting / ended) ---- */
.sheet {
  position: relative;
  z-index: 2;
  width: min(440px, calc(100vw - 32px));
  padding: 28px 28px 24px;
  background: color-mix(in srgb, var(--ink1) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(18px);
  display: grid;
  gap: 14px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text2);
}
.moon {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(
    circle at 35% 35%,
    #e9f4fa,
    var(--glow) 60%,
    #5d8aa0
  );
  box-shadow: 0 0 12px color-mix(in srgb, var(--glow) 60%, transparent);
}
.moon.pulse {
  animation: pulse 1.6s var(--ease) infinite;
}
@keyframes pulse {
  50% {
    box-shadow: 0 0 22px var(--glow);
  }
}
@media (prefers-reduced-motion: reduce) {
  .moon.pulse {
    animation: none;
  }
}

h1,
h2 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
h1 {
  font-size: 26px;
}
h2 {
  font-size: 20px;
}
.sub {
  margin: -8px 0 0;
  color: var(--text2);
}

button {
  font: inherit;
  color: var(--text);
  background: var(--ink2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
  transition:
    background 0.12s var(--ease),
    border-color 0.12s var(--ease);
}
button:hover {
  background: #262c34;
}
button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 2px solid var(--glow);
  outline-offset: 2px;
}
button:disabled {
  opacity: 0.45;
  cursor: default;
}
button.primary {
  background: var(--glow);
  border-color: transparent;
  color: #0b1218;
  font-weight: 600;
  font-size: 17px;
  padding: 13px 18px;
}
button.primary:hover:not(:disabled) {
  background: #b4d6e6;
}
button.quiet {
  background: transparent;
  justify-self: start;
  color: var(--text2);
}
button.danger {
  color: #ffd2cb;
}

.options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.field {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--text2);
}
select {
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--ink2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  min-width: 0;
}
.check {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text2);
}
.check input {
  accent-color: var(--glow);
  width: 16px;
  height: 16px;
  margin: 0;
}

.checks {
  list-style: none;
  margin: 2px 0 0;
  padding: 12px 0 0;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 4px;
  font-size: 12.5px;
  color: var(--text2);
}
.checks li::before {
  content: "●";
  margin-right: 8px;
  font-size: 9px;
  vertical-align: 2px;
}
.checks li.ok::before {
  color: var(--ok);
}
.checks li.warn::before {
  color: var(--warn);
}
.checks li.bad::before {
  color: var(--bad);
}

.pin {
  display: block;
  font: 600 44px/1 var(--mono);
  letter-spacing: 0.3em;
  text-align: center;
  padding: 16px 0 14px;
  color: var(--glow);
  background: var(--ink2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.steps {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 6px;
  font-size: 14px;
  color: var(--text2);
}
.steps b {
  color: var(--text);
  font-weight: 600;
}

.otp {
  display: grid;
  grid-template-columns: 1fr 1.4fr auto;
  gap: 10px;
  align-items: end;
}
.otp input {
  font: inherit;
  color: var(--text);
  background: var(--ink2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  min-width: 0;
}
.otp button.primary {
  font-size: 15px;
  padding: 10px 16px;
}
.row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.small {
  font-size: 12.5px;
  margin: 0;
}
@media (max-width: 520px) {
  .otp {
    grid-template-columns: 1fr 1fr;
  }
  .otp button.primary {
    grid-column: 1 / -1;
  }
}

.pw {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}
.pw input {
  font: inherit;
  color: var(--text);
  background: var(--ink2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  min-width: 0;
}
.pw button.primary {
  font-size: 15px;
  padding: 10px 16px;
}

#standby {
  position: absolute;
  z-index: 3;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink1) 92%, transparent);
  border: 1px solid var(--line);
  font-size: 14px;
}

/* Off-screen but focusable: brings up the phone's keyboard. */
#kbd {
  position: absolute;
  left: -200px;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.stages {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
  font-size: 14px;
}
.stages li {
  display: flex;
  gap: 10px;
  align-items: baseline;
  color: var(--text2);
}
.stages li::before {
  content: "○";
  width: 1em;
  color: var(--text2);
}
.stages li.active {
  color: var(--text);
}
.stages li.active::before {
  content: "◐";
  color: var(--glow);
}
.stages li.done::before {
  content: "✓";
  color: var(--ok);
}
.stages li.failed {
  color: #ffd2cb;
}
.stages li.failed::before {
  content: "✕";
  color: var(--bad);
}

/* ---- in-stream chrome ---- */
#input {
  position: absolute;
  inset: 0;
  z-index: 1;
  outline: none;
}
#stage.free #input { cursor: none; } /* the PC draws its own cursor into the picture */

/* ---- corner moon (desktop mode) ---- */
#corner {
  position: absolute;
  z-index: 3;
  top: calc(12px + env(safe-area-inset-top, 0px));
  right: 12px;
  width: 34px;
  height: 34px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: color-mix(in srgb, var(--ink1) 70%, transparent);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 0.16s var(--ease), transform 0.16s var(--ease);
  cursor: pointer;
}
#corner.awake {
  opacity: 0.45;
  transform: none;
}
#corner.near { opacity: 1; transform: none; }

/* ---- the deck: Moonshine's in-stream menu ---- */
#deck {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(4, 6, 8, 0.55);
  animation: deck-in 0.14s var(--ease);
}
@keyframes deck-in { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { #deck { animation: none; } }
.deck-card {
  width: min(420px, 100%);
  display: grid;
  gap: 12px;
  padding: 20px;
  background: color-mix(in srgb, var(--ink1) 94%, transparent);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(18px);
}
.deck-head { display: grid; gap: 4px; }
.deck-sub {
  margin: 0;
  font: 12px/1.4 var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--text2);
}
.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--ink0);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.seg button {
  display: grid;
  gap: 1px;
  background: transparent;
  border-color: transparent;
  padding: 8px 10px;
  font-weight: 600;
}
.seg button small { font-weight: 400; font-size: 11.5px; color: var(--text2); }
.seg button[aria-checked="true"] {
  background: var(--glow);
  border-color: transparent;
  color: #0b1218;
}
.seg button[aria-checked="true"] small {
  color: #0b1218;
  opacity: 0.75;
}
.seg button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.deck-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.deck-row button { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.deck-row button[aria-pressed="true"] { border-color: var(--glow); }
.send {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text2);
}
.send span { margin-right: 2px; }
.send button { font-size: 12.5px; padding: 5px 9px; border-radius: 8px; }
.deck-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.hint-line { margin: 0; font-size: 11.5px; color: var(--text2); line-height: 1.7; }

#hint {
  position: absolute;
  z-index: 3;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  padding: 9px 14px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink1) 90%, transparent);
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  pointer-events: none;
}
kbd {
  font: 12px var(--mono);
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--ink2);
}

#sound {
  position: absolute;
  z-index: 3;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  right: 24px;
}

#stats {
  position: absolute;
  z-index: 3;
  top: calc(10px + env(safe-area-inset-top, 0px));
  left: 10px;
  margin: 0;
  padding: 10px 12px;
  font: 12px/1.5 var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background: rgba(0, 0, 0, 0.62);
  border-radius: 10px;
  pointer-events: none;
}

@media (max-width: 520px) {
  .options {
    grid-template-columns: 1fr 1fr;
  }
  .deck-row {
    grid-template-columns: 1fr;
  }
}

/* Game-only links: the desktop shortcuts would be filtered on the PC anyway. */
body.game-link [data-desktop-only] {
  display: none;
}

/* ---- on-screen controller (phones and tablets) ---- */
#touchpad {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  touch-action: none;
}
#touchpad .tp-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  pointer-events: auto;
}
#touchpad .tp-left { left: 0; width: 45%; }
#touchpad .tp-right { right: 0; width: 55%; }
#touchpad .tp-stick {
  position: absolute;
  width: 112px;
  height: 112px;
  margin: -56px 0 0 -56px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.06);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s var(--ease);
}
#touchpad .tp-stick.on { opacity: 1; }
#touchpad .tp-knob {
  position: absolute;
  left: 32px;
  top: 32px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(158, 199, 219, 0.55);
}
#touchpad button {
  pointer-events: auto;
  touch-action: none;
  color: var(--text);
  background: rgba(22, 25, 30, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(6px);
  font-weight: 600;
  user-select: none;
  -webkit-user-select: none;
}
#touchpad button.on { background: rgba(158, 199, 219, 0.6); color: #0b1218; }
#touchpad .tp-face {
  position: absolute;
  right: calc(18px + env(safe-area-inset-right, 0px));
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  width: 168px;
  height: 168px;
}
#touchpad .tp-face button {
  position: absolute;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  padding: 0;
  font-size: 18px;
}
#touchpad .tp-y { left: 56px; top: 0; }
#touchpad .tp-x { left: 0; top: 56px; }
#touchpad .tp-b { left: 112px; top: 56px; }
#touchpad .tp-a { left: 56px; top: 112px; }
#touchpad .tp-shoulders {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top, 0px));
  display: flex;
  gap: 8px;
}
#touchpad .tp-l { left: calc(14px + env(safe-area-inset-left, 0px)); }
#touchpad .tp-r { right: calc(14px + env(safe-area-inset-right, 0px)); }
#touchpad .tp-shoulders button { width: 64px; height: 40px; border-radius: 12px; padding: 0; font-size: 13px; }
#touchpad .tp-mid {
  position: absolute;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 18px;
}
#touchpad .tp-mid button { width: 46px; height: 32px; border-radius: 10px; padding: 0; font-size: 15px; }
