/* FitDuel production UI — athletic arena, cyan/lime, no purple/cream AI defaults */
:root {
  --bg0: #06090d;
  --bg1: #0b1219;
  --ink: #f2f6fb;
  --muted: #a9bccf;
  --line: rgba(158, 190, 220, 0.14);
  --cyan: #2ec5ff;
  --cyan-dim: rgba(46, 197, 255, 0.16);
  --lime: #c6ff4a;
  --lime-dim: rgba(198, 255, 74, 0.14);
  --danger: #ff6b7a;
  --ok: #4dffb0;
  --display: "Bebas Neue", Impact, sans-serif;
  --display-ru: "Unbounded", "Manrope", sans-serif;
  --sans: "Manrope", "Segoe UI", sans-serif;
  --radius: 14px;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  background: var(--bg0);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
body { overflow-x: hidden; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.fineprint { color: var(--muted); font-size: 0.9rem; margin: 0.35rem 0 0; }
code { color: var(--lime); font-family: ui-monospace, monospace; font-size: 0.85em; }

/* Atmosphere */
.atmosphere {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden;
  background:
    linear-gradient(rgba(6, 9, 13, 0.62), rgba(6, 9, 13, 0.5)),
    url("/assets/atmos/arena-16x9.jpg") center / cover no-repeat,
    radial-gradient(1200px 700px at 12% -10%, rgba(46, 197, 255, 0.18), transparent 55%),
    linear-gradient(165deg, #05080c 0%, #0b141c 48%, #071018 100%);
}
.orb {
  position: absolute; border-radius: 50%; filter: blur(60px); opacity: 0.55;
  pointer-events: none;
  animation: drift 14s var(--ease) infinite alternate;
}
.orb-a {
  width: 42vw; height: 42vw; max-width: 520px; max-height: 520px;
  left: -8%; top: 18%;
  opacity: 0.28;
  background: radial-gradient(circle, rgba(46,197,255,.35), transparent 70%);
}
.orb-b {
  width: 36vw; height: 36vw; max-width: 440px; max-height: 440px;
  right: -6%; bottom: 8%;
  background: radial-gradient(circle, rgba(198,255,74,.22), transparent 70%);
  animation-delay: -4s;
}
.grain {
  position: absolute; inset: 0; opacity: 0.045; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(3%, -4%, 0) scale(1.08); }
}

.shell {
  position: relative; z-index: 1;
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.1rem 0 3.5rem;
  animation: rise 0.7s var(--ease) both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.5rem;
}
.logo { display: inline-flex; align-items: center; gap: 0.65rem; }
.logo-mark {
  width: 28px; height: 28px; border-radius: 8px;
  object-fit: contain;
  display: block;
  box-shadow: 0 0 24px rgba(46,197,255,.25);
}
.hero-mark {
  display: block;
  width: 88px;
  height: 88px;
  margin: 0.35rem auto 0.15rem;
  object-fit: contain;
  filter: drop-shadow(0 8px 28px rgba(46,197,255,.35));
}
.logo-text {
  font-family: var(--display);
  letter-spacing: 0.06em;
  font-size: 1.55rem;
  line-height: 1;
}
.logo-text span { color: var(--cyan); }
.logo-hero {
  font-size: clamp(4.2rem, 16vw, 7.5rem);
  margin: 0.15rem 0 0.55rem;
  text-shadow: 0 10px 60px rgba(46, 197, 255, 0.22);
}
/* Cyrillic titles — Bebas has almost no Russian glyphs */
.section-title,
.home-hero .section-title,
.match-bar-copy .section-title,
.results-view .section-title,
#view-onboarding .section-title,
#view-modes .section-title,
#view-setup .section-title,
#view-join .section-title,
#view-rankings .section-title,
#view-settings .section-title {
  font-family: var(--display-ru);
  letter-spacing: -0.02em;
  text-transform: none;
  font-weight: 600;
}
.topbar-right { display: flex; align-items: center; gap: 0.55rem; }
.pill {
  display: inline-flex; align-items: center;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.82rem;
  background: rgba(8, 14, 20, 0.55);
  backdrop-filter: blur(8px);
}

/* Buttons / fields */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(12, 18, 26, 0.72);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.72rem 1.2rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: transform 0.2s var(--ease), border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
.btn:hover { transform: translateY(-1px); border-color: rgba(46,197,255,.35); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.85rem; }
.btn-block { width: 100%; }
.btn-primary {
  background: linear-gradient(120deg, rgba(46,197,255,.22), rgba(12,24,32,.9) 55%);
  border-color: rgba(46,197,255,.55);
  color: #dff6ff;
  box-shadow: 0 10px 30px rgba(46,197,255,.12);
}
.btn-accent {
  background: linear-gradient(120deg, rgba(198,255,74,.16), rgba(12,24,18,.88) 55%);
  border-color: rgba(198,255,74,.45);
  color: #eaffb8;
}
.btn-ghost { background: transparent; }
.cta-row { display: flex; flex-wrap: wrap; gap: 0.65rem; }
.inline-actions { display: flex; gap: 0.5rem; width: 100%; }
.inline-actions input { flex: 1; }

.field { display: grid; gap: 0.35rem; }
.field > span {
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted);
}
input, select {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(5, 10, 14, 0.78);
  border-radius: 12px;
  padding: 0.78rem 0.9rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, select:focus {
  border-color: rgba(46,197,255,.55);
  box-shadow: 0 0 0 3px var(--cyan-dim);
}

/* Toast */
.toast {
  margin: 0 0 1rem;
  padding: 0.8rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(10, 16, 22, 0.85);
  backdrop-filter: blur(10px);
  animation: toast-in 0.35s var(--ease);
}
.toast.ok { border-color: rgba(77,255,176,.4); color: var(--ok); }
.toast.err { border-color: rgba(255,107,122,.45); color: var(--danger); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

/* Login — brand first, one composition */
.login-view {
  min-height: calc(100dvh - 6rem);
  display: grid;
  align-items: center;
}
.login-hero { max-width: 34rem; }
.eyebrow {
  margin: 0;
  color: var(--lime);
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 600;
}
.lede {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 32ch;
}
.login-panel {
  display: grid;
  gap: 0.85rem;
  padding: 1.15rem;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  background: rgba(8, 13, 19, 0.62);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

/* Lobby */
.section-title {
  margin: 0;
  font-size: clamp(1.85rem, 5vw, 2.55rem);
  line-height: 1.1;
}
.block-title {
  margin: 0 0 0.85rem;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.lobby-head { margin-bottom: 1.25rem; }
.lobby-layout {
  display: grid;
  gap: 1.5rem;
}
@media (min-width: 920px) {
  .lobby-layout { grid-template-columns: 1.35fr 0.85fr; align-items: start; }
}
.duel-forge {
  padding: 1.25rem 1.3rem 1.4rem;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 6px);
  background: linear-gradient(160deg, rgba(14,22,30,.8), rgba(8,12,18,.72));
  box-shadow: var(--shadow);
}
.forge-grid {
  display: grid;
  gap: 0.85rem;
  margin-bottom: 1rem;
}
@media (min-width: 560px) {
  .forge-grid { grid-template-columns: 1.4fr 0.8fr; }
}
.invite, .join-strip {
  margin-top: 1.15rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
}
.side-rail { display: grid; gap: 1rem; }
.rail-block {
  padding: 1rem 1.05rem;
  border-top: 1px solid var(--line);
}
.rank-list { list-style: none; margin: 0; padding: 0; }
.rank-list li {
  display: flex; justify-content: space-between; gap: 0.75rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid rgba(158, 190, 220, 0.08);
  font-size: 0.92rem;
}
.rank-list li:last-child { border-bottom: 0; }
.rank-list strong { font-variant-numeric: tabular-nums; color: var(--cyan); }

/* Match */
.match-bar {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem;
  margin-bottom: 1rem; align-items: end;
}
.match-layout {
  display: grid; gap: 1rem;
}
@media (min-width: 960px) {
  .match-layout { grid-template-columns: 1.45fr 0.7fr; }
}
.stage {
  position: relative;
  aspect-ratio: 16 / 11;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #03060a;
  box-shadow: var(--shadow);
}
.stage video, .stage canvas#overlay {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  transform: scaleX(-1);
}
.stage canvas#overlay { pointer-events: none; }
.cam-status {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  max-width: min(38rem, 92%);
  padding: 0.9rem 1.05rem;
  border-radius: 12px;
  background: rgba(4, 8, 14, 0.9);
  border: 1px solid var(--line);
  text-align: center;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--text, #e8eef6);
  pointer-events: none;
}
.cam-status.warn { color: #ffd56a; border-color: rgba(255, 213, 106, 0.35); }
.cam-status.info { color: #9ad8ff; }
.stage-hud {
  position: absolute; left: 0; right: 0; top: 0; z-index: 2;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.5rem;
  align-items: start;
  padding: 0.9rem;
  background: linear-gradient(180deg, rgba(0,0,0,.72), transparent 78%);
}
.scoreboard { min-width: 0; }
.scoreboard.opp { text-align: right; }
.score-label {
  display: inline-block;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.15rem;
}
.score {
  font-family: var(--display);
  font-size: clamp(2.4rem, 7vw, 3.6rem);
  line-height: 0.9;
  letter-spacing: 0.03em;
}
.scoreboard.you .score { color: var(--cyan); }
.scoreboard.opp .score { color: var(--lime); }
.vs {
  font-family: var(--display);
  font-size: 1.4rem;
  letter-spacing: 0.08em;
  color: rgba(242,246,251,.55);
  padding-top: 0.55rem;
}
.meter {
  margin-top: 0.45rem;
  height: 4px;
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  overflow: hidden;
}
.meter > i {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--cyan), var(--lime));
  transition: width 0.35s var(--ease);
}
.countdown {
  position: absolute; inset: 0; z-index: 4;
  display: grid; place-items: center;
  background: rgba(3, 6, 10, 0.62);
  font-family: var(--display);
  font-size: clamp(5rem, 18vw, 9rem);
  letter-spacing: 0.04em;
  color: var(--lime);
  text-shadow: 0 0 40px rgba(198,255,74,.35);
  animation: pulse-count 1s var(--ease) infinite;
}
@keyframes pulse-count {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.06); opacity: 0.85; }
}
.opponent-panel {
  padding: 1rem;
  border-top: 1px solid var(--line);
}
.skel {
  width: 100%;
  height: auto;
  aspect-ratio: 8 / 5;
  display: block;
  border-radius: 12px;
  background:
    radial-gradient(circle at 50% 30%, rgba(46,197,255,.12), transparent 45%),
    #05090e;
  border: 1px solid var(--line);
}

