:root {
  --bg: #0d1424;
  --panel: rgba(16, 22, 38, 0.86);
  --panel-solid: #121a2e;
  --line: rgba(255, 255, 255, 0.09);
  --text: #ece6d8;
  --muted: #9aa3b5;
  --accent: #e0a84f;
  --accent-2: #7fb2d9;
  --imp3: #f2c46b;
  --radius: 12px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', sans-serif;
  --serif: Georgia, 'Noto Serif', 'Times New Roman', serif;
  --side-w: 360px;
  --fs: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: var(--font); font-size: var(--fs); }
body.kids { --fs: 18px; --side-w: 420px; }
#stage { position: fixed; inset: 0; }
#stage canvas { display: block; touch-action: none; cursor: grab; }
#stage canvas:active { cursor: grabbing; }
#loading { position: fixed; inset: 0; display: grid; place-items: center; font-family: var(--serif); font-size: 28px; color: var(--accent); background: var(--bg); z-index: 50; }

.btn { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; cursor: pointer; backdrop-filter: blur(8px); }
.btn:hover { border-color: var(--accent); }
.btn[aria-pressed='true'] { background: var(--accent); color: #1a1206; border-color: var(--accent); }
.btn.lang { appearance: none; -webkit-appearance: none; padding: 8px 14px; text-align: center; }
.btn.lang option { color: #111; background: #fff; }
.btn.help { position: relative; font-size: 17px; font-weight: 600; }
/* a new version that has not been read yet */
.btn.help.news::after { content: ''; position: absolute; top: 2px; right: 2px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--panel-solid); }
.btn.round { width: 38px; height: 38px; padding: 0; font-size: 20px; line-height: 1; }
.btn.ghost { background: transparent; width: 100%; margin: 8px 0 16px; }

.top { position: fixed; top: 12px; left: 12px; right: calc(var(--side-w) + 24px); display: flex; gap: 12px; align-items: stretch; pointer-events: none; z-index: 5; }
.top > * { pointer-events: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); backdrop-filter: blur(8px); padding: 10px 14px; }
.brand { font-family: var(--serif); font-size: 22px; color: var(--accent); display: flex; align-items: center; gap: 8px; }
.conn { width: 8px; height: 8px; border-radius: 50%; background: #5cb85c; display: inline-block; }
.conn.off { background: #d9534f; }
.time { min-width: 210px; }
.year { font-family: var(--serif); font-size: 1.6em; line-height: 1.1; }
.sub { color: var(--muted); }
.sub.next { font-size: 11px; opacity: .75; }
.sub.next:empty { display: none; }
.tick { height: 3px; background: var(--line); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.tick i { display: block; height: 100%; background: var(--accent); width: 0; }
.stats { display: flex; gap: 18px; align-items: center; }
.stats div, .kpis div { display: flex; flex-direction: column; }
.stats span, .kpis span { color: var(--muted); font-size: 0.8em; }
.stats b, .kpis b { font-size: 1.25em; font-variant-numeric: tabular-nums; }

.side { position: fixed; top: 12px; right: 12px; bottom: 12px; width: var(--side-w); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); backdrop-filter: blur(10px); display: flex; flex-direction: column; z-index: 5; transition: transform 0.25s; }
body.side-hidden .side { transform: translateX(calc(100% + 12px)); }
/* the little tab on the panel's left edge: hides it, and stays at the screen edge to bring it back */
.side-handle { position: absolute; left: -26px; top: 50%; transform: translateY(-50%); width: 26px; height: 64px; padding: 0; font: inherit; font-size: 20px; line-height: 1; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-right: 0; border-radius: 10px 0 0 10px; backdrop-filter: blur(10px); cursor: pointer; }
.side-handle:hover { color: var(--accent); }
body.side-hidden .side-handle span { display: inline-block; transform: scaleX(-1); }
body.side-hidden .top { right: 12px; }
.tabs { display: flex; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.tab { flex: 1 0 auto; font: inherit; background: none; border: 0; color: var(--muted); padding: 10px 6px; font-size: 13px; white-space: nowrap; cursor: pointer; border-bottom: 2px solid transparent; }
.discoveries { list-style: none; margin: 0; padding: 0; }
.discoveries li { padding: 8px 2px; border-bottom: 1px solid var(--line); }
.discoveries li.todo { color: var(--muted); opacity: 0.55; }
.discoveries li.todo b { font-weight: 500; }
/* each age is its own card with a clear title */
.tech-age { margin: 14px 0 0; padding: 0 12px 4px; background: rgba(255, 255, 255, 0.035); border: 1px solid var(--line); border-left: 3px solid var(--accent-2); border-radius: var(--radius); }
.tech-age + .tech-age { margin-top: 18px; }
h3.tech-era { display: flex; justify-content: space-between; align-items: baseline; margin: 0 -12px; padding: 10px 12px 8px; font-family: var(--serif); font-size: 16px; font-weight: 600; color: var(--accent-2); border-bottom: 1px solid var(--line); }
h3.tech-era span { font-family: var(--font); font-size: 12px; color: var(--muted); font-weight: 400; }
.tech-age .discoveries li:last-child { border-bottom: 0; }
h3.todo-era { margin: 14px 0 2px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.discoveries .yr { color: var(--accent); }
.tab[aria-selected='true'] { color: var(--text); border-bottom-color: var(--accent); }
.side-body { overflow-y: auto; padding: 10px 14px; flex: 1; }
.chk { display: flex; gap: 8px; align-items: center; color: var(--muted); margin: 4px 0 10px; }

.events { list-style: none; margin: 0; padding: 0; }
.ev { display: grid; grid-template-columns: 26px 1fr; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.ev-icon { font-size: 1.15em; }
.ev-year { color: var(--muted); font-size: 0.8em; }
.ev.imp1 .ev-text { color: #c4c9d4; }
.ev.imp3 .ev-text { color: var(--imp3); font-family: var(--serif); font-size: 1.05em; }

.bands, .heroes { list-style: none; margin: 0; padding: 0; }
.bands li, .heroes li { padding: 9px 0; border-bottom: 1px solid var(--line); cursor: pointer; display: flex; gap: 10px; }
.heroes li { flex-direction: column; gap: 2px; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: none; margin-top: 4px; }
.muted { color: var(--muted); }
small { color: var(--muted); }

.kpis { display: flex; gap: 18px; margin: 10px 0; }
h3 { font-family: var(--serif); font-weight: normal; color: var(--accent); margin: 16px 0 8px; }
.chart { width: 100%; height: 140px; display: block; touch-action: pan-y; cursor: crosshair; }
.chart-wrap { position: relative; }
.chart-tip { position: absolute; top: 4px; max-width: 70%; padding: 6px 9px; background: var(--panel-solid); border: 1px solid var(--line); border-radius: 10px; font-size: 12px; line-height: 1.4; pointer-events: none; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35); z-index: 2; }
.chart-tip i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
.chart-found { margin-top: 3px; color: var(--accent); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted); margin: -4px 0 4px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.techs { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { padding: 4px 10px; border-radius: 999px; background: rgba(224, 168, 79, 0.14); border: 1px solid rgba(224, 168, 79, 0.35); font-size: 0.9em; }

.controls { position: fixed; left: 12px; bottom: 12px; display: flex; gap: 8px; flex-wrap: wrap; z-index: 5; }

#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: 64px; width: min(560px, calc(100vw - var(--side-w) - 48px)); display: flex; flex-direction: column; gap: 8px; z-index: 6; pointer-events: none; margin-left: calc(var(--side-w) / -2); }
.toast { background: var(--panel-solid); border: 1px solid var(--line); border-left: 3px solid var(--accent-2); border-radius: 10px; padding: 10px 14px; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35); transition: opacity 0.8s, transform 0.8s; }
.toast.imp3 { border-left-color: var(--imp3); font-family: var(--serif); }
/* names in the chronicle that lead to a person or a band */
a.ref { color: var(--accent-2); text-decoration: none; border-bottom: 1px dotted currentColor; cursor: pointer; }
a.ref:hover { border-bottom-style: solid; }
.toast a.ref { pointer-events: auto; }
.toast.out { opacity: 0; transform: translateY(10px); }

.card { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 64px); overflow-y: auto; background: var(--panel-solid); border: 1px solid var(--line); border-radius: 16px; padding: 22px; z-index: 20; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); }
.card.beside { left: 0; top: 0; transform: none; will-change: transform; width: min(380px, calc(100vw - 32px)); max-height: min(560px, calc(100vh - 24px)); border-color: rgba(255, 42, 42, 0.55); }
.card h2 { font-family: var(--serif); font-weight: normal; margin: 0 0 4px; display: flex; gap: 10px; align-items: center; }
.card .close { position: absolute; top: 12px; right: 12px; }
.card.beside .close { display: none; } /* a click on the map closes it */
.card a { color: var(--accent-2); text-decoration: none; }
.card a.dead { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(255,255,255,0.25); }
.person-head { display: flex; gap: 14px; align-items: center; }
.avatar { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font-size: 30px; background: rgba(127, 178, 217, 0.15); flex: none; }
.avatar.f { background: rgba(224, 168, 79, 0.15); }
.genes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; margin: 16px 0; }
.gene span { font-size: 0.85em; color: var(--muted); }
.bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); }
.family { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; }
.family dt { color: var(--muted); }
.family dd { margin: 0; }
.deeds { padding-left: 18px; margin: 0; }
.names { line-height: 1.8; }

