/* WikiRoute — тёмная тема в духе Википедии */
:root {
  --bg: #101418;
  --subtle: #1b1e22;
  --interactive: #27292d;
  --border: #54595d;
  --hair: #3a3e43;
  --text: #eaecf0;
  --muted: #a2a9b1;
  --link: #88a3e8;
  --link-hover: #a6bbf5;
  --red: #fd7865;
  --green: #6fc6a6;
  --yellow: #e8c66b;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Lato, 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --serif: 'Linux Libertine', 'Georgia', 'Times', 'Source Serif Pro', serif;
  color-scheme: dark;
}
* { box-sizing: border-box; border-radius: 0; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.6 var(--sans); }
button, input { font: inherit; color: inherit; }
.hidden { display: none !important; }
.dim, .note, .muted { color: var(--muted); }
.note { font-size: 13px; margin: 6px 0 0; }
.small { font-size: 12.5px; }
.mono, .timer, .count b { font-variant-numeric: tabular-nums; }
.dot { display: inline-block; width: 8px; height: 8px; flex: none; }
a { color: var(--link); }

/* кнопки, поля */
.btn {
  background: var(--interactive); border: 1px solid var(--border); color: var(--text);
  padding: 5px 12px; min-height: 32px; font-weight: 700; cursor: pointer;
}
.btn:hover { background: #303236; border-color: #72777d; }
.btn:active { background: #3a3d42; }
.btn.primary { background: var(--link); border-color: var(--link); color: #101418; }
.btn.primary:hover { background: var(--link-hover); border-color: var(--link-hover); }
.btn.sm { min-height: 28px; padding: 2px 10px; font-weight: 400; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.link-btn { background: none; border: 0; padding: 0; color: var(--link); cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
input:not([type=range]) {
  width: 100%; background: var(--bg); border: 1px solid var(--border); padding: 5px 8px; min-height: 32px; outline: none;
}
input:not([type=range]):focus { border-color: var(--link); box-shadow: inset 0 0 0 1px var(--link); }
.shake { border-color: var(--red) !important; box-shadow: inset 0 0 0 1px var(--red) !important; }

/* заголовки в стиле Википедии */
.logo { font: 400 48px/1.1 var(--serif); margin: 0; text-align: center; letter-spacing: .01em; }
.logo-sm { font: 400 18px var(--serif); color: var(--text); white-space: nowrap; }
.page-title { font: 400 28.8px/1.3 var(--serif); margin: 0 0 4px; padding-bottom: 2px; border-bottom: 1px solid var(--border); }
h2 { font: 400 22px/1.3 var(--serif); margin: 0 0 10px; padding-bottom: 2px; border-bottom: 1px solid var(--border); }
h2 .dim { font: 400 13px var(--sans); }
.subtitle { color: var(--muted); margin: 0 0 18px; font-size: 13px; }
.subtitle b { color: var(--text); font-weight: 700; letter-spacing: .1em; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 24px; border-bottom: 1px solid var(--hair); }
.page { max-width: 1200px; margin: 0 auto; padding: 22px 24px 48px; }

/* главная */
#home { min-height: 100%; display: flex; justify-content: center; padding: 10vh 16px 40px; }
.home { width: 100%; max-width: 440px; display: flex; flex-direction: column; gap: 14px; }
.tagline { font: italic 15px var(--serif); color: var(--muted); text-align: center; margin: -6px 0 6px; }
.lead { margin: 0 0 6px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field span { font-weight: 700; }
.home-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.join-row { display: flex; gap: 8px; }
.join-row input { text-transform: uppercase; letter-spacing: .12em; }
.join-row input::placeholder { letter-spacing: 0; text-transform: none; }
.rules { margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--hair); display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 13px; }
.rules dt { font-weight: 700; }
.rules dd { margin: 0; color: var(--muted); }

/* лобби */
.lobby-grid { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(340px, 1.4fr) minmax(240px, 1fr); gap: 32px; }
.col { min-width: 0; }
.player { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.player.off { opacity: .45; }
.player .pname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player .meta { color: var(--muted); font-size: 12.5px; }
.kick { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0 2px; font-size: 12.5px; }
.kick:hover { color: var(--red); text-decoration: underline; }
.team-box { margin-bottom: 14px; }
.team-head { display: flex; align-items: baseline; gap: 8px; border-bottom: 1px solid var(--hair); margin-bottom: 4px; padding-bottom: 2px; }
.team-head b { font-weight: 700; }
.team-head .n { color: var(--muted); margin-right: auto; font-size: 12.5px; }
.bots { margin-top: 18px; padding-top: 10px; border-top: 1px solid var(--hair); }
.bot-btns { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }

.setting { display: grid; grid-template-columns: 100px 1fr; gap: 12px; align-items: start; padding: 8px 0; border-bottom: 1px solid var(--hair); }
.setting .label { font-weight: 700; padding-top: 5px; }
.seg { display: flex; flex-wrap: wrap; }
.seg button { background: var(--interactive); border: 1px solid var(--border); margin: 0 -1px -1px 0; padding: 4px 10px; min-height: 30px; cursor: pointer; }
.seg button:hover:not(:disabled) { background: #303236; }
.seg button.on { background: var(--link); border-color: var(--link); color: #101418; font-weight: 700; position: relative; }
.seg button:disabled { cursor: default; }
.seg button:disabled:not(.on) { color: var(--muted); }
.diff-top { display: flex; justify-content: space-between; margin-bottom: 4px; }
.diff-top #diffName { font-weight: 700; }
input[type=range] { width: 100%; accent-color: var(--link); margin: 4px 0; }
#startBtn { margin-top: 16px; min-height: 38px; }

/* чат */
.chat-col { display: flex; flex-direction: column; }
.chat { display: flex; flex-direction: column; gap: 6px; min-height: 0; flex: 1; }
.chat-tabs { display: flex; gap: 12px; font-size: 13px; }
.chat-tabs button { background: none; border: 0; padding: 0; color: var(--link); cursor: pointer; }
.chat-tabs button.on { color: var(--text); font-weight: 700; cursor: default; }
.chat-log { flex: 1; overflow-y: auto; min-height: 120px; max-height: 50vh; font-size: 13px; }
.msg { padding: 1px 0; word-wrap: break-word; }
.msg b { font-weight: 700; margin-right: 4px; }
.msg .scope { color: var(--muted); font-size: 12px; margin-right: 4px; }
.chat-form input { min-height: 30px; }

/* генерация */
#generating { min-height: 100%; display: flex; align-items: center; justify-content: center; }
.gen { width: 320px; text-align: center; color: var(--muted); }
.gen-line { height: 2px; background: var(--hair); position: relative; overflow: hidden; margin-bottom: 14px; }
.gen-line i { position: absolute; top: 0; bottom: 0; width: 30%; background: var(--link); animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { from { left: -30%; } to { left: 100%; } }

/* игра */
#game { height: 100%; display: flex; flex-direction: column; }
.game-top { display: grid; grid-template-columns: minmax(200px, 340px) 1fr auto; gap: 20px; align-items: center; padding: 8px 20px; border-bottom: 1px solid var(--hair); }
.goal { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.goal .logo-sm { margin-right: 10px; }
.goal b { color: var(--green); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chain-wrap { display: flex; align-items: baseline; justify-content: center; gap: 16px; min-width: 0; }
.chain { display: flex; align-items: baseline; overflow-x: auto; scrollbar-width: none; min-width: 0; white-space: nowrap; font-size: 13.5px; }
.chain::-webkit-scrollbar { display: none; }
.chain .node { color: var(--muted); max-width: 200px; overflow: hidden; text-overflow: ellipsis; flex: none; }
.chain .node.cur { color: var(--text); font-weight: 700; }
.node.goal-node { color: var(--green) !important; font-weight: 700; }
.sep { color: #72777d; padding: 0 6px; flex: none; }
.count { flex: none; color: var(--muted); }
.count b { color: var(--text); font-size: 16px; }
.count em { font-style: normal; color: var(--red); }
.top-right { display: flex; align-items: baseline; gap: 16px; }
.timer { font-size: 16px; }
.timer.low { color: var(--red); }

.game-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 300px; }
.article-wrap { position: relative; overflow-y: auto; }
.banner { position: sticky; top: 0; z-index: 4; padding: 8px 24px; background: var(--subtle); border-bottom: 1px solid var(--hair); }
.banner b { font-weight: 700; }
#article { position: relative; max-width: 960px; margin: 0 auto; padding: 20px 32px 80px; }
.art-title { font: 400 28.8px/1.3 var(--serif); margin: 0 0 14px; padding-bottom: 2px; border-bottom: 1px solid var(--border); }
#overlay { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.loading { position: absolute; left: 0; right: 0; top: 0; height: 2px; overflow: hidden; z-index: 6; }
.loading i { position: absolute; top: 0; bottom: 0; width: 30%; background: var(--link); animation: slide 1s ease-in-out infinite; }

.sidebar { border-left: 1px solid var(--hair); overflow-y: auto; display: flex; flex-direction: column; padding: 0 16px; font-size: 13px; }
.side { padding: 12px 0; border-bottom: 1px solid var(--hair); }
.side:last-child { border-bottom: 0; }
.side h3 { font: 700 13px var(--sans); margin: 0 0 6px; color: var(--muted); }
.side h3 .dim { font-weight: 400; }
.tc { display: flex; gap: 10px; align-items: flex-start; }
.tc img { width: 64px; height: 64px; object-fit: cover; flex: none; }
.t-title { font: 400 17px/1.3 var(--serif); color: var(--green); }
.t-desc { color: var(--muted); margin-top: 2px; }
.extract { margin: 8px 0 4px; max-height: 140px; overflow-y: auto; }
.members { display: flex; flex-direction: column; gap: 2px; margin-bottom: 6px; }
.member { display: flex; align-items: center; gap: 8px; background: none; border: 0; padding: 0; cursor: pointer; text-align: left; color: var(--text); }
.member:hover span { text-decoration: underline; }
.member.off { opacity: .45; }
.hint-list { display: flex; flex-direction: column; }
.hint-btn { display: flex; justify-content: space-between; gap: 8px; background: none; border: 0; padding: 3px 0; cursor: pointer; text-align: left; color: var(--link); }
.hint-btn:hover:not(:disabled) span { text-decoration: underline; }
.hint-btn b { color: var(--red); font-weight: 400; white-space: nowrap; }
.hint-btn:disabled { color: var(--muted); cursor: default; }
.hint-btn:disabled b { color: var(--muted); }
.hint-res { margin-top: 8px; }
.hr-head { font-weight: 700; }
.hr-head em { font-style: normal; color: var(--red); font-weight: 400; }
.hint-res p { margin: 2px 0 0; }
.tags span + span::before { content: ' · '; color: #72777d; }
.brow { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.brow[data-watch] { cursor: pointer; }
.brow[data-watch]:hover .bname { text-decoration: underline; }
.brow.me .bname { font-weight: 700; }
.brow.watching .bname { color: var(--link); }
.bname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bst { color: var(--muted); }
.bscore { min-width: 24px; text-align: right; font-variant-numeric: tabular-nums; }
.bscore em { font-style: normal; color: var(--red); }
.chat-side { flex: 1; display: flex; flex-direction: column; min-height: 200px; }

.countdown { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: rgba(16,20,24,.95); text-align: center; padding: 16px; }
.countdown #cdNum { display: block; font: 400 96px/1 var(--serif); }
.countdown p { font: 400 20px var(--serif); margin: 16px 0 0; color: var(--muted); }
.countdown p b { color: var(--text); font-weight: 400; }

/* курсоры и выделения команды */
.rcur { position: absolute; left: 0; top: 0; transition: transform .08s linear; will-change: transform; }
.rcur svg { display: block; }
.rcur span { position: absolute; left: 12px; top: 16px; background: var(--c); color: #101418; font: 700 11px var(--sans); padding: 0 5px; white-space: nowrap; }
.rcur.ping svg { outline: 2px solid var(--c); outline-offset: 6px; }
.rsel { position: absolute; opacity: .3; }

/* статья Википедии — тёмная тема */
#artContent { font-size: 16px; line-height: 1.6; }
#artContent :is(div, table, tbody, thead, tr, td, th, span, p, li, ul, ol, dl, dd, dt, caption, figure, figcaption, center, small, big, b, i, abbr, sup, sub, h1, h2, h3, h4, h5, h6) {
  background-color: transparent !important;
  background-image: none !important;
  color: inherit !important;
  border-color: var(--hair) !important;
}
#artContent a.wl { color: var(--link); cursor: pointer; text-decoration: none; }
#artContent a.wl:hover { text-decoration: underline; }
#artContent a.wl.going { color: var(--link-hover); text-decoration: underline; }
#artContent a.wl.warm { color: var(--green); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
#artContent a.wl.rhover { outline: 2px solid var(--hc); outline-offset: 1px; }
#artContent a.anchor { color: var(--link); text-decoration: none; }
#game.readonly #artContent a.wl { cursor: default; }
#artContent h2 { font: 400 22px/1.3 var(--serif); margin: 1em 0 .25em; padding-bottom: 2px; border-bottom: 1px solid var(--border) !important; }
#artContent h3 { font: 700 17px/1.4 var(--sans); margin: .8em 0 .2em; }
#artContent h4 { font: 700 15px var(--sans); margin: .6em 0 .2em; }
#artContent p { margin: .5em 0; }
#artContent ul { padding-left: 1.6em; margin: .3em 0; list-style: square; }
#artContent sup, #artContent sub { line-height: 1; font-size: 75%; }
#artContent .reference, #artContent .reflist, #artContent ol.references, #artContent .references-small { font-size: 13px; }
#artContent img { max-width: 100%; height: auto; vertical-align: middle; }
#artContent table { border-collapse: collapse; font-size: 14px; }
#artContent .wikitable, #artContent .wikitable td, #artContent .wikitable th { border: 1px solid var(--border) !important; }
#artContent .wikitable { margin: 1em 0; background-color: var(--subtle) !important; }
#artContent .wikitable td, #artContent .wikitable th { padding: 4px 8px; }
#artContent .wikitable th { background-color: var(--interactive) !important; }
#artContent .infobox {
  float: right; clear: right; width: 22em; max-width: 45%; margin: 0 0 1em 1.4em; padding: 3px;
  border: 1px solid var(--border) !important; background-color: var(--subtle) !important; font-size: 13px; line-height: 1.5;
}
#artContent .infobox td, #artContent .infobox th { padding: 3px 6px; vertical-align: top; text-align: left; }
#artContent .infobox-above, #artContent .infobox > caption, #artContent .infobox .infobox-title { font-size: 16px; font-weight: 700; text-align: center !important; }
#artContent .infobox-header, #artContent .infobox th[colspan] { background-color: var(--interactive) !important; text-align: center !important; }
#artContent figure, #artContent .thumb { margin: .4em 0 1em 1.4em; float: right; clear: right; max-width: 300px; font-size: 13px; line-height: 1.4; }
#artContent figure.mw-halign-left, #artContent .tleft { float: left; margin: .4em 1.4em 1em 0; }
#artContent figure.mw-halign-center, #artContent figure.mw-halign-none { float: none; margin: .6em auto; }
#artContent figure > a, #artContent figure > span { display: block; }
#artContent figcaption, #artContent .thumbcaption { padding: 4px 0; color: var(--muted) !important; border-bottom: 1px solid var(--hair); }
#artContent .hatnote, #artContent .dablink { font-style: italic; padding-left: 1.6em; margin-bottom: .5em; color: var(--muted) !important; }
#artContent .ambox, #artContent .tmbox { border: 1px solid var(--hair) !important; border-left: 3px solid var(--yellow) !important; padding: 4px 10px; margin: .5em 0; font-size: 13px; }
#artContent .navbox, #artContent .navbox-inner { width: 100%; font-size: 12.5px; border: 1px solid var(--border) !important; margin-top: 10px; }
#artContent .navbox th, #artContent .navbox td { padding: 2px 6px; }
#artContent .navbox-title, #artContent .navbox-group, #artContent .navbox-abovebelow { background-color: var(--interactive) !important; }
#artContent .navbox-list { line-height: 1.7; }
#artContent .mw-collapsible-toggle, #artContent .navbar, #artContent .toc, #artContent #toc { display: none; }
#artContent blockquote { border-left: 3px solid var(--hair); margin: 1em 0; padding: 0 16px; }
#artContent pre, #artContent code { background: var(--subtle); font-size: 13px; }
#artContent pre { padding: 10px 12px; overflow-x: auto; border: 1px solid var(--hair); }
#artContent .mw-references-columns, #artContent .references-column-width { column-width: 30em; }
#artContent :is(.skin-invert, .skin-invert-image img, .mwe-math-fallback-image-inline, .mwe-math-fallback-image-display) { filter: invert(1) hue-rotate(180deg); }
#artContent .metadata.plainlinks, #artContent .sistersitebox, #artContent .ruwikiWikimediaNavigation { display: none; }

/* результаты */
.res-table { width: 100%; border-collapse: collapse; background: var(--subtle); margin: 8px 0 20px; }
.res-table th, .res-table td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; vertical-align: top; }
.res-table th { background: var(--interactive); font-weight: 700; }
.res-table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.res-table tr.me td:first-child { box-shadow: inset 3px 0 0 var(--link); }
.res-table .sub { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.route-line { font: 400 17px var(--serif); color: var(--muted); margin: 0 0 14px; }
.route-line b { color: var(--text); font-weight: 400; }
.rpath { line-height: 1.7; }
.rpath .node { white-space: nowrap; }
.ref { margin: 0 0 20px; }
.res-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* уведомления */
#toasts { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; z-index: 100; pointer-events: none; }
.toast { background: var(--interactive); border: 1px solid var(--border); padding: 6px 14px; max-width: 90vw; }
.toast.bad { border-color: var(--red); }
.toast.out { opacity: 0; transition: opacity .4s; }

/* адаптив */
@media (max-width: 1100px) {
  .lobby-grid { grid-template-columns: 1fr 1fr; }
  .chat-col { grid-column: 1 / -1; }
  .game-body { grid-template-columns: 1fr 260px; }
}
@media (max-width: 760px) {
  .page { padding: 16px; }
  .lobby-grid { grid-template-columns: 1fr; gap: 24px; }
  .setting { grid-template-columns: 1fr; gap: 4px; }
  .game-top { grid-template-columns: 1fr auto; padding: 8px 16px; }
  .goal .logo-sm { display: none; }
  .chain-wrap { grid-column: 1 / -1; grid-row: 2; justify-content: flex-start; }
  .game-body { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .sidebar { max-height: 40vh; border-left: 0; border-top: 1px solid var(--hair); }
  #article { padding: 16px 16px 60px; }
  #artContent .infobox, #artContent figure, #artContent .thumb { float: none; max-width: 100%; width: auto; margin: 10px 0; }
  .home-actions { grid-template-columns: 1fr; }
  .bar { padding: 10px 16px; }
}
.res-table th:not(:nth-child(2)):not(:last-child) { width: 1%; white-space: nowrap; }