@media (max-width: 640px) {
  .login-panel { padding: 1rem; }
  .menu-grid { grid-template-columns: 1fr; }
}

/* —— Menu system —— */
.btn-reset {
  appearance: none; border: 0; background: transparent; padding: 0; cursor: pointer; color: inherit;
}
.icon-btn {
  width: 36px; height: 36px; border-radius: 999px;
  border: 1px solid var(--line); background: rgba(8,14,20,.55);
  color: var(--cyan); cursor: pointer;
}
.auth-tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.35rem;
  margin: 0 0 0.85rem; padding: 0.25rem;
  border: 1px solid var(--line); border-radius: 999px;
  background: rgba(5,10,14,.55);
}
.auth-tab {
  border: 0; background: transparent; color: var(--muted);
  border-radius: 999px; padding: 0.55rem 0.75rem; font-weight: 600; cursor: pointer;
}
.auth-tab.active {
  background: rgba(46,197,255,.16); color: var(--ink);
}
.auth-view, .home-view, .results-view { animation: rise 0.55s var(--ease) both; }
.home-hero { margin-bottom: 1.25rem; text-shadow: 0 2px 14px rgba(0, 0, 0, 0.75); }
.menu-grid {
  display: grid; gap: 0.85rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.menu-card, .mode-card {
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.1rem 1.15rem;
  background: linear-gradient(160deg, rgba(14,22,30,.92), rgba(8,12,18,.86));
  backdrop-filter: blur(10px);
  color: inherit;
  cursor: pointer;
  transition: transform 0.2s var(--ease), border-color 0.2s, box-shadow 0.2s;
}
.menu-glyph, .mode-glyph {
  width: 52px;
  height: 52px;
  object-fit: contain;
  display: block;
  margin-bottom: 0.55rem;
  filter: drop-shadow(0 6px 16px rgba(0,0,0,.4));
}
.menu-card:hover, .mode-card:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: rgba(46,197,255,.4);
  box-shadow: 0 16px 40px rgba(0,0,0,.35);
}
.menu-kicker {
  display: block; font-size: 0.72rem; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--lime); margin-bottom: 0.35rem;
}
.menu-card strong, .mode-card strong {
  display: block; font-size: 1.15rem; margin-bottom: 0.25rem;
}
.menu-desc, .mode-card p {
  margin: 0; color: var(--muted); font-size: 0.9rem;
}
.mode-list { display: grid; gap: 0.75rem; margin-top: 1rem; }
.mode-card.disabled, .mode-card:disabled {
  opacity: 0.45; cursor: not-allowed; transform: none;
}
.mode-badge {
  display: inline-block; margin-bottom: 0.45rem;
  font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase;
  padding: 0.2rem 0.5rem; border-radius: 999px; border: 1px solid var(--line); color: var(--muted);
}
.mode-badge.cyan { color: var(--cyan); border-color: rgba(46,197,255,.4); }
.mode-badge.lime { color: var(--lime); border-color: rgba(198,255,74,.4); }
.back-link {
  border: 0; background: transparent; color: var(--muted);
  padding: 0; margin: 0 0 0.85rem; cursor: pointer; font-weight: 600;
}
.back-link:hover { color: var(--cyan); }
.setup-panel {
  margin-top: 1rem; padding: 1.15rem;
  border: 1px solid var(--line); border-radius: 16px;
  background: rgba(8,13,19,.85);
  backdrop-filter: blur(10px);
}
.stack-gap { display: grid; gap: 0.9rem; }
.switch-row {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: 0.35rem 0;
}
.switch-row input { width: auto; accent-color: var(--cyan); }
.rail-block.pad {
  padding: 1rem 1.05rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(8,13,19,.45);
}
.recent { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.35rem; }
.recent-btn {
  border: 1px solid var(--line); background: rgba(5,10,14,.7);
  color: var(--cyan); border-radius: 999px; padding: 0.35rem 0.7rem;
  font-size: 0.82rem; cursor: pointer;
}
.results-view { padding-top: 2rem; }
input[type="range"] { accent-color: var(--cyan); padding: 0; height: 1.4rem; }