@media (max-width: 900px) {
  :root { --side-w: 100vw; }
  .top { right: 12px; flex-wrap: wrap; }
  .stats .wide { display: none; }
  .side { top: auto; height: 42vh; left: 0; right: 0; bottom: 0; width: auto; border-radius: 16px 16px 0 0; }
  .controls { bottom: calc(42vh + 12px); }
  body.side-hidden .side { transform: translateY(100%); }
  .side-handle { display: none; } /* on a phone the Панел button does it */
  body.side-hidden .controls { bottom: 12px; }
  #toasts { margin-left: 0; width: calc(100vw - 32px); bottom: calc(42vh + 64px); }
  .brand { display: none; }
}

.brand .build { display: block; font-family: var(--sans, system-ui, sans-serif); font-size: 10px; color: var(--muted); letter-spacing: 0.02em; margin-top: 2px; }

/* family tree */
.card.wide { width: min(860px, calc(100vw - 32px)); }
.tree-btn { margin-top: 12px; }
.tree { overflow-x: auto; margin: 14px 0; padding-bottom: 6px; }
.tn { display: flex; align-items: center; gap: 10px; }
.tpar { display: flex; flex-direction: column; gap: 6px; padding-left: 10px; border-left: 1px solid var(--line); }
.tbox { min-width: 150px; max-width: 190px; padding: 6px 9px; border-radius: 9px; background: rgba(127, 178, 217, 0.13); border: 1px solid rgba(127, 178, 217, 0.35); cursor: pointer; line-height: 1.25; }
.tbox.f { background: rgba(224, 168, 79, 0.13); border-color: rgba(224, 168, 79, 0.4); }
.tbox.dead { opacity: 0.75; }
.tbox.empty { cursor: default; color: var(--muted); background: transparent; border-style: dashed; border-color: var(--line); font-size: 13px; }
.tbox b { display: block; font-weight: 600; font-size: 13.5px; }
.tbox small { color: var(--muted); font-size: 12px; }
.tbox:not(.empty):hover { border-color: var(--accent-2); }
.tbox.royal { box-shadow: inset 0 0 0 1px rgba(240, 200, 90, 0.55); }
.tfam { display: flex; flex-direction: column; gap: 8px; }
.trow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.trow > .muted { width: 70px; font-size: 13px; }
.tkids { font-size: 13px; flex: 1 1 160px; }
.kingdoms details.kings { margin-top: 4px; }
.kingdoms details.kings ol { margin: 4px 0 0 18px; padding: 0; font-size: 13px; }
.tline { margin-top: 8px; }
.tline summary { cursor: pointer; color: var(--accent-2); }
.tline ol { max-height: 260px; overflow-y: auto; margin: 8px 0 0; padding-left: 28px; font-size: 14px; }

