:root {
  --bg: #090b10;
  --panel: #12151d;
  --panel-soft: #171b25;
  --line: rgba(255, 255, 255, 0.1);
  --text: #f6f5f0;
  --muted: #8e95a7;
  --yellow: #ffe252;
  --pink: #ff79b0;
  --green: #70efb5;
  --danger: #ff6266;
  color-scheme: dark;
  font-family: "Segoe UI", "Microsoft YaHei UI", "PingFang SC", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    var(--bg);
  background-size: 28px 28px;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.mobile-glow {
  position: fixed;
  z-index: -1;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  opacity: 0.13;
  filter: blur(100px);
  pointer-events: none;
}

.glow-a {
  top: -150px;
  left: -120px;
  background: var(--yellow);
}

.glow-b {
  right: -140px;
  bottom: 5%;
  background: var(--pink);
}

.lobby-shell {
  width: min(1020px, calc(100% - 32px));
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 0 max(36px, env(safe-area-inset-bottom));
}

.mobile-brand,
.compact-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mobile-logo {
  display: flex;
  position: relative;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  transform: rotate(-4deg);
  border-radius: 12px;
  background: var(--yellow);
}

.mobile-logo::after {
  position: absolute;
  bottom: 8px;
  width: 19px;
  height: 6px;
  border-bottom: 3px solid #16171c;
  border-radius: 50%;
  content: "";
}

.mobile-logo i {
  width: 5px;
  height: 7px;
  margin: 0 4px 6px;
  border-radius: 50%;
  background: #16171c;
}

.mobile-brand b {
  display: block;
  font-size: 18px;
  font-style: italic;
  font-weight: 900;
}

.mobile-brand small,
.compact-brand small {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.lobby-hero {
  max-width: 720px;
  padding: clamp(58px, 9vw, 108px) 0 48px;
}

.mobile-eyebrow {
  color: var(--muted);
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.2em;
}

.lobby-hero h1 {
  margin: 10px 0 18px;
  font-size: clamp(46px, 8vw, 78px);
  font-weight: 950;
  letter-spacing: -0.065em;
  line-height: 0.94;
}

.lobby-hero h1 em {
  color: var(--yellow);
  font-style: normal;
}

.lobby-hero p {
  max-width: 610px;
  margin: 0;
  color: #a7adba;
  font-size: 14px;
  line-height: 1.75;
}

.secure-warning {
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 98, 102, 0.32);
  border-radius: 10px;
  color: #ffd6d7;
  background: rgba(255, 98, 102, 0.08);
  font-size: 12px;
  line-height: 1.5;
}

.lobby-actions {
  display: grid;
  grid-template-columns: 1fr 44px 1fr;
  gap: 15px;
  align-items: stretch;
}

.lobby-card {
  display: flex;
  position: relative;
  min-height: 390px;
  padding: 27px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  flex-direction: column;
  background: rgba(18, 21, 29, 0.95);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.25);
}

.create-card {
  border-color: rgba(255, 226, 82, 0.22);
}

.join-card {
  border-color: rgba(255, 121, 176, 0.22);
}

.card-number {
  position: absolute;
  top: 15px;
  right: 19px;
  color: rgba(255, 255, 255, 0.07);
  font-family: Consolas, monospace;
  font-size: 56px;
  font-weight: 900;
}

.lobby-card > div {
  position: relative;
  z-index: 1;
  margin-bottom: auto;
}