.coach-panel {
  position: absolute;
  left: 0.75rem;
  right: 0.75rem;
  bottom: 0.75rem;
  z-index: 4;
  padding: 0.7rem 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(5, 10, 14, 0.82);
  backdrop-filter: blur(8px);
  max-width: 420px;
}
.coach-panel.ok { border-color: rgba(77, 255, 176, 0.45); }
.coach-panel.bad { border-color: rgba(255, 107, 122, 0.5); }
.coach-panel strong { display: block; margin-bottom: 0.35rem; font-size: 0.92rem; }
.coach-toggle {
  display: flex; justify-content: space-between; align-items: center; gap: 0.5rem;
  width: 100%; padding: 0; border: 0; background: none; color: inherit;
  text-align: left; cursor: pointer;
}
.coach-chevron { color: var(--muted); transition: transform 0.2s var(--ease); }
.coach-panel:not(.collapsed) .coach-chevron { transform: rotate(90deg); }
.coach-panel.collapsed { padding: 0.5rem 0.75rem; }
.coach-panel.collapsed strong { margin-bottom: 0; }
.coach-panel.collapsed .coach-tips,
.coach-panel.collapsed .coach-detail { display: none; }
.coach-tips {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: 0.8rem;
}
.coach-tips li { margin: 0.15rem 0; }
#btn-ready:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* —— Responsive: phones + tablets —— */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}
.shell {
  width: min(1120px, calc(100% - 1.5rem));
  padding:
    max(0.85rem, env(safe-area-inset-top))
    0
    calc(2.5rem + env(safe-area-inset-bottom));
}
.btn, .menu-card, .mode-card, .auth-tab, .icon-btn, .back-link, .recent-btn {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
input, select, .btn {
  min-height: 44px;
}
.icon-btn {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}

.match-view {
  padding-bottom: 0.5rem;
}
.match-bar-copy {
  min-width: 0;
  flex: 1 1 12rem;
}
.match-bar-copy .section-title {
  font-size: clamp(1.55rem, 5vw, 2.4rem);
  overflow-wrap: anywhere;
}
.match-bar-copy .muted {
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}
.match-actions {
  flex: 1 1 auto;
  justify-content: flex-end;
}
.opponent-panel {
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(8, 13, 19, 0.55);
}
.toast {
  word-break: break-word;
  overflow-wrap: anywhere;
  font-size: 0.92rem;
  max-height: 40vh;
  overflow: auto;
}

/* Large phones / small tablets portrait */
@media (max-width: 900px) {
  .match-layout {
    grid-template-columns: 1fr;
  }
  .stage {
    width: 100%;
    aspect-ratio: auto;
    min-height: min(62dvh, 720px);
    max-height: calc(100dvh - 11rem);
  }
  .opponent-panel {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 0.75rem;
    align-items: center;
  }
  .opponent-panel .block-title {
    grid-column: 1 / -1;
    margin-bottom: 0;
  }
  .opponent-panel .skel {
    aspect-ratio: 16 / 10;
    max-height: 140px;
  }
  .opponent-panel .fineprint {
    margin: 0;
  }
}

/* Phones */
@media (max-width: 720px) {
  .shell {
    width: calc(100% - 1rem);
    padding-top: max(0.55rem, env(safe-area-inset-top));
    padding-bottom: calc(1.25rem + env(safe-area-inset-bottom));
  }
  .topbar {
    gap: 0.5rem;
    margin-bottom: 0.85rem;
  }
  .logo-text { font-size: 1.25rem; }
  .logo-mark { width: 24px; height: 24px; }
  .pill {
    max-width: 28vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .logo-hero {
    font-size: clamp(3.2rem, 18vw, 5rem);
  }
  .hero-mark { width: 72px; height: 72px; }
  .atmosphere {
    background-image: url("/assets/atmos/arena-9x16.jpg");
  }
  .lede {
    font-size: 0.95rem;
    max-width: none;
  }
  .section-title {
    font-size: clamp(1.55rem, 7vw, 2rem);
  }
  .menu-grid {
    grid-template-columns: 1fr;
  }
  .menu-card, .mode-card {
    padding: 1rem;
  }
  .forge-grid {
    grid-template-columns: 1fr;
  }
  .inline-actions {
    flex-direction: column;
  }
  .inline-actions .btn {
    width: 100%;
  }
  .auth-view {
    min-height: calc(100dvh - 5.5rem);
    align-items: start;
    padding-top: 0.25rem;
  }
  .login-panel {
    padding: 0.9rem;
  }

  .match-view {
    display: flex;
    flex-direction: column;
    min-height: calc(100dvh - 4.5rem);
  }
  .match-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
    margin-bottom: 0.65rem;
  }
  .match-actions {
    display: grid;
    grid-template-columns: 1fr 1.4fr 0.7fr;
    gap: 0.45rem;
    width: 100%;
    position: sticky;
    bottom: calc(0.45rem + env(safe-area-inset-bottom));
    z-index: 8;
    order: 3;
    padding: 0.45rem;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: rgba(6, 10, 14, 0.92);
    backdrop-filter: blur(12px);
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.35);
  }
  .match-view .match-bar {
    display: contents;
  }
  .match-bar-copy {
    order: 1;
  }
  .match-layout {
    order: 2;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    min-height: 0;
  }
  .stage {
    flex: 1 1 auto;
    min-height: min(40dvh, 480px);
    max-height: none;
    height: min(54dvh, calc(100dvh - 16rem));
    border-radius: 14px;
  }
  .stage-hud {
    padding: 0.65rem;
    gap: 0.25rem;
  }
  .score {
    font-size: clamp(2rem, 11vw, 2.8rem);
  }
  .score-label {
    font-size: 0.62rem;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .vs {
    font-size: 1.05rem;
    padding-top: 0.35rem;
  }
  .coach-panel {
    left: 0.5rem;
    right: 0.5rem;
    bottom: 0.5rem;
    max-width: none;
    padding: 0.55rem 0.65rem;
  }
  .coach-panel strong {
    font-size: 0.82rem;
  }
  .coach-tips {
    font-size: 0.72rem;
    padding-left: 0.95rem;
    max-height: 4.6em;
    overflow: hidden;
  }
  .coach-panel .fineprint {
    font-size: 0.72rem;
    margin-top: 0.2rem;
  }
  .opponent-panel {
    grid-template-columns: 1fr;
    padding: 0.65rem 0.75rem;
  }
  .opponent-panel .skel {
    max-height: 110px;
  }
  .countdown {
    font-size: clamp(4rem, 28vw, 7rem);
  }
  .results-view {
    padding-top: 1.25rem;
  }
  .results-view .cta-row {
    display: grid;
    grid-template-columns: 1fr;
  }
  .results-view .cta-row .btn {
    width: 100%;
  }
}

/* Tiny phones */
@media (max-width: 380px) {
  .match-actions {
    grid-template-columns: 1fr 1fr;
  }
  #btn-manual-rep {
    grid-column: 1 / -1;
  }
  .pill { display: none; }
  .stage {
    height: min(62dvh, calc(100dvh - 12rem));
  }
}

