:root {
  --bg: #12110f;
  --panel: rgba(22, 21, 19, 0.78);
  --line: rgba(255, 244, 226, 0.1);
  --ink: #f4efe6;
  --muted: rgba(244, 239, 230, 0.58);
  --accent: #e2c39a;
  --good: #8fd4a8;
  --warn: #e0b15a;
  --bad: #e08a7a;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
  overscroll-behavior: none;
  font-family: "SF Pro Display", "SF Pro Text", -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;
}

button,
select,
a {
  font: inherit;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

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

.topbar,
.pair,
.gate,
.warn {
  backdrop-filter: blur(22px);
  background: var(--panel);
  border: 1px solid var(--line);
}

.topbar {
  position: absolute;
  top: 20px;
  left: 20px;
  right: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border-radius: 18px;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand small {
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 11px;
}

.brand strong,
#model-name {
  font-size: 17px;
  font-weight: 600;
}

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

select,
.ghost {
  appearance: none;
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
}

.ghost {
  cursor: pointer;
}

#status {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-size: 13px;
}

#status[data-kind="lan"],
#status[data-kind="live"],
#status[data-kind="p2p"] {
  color: var(--good);
}

#status[data-kind="relay"],
#status[data-kind="waiting"],
#status[data-kind="peering"] {
  color: var(--warn);
}

#status[data-kind="disconnected"] {
  color: var(--bad);
}

.pair {
  position: absolute;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  width: min(380px, calc(100vw - 32px));
  padding: 22px 22px 18px;
  border-radius: 24px;
  text-align: center;
}

.pair.hidden {
  display: none;
}

.pair img {
  width: 210px;
  height: 210px;
  border-radius: 18px;
  background: #f4f1ea;
  display: block;
  margin: 12px auto 14px;
}

.pair p,
.pair a {
  color: var(--muted);
  font-size: 13px;
  word-break: break-all;
  display: block;
  margin-top: 6px;
}

.pair h2 {
  margin: 0;
  font-size: 18px;
}

.phone {
  min-height: 100dvh;
  display: grid;
  place-items: stretch;
}

#screen {
  width: 100%;
  height: 100dvh;
  display: block;
  background: #07080c;
}

.gate {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: end center;
  padding: 28px 20px 40px;
}

.gate-card {
  width: min(420px, 100%);
  display: grid;
  gap: 12px;
}

.gate h1 {
  margin: 0;
  font-size: 28px;
}

.gate p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

#start {
  border: 0;
  border-radius: 16px;
  padding: 16px 18px;
  background: var(--ink);
  color: #161513;
  font-weight: 620;
}

.warn {
  color: var(--warn);
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13px;
}

.warn[hidden],
.gate[hidden] {
  display: none !important;
}

#live-status {
  position: fixed;
  top: 18px;
  right: 16px;
  font-size: 12px;
  color: var(--muted);
}

.phone select {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 3;
  max-width: 58vw;
}