.lobby-card small {
  color: var(--muted);
  font-family: Consolas, monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.lobby-card h2 {
  margin: 5px 0 7px;
  font-size: 28px;
}

.lobby-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.lobby-card label {
  display: block;
  margin-top: 14px;
}

.lobby-card label span {
  display: block;
  margin: 0 0 6px 2px;
  color: #b7bcc8;
  font-size: 10px;
  font-weight: 700;
}

.lobby-card input {
  width: 100%;
  height: 48px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: white;
  outline: none;
  background: #0b0d12;
}

.lobby-card input:focus {
  border-color: var(--yellow);
}

.lobby-card .room-code-input {
  font-family: Consolas, monospace;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.mobile-primary,
.mobile-secondary,
.room-start {
  min-height: 50px;
  margin-top: 16px;
  border: 0;
  border-radius: 11px;
  color: #15161b;
  background: var(--yellow);
  font-weight: 900;
}

.mobile-secondary {
  color: white;
  background: var(--pink);
}

.lobby-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #686f80;
  font-size: 10px;
}

.lobby-divider::before,
.lobby-divider::after {
  width: 1px;
  height: 38%;
  margin: 10px 0;
  background: var(--line);
  content: "";
}

.lobby-divider {
  flex-direction: column;
}

.lobby-footer {
  display: flex;
  justify-content: space-between;
  padding: 22px 4px 0;
  color: var(--muted);
  font-size: 10px;
}

.lobby-footer span {
  display: flex;
  align-items: center;
}

.lobby-footer i {
  width: 6px;
  height: 6px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--green);
}

.lobby-footer a {
  color: var(--muted);
}

.room-page {
  padding-bottom: env(safe-area-inset-bottom);
  background:
    radial-gradient(circle at 22% 15%, rgba(255, 226, 82, 0.07), transparent 32%),
    radial-gradient(circle at 82% 70%, rgba(255, 121, 176, 0.06), transparent 33%),
    var(--bg);
}

.room-topbar {
  display: grid;
  position: sticky;
  z-index: 30;
  top: 0;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 64px;
  padding: max(9px, env(safe-area-inset-top)) 14px 9px;
  border-bottom: 1px solid var(--line);
  background: rgba(9, 11, 16, 0.88);
  backdrop-filter: blur(16px);
}

.mini-logo {
  display: grid;
  width: 34px;
  height: 34px;
  transform: rotate(-4deg);
  border-radius: 9px;
  color: #15161b;
  place-items: center;
  background: var(--yellow);
  font-size: 13px;
  font-weight: 900;
}

.compact-brand b {
  display: block;
  font-size: 13px;
  font-style: italic;
  font-weight: 900;
}

.room-code-chip {
  display: flex;
  min-width: 100px;
  height: 43px;
  padding: 4px 14px;
  border: 1px solid rgba(255, 226, 82, 0.22);
  border-radius: 22px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(255, 226, 82, 0.06);
}

.room-code-chip small {
  color: var(--muted);
  font-size: 7px;
  font-weight: 700;
}

.room-code-chip b {
  color: var(--yellow);
  font-family: Consolas, monospace;
  font-size: 15px;
  letter-spacing: 0.1em;
}

.leave-top {
  justify-self: end;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-size: 10px;
  font-weight: 700;
}

.room-shell {
  display: grid;
  width: min(1120px, calc(100% - 24px));
  margin: 0 auto;
  padding: 16px 0 30px;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.75fr);
  gap: 14px;
}

.mobile-video-card {
  position: relative;
  overflow: hidden;
  min-height: 620px;
  border: 1px solid rgba(255, 226, 82, 0.18);
  border-radius: 20px;
  grid-row: span 3;
  background: #11141b;
}

.mobile-video-card video {
  width: 100%;
  height: 100%;
  min-height: 620px;
  object-fit: cover;
}

.mobile-video-card video.mirror {
  transform: scaleX(-1);
}

.camera-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(transparent 52%, rgba(5, 6, 9, 0.88) 100%);
  pointer-events: none;
}

.camera-grid {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.028) 1px, transparent 1px);
  background-size: 70px 70px;
  pointer-events: none;
  mask-image: linear-gradient(black, transparent 72%);
}

.camera-state {
  display: flex;
  position: absolute;
  align-items: center;
  border: 1px solid var(--line);
  color: #e3e5e9;
  background: rgba(7, 8, 11, 0.65);
  backdrop-filter: blur(8px);
  font-size: 9px;
  font-weight: 700;
}

