:root {
  color-scheme: dark;
  --bg: #0b0f17;
  --panel: rgba(15, 21, 32, 0.78);
  --panel-2: rgba(15, 21, 32, 0.92);
  --stroke: rgba(255, 255, 255, 0.12);
  --text: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.62);
  --accent: #6ee7ff;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #fb7185;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
  --radius: 16px;
  --radius-sm: 12px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
}

* {
  box-sizing: border-box;
}

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

body {
  background-color: var(--bg);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #000;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  z-index: 30;
  background: linear-gradient(
    to bottom,
    rgba(11, 15, 23, 0.85),
    rgba(11, 15, 23, 0.2),
    rgba(11, 15, 23, 0)
  );
  backdrop-filter: blur(10px);
}

.brand {
  display: grid;
  gap: 2px;
}

.brand__title {
  font-size: 14px;
  font-weight: 650;
  letter-spacing: 0.2px;
}

.brand__sub {
  font-size: 12px;
  color: var(--muted);
}

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

.fps {
  min-width: 72px;
  text-align: right;
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 650;
  letter-spacing: 0.2px;
  color: rgba(255, 255, 255, 0.88);
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(10px);
}

.fps[hidden] {
  display: none;
}

.fps--center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
}

.btn {
  appearance: none;
  border: 1px solid var(--stroke);
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  cursor: pointer;
  user-select: none;
  transition: transform 90ms ease, background 120ms ease, border-color 120ms ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
}

.btn--ghost {
  background: rgba(255, 255, 255, 0.03);
}

.menu {
  position: relative;
}

.menu__panel {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  min-width: 220px;
  background: var(--panel-2);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  padding: 6px;
  z-index: 20;
}

.menu__item {
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  text-decoration: none;
  padding: 10px 10px;
  cursor: pointer;
  transition: background 120ms ease;
  display: flex;
  align-items: center;
  gap: 10px;
  user-select: none;
}

.menu__item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.menu__toggle {
  gap: 12px;
}

.menu__toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.35);
}

.video,
.canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.video {
  object-fit: cover;
  background: rgba(0, 0, 0, 0.35);
}

.canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.gameCanvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.gameVideo {
  position: absolute;
  right: 14px;
  bottom: calc(14px + env(safe-area-inset-bottom));
  width: 132px;
  height: 176px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
  object-fit: cover;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.gameVideo.isVisible {
  opacity: 0.92;
}

.loading {
  position: absolute;
  left: 14px;
  top: 14px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 8px 10px;
  border-radius: 12px;
  color: var(--muted);
  backdrop-filter: blur(10px);
  font-family: var(--mono);
  font-size: 12px;
  z-index: 10;
}

.postureBadge {
  position: absolute;
  left: 14px;
  bottom: calc(14px + env(safe-area-inset-bottom));
  z-index: 35;
  display: grid;
  grid-template-columns: 22px 1fr;
  grid-template-rows: auto auto;
  column-gap: 10px;
  row-gap: 2px;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--stroke);
  background: var(--panel);
  backdrop-filter: blur(10px);
  box-shadow: 0 12px 44px rgba(0, 0, 0, 0.45);
  min-width: 188px;
}

.postureBadge.isPulse {
  animation: posturePulse 220ms ease-out;
}

@keyframes posturePulse {
  from {
    transform: scale(0.98);
    border-color: rgba(110, 231, 255, 0.55);
  }
  to {
    transform: scale(1);
    border-color: rgba(255, 255, 255, 0.12);
  }
}

.postureBadge__icon {
  width: 22px;
  height: 22px;
  grid-row: 1 / span 2;
  opacity: 0.95;
}

.postureBadge__text {
  font-weight: 650;
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.postureBadge__hint {
  font-family: var(--mono);
  font-size: 11px;
  color: rgba(255, 255, 255, 0.62);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.postureIndicator {
  position: absolute;
  left: 14px;
  bottom: calc(14px + env(safe-area-inset-bottom));
  z-index: 35;
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--stroke);
  background: var(--panel);
  backdrop-filter: blur(10px);
  box-shadow: 0 12px 44px rgba(0, 0, 0, 0.45);
}

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

.postureRow__side {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.3);
  font-family: var(--mono);
  font-size: 11px;
  color: rgba(255, 255, 255, 0.72);
}

.postureRow__icon {
  width: 18px;
  height: 18px;
  display: block;
  opacity: 0.95;
}

.postureRow__textWrap {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.postureRow__text {
  font-weight: 650;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.postureRow__meta {
  font-family: var(--mono);
  font-size: 11px;
  color: rgba(255, 255, 255, 0.62);
  white-space: nowrap;
}

.toastHost {
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: 14px;
  display: grid;
  gap: 10px;
  z-index: 50;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: rgba(10, 12, 18, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  padding: 10px 12px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.toast__title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 650;
  margin-bottom: 6px;
}

.toast__body {
  color: var(--muted);
  font-size: 13px;
}

.toast__code {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
}

.toast__hint {
  margin-top: 6px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.48);
}

@media (max-width: 760px) {
  .topbar {
    padding: calc(10px + env(safe-area-inset-top)) 10px 10px;
  }
}
