:root {
  --bg: #0d1726;
  --panel: #15233a;
  --panel2: #1c2e4a;
  --text: #e8eef8;
  --muted: #8ea2c0;
  --accent: #fbbf24;
  --ok: #22c55e;
  --bad: #ef4444;
  --land: #c9c3a3;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(ellipse at center, #16365c 0%, var(--bg) 70%);
  color: var(--text);
  font-family: "Segoe UI", system-ui, sans-serif;
  overflow-x: hidden;
}
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; background: rgba(0,0,0,.25);
}
.logo { font-weight: 800; font-size: 20px; letter-spacing: .5px; }
.phase { color: var(--accent); font-weight: 600; }

.layout { display: grid; grid-template-columns: 1fr 300px; gap: 12px; padding: 12px; height: calc(100% - 50px); }
.map-wrap { position: relative; display: flex; flex-direction: column; min-height: 0; }
.status {
  text-align: center; font-size: 18px; padding: 8px; background: var(--panel);
  border-radius: 10px; margin-bottom: 8px; min-height: 40px;
}
#map { flex: 1; width: 100%; min-height: 300px; }

.side { background: var(--panel); border-radius: 12px; padding: 12px; overflow-y: auto; display: flex; flex-direction: column; }
.side h3 { margin: 4px 0 8px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.pl { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; background: var(--panel2); margin-bottom: 6px; border-left: 5px solid; }
.pl.dead { opacity: .4; text-decoration: line-through; }
.pl .nm { font-weight: 700; flex: 1; }
.pl .sc { font-size: 20px; font-weight: 800; }
.pl .meta { font-size: 12px; color: var(--muted); }
.log { margin: 0; padding-left: 20px; font-size: 13px; color: var(--muted); flex: 1; overflow-y: auto; }
.log li { margin-bottom: 4px; }
.log li b { color: var(--text); }

/* Map */
.hex { stroke: #3b2f1c; stroke-width: 2; transition: fill .3s; cursor: default; }
.hex.free { fill: var(--land); }
.hex.selectable { cursor: pointer; stroke: #fff; stroke-width: 4; animation: pulse 1s infinite alternate; }
.hex.selectable:hover { filter: brightness(1.2); }
.hex.target { stroke: var(--bad); stroke-width: 6; }
@keyframes pulse { from { stroke-opacity: 1; } to { stroke-opacity: .3; } }
.rname { font-size: 10px; fill: #1b1408; text-anchor: middle; pointer-events: none; font-weight: 600; }
.rname.owned { fill: #fff; }
.rval { font-size: 15px; font-weight: 800; text-anchor: middle; fill: #fff; pointer-events: none; paint-order: stroke; stroke: rgba(0,0,0,.55); stroke-width: 3px; }
.rcap { font-size: 26px; text-anchor: middle; pointer-events: none; }
.towers { font-size: 12px; text-anchor: middle; fill: #fff; pointer-events: none; paint-order: stroke; stroke: #000; stroke-width: 2px; }

/* Overlays */
.overlay { position: fixed; inset: 0; background: rgba(5,10,20,.72); display: flex; align-items: center; justify-content: center; z-index: 10; padding: 16px; }
.hidden { display: none !important; }
.card { background: var(--panel); border-radius: 16px; padding: 22px; width: 100%; max-width: 560px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.start h1 { margin-top: 0; }
.rules { color: var(--muted); line-height: 1.5; padding-left: 18px; }
.rules b { color: var(--text); }
label { display: flex; justify-content: space-between; align-items: center; margin: 10px 0; }
select { background: var(--panel2); color: var(--text); border: 1px solid #33496d; border-radius: 6px; padding: 6px 10px; font-size: 15px; }
.btn { background: var(--accent); color: #1a1300; border: none; border-radius: 10px; padding: 10px 18px; font-size: 16px; font-weight: 700; cursor: pointer; }
.btn:hover { filter: brightness(1.1); }
.btn.big { width: 100%; padding: 14px; font-size: 18px; margin-top: 12px; }

.qhead { display: flex; justify-content: space-between; font-size: 14px; color: var(--muted); margin-bottom: 8px; gap: 8px; flex-wrap: wrap; }
.qkind { color: var(--accent); font-weight: 700; }
.timer { height: 8px; background: #0b1424; border-radius: 4px; overflow: hidden; }
#timerbar { height: 100%; background: var(--accent); width: 100%; }
.qtext { font-size: 22px; font-weight: 700; margin: 18px 0; line-height: 1.3; }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.opt { background: var(--panel2); color: var(--text); border: 2px solid #33496d; border-radius: 10px; padding: 14px; font-size: 16px; cursor: pointer; text-align: left; position: relative; min-height: 56px; }
.opt:hover:not(:disabled) { border-color: var(--accent); }
.opt:disabled { cursor: default; }
.opt.chosen { border-color: var(--accent); }
.opt.correct { background: #14532d; border-color: var(--ok); }
.opt.wrong { background: #5b1a1a; border-color: var(--bad); }
.opt .dots { position: absolute; right: 8px; top: 6px; display: flex; gap: 3px; }
.dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; display: inline-block; }
.numrow { display: flex; gap: 10px; }
.numrow input { flex: 1; font-size: 24px; padding: 10px; border-radius: 10px; border: 2px solid #33496d; background: var(--panel2); color: var(--text); min-width: 0; }
.qresult { margin-top: 14px; font-size: 15px; }
.qresult table { width: 100%; border-collapse: collapse; }
.qresult td { padding: 6px; border-bottom: 1px solid #263a5a; }
.qresult .ans { font-size: 18px; color: var(--ok); font-weight: 800; margin-bottom: 8px; }
#qnext { margin-top: 12px; width: 100%; }
.spect { color: var(--muted); font-style: italic; }
.endrow { display: flex; justify-content: space-between; padding: 10px; border-radius: 8px; background: var(--panel2); margin-bottom: 6px; border-left: 5px solid; font-size: 18px; }

@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; height: auto; padding: 8px 16px; }
  #map { min-height: 360px; }
  .side { max-height: 380px; }
  .opts { grid-template-columns: 1fr; }
  .qtext { font-size: 19px; }
}

/* ===== Онлайн: навигация, формы, страницы ===== */
a { color: var(--accent); }
.logo { color: var(--text); text-decoration: none; }
.navlink { color: var(--muted); text-decoration: none; margin-right: auto; margin-left: 16px; }
.topbar { gap: 16px; flex-wrap: wrap; }
.nav { display: flex; gap: 4px; margin-right: auto; }
.nav a { color: var(--muted); text-decoration: none; padding: 6px 12px; border-radius: 8px; }
.nav a:hover { color: var(--text); background: var(--panel2); }
.nav a.active { color: var(--text); background: var(--panel2); }
.userbox { display: flex; align-items: center; gap: 8px; }
.plink { color: var(--text); font-weight: 700; text-decoration: none; }
.plink:hover { color: var(--accent); text-decoration: underline; }
.elo-badge { background: var(--panel2); border: 1px solid #33496d; border-radius: 999px; padding: 2px 10px; font-weight: 700; color: var(--accent); font-size: 14px; }
.btn.small { padding: 6px 12px; font-size: 14px; text-decoration: none; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid #33496d; }
.btn.ghost.danger { color: #fca5a5; border-color: #7f1d1d; margin-top: 10px; }
.btn:disabled { opacity: .5; cursor: default; }
.page { display: flex; justify-content: center; padding: 24px 16px; }
.card.narrow { max-width: 520px; }
.card.wide { max-width: 900px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.error { color: #fca5a5; min-height: 20px; font-size: 14px; }
.tabs { display: flex; gap: 6px; margin: 16px 0 10px; }
.tab { flex: 1; background: var(--panel2); color: var(--muted); border: 1px solid #33496d; border-radius: 8px; padding: 10px; font-size: 15px; cursor: pointer; }
.tab.active { color: var(--text); border-color: var(--accent); }
.form { display: flex; flex-direction: column; gap: 10px; }
.form input, .search { background: var(--panel2); color: var(--text); border: 1px solid #33496d; border-radius: 8px; padding: 12px; font-size: 16px; width: 100%; }
.form input:focus, .search:focus, .numrow input:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px; margin: 14px 0; }
.stat { background: var(--panel2); border-radius: 10px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 22px; }
.stat span { color: var(--muted); font-size: 13px; }
.searching { display: flex; align-items: center; gap: 14px; background: var(--panel2); border-radius: 10px; padding: 14px; font-size: 17px; }
.spinner { width: 28px; height: 28px; border: 4px solid #33496d; border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
.phasebar { display: flex; justify-content: space-between; color: var(--accent); font-weight: 600; padding: 0 4px 6px; }
.table-wrap { overflow-x: auto; }
.board { width: 100%; border-collapse: collapse; margin-top: 12px; }
.board th { text-align: left; color: var(--muted); font-weight: 600; font-size: 13px; padding: 8px; border-bottom: 1px solid #33496d; }
.board td { padding: 10px 8px; border-bottom: 1px solid #22385a; }
.board tr:hover td { background: rgba(255,255,255,.03); }
.board tr.me td { background: rgba(251,191,36,.1); }
.search { margin-top: 8px; }
.up { color: var(--ok); font-weight: 700; }
.down { color: var(--bad); font-weight: 700; }
.place.p1 { color: var(--accent); font-weight: 700; }
.prof-head { display: flex; align-items: center; gap: 16px; }
.prof-head h1 { margin: 0 0 4px; }
.avatar { width: 64px; height: 64px; border-radius: 50%; background: var(--accent); color: #1a1300; display: flex; align-items: center; justify-content: center; font-size: 30px; font-weight: 800; flex-shrink: 0; }
.chart { width: 100%; height: 160px; background: var(--panel2); border-radius: 10px; }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 2.5; vector-effect: non-scaling-stroke; }
.chart-dot { fill: var(--accent); }
.chart-base { stroke: #33496d; stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; }
.chart-label { fill: var(--muted); font-size: 11px; }
.endrow { gap: 10px; flex-wrap: wrap; font-size: 16px; }
@media (max-width: 820px) {
  .nav { order: 3; width: 100%; margin-right: 0; }
  .board td, .board th { padding: 8px 4px; font-size: 14px; }
}

/* ===== Карта Москвы ===== */
.mkad-bg { fill: #2b3a2a; }
.mkad { fill: none; stroke: #9aa5b8; stroke-width: 5; stroke-linejoin: round; pointer-events: none; opacity: .85; }
.river { fill: none; stroke: #4aa3df; stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; opacity: .75; pointer-events: none; }
#map .hex { stroke: #1d2a1c; stroke-width: 1.5; stroke-linejoin: round; }
#map .hex.selectable { stroke: #fff; stroke-width: 3.5; }
#map .hex.target { stroke: var(--bad); stroke-width: 5; }
#map .rname { font-size: 10.5px; }
#map .rval { font-size: 13px; }
#map .rcap { font-size: 20px; }
#map .towers { font-size: 10px; }
/* Поля с фото и поля за МКАД */
.rphoto { pointer-events: none; }
#map .hex.photo.free { fill: #c9c3a3; fill-opacity: .35; }
#map .hex.photo:not(.free) { fill-opacity: .55; }
#map .hex.remote { stroke: #9aa5b8; stroke-width: 3; }
#map .hex.photo ~ text { }
#map .rname.onphoto { fill: #fff; }
.road { stroke: #9aa5b8; stroke-width: 4; stroke-dasharray: 10 7; opacity: .8; }
#map .rname.owned { paint-order: stroke; stroke: rgba(0,0,0,.55); stroke-width: 2.5px; }
