:root {
  color-scheme: light;
  --ink: #102033;
  --muted: #6e7a8a;
  --line: rgba(255, 255, 255, .58);
  --glass: rgba(255, 255, 255, .58);
  --glass-strong: rgba(255, 255, 255, .78);
  --blue: #0877ff;
  --mint: #20c997;
  --rose: #ff4d6d;
  --amber: #ffb020;
  --shadow: 0 18px 54px rgba(26, 63, 104, .20);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", "Segoe UI", "Microsoft YaHei UI", sans-serif;
  background:
    radial-gradient(circle at 12% 8%, rgba(48, 145, 255, .34), transparent 30%),
    radial-gradient(circle at 84% 18%, rgba(32, 201, 151, .28), transparent 28%),
    linear-gradient(145deg, #f6fbff 0%, #edf5ff 45%, #fff7dc 100%);
  background-attachment: fixed;
  letter-spacing: 0;
  padding: 14px 12px calc(86px + env(safe-area-inset-bottom));
}

button, input {
  font: inherit;
}

button {
  min-height: 46px;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

input {
  width: 100%;
  min-height: 46px;
  border: 1px solid rgba(255, 255, 255, .7);
  border-radius: 16px;
  background: rgba(255, 255, 255, .66);
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.app-shell {
  width: min(100%, 520px);
  margin: 0 auto;
  display: grid;
  gap: 14px;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 4px 2px;
}

.eyebrow, .hero-subtitle, .muted, .hint {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 5px;
  font-size: 12px;
  font-weight: 850;
}

h1, h2, p {
  margin: 0;
}

h1 {
  font-size: 34px;
  line-height: 1.02;
  letter-spacing: 0;
}

h2 {
  font-size: 19px;
  letter-spacing: 0;
}

.hero-subtitle {
  margin-top: 6px;
  font-size: 13px;
}

.icon-button {
  width: 48px;
  height: 48px;
  border-radius: 18px;
  background: var(--glass-strong);
  color: var(--blue);
  font-weight: 950;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.player-glass, .room-card, .leader-row, .match-card, .dialog-card {
  border: 1px solid var(--line);
  background: var(--glass);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px) saturate(1.2);
}

.player-glass {
  border-radius: 26px;
  padding: 15px;
  display: grid;
  gap: 13px;
}

.player-glass strong {
  display: block;
  margin-top: 3px;
  font-size: 22px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.mini-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.mini-stats span {
  min-width: 0;
  border-radius: 18px;
  background: rgba(255, 255, 255, .52);
  padding: 10px 7px;
  text-align: center;
}

.mini-stats b, .mini-stats small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-stats b { font-size: 14px; }
.mini-stats small { color: var(--muted); font-size: 11px; margin-top: 3px; }

.view { display: none; }
.view.active { display: grid; gap: 12px; }

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  padding: 5px;
  border-radius: 20px;
  background: rgba(255,255,255,.44);
  border: 1px solid var(--line);
}

.segmented button, .auth-switch button {
  border-radius: 16px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
}

.segmented button.active, .auth-switch button.active {
  background: rgba(255,255,255,.82);
  color: var(--blue);
  box-shadow: 0 8px 18px rgba(8, 119, 255, .14);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 38px;
}

.text-button {
  min-height: 36px;
  border-radius: 14px;
  padding: 0 12px;
  color: var(--blue);
  background: rgba(255,255,255,.52);
  font-weight: 850;
}

.pill {
  border-radius: 999px;
  background: rgba(255,255,255,.58);
  padding: 7px 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.room-list, .leaderboard, .action-stack {
  display: grid;
  gap: 10px;
}

.room-card {
  border-radius: 24px;
  padding: 13px;
  display: grid;
  gap: 12px;
}

.room-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.teams {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: stretch;
}

.team {
  display: grid;
  gap: 7px;
}

.slot {
  min-height: 46px;
  border-radius: 16px;
  background: rgba(255,255,255,.58);
  border: 1px solid rgba(255,255,255,.6);
  color: var(--ink);
  padding: 8px;
  font-weight: 850;
  overflow-wrap: anywhere;
}

.slot.empty {
  color: var(--blue);
}

.versus {
  align-self: center;
  color: var(--muted);
  font-weight: 950;
}

.room-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.primary, .glass-button {
  border-radius: 17px;
  font-weight: 950;
  padding: 0 14px;
}

.primary {
  color: white;
  background: linear-gradient(135deg, var(--blue), #4aa7ff);
  box-shadow: 0 12px 26px rgba(8,119,255,.26);
}

.glass-button {
  color: var(--blue);
  background: rgba(255,255,255,.64);
  border: 1px solid var(--line);
}

.danger { color: var(--rose); }

.leader-row {
  border-radius: 20px;
  padding: 12px;
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 10px;
}

.leader-row strong, .leader-row span {
  min-width: 0;
}

.leader-meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.bottom-tabs {
  position: fixed;
  left: 50%;
  bottom: max(10px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(calc(100% - 20px), 520px);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 7px;
  border-radius: 24px;
  background: rgba(255,255,255,.72);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
  z-index: 20;
}

.bottom-tabs button {
  border-radius: 18px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 950;
}

.bottom-tabs button.active {
  color: var(--blue);
  background: rgba(8,119,255,.12);
}

.match-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: end;
  justify-content: center;
  padding: 16px 12px calc(16px + env(safe-area-inset-bottom));
  background: rgba(23, 37, 57, .24);
  backdrop-filter: blur(10px);
}

.match-overlay.hidden, .hidden { display: none !important; }

.match-card {
  width: min(100%, 520px);
  border-radius: 30px;
  padding: 16px;
  display: grid;
  gap: 14px;
}

.match-top, .power-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-weight: 850;
}

.match-top strong {
  color: var(--ink);
}

.rope-stage {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
}

.team-name {
  width: 42px;
  font-size: 12px;
  font-weight: 950;
  color: var(--muted);
}

.team-name.right { text-align: right; }

.rope-track {
  position: relative;
  height: 78px;
  border-radius: 24px;
  background: rgba(255,255,255,.5);
  overflow: hidden;
}

.rope {
  position: absolute;
  left: 8%;
  right: 8%;
  top: 50%;
  height: 8px;
  border-radius: 999px;
  transform: translateY(-50%);
  background: repeating-linear-gradient(90deg, #9b6a3d 0 12px, #d8a15f 12px 24px);
}

.knot {
  position: absolute;
  left: calc(50% - 13px);
  top: calc(50% - 13px);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--amber), #fff0a8);
  box-shadow: 0 6px 16px rgba(255,176,32,.35);
  transition: left .12s linear;
}

.pull-button {
  height: 88px;
  border-radius: 28px;
  background: linear-gradient(180deg, #ff6d86, #ff2f5f);
  color: white;
  font-size: 30px;
  font-weight: 1000;
  box-shadow: 0 20px 36px rgba(255,47,95,.32);
}

.pull-button:active {
  transform: scale(.98);
}

dialog {
  width: min(calc(100% - 20px), 500px);
  border: 0;
  padding: 0;
  background: transparent;
}

dialog::backdrop {
  background: rgba(16,32,51,.28);
  backdrop-filter: blur(10px);
}

.dialog-card {
  border-radius: 28px;
  color: var(--ink);
  overflow: hidden;
}

.dialog-head {
  min-height: 54px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,.42);
}

.dialog-body {
  padding: 14px;
  display: grid;
  gap: 12px;
}

.close {
  width: 38px;
  height: 38px;
  border-radius: 14px;
  background: rgba(255,255,255,.54);
  color: var(--muted);
  font-size: 24px;
}

.auth-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 5px;
  border-radius: 19px;
  background: rgba(255,255,255,.46);
}

.auth-pane {
  display: none;
  gap: 10px;
}

.auth-pane.active {
  display: grid;
}

.code-box {
  display: grid;
  gap: 5px;
  border-radius: 18px;
  background: rgba(8,119,255,.1);
  color: var(--blue);
  padding: 12px;
  text-align: center;
}

.code-box strong {
  font-size: 24px;
  letter-spacing: 0;
}

.result-card .mvp {
  border-radius: 22px;
  padding: 14px;
  background: linear-gradient(135deg, rgba(255,176,32,.2), rgba(255,255,255,.66));
}

.bar {
  height: 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.6);
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--mint));
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(88px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: min(92%, 420px);
  padding: 11px 14px;
  border-radius: 16px;
  background: rgba(16,32,51,.84);
  color: white;
  font-size: 13px;
  font-weight: 800;
  z-index: 50;
}

@media (min-width: 700px) {
  body {
    padding-top: 26px;
  }

  .match-overlay {
    align-items: center;
  }
}
