:root {
  --bg: #07070b;
  --panel: #111118;
  --panel2: #191923;
  --line: #262633;
  --text: #f5f4ff;
  --muted: #9392a8;
  --accent: #7c5cff;
  --accent2: #b9a7ff;
  --ok: #38c172;
  --danger: #ef5b7a;
  --warn: #f0b13e;
  --shadow: 0 18px 50px rgba(0,0,0,.45);
  --radius: 18px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }
body {
  background:
    radial-gradient(circle at 15% 0%, rgba(124,92,255,.18), transparent 35%),
    radial-gradient(circle at 90% 10%, rgba(239,91,122,.10), transparent 30%),
    var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
button, input { font: inherit; }
button { cursor: pointer; border: 0; color: inherit; background: none; }
a { color: var(--accent2); text-decoration: none; }
b { font-weight: 700; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13.5px; }
.error { color: var(--danger); font-size: 13px; min-height: 18px; }
.eyebrow {
  color: var(--accent2); text-transform: uppercase; letter-spacing: .14em;
  font-size: 11px; font-weight: 700; margin-bottom: 6px;
}
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

#app { min-height: 100dvh; display: flex; flex-direction: column; }
.top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line);
  background: rgba(7,7,11,.82); backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 20;
}
.brand { color: var(--text); font-weight: 800; letter-spacing: -.03em; font-size: 19px; }
.brand span { color: var(--accent2); }
.top-actions { display: flex; align-items: center; gap: 10px; }
.badge {
  padding: 5px 10px; border-radius: 999px; background: var(--panel2);
  color: var(--muted); font-size: 11.5px; font-weight: 700; letter-spacing: .04em;
}
.badge.online { color: #9df0bd; background: rgba(56,193,114,.16); }
.badge.local { color: #ffe1a1; background: rgba(240,177,62,.14); }
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: var(--panel2); font-size: 17px;
}
.ghost {
  padding: 9px 14px; border-radius: 10px; background: var(--panel2);
  color: var(--text); font-size: 13.5px; font-weight: 600;
}
.primary { background: linear-gradient(135deg, var(--accent), #9b83ff); color: #fff; }
.big { padding: 13px 20px; border-radius: 12px; font-size: 15px; font-weight: 700; }
main { flex: 1; width: 100%; }
.screen {
  width: min(1180px, 100%); margin: 0 auto; padding: 28px 20px 60px;
  animation: screen-in .2s ease-out;
}
@keyframes screen-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- главная ---------- */
.hero {
  display: grid; grid-template-columns: 1.1fr .9fr; gap: 34px;
  align-items: center; min-height: 340px; padding: 20px 0 34px;
}
.hero h1 { font-size: clamp(38px, 6vw, 66px); line-height: .96; letter-spacing: -.045em; }
.lead { color: var(--muted); max-width: 540px; margin-top: 14px; font-size: 16px; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 24px; }
.hero-actions .primary { box-shadow: 0 10px 30px rgba(124,92,255,.35); }
.hero-art {
  position: relative; height: 290px; border-radius: 28px; overflow: hidden;
  background: linear-gradient(160deg, #171528, #0b0a12 70%);
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.art-road {
  position: absolute; inset: 40px -40px;
  background: #22212d;
  transform: rotate(-14deg) skewX(-6deg);
  border: 10px solid #35334a;
  border-radius: 60px;
}
.art-road::after {
  content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 4px;
  background: repeating-linear-gradient(to bottom, #6c6890 0 22px, transparent 22px 44px);
  transform: translateX(-50%);
}
.art-car {
  position: absolute; width: 60px; height: 32px; border-radius: 10px;
  box-shadow: 0 12px 24px rgba(0,0,0,.5);
  animation: drive 5s ease-in-out infinite;
}
.art-car::before, .art-car::after {
  content: ""; position: absolute; width: 14px; height: 6px; border-radius: 3px;
  background: rgba(0,0,0,.55);
}
.art-car::before { left: 10px; top: -4px; box-shadow: 0 30px 0 rgba(0,0,0,.55); }
.art-car::after { right: 10px; top: -4px; box-shadow: 0 30px 0 rgba(0,0,0,.55); }
.art-car.c1 { background: linear-gradient(180deg, #9b83ff, #6a4ee0); left: 28%; top: 46%; animation-delay: -.2s; }
.art-car.c2 { background: linear-gradient(180deg, #ffd36b, #e09a24); left: 55%; top: 62%; animation-delay: -1.8s; }
.art-car.c3 { background: linear-gradient(180deg, #ff8ba4, #d94666); left: 68%; top: 30%; animation-delay: -3.1s; }
@keyframes drive { 50% { transform: translate(18px, -10px) rotate(-4deg); } }

.grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px; margin-top: 16px;
}
.card {
  background: linear-gradient(180deg, rgba(25,25,35,.9), rgba(17,17,24,.9));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
  box-shadow: 0 1px 0 rgba(255,255,255,.03) inset;
}
.card h3 { font-size: 15px; margin-bottom: 8px; display: flex; gap: 8px; align-items: center; }
.card .muted { margin-bottom: 10px; }
.card input {
  width: 100%; padding: 11px 13px; border-radius: 10px;
  background: var(--panel2); color: var(--text); border: 1px solid transparent;
  outline: none; text-transform: uppercase; letter-spacing: .12em;
}
.card input:focus { border-color: var(--accent); }
.card button, .card .ghost {
  padding: 10px 14px; border-radius: 10px; background: var(--panel2);
  font-size: 13.5px; font-weight: 600;
}
.card .row input { flex: 1; min-width: 110px; }
.card .row button { flex-shrink: 0; }
.card button.primary {
  background: linear-gradient(135deg, var(--accent), #9b83ff);
  color: #fff;
  box-shadow: 0 10px 26px rgba(124, 92, 255, .28);
}

.maps-strip { margin-top: 14px; }
.map-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.map-card {
  display: flex; align-items: center; gap: 14px; padding: 12px;
  border-radius: 14px; background: var(--panel2);
}
.map-card b { display: block; }
.map-card span { color: var(--muted); font-size: 12.5px; }
.map-preview { width: 96px; height: 64px; border-radius: 10px; flex-shrink: 0; position: relative; overflow: hidden; }
.map-preview::before {
  content: ""; position: absolute; inset: 12px 16px; border: 9px solid #55516f;
  border-radius: 40% 55% 45% 50%; transform: rotate(-12deg);
}
.map-card.yard .map-preview { background: #0c1119; }
.map-card.coast .map-preview { background: #0a1a22; }
.map-card.coast .map-preview::before { border-color: #4f7f8f; border-radius: 55% 40% 60% 35%; }
.map-card.mountain .map-preview { background: #152025; }
.map-card.mountain .map-preview::before { border-color: #79949b; border-radius: 48% 62% 43% 57%; }
.map-card.industrial .map-preview { background: #1b1814; }
.map-card.industrial .map-preview::before { border-color: #8a775f; border-radius: 38% 52% 61% 44%; }

.contacts { display: flex; flex-direction: column; gap: 6px; max-height: 230px; overflow-y: auto; }
.contact {
  display: flex; align-items: center; gap: 9px; padding: 7px 8px;
  border-radius: 10px; background: rgba(255,255,255,.03);
}
.contact .avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.contact .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.contact button { padding: 6px 9px; font-size: 12px; border-radius: 8px; }
.contact .call { background: rgba(56,193,114,.16); color: #8eeab4; }
.hotspot { margin-top: 10px; font-size: 13px; color: var(--muted); }
.local-name {
  display: none; flex-direction: column; gap: 5px; margin-bottom: 10px;
  font-size: 12.5px; color: var(--muted);
}
.local-name input { text-transform: none; letter-spacing: 0; }
body.local-mode .local-name { display: flex; }
.hotspot ol { padding-left: 20px; display: grid; gap: 6px; }
.hotspot b { color: var(--text); }

/* ---------- подробная инструкция ---------- */
.guide { margin-top: 16px; }
.guide-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 18px; flex-wrap: wrap; margin-bottom: 16px;
}
.guide-head h2 { font-size: clamp(24px, 4vw, 38px); letter-spacing: -.03em; margin-bottom: 8px; }
.guide-head .muted { max-width: 720px; }
.host-app-note {
  margin-top: 10px; padding: 10px 12px; border-radius: 12px;
  background: rgba(56,193,114,.12); border: 1px solid rgba(56,193,114,.35);
  color: #a9edc6; font-size: 13.5px; line-height: 1.45;
}
.host-app-note b { color: #fff; }
.guide-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px; align-items: start;
}
.guide-grid details {
  background: var(--panel2); border: 1px solid var(--line);
  border-radius: 14px; padding: 0 14px 12px;
}
.guide-grid summary {
  cursor: pointer; padding: 13px 0; font-weight: 700; font-size: 14px;
  color: var(--accent2); list-style: none;
}
.guide-grid summary::-webkit-details-marker { display: none; }
.guide-grid summary::before { content: "＋ "; color: var(--muted); }
.guide-grid details[open] summary::before { content: "− "; }
.guide-grid ol, .guide-grid ul { padding-left: 20px; display: grid; gap: 7px; font-size: 13.5px; color: var(--muted); }
.guide-grid li b { color: var(--text); }
.guide-grid code {
  background: rgba(0,0,0,.35); color: #e7e2ff; border-radius: 5px;
  padding: 1px 5px; font-size: 12px; word-break: break-all;
}
.guide-grid p { font-size: 13.5px; color: var(--muted); margin-top: 10px; }
.guide-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-top: 16px;
}
.guide-foot .muted { max-width: 650px; }
@media (max-width: 760px) {
  .guide-grid { grid-template-columns: 1fr; }
  .guide-head button { width: 100%; }
}

/* ---------- настройка ---------- */
.screen-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  margin-bottom: 18px; flex-wrap: wrap;
}
.screen-head h2 { font-size: clamp(24px, 4vw, 36px); letter-spacing: -.03em; }
.setup-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 14px; }
.picker { display: grid; gap: 9px; }
.pick {
  display: flex; align-items: center; gap: 12px; padding: 12px;
  border-radius: 13px; background: var(--panel2); border: 2px solid transparent;
  text-align: left; width: 100%;
}
.pick.active { border-color: var(--accent); background: rgba(124,92,255,.13); }
.pick .swatch { width: 46px; height: 30px; border-radius: 8px; flex-shrink: 0; }
.pick .swatch.track { height: 44px; border-radius: 10px; background: #20202b; position: relative; overflow: hidden; }
.pick .swatch.track::before {
  content: ""; position: absolute; inset: 10px 12px; border: 7px solid #625d80;
  border-radius: 50%;
}
.pick b { display: block; font-size: 14px; color: var(--text); }
.pick span { color: var(--muted); font-size: 12.5px; }
.picker.compact { grid-template-columns: repeat(3, 1fr); }
.picker.compact .pick { display: block; padding: 9px; text-align: center; }
.picker.compact .pick .swatch { margin: 0 auto 6px; width: 36px; height: 23px; }
.picker.compact .pick span { display: none; }
.setup-foot { display: flex; align-items: center; gap: 16px; margin-top: 18px; flex-wrap: wrap; }

/* ---------- лобби ---------- */
.room-code { color: var(--accent2); letter-spacing: .12em; font-family: ui-monospace, monospace; }
.room-link-row {
  display: flex; align-items: center; gap: 8px; max-width: 100%; margin-top: 4px;
}
.room-link-row #room-link {
  min-width: 0; overflow-wrap: anywhere; cursor: pointer; user-select: text;
}
.copy-mini {
  flex-shrink: 0; padding: 5px 9px; border-radius: 8px;
  background: var(--panel2); color: var(--accent2);
  border: 1px solid var(--line); font-size: 13px; line-height: 1;
}
.copy-mini:hover { background: var(--hover); }
.lobby-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 14px; }
.lobby-grid .card h3 { margin-top: 14px; }
.lobby-grid .card h3:first-child { margin-top: 0; }
.count { color: var(--muted); font-size: 11.5px; font-weight: 600; margin-left: auto; }
.members { display: grid; gap: 6px; }
.member {
  display: flex; align-items: center; gap: 9px; padding: 8px 9px;
  border-radius: 10px; background: rgba(255,255,255,.03);
}
.member .avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--accent);
  display: grid; place-items: center; font-size: 12.5px; font-weight: 700; flex-shrink: 0;
}
.member .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member .tag { color: var(--muted); font-size: 11.5px; }
.member select {
  width: auto; padding: 5px 7px; border-radius: 7px; background: var(--panel);
  color: var(--text); border: 1px solid var(--line); font-size: 12px;
}
.member button { padding: 5px 8px; border-radius: 7px; background: var(--panel); color: var(--danger); font-size: 12px; }
.empty-line { color: var(--muted); font-size: 12.5px; padding: 7px 2px; }
.lobby-actions { display: grid; gap: 8px; margin-top: 16px; }
.lobby-actions button { padding: 12px; border-radius: 11px; font-weight: 700; }

/* ---------- гонка ---------- */
.race-screen {
  position: fixed; inset: 0; width: 100%; padding: 0; margin: 0; z-index: 50;
  background: #0a1014; overflow: hidden;
}
#track { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hud { position: absolute; inset: 0; pointer-events: none; padding: 14px; }
.hud-left, .hud-right { position: absolute; top: 14px; display: flex; gap: 8px; align-items: flex-start; }
.hud-left { left: 14px; }
.hud-right { right: 14px; flex-direction: column; align-items: flex-end; }
.hud-btn {
  pointer-events: auto; width: 40px; height: 40px; border-radius: 50%;
  background: rgba(10,12,18,.7); color: #fff; font-size: 18px;
  border: 1px solid rgba(255,255,255,.14); backdrop-filter: blur(8px);
}
.hud-pill {
  display: flex; gap: 12px; padding: 9px 13px; border-radius: 12px;
  background: rgba(10,12,18,.7); border: 1px solid rgba(255,255,255,.12);
  font-weight: 700; font-size: 13.5px; backdrop-filter: blur(8px);
}
.hud-pill span:last-child { color: var(--accent2); font-variant-numeric: tabular-nums; }
.speedo {
  min-width: 92px; padding: 8px 13px; border-radius: 14px; text-align: right;
  background: rgba(10,12,18,.72); border: 1px solid rgba(255,255,255,.12);
  backdrop-filter: blur(8px);
}
.speedo b { font-size: 26px; font-variant-numeric: tabular-nums; }
.speedo span { display: block; color: var(--muted); font-size: 10.5px; letter-spacing: .08em; }
.leaderboard {
  margin-top: 8px; padding: 8px 10px; border-radius: 12px; min-width: 160px;
  background: rgba(10,12,18,.65); border: 1px solid rgba(255,255,255,.1);
  font-size: 12px; backdrop-filter: blur(8px);
}
.hud-location {
  position: absolute; left: 50%; top: 16px; transform: translateX(-50%);
  padding: 6px 14px; border-radius: 999px; font-size: 12.5px; font-weight: 700;
  letter-spacing: .06em; color: #dcd9ff; background: rgba(10,12,18,.62);
  border: 1px solid rgba(255,255,255,.12); backdrop-filter: blur(8px);
  white-space: nowrap;
}
.leaderboard div { display: flex; justify-content: space-between; gap: 10px; padding: 2px 0; }
.leaderboard .me { color: var(--accent2); font-weight: 700; }
#minimap-wrap {
  position: absolute; right: 14px; bottom: 88px; border-radius: 12px; overflow: hidden;
  background: rgba(8,10,14,.72); border: 1px solid rgba(255,255,255,.12);
  backdrop-filter: blur(6px);
}
#minimap { display: block; width: 150px; height: 108px; }
.touch {
  position: absolute; inset: auto 0 0 0; display: flex; justify-content: space-between;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  pointer-events: none; z-index: 55;
}
.touch-left, .touch-right { display: flex; gap: 10px; align-items: flex-end; }
.touch-btn {
  pointer-events: auto; width: 76px; height: 76px; border-radius: 50%;
  background: rgba(18,20,30,.72); border: 1px solid rgba(255,255,255,.16);
  color: #fff; font-size: 25px; font-weight: 700;
  touch-action: none; user-select: none; -webkit-user-select: none;
  backdrop-filter: blur(6px);
}
.touch-btn.small { width: 62px; height: 62px; font-size: 12px; border-radius: 18px; }
.touch-btn.gas { background: rgba(56,193,114,.3); border-color: rgba(120,240,170,.45); }
.touch-btn.brake { background: rgba(239,91,122,.25); border-color: rgba(255,150,175,.4); }
.countdown {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: clamp(64px, 15vw, 128px); font-weight: 900; color: #fff;
  text-shadow: 0 10px 60px rgba(124,92,255,.7); pointer-events: none;
  transform: translateY(-12vh);
}
.results {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 20px;
  background: rgba(4,5,8,.72); backdrop-filter: blur(8px); z-index: 60;
}
.results-box {
  width: min(520px, 100%); padding: 26px; border-radius: 22px;
  background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.results-box h2 { font-size: 30px; letter-spacing: -.03em; }
.result-table { display: grid; gap: 6px; margin: 16px 0; }
.result-table div {
  display: flex; justify-content: space-between; gap: 10px; padding: 8px 10px;
  border-radius: 9px; background: var(--panel2); font-size: 13.5px;
}

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: 20px; }
  .hero-art { height: 220px; }
  .grid { grid-template-columns: 1fr; }
  .setup-grid, .lobby-grid { grid-template-columns: 1fr; }
  .screen { padding: 20px 14px 44px; }
  .top { padding: 10px 14px; }
}
@media (max-width: 560px) {
  .map-cards { grid-template-columns: 1fr; }
  .hero-actions button { width: 100%; }
  .hero h1 { font-size: 42px; }
  .screen-head { align-items: flex-start; }
  .touch-btn { width: 66px; height: 66px; }
  .touch-btn.small { width: 54px; height: 54px; }
  #minimap { width: 118px; height: 86px; }
  .leaderboard { min-width: 132px; font-size: 11px; }
  .speedo b { font-size: 22px; }
}
@media (hover: hover) and (pointer: fine) {
  .touch { display: none; }
  #minimap-wrap { bottom: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ===== лёгкий режим Android WebView ===== */
html.kt-app * { box-shadow: none !important; }
html.kt-app .top,
html.kt-app .hud-pill,
html.kt-app .speedo,
html.kt-app .leaderboard,
html.kt-app #minimap-wrap,
html.kt-app .touch-btn,
html.kt-app .hud-location,
html.kt-app .results { backdrop-filter: none !important; }
html.kt-app .art-car { animation: none; }