/* secrets tab */
.secrets { margin: 8px 0 0; padding-left: 34px; color: #6d7480; font-size: 14px; line-height: 1.75; }
.secrets li::marker { color: #565d68; }
.secrets li.found { color: var(--text); }
.secrets li.found::marker { color: var(--accent); }
.secrets li.found b { color: var(--accent-2); font-weight: 600; }
.secret-ico { display: inline-block; vertical-align: -5px; margin-right: 6px; }

.person-head .title { color: var(--accent); font-weight: 600; }

/* the "?" window: one line per version that opens and closes, then the help */
.card.helpcard { width: min(600px, calc(100vw - 32px)); }
.releases { margin: 18px 0 4px; }
.release { border: 1px solid var(--line); border-radius: 10px; margin: 0 0 8px; background: rgba(255, 255, 255, 0.03); }
.release summary { cursor: pointer; padding: 9px 12px; color: var(--accent-2); font-weight: 600; list-style: none; display: flex; justify-content: space-between; }
.release summary::-webkit-details-marker { display: none; }
.release summary::after { content: '▾'; color: var(--muted); transition: transform 0.15s; }
.release[open] summary::after { transform: rotate(180deg); }
.release ul { margin: 0; padding: 0 14px 10px 32px; line-height: 1.5; }
.card.helpcard h4 { margin: 12px 0 4px; color: var(--accent); font-weight: 600; }
.help { margin: 0; padding-left: 20px; line-height: 1.5; }
.help li { margin: 2px 0; }
/* "what's new": breaking changes and new-world-only notes on top of each version */
.release .tag { display: inline-block; font-size: 0.75em; font-weight: 600; padding: 0 6px; border-radius: 8px; margin-right: 2px; vertical-align: 1px; }
.release .tag.breaking { background: #b3261e; color: #fff; }
.release .tag.new { background: #c27c0e; color: #fff; }
.release .tag.old { background: #3b5b8c; color: #fff; }
.release .kind { font-size: 0.85em; }
.release .kind.fix { color: #66bb6a; }
.release .kind.add { color: #c27c0e; }
/* the Kingdoms tab */
.kingdoms { list-style: none; margin: 0; padding: 0; }
.kingdoms li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.kingdoms li .dot { margin-top: 6px; flex: none; }
.kingdoms li > div > div { margin-top: 2px; }
.kingdoms a { color: var(--accent-2); text-decoration: none; }
.kingdoms a:hover { text-decoration: underline; }

/* famous people of the real world */
.fame-star { color: #ff3030; text-shadow: 0 0 4px rgba(255, 48, 48, 0.45); }
.famous li.found { cursor: pointer; margin-bottom: 4px; line-height: 1.35; }
.famous li.found .muted { font-size: 12px; }
.famous .alive { font-size: 11px; color: #7fd18b; margin-left: 4px; }
.brand .planet { color: #e0785a; font-size: 0.8em; }
.sound-wrap { position: relative; display: inline-block; }
.sound-panel { position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); display: grid; gap: 8px; padding: 10px 12px; background: var(--panel-solid); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4); z-index: 20; }
.sound-panel[hidden] { display: none; }
.maps-panel { --cw: min(110px, calc((100vw - 48px) / 5)); --ch: calc(var(--cw) / 2); display: block; position: fixed; left: 50%; top: 50%; bottom: auto; transform: translate(-50%, -50%); }
.maps-grid { position: relative; width: calc(var(--cw) * 5); height: calc(var(--ch) * 5); }
.maps-grid > * { position: absolute; width: var(--cw); height: var(--ch); clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.maps-grid img { cursor: pointer; display: block; }
.maps-grid img:hover { filter: brightness(1.25); }
.maps-grid .closed { background: rgba(255, 255, 255, 0.03); transform: scale(0.94); }
.maps-ring { pointer-events: none; background: none; border: 0; }
.maps-ring svg { width: 100%; height: 100%; display: block; }
.maps-note { margin-top: 6px; font-size: 12px; opacity: 0.7; text-align: center; }
.sound-row { display: flex; align-items: center; gap: 10px; }
.sound-row .btn { min-width: 92px; }
.sound-row input[type='range'] { width: 130px; accent-color: var(--accent); }
.app-wrap[hidden] { display: none; }
.news-panel { min-width: 240px; max-width: calc(100vw - 24px); left: 0; transform: none; }
.news-panel .btn { width: 100%; text-align: left; }
.news-panel .news-server { text-align: center; opacity: 0.85; }

/* more maps: arrows at the edges of the screen to the maps next door */
.map-arrow { position: fixed; z-index: 4; opacity: 0.8; }
.map-arrow:hover { opacity: 1; }
#mapN { top: 64px; left: 50%; transform: translateX(-50%); }
#mapS { bottom: 64px; left: 50%; transform: translateX(-50%); }
#mapW { left: 12px; top: 50%; transform: translateY(-50%); }
#mapE { right: 12px; top: 50%; transform: translateY(-50%); }
body:not(.side-hidden) #mapE { right: calc(var(--side-w) + 24px); }
.maps-wrap[hidden] { display: none; }

/* the Android app: a ☰ menu at the top right, only the zoom on the map */
body.in-app .controls { display: none; }
body.in-app .top { right: 64px; }
#menuBtn { position: fixed; top: 12px; right: 12px; z-index: 12; width: 44px; height: 44px; font-size: 20px; }
#appMenu { position: fixed; top: 64px; right: 12px; width: min(280px, calc(100vw - 24px)); max-height: calc(100vh - 80px); overflow-y: auto; padding: 8px 12px 12px; background: var(--panel-solid); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5); z-index: 12; }
#appMenu[hidden] { display: none; }
#appMenu section { display: grid; gap: 6px; padding: 6px 0 8px; border-bottom: 1px solid var(--line); }
#appMenu section:last-child { border-bottom: 0; }
#appMenu h4 { margin: 4px 0 2px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
#appMenu .btn { width: 100%; text-align: left; min-height: 42px; }
#appMenu .btn.round.help { width: 100%; border-radius: 999px; }
#appMenu .sound-wrap { display: grid; gap: 6px; }
#appMenu .sound-wrap[hidden], #appMenu [hidden] { display: none; }
#appMenu .sound-panel:not(.maps-panel) { position: static; transform: none; box-shadow: none; }
.zoom-rail { position: fixed; right: 12px; bottom: 12px; z-index: 6; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; backdrop-filter: blur(8px); }
.zoom-rail input[type=range] { writing-mode: vertical-lr; direction: rtl; width: 28px; height: 150px; margin: 0; accent-color: var(--accent); }
@media (max-width: 900px) {
  body.in-app .zoom-rail { bottom: calc(42vh + 12px); }
  body.in-app.side-hidden .zoom-rail { bottom: 12px; }
  body.in-app .top { right: 64px; }
}