/* Phones landscape — keep camera usable */
@media (max-width: 960px) and (orientation: landscape) and (max-height: 520px) {
  .shell {
    width: calc(100% - 1rem);
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
  }
  .topbar { margin-bottom: 0.45rem; }
  .match-view .match-bar { display: flex; flex-wrap: wrap; }
  .match-actions {
    position: static;
    order: 0;
    display: flex;
    width: auto;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
  }
  .match-layout {
    display: grid;
    grid-template-columns: 1.5fr 0.7fr;
    gap: 0.55rem;
  }
  .stage {
    height: calc(100dvh - 6.5rem);
    min-height: 0;
    max-height: none;
  }
  .coach-tips { display: none; }
  .opponent-panel {
    display: flex;
    flex-direction: column;
    height: calc(100dvh - 6.5rem);
  }
  .opponent-panel .skel {
    flex: 1;
    max-height: none;
    aspect-ratio: auto;
  }
}

/* Tablets portrait */
@media (min-width: 721px) and (max-width: 1100px) {
  .menu-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .match-layout {
    grid-template-columns: 1fr;
  }
  .stage {
    min-height: min(58dvh, 760px);
    aspect-ratio: 16 / 11;
  }
  .opponent-panel {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 1rem;
    align-items: center;
  }
  .opponent-panel .block-title {
    grid-column: 1 / -1;
  }
}