.top-camera-state {
  top: 13px;
  left: 13px;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 6px;
}

.camera-state i {
  width: 6px;
  height: 6px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--danger);
}

.camera-state i.online {
  background: var(--green);
  box-shadow: 0 0 8px rgba(112, 239, 181, 0.8);
}

.flip-camera {
  display: grid;
  position: absolute;
  top: 13px;
  right: 13px;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 50%;
  place-items: center;
  background: rgba(7, 8, 11, 0.65);
  backdrop-filter: blur(8px);
  font-size: 20px;
}

.camera-permission {
  display: flex;
  position: absolute;
  z-index: 4;
  inset: 0;
  padding: 35px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background:
    radial-gradient(circle at center, rgba(255, 226, 82, 0.1), transparent 40%),
    #0e1117;
}

.permission-face {
  display: grid;
  width: 70px;
  height: 70px;
  margin-bottom: 17px;
  border: 1px solid rgba(255, 226, 82, 0.3);
  border-radius: 50%;
  color: var(--yellow);
  place-items: center;
  background: rgba(255, 226, 82, 0.07);
  font-size: 26px;
}

.camera-permission h1 {
  margin: 0 0 8px;
  font-size: 28px;
}

.camera-permission p {
  max-width: 380px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.camera-permission button {
  min-width: 190px;
  min-height: 48px;
  margin: 22px 0 10px;
  border: 0;
  border-radius: 10px;
  color: #15161b;
  background: var(--yellow);
  font-weight: 900;
}

.camera-permission small {
  color: #666d7c;
  font-size: 9px;
}

.own-readout {
  display: flex;
  position: absolute;
  z-index: 3;
  right: 20px;
  bottom: 20px;
  left: 20px;
  align-items: center;
  gap: 15px;
}

.own-readout h2 {
  margin: 4px 0 2px;
  font-size: 23px;
}

.own-readout p {
  margin: 0;
  color: #adb2bd;
  font-size: 10px;
}

.mobile-score-ring {
  --score: 0;
  display: grid;
  min-width: 94px;
  width: 94px;
  height: 94px;
  border-radius: 50%;
  place-items: center;
  text-align: center;
  background:
    radial-gradient(circle, rgba(11, 13, 18, 0.96) 61%, transparent 62%),
    conic-gradient(var(--yellow) calc(var(--score) * 1%), rgba(255, 255, 255, 0.12) 0);
}

.mobile-score-ring strong,
.mobile-score-ring small {
  display: block;
}

.mobile-score-ring strong {
  font-family: Consolas, monospace;
  font-size: 30px;
  line-height: 0.9;
}

.mobile-score-ring small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 8px;
}

.room-status-row {
  display: grid;
  gap: 14px;
}

.opponent-card,
.judge-card,
.mobile-controls,
.mobile-events {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(18, 21, 29, 0.94);
}

.opponent-card {
  padding: 17px;
  border-color: rgba(255, 121, 176, 0.2);
}

.opponent-head {
  display: grid;
  grid-template-columns: 39px 1fr auto;
  align-items: center;
  gap: 9px;
}

.seat-badge {
  display: grid;
  height: 39px;
  border-radius: 10px;
  color: var(--pink);
  place-items: center;
  background: rgba(255, 121, 176, 0.1);
  font-size: 9px;
  font-weight: 800;
}

.opponent-head small,
.opponent-head b {
  display: block;
}

.opponent-head small {
  color: var(--muted);
  font-family: Consolas, monospace;
  font-size: 8px;
}

.opponent-head b {
  margin-top: 2px;
  font-size: 13px;
}

.opponent-head em {
  color: var(--muted);
  font-size: 9px;
  font-style: normal;
  font-weight: 700;
}

.opponent-head em.online {
  color: var(--green);
}

.opponent-score {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 14px;
}

