:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ink: #f7f3e8;
  --muted: #aeb8c6;
  --panel: rgba(6, 16, 31, 0.78);
  --panel-strong: rgba(5, 13, 26, 0.94);
  --blue: #38a3ff;
  --red: #ff4d5f;
  --gold: #f6bd43;
  --green: #31d995;
}

* { box-sizing: border-box; }

html, body, #app, #game {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: #07111f;
  color: var(--ink);
  user-select: none;
}

button { font: inherit; }

#game canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

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

.glass,
.glass-heavy {
  background: rgba(15, 23, 42, 0.74);
  border: 1px solid rgba(255,255,255,.1);
  box-shadow: 0 12px 34px rgba(0,0,0,.24);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.glass-heavy {
  background: linear-gradient(145deg, rgba(13,27,49,.97), rgba(5,13,26,.96));
  border-color: rgba(246,189,67,.22);
  box-shadow: 0 30px 90px rgba(0,0,0,.55), inset 0 1px rgba(255,255,255,.06);
}

.match-meta {
  position: absolute;
  top: 16px;
  left: 16px;
  width: 190px;
  padding: 8px 12px;
  border-radius: 10px;
}

.eyebrow {
  display: block;
  color: var(--muted);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .1em;
}

.match-meta strong {
  display: block;
  margin-top: 2px;
  color: var(--gold);
  font-size: 13px;
}

.carrier {
  display: block;
  margin: 8px -2px -2px;
  padding: 7px 10px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 9px;
  background: rgba(15,23,42,.78);
  color: #e5edf7;
  font-size: 12px;
  font-weight: 800;
}

.scoreboard {
  position: absolute;
  top: 16px;
  left: 50%;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
  min-width: 286px;
  padding: 8px 16px;
  border-radius: 14px;
  transform: translateX(-50%);
}

.team { display: flex; align-items: center; gap: 7px; font-size: 12px; }
.team-red { justify-content: flex-end; }
.team i { width: 9px; height: 9px; border-radius: 50%; box-shadow: 0 0 14px currentColor; }
.team-blue i { color: var(--blue); background: var(--blue); }
.team-red i { color: var(--red); background: var(--red); }
.team b { font-size: 24px; line-height: 1; }

.clock { text-align: center; min-width: 68px; }
.clock strong { display: block; color: var(--gold); font-size: 20px; letter-spacing: .03em; }
.clock span { display: block; color: #738196; font-size: 8px; font-weight: 900; letter-spacing: .18em; }

.top-actions {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  gap: 6px;
  pointer-events: auto;
}

.fps, .icon-button {
  min-height: 34px;
  padding: 0 11px;
  border-radius: 10px;
  color: #dce6f2;
  font-size: 11px;
  font-weight: 800;
}

.fps { display: grid; place-items: center; color: var(--green); }
.icon-button { cursor: pointer; transition: transform .18s, border-color .18s, background .18s; }
.icon-button:hover { transform: translateY(-2px); border-color: rgba(246,189,67,.45); background: rgba(17,34,58,.9); }
.icon-button.square { width: 38px; padding: 0; font-size: 16px; }
.utility-hidden { display: none !important; }

.stamina-panel {
  position: absolute;
  left: 16px;
  bottom: 18px;
  width: min(210px, 34vw);
}

.stamina-copy { display: flex; justify-content: space-between; margin-bottom: 7px; font-size: 9px; letter-spacing: .08em; }
.stamina-copy span { color: var(--muted); font-weight: 800; }
.stamina-copy b { display: none; }
.meter { height: 7px; overflow: hidden; background: rgba(255,255,255,.16); border-radius: 999px; }
.meter i { display: block; width: 100%; height: 100%; background: linear-gradient(90deg, #24c887, #61f2ad); box-shadow: 0 0 18px rgba(49,217,149,.55); border-radius: inherit; transition: width .15s; }

.controls {
  position: absolute;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 6px;
  width: 246px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.controls > div { display: flex; justify-content: flex-end; align-items: center; gap: 8px; color: #eef4fb; font-size: 11px; font-weight: 750; text-shadow: 0 1px 8px rgba(0,0,0,.55); }
kbd { display: inline-grid; place-items: center; min-width: 32px; padding: 3px 7px; color: #fff; background: rgba(15,23,42,.78); border: 1px solid rgba(255,255,255,.18); border-radius: 5px; font: 800 10px/1.2 Inter, ui-sans-serif, system-ui, sans-serif; box-shadow: inset 0 -2px rgba(0,0,0,.2), 0 4px 12px rgba(0,0,0,.18); }

.objective {
  position: absolute;
  right: 18px;
  bottom: 96px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  color: #e6edf5;
  font-size: 12px;
  font-weight: 900;
  text-shadow: 0 2px 10px rgba(0,0,0,.65);
  transform: none;
  transition: opacity .2s;
}

.goal-banner {
  position: absolute;
  top: 32%;
  left: 50%;
  color: var(--gold);
  font-size: clamp(46px, 8vw, 110px);
  font-weight: 950;
  letter-spacing: 0;
  text-shadow: 0 8px 40px rgba(0,0,0,.48), 0 0 35px rgba(246,189,67,.32);
  transform: translate(-50%, -50%) scale(.75);
  opacity: 0;
  transition: opacity .2s, transform .28s cubic-bezier(.2,.8,.2,1.3);
}
.goal-banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(2, 6, 12, .58);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  transition: opacity .25s;
}

.overlay.hidden { opacity: 0; pointer-events: none; visibility: hidden; }

.intro-card,
.pause-card,
.settings-card {
  width: min(610px, 94vw);
  padding: clamp(26px, 5vw, 52px);
  border-radius: 28px;
  text-align: center;
}

.pause-card {
  width: min(320px, 92vw);
  padding: 28px 24px;
  border-radius: 16px;
}
.settings-card { width: min(560px, 94vw); }
.online-card { width: min(540px, 94vw); padding: clamp(28px, 5vw, 48px); border-radius: 28px; text-align: center; }
.online-description { margin: 8px auto 22px; color: var(--muted); line-height: 1.65; }
.invite-box { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 12px; }
.invite-box input { min-width: 0; min-height: 46px; padding: 0 12px; border: 1px solid rgba(255,255,255,.12); border-radius: 9px; color: #fff; background: #0d1c30; outline: none; }
.invite-box button { min-width: 105px; border: 0; border-radius: 9px; color: #1f1605; background: var(--gold); font-weight: 900; cursor: pointer; }
.online-status { min-height: 20px; margin: 15px 0 2px; color: #8ddff7; font-size: 12px; }
.online-status.error { color: #ff8b98; }
.hidden-control { display: none !important; }
.setup-screen {
  place-items: stretch;
  padding: 0;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(4,8,18,.9), rgba(4,8,18,.5) 42%, rgba(4,8,18,.82)),
    radial-gradient(circle at 26% 16%, rgba(246,189,67,.16), transparent 28%),
    linear-gradient(145deg, #0d1421 0%, #232f35 42%, #070a12 100%);
}
.setup-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(135deg, transparent 0 38%, rgba(255,255,255,.12) 39% 41%, transparent 42%),
    linear-gradient(30deg, transparent 0 55%, rgba(255,255,255,.08) 56% 58%, transparent 59%),
    repeating-linear-gradient(90deg, rgba(255,255,255,.05) 0 1px, transparent 1px 68px);
  opacity: .45;
}
.setup-panel {
  width: 100%;
  min-height: 100%;
  color: #fff;
}
.setup-menu {
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  padding: 28px;
  text-align: center;
}
.menu-mark { font-size: 50px; filter: drop-shadow(0 14px 30px rgba(0,0,0,.5)); }
.setup-menu h1 {
  margin: 0;
  font-size: clamp(38px, 6vw, 76px);
  line-height: 1;
}
.menu-lead {
  max-width: 620px;
  margin: 0 0 10px;
  color: #e7edf5;
  font-size: clamp(16px, 2.1vw, 24px);
  font-weight: 700;
}
.menu-actions {
  display: grid;
  gap: 10px;
  width: min(310px, 86vw);
}
.language-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  color: #aeb8c6;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}
.lang-button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 9px;
  color: #eef4fb;
  background: rgba(255,255,255,.07);
  cursor: pointer;
}
.lang-button.is-active { border-color: rgba(246,189,67,.55); color: var(--gold); }
.setup-stage {
  display: grid;
  grid-template-columns: minmax(320px, 41vw) 1fr;
  grid-template-rows: 1fr auto;
  gap: 24px;
  padding: 34px 20px 20px;
}
.showcase {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 14px;
  min-width: 0;
}
.showcase h2,
.setup-match h2 {
  margin: 0;
  font-size: clamp(30px, 4.5vw, 46px);
  line-height: 1.05;
}
.preview-box {
  position: relative;
  min-height: 430px;
  overflow: hidden;
  border-radius: 0 0 20px 20px;
  background:
    radial-gradient(ellipse at center bottom, rgba(246,189,67,.2), transparent 55%),
    linear-gradient(180deg, rgba(255,255,255,.05), rgba(3,7,16,.68));
  box-shadow: inset 0 -90px 80px rgba(2,6,16,.56);
}
.flag-ribbon {
  position: absolute;
  top: 0;
  left: 12%;
  width: 210px;
  height: 150px;
  background: linear-gradient(135deg, #b51224, #e33a40);
  clip-path: polygon(0 0, 100% 0, 82% 100%, 0 80%);
  opacity: .82;
}
.rider-figure {
  position: absolute;
  left: 50%;
  bottom: 44px;
  width: 172px;
  height: 360px;
  transform: translateX(-50%);
}
.rider-head {
  position: absolute;
  top: 26px;
  left: 54px;
  width: 64px;
  height: 72px;
  border-radius: 44% 44% 48% 48%;
  background: #c69265;
  box-shadow: 0 -18px 0 #f5f0df;
}
.rider-body {
  position: absolute;
  top: 106px;
  left: 24px;
  display: grid;
  place-items: center;
  width: 124px;
  height: 146px;
  border-radius: 22px 22px 12px 12px;
  color: #fff;
  background: linear-gradient(160deg, #a91526, #e63745);
  font-size: 42px;
  font-weight: 950;
  box-shadow: inset 0 0 0 5px rgba(255,255,255,.08), 0 18px 40px rgba(0,0,0,.42);
}
.rider-legs {
  position: absolute;
  left: 50px;
  bottom: 0;
  width: 70px;
  height: 126px;
  border-radius: 0 0 18px 18px;
  background: linear-gradient(90deg, #101923 0 38%, transparent 38% 62%, #101923 62%);
}
.name-field {
  display: grid;
  gap: 7px;
  color: #aeb8c6;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}
.name-field input {
  min-height: 44px;
  padding: 0 13px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 9px;
  color: #fff;
  background: rgba(255,255,255,.07);
  font: 700 14px/1 Inter, ui-sans-serif, system-ui, sans-serif;
  outline: none;
}
.option-grid {
  align-self: center;
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap: 12px;
  min-width: 0;
}
.rider-grid .stat-card:last-child,
.horse-grid .stat-card:last-child { grid-column: 1 / 2; }
.stat-card {
  display: grid;
  grid-template-columns: 54px 1fr auto;
  gap: 7px 12px;
  min-height: 128px;
  padding: 18px 20px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 14px;
  color: #edf4fb;
  background: rgba(255,255,255,.075);
  text-align: left;
  cursor: pointer;
  box-shadow: inset 0 1px rgba(255,255,255,.05);
}
.stat-card.is-selected {
  border-color: rgba(246,189,67,.78);
  background: linear-gradient(135deg, rgba(246,189,67,.16), rgba(255,255,255,.055));
  box-shadow: 0 0 0 1px rgba(246,189,67,.15), 0 16px 38px rgba(0,0,0,.2);
}
.stat-card b {
  grid-row: 1 / 3;
  color: var(--gold);
  font-size: 28px;
  line-height: 1;
}
.stat-card strong { font-size: 15px; }
.dots::before { content: "● ● ●"; font-size: 15px; letter-spacing: .16em; }
.kgz::before { color: #ff4055; text-shadow: 17px 0 #f6bd43, 34px 0 #fff; }
.kaz::before, .uzb::before, .rus::before { color: #4387ff; text-shadow: 17px 0 #f6bd43, 34px 0 #50d88b; }
.tkm::before { color: #50d88b; text-shadow: 17px 0 #fff, 34px 0 #ff4055; }
.stat-card > span:not(.dots) {
  grid-column: 2 / 4;
  display: grid;
  grid-template-columns: 90px 1fr 28px;
  align-items: center;
  gap: 10px;
  color: #aeb8c6;
  font-size: 11px;
}
.stat-card i {
  height: 10px;
  background:
    linear-gradient(90deg, var(--gold) 0 calc(var(--v) * 1%), rgba(10,12,18,.75) calc(var(--v) * 1%) 100%),
    repeating-linear-gradient(90deg, transparent 0 5px, rgba(255,255,255,.22) 5px 7px);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
}
.stat-card em {
  color: #f5f7fb;
  font-style: normal;
  text-align: right;
}
.horse-preview {
  display: grid;
  place-items: center;
}
.preview-horse {
  position: relative;
  width: 250px;
  height: 300px;
  filter: drop-shadow(0 24px 45px rgba(0,0,0,.5));
}
.preview-horse span:nth-child(1) {
  position: absolute;
  left: 34px;
  top: 86px;
  width: 170px;
  height: 90px;
  border-radius: 48% 44% 38% 42%;
  background: #9c6542;
}
.preview-horse span:nth-child(2) {
  position: absolute;
  left: 174px;
  top: 54px;
  width: 58px;
  height: 78px;
  border-radius: 44% 44% 36% 36%;
  background: #9c6542;
  transform: rotate(-18deg);
}
.preview-horse span:nth-child(3) {
  position: absolute;
  left: 28px;
  top: 102px;
  width: 44px;
  height: 118px;
  border-radius: 70% 30% 20% 20%;
  background: #211712;
  transform: rotate(18deg);
}
.preview-horse span:nth-child(4),
.preview-horse span:nth-child(5) {
  position: absolute;
  top: 164px;
  width: 20px;
  height: 110px;
  border-radius: 999px;
  background: #5d3929;
}
.preview-horse span:nth-child(4) { left: 78px; }
.preview-horse span:nth-child(5) { left: 156px; }
.horse-card b {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(246,189,67,.45);
  border-radius: 50%;
  font-size: 26px;
}
.setup-nav {
  grid-column: 1 / -1;
  display: flex;
  gap: 12px;
  padding-top: 18px;
  border-top: 1px solid rgba(255,255,255,.1);
}
.setup-nav button {
  width: auto;
  min-width: 118px;
  padding: 0 28px;
}
.setup-match {
  width: min(990px, 92vw);
  min-height: auto;
  place-self: center;
  display: grid;
  gap: 20px;
}
.setup-native-select { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.setup-status { display: none; }
.setup-group {
  display: grid;
  gap: 9px;
}
.setup-group > span {
  color: #aeb8c6;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .18em;
  text-transform: uppercase;
}
.segmented-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}
.segmented-row button {
  min-height: 48px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 11px;
  color: #eef4fb;
  background: rgba(255,255,255,.07);
  font-weight: 800;
  cursor: pointer;
}
.segmented-row button.is-selected {
  border-color: rgba(246,189,67,.8);
  color: #fff;
  background: linear-gradient(135deg, rgba(246,189,67,.2), rgba(255,255,255,.06));
}
.segmented-row small {
  display: block;
  margin-top: 3px;
  color: #aeb8c6;
  font-size: 10px;
}
.math-card {
  display: grid;
  gap: 14px;
  padding: 22px 24px;
  border: 1px solid rgba(246,189,67,.22);
  border-radius: 18px;
  background: rgba(246,189,67,.08);
}
.math-card h3 {
  margin: 0;
  color: var(--gold);
  font-size: 16px;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.math-card small { color: #bcc7d4; }

.setup-screen,
.setup-screen * {
  letter-spacing: 0;
}

.setup-screen {
  overflow: auto;
  background:
    linear-gradient(90deg, rgba(5, 8, 14, .92) 0%, rgba(5, 8, 14, .74) 38%, rgba(5, 8, 14, .32) 72%, rgba(5, 8, 14, .72) 100%),
    linear-gradient(0deg, rgba(5, 8, 14, .94), rgba(5, 8, 14, .02) 54%),
    url("/at-chabysh-bg.png") center / cover no-repeat;
}

.setup-screen::before {
  background:
    linear-gradient(90deg, rgba(246,189,67,.18) 0 1px, transparent 1px 100%),
    linear-gradient(0deg, rgba(255,255,255,.08) 0 1px, transparent 1px 100%);
  background-size: 72px 72px;
  mask-image: linear-gradient(90deg, transparent, #000 20%, #000 80%, transparent);
  opacity: .26;
}

.setup-menu {
  display: grid;
  grid-template-columns: minmax(330px, 430px) minmax(420px, 1fr);
  align-items: center;
  justify-items: stretch;
  gap: clamp(22px, 4vw, 74px);
  padding: clamp(28px, 5vw, 76px);
  text-align: left;
}

.menu-copy {
  display: grid;
  align-content: center;
  gap: 16px;
  max-width: 430px;
}

.menu-badge {
  width: max-content;
  padding: 7px 10px;
  border: 1px solid rgba(246,189,67,.48);
  border-radius: 8px;
  color: var(--gold);
  background: rgba(8, 12, 20, .72);
  font-size: 11px;
  font-weight: 900;
}

.setup-menu h1 {
  max-width: 420px;
  margin: 0;
  color: #fff;
  font-size: clamp(52px, 7vw, 100px);
  line-height: .94;
  text-shadow: 0 16px 40px rgba(0,0,0,.45);
}

.menu-lead {
  max-width: 360px;
  margin: 0;
  color: #e8edf3;
  font-size: clamp(15px, 1.5vw, 19px);
  font-weight: 750;
  line-height: 1.45;
}

.menu-actions {
  display: grid;
  gap: 9px;
  width: min(300px, 100%);
  margin-top: 8px;
}

.primary-button,
.secondary-button,
.online-button,
.lang-button,
.segmented-row button {
  border-radius: 8px;
}

.primary-button,
.secondary-button,
.online-button {
  min-height: 48px;
  letter-spacing: 0;
}

.primary-button {
  color: #1b1304;
  background: linear-gradient(135deg, #ffe082, #f5a91f);
  box-shadow: 0 14px 32px rgba(245,169,31,.22);
}

.secondary-button {
  margin-top: 0;
  color: #f3f7fb;
  background: rgba(9, 14, 24, .64);
  border: 1px solid rgba(255,255,255,.12);
}

.language-row {
  justify-content: flex-start;
  margin-top: 6px;
  text-transform: none;
}

.lang-button {
  color: #eaf0f7;
  background: rgba(9,14,24,.62);
}

.menu-visual {
  position: relative;
  min-height: min(620px, 76vh);
  display: grid;
  align-items: end;
  overflow: hidden;
}

.menu-visual::before {
  content: "";
  position: absolute;
  left: 8%;
  right: 0;
  bottom: 18px;
  height: 34%;
  border: 1px solid rgba(246,189,67,.22);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(246,189,67,.14), rgba(20,90,68,.2)),
    rgba(8,12,18,.38);
  transform: skewX(-10deg);
}

.menu-visual img {
  position: relative;
  z-index: 1;
  width: min(900px, 66vw);
  max-width: none;
  justify-self: end;
  filter: drop-shadow(0 28px 46px rgba(0,0,0,.48));
  transform: translateX(8%);
}

.arena-label {
  position: absolute;
  right: 36px;
  bottom: 36px;
  z-index: 2;
  padding: 9px 12px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 8px;
  color: rgba(255,255,255,.82);
  background: rgba(9,14,24,.68);
  font-size: 12px;
  font-weight: 950;
}

.setup-stage {
  grid-template-columns: minmax(320px, 38vw) minmax(520px, 1fr);
  gap: clamp(14px, 2.4vw, 34px);
  min-height: 100dvh;
  padding: clamp(16px, 2.6vw, 30px);
}

.showcase h2,
.setup-match h2 {
  color: #fff;
  font-size: clamp(28px, 3.35vw, 44px);
  text-shadow: 0 12px 30px rgba(0,0,0,.42);
}

.preview-box {
  min-height: clamp(320px, 48vh, 430px);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.08), rgba(8,12,20,.34)),
    radial-gradient(ellipse at center bottom, rgba(246,189,67,.22), transparent 58%);
  box-shadow: inset 0 -120px 90px rgba(5,8,14,.52), 0 18px 46px rgba(0,0,0,.28);
}

.preview-rider-img,
.preview-horse-img {
  position: absolute;
  left: 50%;
  bottom: 24px;
  width: min(650px, 54vw);
  max-width: none;
  transform: translateX(-50%);
  filter: drop-shadow(0 26px 42px rgba(0,0,0,.46));
}

.preview-rider-img { width: min(650px, 54vw); }
.preview-horse-img { width: min(620px, 52vw); }

.flag-ribbon {
  top: 0;
  left: 8%;
  width: 170px;
  height: 118px;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 14px 24px rgba(0,0,0,.28);
}

.name-field input {
  border-radius: 8px;
  background: rgba(7, 12, 21, .72);
}

.option-grid {
  gap: 10px;
}

.stat-card {
  min-height: 118px;
  border-radius: 8px;
  background: rgba(8, 13, 22, .62);
  border-color: rgba(255,255,255,.13);
  box-shadow: inset 0 1px rgba(255,255,255,.05);
}

.stat-card:hover {
  border-color: rgba(246,189,67,.42);
  background: rgba(12, 18, 28, .74);
}

.stat-card.is-selected {
  border-color: rgba(246,189,67,.84);
  background:
    linear-gradient(135deg, rgba(246,189,67,.18), rgba(15,120,86,.12)),
    rgba(10, 16, 26, .72);
}

.stat-card i {
  border-radius: 2px;
  background:
    linear-gradient(90deg, var(--gold) 0 calc(var(--v) * 1%), rgba(8,12,18,.78) calc(var(--v) * 1%) 100%),
    repeating-linear-gradient(90deg, transparent 0 4px, rgba(255,255,255,.24) 4px 6px);
}

.horse-card b {
  border-radius: 8px;
  background: rgba(246,189,67,.1);
}

.setup-nav {
  border-top-color: rgba(255,255,255,.12);
}

.setup-match {
  width: min(1040px, 92vw);
  padding: clamp(20px, 3vw, 34px);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px;
  background: rgba(7, 12, 21, .56);
  box-shadow: 0 24px 70px rgba(0,0,0,.32);
}

.setup-group > span {
  letter-spacing: 0;
}

.segmented-row button {
  min-height: 48px;
  background: rgba(255,255,255,.07);
}

.segmented-row button.is-selected {
  border-color: rgba(246,189,67,.86);
  background: linear-gradient(135deg, rgba(246,189,67,.2), rgba(35,115,90,.18));
}

.math-card {
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(246,189,67,.12), rgba(18,114,86,.1));
}

.math-card h3 {
  letter-spacing: 0;
}

.brand-mark { display: grid; place-items: center; width: 64px; height: 64px; margin: 0 auto 18px; border: 1px solid rgba(246,189,67,.42); border-radius: 8px; color: var(--gold); font-size: 19px; font-weight: 950; box-shadow: 0 0 40px rgba(246,189,67,.15), inset 0 0 22px rgba(246,189,67,.08); }
.gold { color: var(--gold); }
h1 { margin: 9px 0 12px; font-size: clamp(48px, 9vw, 92px); line-height: .9; letter-spacing: 0; }
h2 { margin: 9px 0; font-size: 36px; }
.lead { max-width: 500px; margin: 0 auto; color: #b9c4d2; font-size: 14px; line-height: 1.7; }

.quick-rules { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 26px 0; }
.quick-rules article { padding: 14px 10px; background: rgba(255,255,255,.035); border: 1px solid rgba(255,255,255,.07); border-radius: 8px; }
.quick-rules b { display: block; color: var(--gold); font-size: 11px; letter-spacing: .12em; }
.quick-rules span { display: block; margin-top: 5px; color: #dce4ee; font-size: 11px; }

.team-size-picker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: -10px 0 14px;
  padding: 9px 12px 9px 16px;
  border: 1px solid rgba(246,189,67,.24);
  border-radius: 8px;
  background: rgba(246,189,67,.07);
  color: #d8e0ea;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .08em;
}
.team-size-picker select {
  min-width: 116px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid rgba(246,189,67,.38);
  border-radius: 8px;
  color: #fff;
  background: #0d1c30;
  font-weight: 900;
  outline: none;
}
.team-size-picker select:focus { border-color: var(--gold); }

.primary-button,
.secondary-button,
.online-button {
  width: 100%;
  min-height: 54px;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 900;
  letter-spacing: .08em;
  transition: transform .18s, filter .18s;
}
.primary-button { color: #1f1605; background: linear-gradient(135deg, #ffd56b, #f3a916); box-shadow: 0 16px 35px rgba(243,169,22,.22); }
.secondary-button { margin-top: 9px; color: #dfe8f2; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.08); }
.danger-button { color: #fff; background: linear-gradient(135deg, #f04f5f, #b91c2b); border: 0; box-shadow: 0 14px 30px rgba(185,28,43,.24); }
.online-button { margin-top: 9px; color: #dff9ff; background: linear-gradient(135deg, rgba(32,150,190,.28), rgba(30,95,175,.22)); border: 1px solid rgba(70,205,241,.3); }
.primary-button:hover, .secondary-button:hover, .online-button:hover { transform: translateY(-2px); filter: brightness(1.06); }
.intro-card small { display: block; margin-top: 14px; color: #778599; }
.asset-status { display: block; margin-top: 13px; color: #91a0b3; font-size: 10px; letter-spacing: .04em; }
.asset-status.ready { color: var(--green); }
.pause-icon { display: none; }
.pause-card p { color: var(--muted); line-height: 1.6; }
.pause-card h2 { margin: 0 0 10px; font-size: 26px; letter-spacing: 0; }
.pause-card .primary-button,
.pause-card .secondary-button { min-height: 44px; border-radius: 10px; letter-spacing: 0; text-transform: none; }

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 13px;
  margin: 24px 0;
  text-align: left;
}

.settings-grid label {
  display: grid;
  gap: 8px;
  padding: 13px;
  background: rgba(255,255,255,.035);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 13px;
}

.settings-grid label > span {
  color: #aeb9c7;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.settings-grid select,
.settings-grid input {
  width: 100%;
}

.settings-grid select {
  min-height: 40px;
  padding: 0 11px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px;
  color: #fff;
  background: #0d1c30;
  outline: none;
}

.settings-grid select:focus { border-color: var(--gold); }
.settings-grid input { accent-color: var(--gold); }

.mobile-controls { display: none; }

@media (max-width: 860px), (pointer: coarse) {
  .match-meta { top: 12px; left: 12px; width: 155px; padding: 10px 12px; }
  .match-meta .carrier { display: none; }
  .scoreboard { top: 12px; min-width: 260px; padding: 9px 12px; gap: 8px; }
  .team span { display: none; }
  .top-actions { top: 70px; right: 12px; }
  .fps { display: none; }
  .controls, .objective { display: none; }
  .stamina-panel { bottom: 160px; width: 180px; }
  .setup-screen { overflow-y: auto; }
  .setup-menu {
    grid-template-columns: 1fr;
    align-content: start;
    padding: 22px 14px;
  }
  .menu-copy {
    max-width: none;
  }
  .menu-visual {
    min-height: 300px;
    order: -1;
  }
  .menu-visual img {
    width: min(680px, 112vw);
    justify-self: center;
    transform: translateX(0);
  }
  .arena-label {
    right: 14px;
    bottom: 14px;
  }
  .setup-stage {
    grid-template-columns: 1fr;
    min-height: 100%;
    padding: 22px 14px;
  }
  .preview-box { min-height: 340px; }
  .preview-rider-img,
  .preview-horse-img {
    width: min(640px, 118vw);
  }
  .option-grid { grid-template-columns: 1fr; }
  .rider-grid .stat-card:last-child,
  .horse-grid .stat-card:last-child { grid-column: auto; }
  .stat-card { min-height: 118px; padding: 14px; }
  .stat-card > span:not(.dots) { grid-template-columns: 82px 1fr 26px; }
  .setup-nav {
    position: sticky;
    bottom: 0;
    padding: 12px 0 0;
    background: linear-gradient(180deg, transparent, rgba(5,8,16,.88) 24%);
  }
  .setup-match {
    width: 100%;
    padding: 22px 14px;
  }
  .segmented-row { grid-template-columns: 1fr 1fr; }
  .mobile-controls { position: fixed; inset: auto 14px 20px; z-index: 8; display: flex; justify-content: space-between; pointer-events: none; }
  .mobile-controls button { pointer-events: auto; touch-action: none; width: 54px; height: 54px; border: 1px solid rgba(255,255,255,.16); border-radius: 50%; color: #fff; background: rgba(4,13,25,.72); backdrop-filter: blur(12px); font-size: 12px; font-weight: 900; }
  .move-pad { display: grid; grid-template-columns: repeat(3, 54px); gap: 5px; }
  .move-pad button:nth-child(1) { grid-column: 2; }
  .move-pad button:nth-child(2) { grid-column: 1; grid-row: 2; }
  .move-pad button:nth-child(3) { grid-column: 2; grid-row: 2; }
  .move-pad button:nth-child(4) { grid-column: 3; grid-row: 2; }
  .action-pad { display: grid; grid-template-columns: repeat(2, 58px); gap: 7px; align-content: end; }
  .action-pad button { width: 58px; height: 58px; }
  .action-pad .accent { grid-column: 2; background: rgba(236,72,86,.82); }
}

@media (max-width: 560px) {
  .scoreboard { top: 74px; }
  .top-actions { top: 12px; }
  .match-meta { width: 140px; }
  .quick-rules { grid-template-columns: 1fr; }
  .quick-rules article { display: flex; align-items: center; gap: 12px; text-align: left; }
  .quick-rules span { margin: 0; }
  .intro-card { padding: 28px 22px; }
  .settings-grid { grid-template-columns: 1fr; }
  .setup-menu { padding: 18px 14px; }
  .setup-menu h1 { font-size: 42px; }
  .menu-lead { font-size: 16px; }
  .language-row { align-items: stretch; }
  .lang-button { width: 100%; }
  .menu-visual { min-height: 235px; }
  .preview-box { min-height: 270px; }
  .preview-rider-img,
  .preview-horse-img {
    width: min(520px, 128vw);
    bottom: 12px;
  }
  .flag-ribbon {
    width: 120px;
    height: 88px;
  }
  .segmented-row { grid-template-columns: 1fr; }
  .setup-nav button { flex: 1; min-width: 0; padding: 0 14px; }
}