/* Prefer taller stage when device is phone-like */
@media (max-width: 720px) and (orientation: portrait) {
  .stage video,
  .stage canvas#overlay {
    object-fit: cover;
    object-position: center;
  }
}

.spec-badge {
  margin: 0.35rem 0 0;
  color: var(--lime);
  font-size: 0.82rem;
  font-weight: 600;
}
.spec-dual {
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(8, 13, 19, 0.55);
}
.spec-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}
body.is-spectator .stage {
  /* spectators still see score HUD; camera blank is fine */
  min-height: 180px;
  height: auto;
  aspect-ratio: 16 / 9;
  max-height: 280px;
}
body.is-spectator .stage video,
body.is-spectator .stage canvas#overlay,
body.is-spectator #coach-panel {
  display: none !important;
}
body.is-spectator .opponent-panel.player-only {
  display: none !important;
}
body.is-spectator .spec-dual {
  display: block !important;
}
.opp-media {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #05090e;
}
.opp-cam {
  display: block;
  width: 100%;
  aspect-ratio: 8 / 5;
  object-fit: cover;
  background: #000;
}
.opp-cam.hidden { display: none !important; }
.opp-media.has-video .skel {
  position: absolute;
  inset: auto 0.45rem 0.45rem auto;
  width: 38%;
  aspect-ratio: 8 / 5;
  opacity: 0.92;
  border: 1px solid rgba(198,255,74,.35);
  pointer-events: none;
}
.video-gate {
  margin-top: 0.65rem;
  display: grid;
  gap: 0.55rem;
}
.video-switch {
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(5, 10, 14, 0.45);
}
.video-actions { margin: 0; }
#video-status { margin: 0; color: var(--cyan); }