.opponent-score > strong {
  min-width: 65px;
  color: var(--pink);
  font-family: Consolas, monospace;
  font-size: 40px;
  line-height: 1;
}

.opponent-score span b,
.opponent-score span small {
  display: block;
}

.opponent-score span b {
  font-size: 14px;
}

.opponent-score span small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
}

.mini-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.mini-metrics > span {
  color: var(--muted);
  font-size: 8px;
}

.mini-metrics i {
  display: block;
  height: 3px;
  margin-top: 5px;
  overflow: hidden;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
}

.mini-metrics em {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--pink);
  transition: width 180ms;
}

.judge-card {
  display: flex;
  padding: 17px;
  align-items: center;
  justify-content: space-between;
}

.judge-copy h2 {
  margin: 4px 0;
  font-size: 16px;
}

.judge-copy p {
  margin: 0;
  color: var(--green);
  font-size: 9px;
  font-weight: 700;
}

.mobile-clock {
  text-align: right;
}

.mobile-clock small,
.mobile-clock strong {
  display: block;
}

.mobile-clock small {
  color: var(--muted);
  font-family: Consolas, monospace;
  font-size: 7px;
}

.mobile-clock strong {
  margin-top: 4px;
  font-family: Consolas, monospace;
  font-size: 25px;
}

.mobile-controls {
  padding: 17px;
}

.mobile-threshold label {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  font-weight: 700;
}

.mobile-threshold label b {
  color: var(--yellow);
  font-family: Consolas, monospace;
}

.mobile-threshold input {
  width: 100%;
  margin: 11px 0 0;
  accent-color: var(--yellow);
}

.mobile-threshold > div {
  display: flex;
  justify-content: space-between;
  color: #656c7a;
  font-size: 8px;
}

.room-start {
  width: 100%;
  margin-top: 15px;
}

.room-start small,
.room-start b {
  display: block;
}

.room-start small {
  opacity: 0.54;
  font-family: Consolas, monospace;
  font-size: 7px;
  letter-spacing: 0.12em;
}

.room-start b {
  margin-top: 2px;
  font-size: 14px;
}

.guest-wait {
  margin: 8px 0 0;
  color: var(--muted);
  text-align: center;
  font-size: 11px;
}

.mobile-events {
  padding: 15px 17px;
}

.mobile-events > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.mobile-events > div span {
  font-size: 11px;
  font-weight: 800;
}

.mobile-events > div small {
  color: var(--muted);
  font-size: 8px;
}

.mobile-events ol {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.mobile-events li {
  padding-left: 9px;
  border-left: 2px solid rgba(255, 255, 255, 0.1);
}

.mobile-events li:first-child {
  border-color: var(--yellow);
}

.mobile-events li b,
.mobile-events li span {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.mobile-events li b {
  font-size: 9px;
}

.mobile-events li span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 8px;
}

.mobile-countdown,
.mobile-result,
.rejoin-panel {
  display: grid;
  position: fixed;
  z-index: 80;
  inset: 0;
  padding: 20px;
  place-items: center;
  background: rgba(5, 6, 9, 0.88);
  backdrop-filter: blur(15px);
}

.mobile-countdown {
  align-content: center;
  color: white;
  text-align: center;
}

.mobile-countdown small {
  color: var(--yellow);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.2em;
}

.mobile-countdown strong {
  display: block;
  margin: 8px 0;
  color: var(--yellow);
  font-family: Consolas, monospace;
  font-size: min(42vw, 180px);
  font-style: italic;
  line-height: 0.9;
}

.mobile-countdown span {
  color: var(--muted);
  font-size: 11px;
}

.mobile-result {
  background:
    radial-gradient(circle at center, rgba(255, 226, 82, 0.12), transparent 40%),
    rgba(5, 6, 9, 0.9);
}

.mobile-result-card,
.rejoin-panel > div {
  width: min(390px, 100%);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 22px;
  text-align: center;
  background: #12151d;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.5);
}

.result-emoji {
  margin: 10px 0 4px;
  font-size: 58px;
}

.mobile-result-card h2 {
  margin: 0;
  font-size: 29px;
}

.mobile-result-card > p {
  margin: 8px 0 20px;
  color: var(--muted);
  font-size: 11px;
}

.mobile-result-card .mobile-primary {
  width: 100%;
  margin: 0 0 8px;
}

.result-leave {
  width: 100%;
  min-height: 45px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: #d0d4dc;
  background: rgba(255, 255, 255, 0.04);
  font-weight: 800;
}

.guest-rematch-note {
  display: block;
  margin: 11px 0;
  color: var(--muted);
  font-size: 9px;
}

.rejoin-panel h2 {
  margin: 0 0 8px;
}

.rejoin-panel p {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 12px;
}

.rejoin-panel a {
  display: grid;
  min-height: 46px;
  border-radius: 10px;
  color: #15161b;
  place-items: center;
  background: var(--yellow);
  font-size: 13px;
  font-weight: 900;
  text-decoration: none;
}

.mobile-toast {
  position: fixed;
  z-index: 100;
  right: 16px;
  bottom: max(16px, env(safe-area-inset-bottom));
  left: 16px;
  max-width: 420px;
  min-height: 44px;
  margin: 0 auto;
  padding: 12px 15px;
  transform: translateY(20px);
  border: 1px solid var(--line);
  border-radius: 11px;
  opacity: 0;
  background: #1a1e28;
  box-shadow: 0 15px 45px rgba(0, 0, 0, 0.45);
  font-size: 11px;
  font-weight: 700;
  pointer-events: none;
  transition: 200ms;
}

.mobile-toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 760px) {
  .lobby-shell {
    width: min(100% - 22px, 520px);
  }

  .lobby-hero {
    padding: 50px 5px 34px;
  }

  .lobby-hero h1 {
    font-size: clamp(43px, 14vw, 64px);
  }

  .lobby-actions {
    grid-template-columns: 1fr;
    gap: 11px;
  }

  .lobby-card {
    min-height: 340px;
    padding: 23px;
  }

  .lobby-divider {
    height: 28px;
    flex-direction: row;
  }

  .lobby-divider::before,
  .lobby-divider::after {
    width: 30%;
    height: 1px;
    margin: 0 10px;
  }

  .lobby-footer {
    align-items: center;
    gap: 12px;
    flex-direction: column;
  }

  .room-topbar {
    grid-template-columns: 1fr auto auto;
  }

  .compact-brand span:last-child {
    display: none;
  }

  .room-code-chip {
    min-width: 88px;
    padding: 4px 9px;
  }

  .leave-top {
    margin-left: 7px;
    padding: 0 8px;
  }

  .room-shell {
    display: block;
    width: calc(100% - 16px);
    padding-top: 8px;
  }

  .mobile-video-card {
    min-height: min(68dvh, 610px);
    border-radius: 16px;
  }

  .mobile-video-card video {
    min-height: min(68dvh, 610px);
  }

  .own-readout {
    right: 15px;
    bottom: 15px;
    left: 15px;
  }

  .mobile-score-ring {
    min-width: 82px;
    width: 82px;
    height: 82px;
  }

  .mobile-score-ring strong {
    font-size: 26px;
  }

  .own-readout h2 {
    font-size: 19px;
  }

  .room-status-row {
    margin-top: 8px;
  }

  .opponent-card,
  .judge-card,
  .mobile-controls,
  .mobile-events {
    border-radius: 14px;
  }

  .mobile-controls,
  .mobile-events {
    margin-top: 8px;
  }
}

@media (orientation: landscape) and (max-height: 620px) {
  .room-shell {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
  }

  .mobile-video-card,
  .mobile-video-card video {
    min-height: calc(100dvh - 88px);
  }

  .room-status-row {
    margin: 0;
  }
}