/* Ragdoll Arena */
.ragdoll-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.rd-stat {
  display: grid;
  gap: 0.35rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(5, 10, 14, 0.45);
}
.rd-stat span { font-size: 0.75rem; color: var(--muted); letter-spacing: 0.06em; }
.rd-stat strong { font-size: 1.35rem; font-family: var(--font-display, inherit); }
.rd-bar {
  height: 6px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}
.rd-bar i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--cyan), var(--lime));
  transition: width 0.35s var(--ease, ease);
}
#rd-canvas {
  width: 100%;
  max-width: 1280px;
  height: auto;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #070b12;
  display: block;
  margin: 0.55rem 0 0.75rem;
  touch-action: none;
  cursor: crosshair;
}
.ragdoll-play-wrap { padding-bottom: 1rem; }
.rd-controls {
  margin-top: 0.25rem;
  flex-wrap: wrap;
  align-items: end;
}
.rd-tier-field {
  min-width: 9rem;
  margin: 0;
}
.rd-tier-field span { font-size: 0.75rem; }
.rd-extra summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--cyan);
  list-style: none;
}
.rd-extra summary::-webkit-details-marker { display: none; }
.rd-log {
  max-height: 160px;
  overflow: auto;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.35);
  font-size: 0.78rem;
  line-height: 1.35;
  color: #c5d4e4;
  white-space: pre-wrap;
}
.rd-champs {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
}
.rd-champs li {
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(5, 10, 14, 0.35);
}
@media (max-width: 720px) {
  .ragdoll-stats { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .spec-grid { grid-template-columns: 1fr; }
  body.is-spectator .stage {
    min-height: 140px;
    max-height: 200px;
    height: auto;
  }
  .opp-media.has-video .skel {
    width: 34%;
  }
}

/* Studio */
.menu-card-studio {
  border-color: rgba(232, 180, 200, 0.35);
  background: linear-gradient(145deg, rgba(232, 180, 200, 0.12), rgba(10, 16, 24, 0.5));
}
.studio-view .studio-eyebrow { color: #e8b4c8; }
.studio-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
  margin-top: 1rem;
}
@media (min-width: 720px) {
  .studio-grid { grid-template-columns: 1fr 1fr; }
  .studio-card-wide { grid-column: 1 / -1; }
}
.studio-h {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  font-family: var(--font-display, inherit);
}
.studio-bar { margin: 0.55rem 0; height: 8px; }
.avatar-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin: 0.75rem 0;
}
.avatar-swatch {
  appearance: none;
  border: 2px solid transparent;
  border-radius: 14px;
  padding: 0.55rem 0.7rem 0.55rem 0.55rem;
  background: rgba(5, 10, 14, 0.45);
  color: var(--text, #e8eef5);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8rem;
}
.avatar-swatch::before { display: none; }
.avatar-swatch-img {
  width: 2.4rem;
  height: 2.4rem;
  object-fit: contain;
  border-radius: 8px;
}
.empty-illu {
  display: block;
  width: min(220px, 70%);
  height: auto;
  margin: 0 auto 0.85rem;
  object-fit: contain;
  filter: drop-shadow(0 12px 28px rgba(0,0,0,.45));
}
.empty-illu-sm { width: min(160px, 55%); }
.empty-state {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 0.45rem;
  padding: 0.75rem 0.5rem 1rem;
}
.empty-state img {
  width: 140px;
  height: auto;
}
.medal-sm {
  width: 22px;
  height: 22px;
  object-fit: contain;
  vertical-align: -5px;
  margin-right: 0.35rem;
}
.avatar-swatch.active {
  border-color: rgba(232, 180, 200, 0.7);
}

/* Monthly cup bracket */
.cup-bracket {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.35rem;
}
.cup-round h5 {
  margin: 0 0 0.35rem;
  font-size: 0.85rem;
  color: var(--cyan, #2ec5ff);
}
.cup-match {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.55rem;
  align-items: center;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(5, 10, 14, 0.4);
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
}
.cup-match em { opacity: 0.55; font-style: normal; }
.cup-match strong { color: #b6ff3b; }
.cup-match.done { border-color: rgba(182,255,59,0.25); }

/* Arena PvP */
.pvp-result {
  margin-top: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(0,0,0,0.22);
  font-size: 0.92rem;
  line-height: 1.4;
}
.pvp-result.ok { border-color: rgba(182,255,59,0.35); }
.pvp-result.done { border-color: rgba(255,255,255,0.12); }
.pvp-log {
  margin-top: 0.5rem;
  font-size: 0.82rem;
  opacity: 0.85;
  font-family: ui-monospace, monospace;
}

.install-card {
  margin-top: 1.15rem;
  padding: 1rem 1.1rem 1.1rem;
  border: 1px solid rgba(198, 255, 74, 0.28);
  border-radius: 16px;
  background: linear-gradient(160deg, rgba(198,255,74,.08), rgba(8,14,12,.75));
}
.install-card strong {
  display: block;
  margin: 0.15rem 0 0.35rem;
  font-size: 1.05rem;
}
.install-card .btn { margin-top: 0.75rem; }
.install-card-plain {
  margin-top: 0.5rem;
  background: transparent;
  border-style: dashed;
}
body.is-installed .is-installed-only { display: block !important; }
@media (display-mode: standalone) {
  .install-card, #menu-install { display: none !important; }
}
