:root {
  --parch: #f4ead3;
  --parch-2: #eadcbc;
  --parch-3: #dccaa2;
  --ink: #2a2017;
  --ink-2: #6b5a45;
  --terra: #b5532c;
  --terra-d: #8e3d1d;
  --gold: #c08a1e;
  --gold-l: #f0d48a;
  --aegean: #2c6e95;
  --olive: #6d7a3b;
  --good: #4f7a2e;
  --bad: #b23a2a;
  --accent: var(--terra);
  --head-bg: linear-gradient(180deg, #8e3d1d, #6e2d14);
  --radius: 10px;
  --shadow: 0 2px 10px rgba(60, 35, 10, .18);
  font-family: 'Noto Serif', Georgia, 'Times New Roman', serif;
}
body[data-epoch="1"] { --accent: #a8641e; --head-bg: linear-gradient(180deg, #8a5418, #5e3a10); }
body[data-epoch="2"] { --accent: #2c6e95; --head-bg: linear-gradient(180deg, #2f6d93, #1e4a66); }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--parch);
  background-image: radial-gradient(circle at 20% 10%, rgba(255,255,255,.5), transparent 50%),
                    radial-gradient(circle at 80% 90%, rgba(180,140,80,.15), transparent 50%);
  color: var(--ink);
  display: flex; flex-direction: column;
  font-size: 15px;
}
button { font-family: inherit; }
.hidden { display: none !important; }
.dim { color: var(--ink-2); font-size: .9em; }
.greek { font-family: 'Noto Serif', 'Palatino Linotype', serif; }
kbd { font-family: inherit; font-size: .75em; border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; opacity: .55; margin-right: 6px; }

/* ---------- верхняя панель ---------- */
#topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 8px 16px; color: #fbf3e2;
  background: var(--head-bg);
  box-shadow: 0 2px 0 rgba(0,0,0,.15);
  position: relative;
}
#topbar::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -8px; height: 8px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='8'%3E%3Cpath d='M0 7h7V1h6v4H9' fill='none' stroke='%23b5532c' stroke-width='1.6' opacity='.55'/%3E%3C/svg%3E") repeat-x;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 230px; }
.logo { font-size: 26px; font-weight: 700; letter-spacing: .02em; color: var(--gold-l); }
.epoch-name { font-weight: 700; font-size: 16px; }
.epoch-sub { font-size: 12px; opacity: .8; }
.resources { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.res {
  display: flex; align-items: baseline; gap: 4px;
  background: rgba(255,255,255,.12); border-radius: 8px; padding: 4px 9px;
  font-variant-numeric: tabular-nums;
}
.res .ic { font-size: 15px; }
.res b { font-size: 15px; }
.res small { font-size: 11px; opacity: .8; color: #d9f0b5; }
.res small.neg { color: #ffb9a8; }
.res .warn { font-style: normal; font-size: 11px; color: #ffd2a1; margin-left: 3px; }
.res.logos { background: var(--gold-l); color: #4a3200; }
.res.logos .ic { font-weight: 700; font-style: italic; }
.study-btn {
  font-size: 16px; font-weight: 700; color: #3a2700; cursor: pointer;
  background: linear-gradient(180deg, #ffe39a, #e2ae3c); border: 0; border-radius: 22px;
  padding: 9px 18px; box-shadow: 0 2px 0 #9b6e12, 0 0 0 0 rgba(240,212,138,.6);
  animation: glow 2.4s infinite;
  white-space: nowrap;
}
.study-btn:hover { filter: brightness(1.05); }
.study-btn .count { background: var(--terra-d); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 13px; margin-left: 4px; }
@keyframes glow { 50% { box-shadow: 0 2px 0 #9b6e12, 0 0 0 8px rgba(240,212,138,0); } 0% { box-shadow: 0 2px 0 #9b6e12, 0 0 0 0 rgba(240,212,138,.6); } }

/* ---------- раскладка ---------- */
main { flex: 1; display: flex; gap: 16px; padding: 18px 16px 12px; min-height: 0; }
#mapWrap { flex: 1; display: flex; flex-direction: column; align-items: center; min-width: 0; position: relative; }
#side { width: 360px; display: flex; flex-direction: column; min-height: 0; background: var(--parch-2); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ---------- карта ---------- */
#map {
  display: grid; gap: 0;
  width: min(100%, calc((100vh - 150px) * 18 / 11));
  border-radius: 14px; overflow: hidden;
  box-shadow: var(--shadow), inset 0 0 0 3px rgba(0,0,0,.08);
  background: #2c6e95;
  user-select: none;
}
.tile {
  aspect-ratio: 1; position: relative; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(14px, 2.1vw, 30px);
  transition: filter .15s;
}
.t-sea { background: #2f74a0; cursor: default;
  background-image: radial-gradient(ellipse at 30% 40%, rgba(255,255,255,.12) 0 18%, transparent 19%),
                    radial-gradient(ellipse at 70% 75%, rgba(255,255,255,.08) 0 14%, transparent 15%); }
.t-sea.alt { background-color: #2b6c97; }
.t-plain { background: #d8c58a; }
.t-plain.alt { background: #d2bd80; }
.t-plain.coast { background: #e7d6a2; }
.t-plain.coast.alt { background: #e2d09a; }
.t-forest { background: #8e9a54; }
.t-forest.alt { background: #86934d; }
.t-hill { background: #b58e5e; }
.t-hill.alt { background: #ad8656; }
.tile:not(.t-sea):hover { filter: brightness(1.1); box-shadow: inset 0 0 0 2px rgba(255,255,255,.6); z-index: 1; }
.tile .deco { opacity: .55; font-size: .78em; pointer-events: none; }
.t-hill .deco { opacity: .45; }
.tile .b { filter: drop-shadow(0 2px 1px rgba(0,0,0,.35)); pointer-events: none; }
.tile .lvl { position: absolute; bottom: 2px; right: 2px; font-size: 10px; line-height: 1; font-weight: 700; color: #fff; background: rgba(42,32,23,.55); border-radius: 4px; padding: 1px 3px; pointer-events: none; font-family: system-ui, sans-serif; }
.tile.special { background-image: radial-gradient(circle, rgba(255,230,150,.75), transparent 70%); }
.tile.special .b { font-size: 1.1em; }
.tile.idle .b { filter: grayscale(1) opacity(.6); }
.tile.idle::after { content: '⚠'; position: absolute; top: 1px; right: 3px; font-size: 10px; }
.tile.pulse { animation: pulse .3s; }
@keyframes pulse { 50% { transform: scale(.9); } }
body.placing .tile.invalid { filter: brightness(.6) saturate(.6); cursor: not-allowed; }
body.placing .tile.valid { box-shadow: inset 0 0 0 2px #fff, inset 0 0 12px rgba(255,255,255,.6); }
body.placing .tile.valid:hover { background-color: #c4e39a; }

.place-hint {
  margin-top: 10px; background: var(--ink); color: #fbf3e2; padding: 8px 14px; border-radius: 8px; font-size: 13px;
}
#log { margin-top: 10px; display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--ink-2); align-self: stretch; padding: 0 6px; }
#log span:first-child { color: var(--ink); }

.float {
  position: fixed; transform: translate(-50%, -50%); pointer-events: none; z-index: 1000;
  font-weight: 700; color: #fff; text-shadow: 0 1px 2px #000, 0 0 6px rgba(0,0,0,.4);
  animation: floatUp 1s ease-out forwards; font-size: 16px; white-space: nowrap;
}
.float.gold { color: var(--gold-l); font-size: 20px; }
@keyframes floatUp { to { transform: translate(-50%, -160%); opacity: 0; } }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 2000;
  background: var(--ink); color: #fbf3e2; padding: 10px 18px; border-radius: 10px; box-shadow: var(--shadow);
  max-width: 90vw; font-size: 14px; transition: opacity .4s;
}
.toast.out { opacity: 0; }

/* ---------- боковая панель ---------- */
.tabs { display: flex; padding: 6px 6px 0; gap: 4px; }
.tabs button {
  flex: 1; border: 0; background: transparent; padding: 9px 4px; font-size: 14px; cursor: pointer;
  border-radius: 8px 8px 0 0; color: var(--ink-2); font-weight: 600;
}
.tabs button.active { background: var(--parch); color: var(--accent); }
#panel { flex: 1; overflow-y: auto; background: var(--parch); margin: 0 6px 6px; border-radius: 0 0 8px 8px; padding: 10px; }
#panel h3 { margin: 16px 2px 8px; font-size: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }
#panel h3 small { text-transform: none; letter-spacing: 0; color: var(--ink-2); font-weight: 400; }
.hint { font-size: 13px; color: var(--ink-2); background: rgba(255,255,255,.45); border-left: 3px solid var(--accent); padding: 7px 10px; border-radius: 4px; margin-bottom: 10px; }
.hint.dim { border-left-color: transparent; background: none; padding: 4px 2px; }

.item { display: flex; gap: 10px; align-items: center; padding: 9px; border-radius: 8px; background: #fff8; margin-bottom: 6px; border: 1px solid transparent; }
.item.selected { border-color: var(--accent); background: #fff; }
.item.disabled .item-ic { filter: grayscale(.6); opacity: .7; }
.item.learned { opacity: .7; }
.item-ic { font-size: 28px; width: 38px; text-align: center; flex: none; }
.item-body { flex: 1; min-width: 0; }
.item-title { font-weight: 700; font-size: 14px; }
.item-desc { font-size: 12px; color: var(--ink-2); margin: 1px 0 4px; }
.item-lock, .item-done { font-size: 12px; color: var(--ink-2); }
.item-done { color: var(--good); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.chip { font-size: 12px; background: var(--parch-2); border-radius: 6px; padding: 1px 6px; white-space: nowrap; }
.chip.lack { color: var(--bad); background: #f6d8cf; }
.chip.logos { background: var(--gold-l); color: #4a3200; font-weight: 700; }
.chip.logos.lack { background: #f4e2b8; color: var(--bad); }
.chip.good { background: #e1ebcd; color: #34511c; }
.chip.bad { background: #f6d8cf; color: var(--bad); }
.chip.muted { background: transparent; color: var(--ink-2); padding-left: 0; }

.btn {
  border: 0; border-radius: 8px; padding: 9px 16px; font-size: 14px; font-weight: 700; cursor: pointer;
  background: var(--accent); color: #fff; box-shadow: 0 2px 0 rgba(0,0,0,.25);
}
.btn:hover:not(:disabled) { filter: brightness(1.08); }
.btn:active:not(:disabled) { transform: translateY(1px); box-shadow: 0 1px 0 rgba(0,0,0,.25); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.small { padding: 6px 11px; font-size: 13px; }
.btn.wide { width: 100%; margin-top: 8px; }
.btn.gold { background: linear-gradient(180deg, #f3cf6d, #d39b25); color: #3a2700; box-shadow: 0 2px 0 #9b6e12; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--parch-3); }
.btn.ghost.danger, .link.danger { color: var(--bad); }
.link { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; font-size: 13px; text-decoration: underline; }

.epoch-card { background: #fff8; border-radius: 8px; padding: 12px; }
.epoch-title { font-size: 20px; font-weight: 700; color: var(--accent); }
.epoch-years { font-size: 13px; color: var(--ink-2); font-style: italic; }
.epoch-card p { font-size: 13.5px; line-height: 1.5; margin: 8px 0 0; }
.reqs { list-style: none; padding: 0; margin: 0; }
.reqs li { display: flex; justify-content: space-between; padding: 6px 8px; border-radius: 6px; font-size: 14px; }
.reqs li:nth-child(odd) { background: #fff6; }
.reqs li.ok { color: var(--good); }
.reqs small { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.timeline { list-style: none; padding: 0 0 0 14px; margin: 0; border-left: 2px solid var(--parch-3); }
.timeline li { padding: 4px 0 6px 10px; position: relative; color: var(--ink-2); }
.timeline li::before { content: ''; position: absolute; left: -21px; top: 9px; width: 10px; height: 10px; border-radius: 50%; background: var(--parch-3); }
.timeline li.past::before { background: var(--good); }
.timeline li.now { color: var(--ink); }
.timeline li.now::before { background: var(--accent); box-shadow: 0 0 0 3px rgba(181,83,44,.25); }
.timeline li.future { opacity: .55; }
.timeline b { display: block; font-size: 14px; }
.timeline small { font-size: 12px; }
.statline { font-size: 13px; line-height: 1.6; }
.dev { margin-top: 14px; padding: 8px; border: 1px dashed var(--ink-2); border-radius: 8px; font-size: 13px; }

.deck { background: #fff8; border-radius: 8px; padding: 10px; margin-bottom: 8px; }
.deck.off { opacity: .6; }
.deck-head { display: flex; gap: 6px; align-items: center; cursor: pointer; }
.deck-bar { display: flex; height: 6px; border-radius: 3px; overflow: hidden; margin: 8px 0 4px; background: var(--parch-3); }
.deck-bar i.learned { background: var(--good); }
.deck-bar i.learning { background: var(--gold); }
.deck-bar i.fresh { background: var(--parch-3); }
.deck-stats { font-size: 12px; color: var(--ink-2); }
.deck-actions { display: flex; gap: 14px; margin-top: 6px; }
.import input[type=text], .import textarea {
  width: 100%; font-family: inherit; font-size: 13px; border: 1px solid var(--parch-3); border-radius: 6px; padding: 7px 9px;
  background: #fffdf7; color: var(--ink); margin-bottom: 6px; resize: vertical;
}
.import-row { display: flex; gap: 8px; justify-content: flex-end; margin-bottom: 4px; }
label.btn { display: inline-block; }

/* ---------- окна ---------- */
.modal { position: fixed; inset: 0; background: rgba(30,20,10,.45); display: flex; align-items: center; justify-content: center; z-index: 500; padding: 16px; }
.modal-box { background: var(--parch); border-radius: 14px; padding: 20px 22px; width: min(480px, 100%); max-height: 90vh; overflow: auto; box-shadow: 0 10px 40px rgba(0,0,0,.35); }
.modal-box h2 { margin: 0 0 2px; font-size: 20px; }
.mb-head { display: flex; gap: 14px; align-items: center; margin-bottom: 10px; }
.mb-ic { font-size: 44px; }
.mb-actions { display: flex; justify-content: space-between; margin-top: 16px; gap: 8px; }
.mb-actions:has(> :only-child) { justify-content: flex-end; }
.upgrade { margin-top: 14px; background: #fff8; border-radius: 8px; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.upgrade .btn { align-self: flex-start; margin-top: 4px; }
.warn { color: var(--bad); }
.epoch-modal { text-align: center; }
.epoch-modal h2 { font-size: 28px; color: var(--accent); margin-top: 6px; }
.epoch-modal p { text-align: left; line-height: 1.55; font-size: 14.5px; }
.epoch-modal p.how { background: #fff8; padding: 10px 12px; border-radius: 8px; font-size: 14px; }
.epoch-modal .btn { margin-top: 6px; padding: 10px 28px; font-size: 15px; }
.meander { height: 10px; margin: -6px -6px 10px; opacity: .6;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='10'%3E%3Cpath d='M0 9h9V1h8v6h-5V4' fill='none' stroke='%23b5532c' stroke-width='1.6'/%3E%3C/svg%3E") repeat-x; }
.deck-table { max-height: 60vh; overflow: auto; margin-top: 10px; }
.deck-table table { width: 100%; border-collapse: collapse; font-size: 14px; }
.deck-table td { padding: 5px 6px; border-bottom: 1px solid var(--parch-3); }
.deck-table td.greek { font-weight: 600; }
.deck-table td.box { color: var(--good); letter-spacing: -1px; white-space: nowrap; font-size: 11px; }

/* ---------- раунд карточек ---------- */
.study { position: fixed; inset: 0; z-index: 800; background: rgba(42,32,23,.72); display: flex; align-items: center; justify-content: center; padding: 16px; backdrop-filter: blur(3px); }
.st-box { width: min(620px, 100%); background: var(--parch); border-radius: 18px; padding: 16px 22px 24px; box-shadow: 0 20px 60px rgba(0,0,0,.5); min-height: 440px; display: flex; flex-direction: column; }
.st-head { display: flex; align-items: center; gap: 12px; }
.st-close { border: 0; background: none; font-size: 20px; cursor: pointer; color: var(--ink-2); padding: 4px 6px; }
.st-bar { flex: 1; height: 10px; background: var(--parch-3); border-radius: 5px; overflow: hidden; }
.st-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), #e9be52); transition: width .3s; }
.st-meta { display: flex; gap: 10px; align-items: center; font-size: 14px; }
.st-earned { background: var(--gold-l); color: #4a3200; font-weight: 700; padding: 3px 10px; border-radius: 12px; }
.st-bonus { font-size: 12px; color: var(--ink-2); text-align: right; min-height: 16px; margin-top: 4px; }
.st-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding-top: 6px; }
.q-label { font-size: 14px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .08em; }
.badge { text-transform: none; letter-spacing: 0; font-size: 12px; background: var(--parch-3); padding: 1px 8px; border-radius: 10px; margin-left: 6px; }
.badge.new { background: #dce9c6; color: #34511c; }
.q-word { font-size: 40px; font-weight: 700; text-align: center; display: flex; align-items: center; gap: 10px; }
.q-word.greek { color: var(--accent); }
.say { border: 0; background: #fff9; border-radius: 50%; width: 36px; height: 36px; font-size: 17px; cursor: pointer; }
.say:hover { background: #fff; }
.q-hint { font-style: italic; color: var(--ink-2); font-size: 15px; }
.q-hint.reveal { visibility: hidden; }
.q-hint.reveal.shown { visibility: visible; }
.flash { background: #fff; border-radius: 14px; padding: 22px 40px; text-align: center; box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.flash-back { font-size: 24px; text-align: center; }
.flash .flash-back { border-top: 1px solid var(--parch-3); padding-top: 10px; margin-top: 4px; }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.opt {
  font-size: 18px; text-align: left; padding: 14px 16px; border-radius: 10px; cursor: pointer;
  background: #fff; border: 2px solid var(--parch-3); color: var(--ink); display: flex; align-items: center;
}
.opt:hover:not(:disabled) { border-color: var(--accent); }
.opt.right { border-color: var(--good); background: #e1ebcd; }
.opt.wrong { border-color: var(--bad); background: #f6d8cf; }
.opt:disabled { cursor: default; }
.feedback { min-height: 44px; display: flex; align-items: center; gap: 14px; font-size: 17px; }
.feedback.ok { color: var(--good); }
.feedback.bad { color: var(--bad); }
.feedback .greek { font-weight: 700; }
.next { margin-top: 2px; }

.slots { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; min-height: 54px; }
.slot { width: 42px; height: 50px; border-bottom: 3px solid var(--ink-2); display: flex; align-items: center; justify-content: center; font-size: 28px; font-weight: 700; color: var(--accent); }
.slot.filled { cursor: pointer; background: #fff8; border-radius: 6px 6px 0 0; }
.slots.right .slot { border-color: var(--good); color: var(--good); }
.slots.wrong .slot { border-color: var(--bad); color: var(--bad); }
.tiles { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; max-width: 520px; }
.tile-l { width: 46px; height: 50px; font-size: 24px; font-family: inherit; border-radius: 8px; border: 0; background: #fff; box-shadow: 0 3px 0 var(--parch-3); cursor: pointer; color: var(--ink); }
.tile-l:hover:not(:disabled) { transform: translateY(-2px); }
.tile-l.used { opacity: .2; }
.build-tools { display: flex; gap: 12px; align-items: center; }

.match { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; width: 100%; }
.match .col { display: flex; flex-direction: column; gap: 8px; }
.mt { font-size: 17px; padding: 12px; border-radius: 10px; border: 2px solid var(--parch-3); background: #fff; cursor: pointer; color: var(--ink); }
.mt.greek { font-weight: 700; }
.mt.sel { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(181,83,44,.2); }
.mt.right { border-color: var(--good); background: #e1ebcd; opacity: .65; }
.mt.wrong { border-color: var(--bad); background: #f6d8cf; animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.flip-actions { display: flex; gap: 10px; }

.end { text-align: center; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.end-l { font-size: 54px; font-weight: 700; color: var(--gold); }
.end-t { font-size: 22px; font-weight: 700; }
.end-actions { display: flex; gap: 10px; margin-top: 12px; }

/* ---------- узкие экраны ---------- */
@media (max-width: 900px) {
  main { flex-direction: column; }
  #side { width: auto; min-height: 420px; }
  #map { width: 100%; }
  #topbar { flex-wrap: wrap; }
  .options { grid-template-columns: 1fr; }
  .q-word { font-size: 32px; }
}

/* ---------- v2: склады, спецстроения, козы, справка ---------- */
.res.full { box-shadow: inset 0 0 0 1.5px #ffb9a8; }
.res.full b { color: #ffd2c6; }
.res.store { opacity: .8; }
.pedia-btn {
  font-size: 18px; border: 0; cursor: pointer; border-radius: 50%; width: 40px; height: 40px;
  background: rgba(255,255,255,.15); color: #fff;
}
.pedia-btn:hover { background: rgba(255,255,255,.28); }
.item.sp { background: linear-gradient(135deg, #fff9e8, #fff4d6); border-color: #ecd9a6; }
.item-title small { color: var(--ink-2); font-weight: 400; }
.item-effect { font-size: 12px; color: #34511c; margin-top: 4px; }
.q {
  border: 0; width: 17px; height: 17px; border-radius: 50%; font-size: 11px; line-height: 17px; padding: 0;
  background: var(--parch-3); color: var(--ink-2); cursor: pointer; font-weight: 700; vertical-align: 1px; margin-left: 2px;
}
.q:hover { background: var(--accent); color: #fff; }
.tile.goat { z-index: 2; }
.tile.goat .goat-ic { filter: drop-shadow(0 2px 1px rgba(0,0,0,.35)); pointer-events: none; display: flex; }
.sect { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); margin-top: 8px; }
.lore { font-style: italic; color: #4c3d2c; line-height: 1.55; }
.em-actions { display: flex; gap: 10px; justify-content: center; }
.modal-box h2 .q { vertical-align: 4px; }

/* ---------- Кипропедия ---------- */
.pedia { position: fixed; inset: 0; z-index: 700; background: rgba(42,32,23,.6); display: flex; align-items: center; justify-content: center; padding: 16px; }
.pedia-box { width: min(1040px, 100%); height: min(760px, 100%); background: var(--parch); border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.45); display: flex; flex-direction: column; overflow: hidden; }
.pedia-top { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px 10px 20px; background: var(--head-bg); color: #fbf3e2; }
.pedia-top .st-close { color: #fbf3e2; }
.pedia-title { font-size: 18px; font-weight: 700; }
.pedia-title small { font-weight: 400; opacity: .7; font-size: 14px; margin-left: 6px; }
.pedia-main { flex: 1; display: flex; min-height: 0; }
.pedia-nav { width: 250px; flex: none; overflow-y: auto; background: var(--parch-2); padding: 8px 6px 16px; }
.pn-group { margin-bottom: 8px; }
.pn-title { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); font-weight: 700; padding: 8px 10px 4px; }
.pn-item { display: flex; gap: 8px; align-items: center; padding: 5px 10px; border-radius: 6px; color: var(--ink); text-decoration: none; font-size: 13.5px; }
.pn-item span { width: 20px; text-align: center; flex: none; }
.pn-item:hover { background: rgba(255,255,255,.5); }
.pn-item.active { background: var(--parch); color: var(--accent); font-weight: 700; }
.pedia-body { flex: 1; overflow-y: auto; padding: 18px 28px 30px; font-size: 14.5px; line-height: 1.55; }
.pedia-body a { color: var(--accent); }
.pedia-body h4 { margin: 18px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }
.pedia-body ol, .pedia-body ul { padding-left: 22px; margin: 6px 0; }
.pedia-body li { margin-bottom: 4px; }
.pedia-body .lead { font-size: 15.5px; }
.pedia-body pre { background: #fffdf7; border: 1px solid var(--parch-3); border-radius: 8px; padding: 10px 12px; font-size: 13px; overflow-x: auto; }
.pedia-body .tip { background: #fff8; border-left: 3px solid var(--gold); padding: 8px 12px; border-radius: 4px; }
.pa-head { display: flex; gap: 14px; align-items: center; margin-bottom: 8px; border-bottom: 1px solid var(--parch-3); padding-bottom: 10px; }
.pa-ic { font-size: 44px; width: 60px; text-align: center; font-weight: 700; color: var(--gold); font-style: italic; }
.pa-head h2 { margin: 0; font-size: 26px; }
.pa-sub { font-size: 12px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .06em; }
table.pt { border-collapse: collapse; width: 100%; margin: 6px 0; font-size: 13.5px; }
table.pt td, table.pt th { padding: 6px 8px; border-bottom: 1px solid var(--parch-3); text-align: left; vertical-align: top; }
table.pt th { font-size: 12px; color: var(--ink-2); font-weight: 600; }
table.pt td:first-child { color: var(--ink-2); }
table.pt.levels td:first-child { font-weight: 700; color: var(--ink); width: 36px; white-space: nowrap; }
table.pt tr.ep1 { background: rgba(168,100,30,.07); }
ul.flat { list-style: none; padding: 0 !important; margin: 0 !important; }
@media (max-width: 760px) {
  .pedia-main { flex-direction: column; }
  .pedia-nav { width: auto; max-height: 34%; }
  .pedia-body { padding: 14px 16px; }
}

/* ---------- v3: уровни зданий, обряды ---------- */
.tabs button { font-size: 13px; padding: 9px 2px; }
.dim.small { font-size: 12px; }
.res.buff { background: rgba(255, 228, 140, .25); }
.res.buff small { color: #ffe9a8; font-variant-numeric: tabular-nums; }
.buffs-list { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.tile .bw { position: relative; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.tile .bw .b { position: absolute; line-height: 1; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.tile .bw .b1 { z-index: 3; }
.tile .bw .b2 { font-size: .56em; left: 27%; top: 30%; z-index: 2; }
.tile .bw .b3 { font-size: .5em; left: 72%; top: 24%; z-index: 1; opacity: .92; }
table.pt tr.lv-logos td:first-child { color: #9b6e12; }
table.pt tr.lv-logos td:first-child::after { content: ' λ'; font-style: italic; font-size: 11px; }
#toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
#toasts .toast { position: static; transform: none; }
.btn.danger-fill { background: var(--bad); }

/* ---------- v4: стадии зданий, цены, население, пути ---------- */
.chip { font-size: 13px; padding: 2px 7px; display: inline-flex; align-items: center; gap: 3px; }
.chip i { font-style: normal; font-size: 16px; line-height: 1; }
.chip.logos i { font-weight: 700; font-style: italic; font-size: 14px; }
.chip[title] { cursor: help; }
.res { cursor: help; }
.res .lbl { color: rgba(255,255,255,.75) !important; font-size: 11px; }
.res.work.short { background: rgba(255, 120, 90, .3); box-shadow: inset 0 0 0 1.5px #ffb9a8; }
.res.work.short .lbl { color: #ffe0d6 !important; }
.btn.off { opacity: .45; }
.path { display: grid; grid-template-columns: 56px 1fr auto; align-items: center; gap: 6px; margin-top: 5px; }
.path-l { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); }
.path .btn { padding: 5px 10px; }
.item .item-body { min-width: 0; }
.upgrade.lv-logos { background: linear-gradient(135deg, #fff9e3, #fff1c9); box-shadow: inset 0 0 0 1px #ecd9a6; }
.newlook { font-size: 13px; background: var(--gold-l); color: #4a3200; border-radius: 10px; padding: 1px 8px; margin-left: 6px; }
.settings { display: flex; flex-direction: column; gap: 8px; background: #fff8; border-radius: 8px; padding: 10px; }
.settings label { display: flex; flex-direction: column; gap: 3px; font-size: 13px; }
.settings select { font-family: inherit; font-size: 13px; padding: 5px; border: 1px solid var(--parch-3); border-radius: 6px; background: #fffdf7; }
.learned-mark { color: var(--good); font-weight: 700; }
.steps { color: var(--gold); letter-spacing: 1px; }
/* стадии облика на карте (меняются на уровнях мудрости 3, 5, 7, 9) */
.tile.stage-2 .lvl { background: #6d7380; }
.tile.stage-3 .lvl, .tile.stage-4 .lvl { background: #b8860b; }
.tile.n1 .bw .b1 { font-size: 1em; left: 50%; top: 50%; }
.tile.n2 .bw .b1 { font-size: .82em; left: 60%; top: 60%; }
.tile.n2 .bw .b2 { font-size: .62em; left: 30%; top: 32%; }
.tile.n3 .bw .b1 { font-size: .78em; left: 56%; top: 62%; }
.tile.n3 .bw .b2 { font-size: .56em; left: 26%; top: 30%; }
.tile.n3 .bw .b3 { font-size: .52em; left: 76%; top: 24%; }
/* слоги */
.slots.syl .slot { width: auto; min-width: 54px; padding: 0 8px; font-size: 24px; }
.tiles.syl .tile-l { width: auto; min-width: 60px; padding: 0 12px; font-size: 21px; }

/* ---------- v5: рисованные SVG-иконки ---------- */
.ico { display: block; width: 100%; height: 100%; overflow: visible; }
.ico.inl { display: inline-block; width: 1.5em; height: 1.5em; vertical-align: -.42em; }
.lg { font-style: italic; }
.res .ic { display: inline-flex; align-items: center; }
.res .ic .ico { width: 20px; height: 20px; }
.res { padding: 3px 7px; }
.resources { gap: 4px; }
.chip i .ico { width: 19px; height: 19px; }
.item-ic { width: 46px; height: 46px; font-size: 30px; display: flex; align-items: center; justify-content: center; }
.item-ic .ico { width: 46px; height: 46px; }
.mb-ic { width: 76px; height: 76px; flex: none; }
.pa-ic { width: 72px; height: 72px; display: flex; align-items: center; justify-content: center; }
.pa-ic .ico { width: 72px; height: 72px; }
.pn-item span { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; }
.pn-item span .ico { width: 22px; height: 22px; }
.tile .b .ico { width: 1.75em; height: 1.75em; }
.tile.special .b .ico { width: 1.85em; height: 1.85em; }
.tile .deco { opacity: .8; }
.tile .deco .ico { width: 1.6em; height: 1.6em; }
.tile.t-hill .deco { opacity: .55; }
.tile.goat .goat-ic .ico { width: 1.6em; height: 1.6em; }
table.pt td .ico.inl { width: 28px; height: 28px; vertical-align: middle; }
table.pt.levels td:nth-child(2) { white-space: nowrap; }
table.pt.levels td.look { white-space: nowrap; }
table.pt.levels th small { font-weight: 400; color: var(--ink-2); }
.newlook .ico.inl { width: 24px; height: 24px; }
.photos { margin-top: 18px; padding: 10px 12px; background: #fff8; border-radius: 8px; font-size: 13.5px; line-height: 1.8; }
.photos a.ext { white-space: nowrap; }
.formula { background: #fffdf7; border: 1px solid var(--parch-3); border-radius: 8px; padding: 8px 12px; font-weight: 600; }

/* ---------- v6: развилка знаний ---------- */
.item.tech { align-items: flex-start; }
.fork { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.fork-opt { border-radius: 8px; padding: 7px 8px; border: 1px solid var(--parch-3); background: #fffdf7; }
.fork-opt.wise { border-color: #e6cf8f; background: linear-gradient(135deg, #fffaf0, #fff3d4); }
.fork-opt.force { border-color: #d9c3a6; background: linear-gradient(135deg, #fbf6ee, #f1e6d6); }
.fork-opt.poor { opacity: .75; }
.fork-h { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; font-size: 13px; }
.fork-tag { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); white-space: nowrap; }
.fork-d { font-size: 11.5px; color: var(--ink-2); font-style: italic; margin: 1px 0 3px; }
.fork-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.fork-or { text-align: center; font-size: 11px; color: var(--ink-2); font-style: italic; line-height: 1; }

/* ---------- v7: обряды, сбор припасов, свёртки ---------- */
.item-note { font-size: 12px; color: var(--accent); font-weight: 600; margin: 1px 0 3px; }
.supply .item { background: linear-gradient(135deg, #f1f7e6, #e3eed0); border: 1px solid #c7d9a6; margin-bottom: 4px; }
.sub-h { font-size: 12px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .06em; margin: 10px 2px 6px; }
.item.rite.active { border: 2px solid #e9b93a; background: linear-gradient(135deg, #fff8dc, #ffeeb8);
  box-shadow: 0 0 0 3px rgba(240, 200, 80, .25), 0 0 16px rgba(240, 190, 60, .45); animation: riteGlow 2.4s ease-in-out infinite; }
@keyframes riteGlow { 50% { box-shadow: 0 0 0 4px rgba(240, 200, 80, .35), 0 0 24px rgba(240, 190, 60, .7); } }
.rite-live { font-size: 11px; font-weight: 700; color: #7a5200; background: #ffe08a; border-radius: 10px; padding: 1px 7px; margin-left: 4px; font-variant-numeric: tabular-nums; }
.btn.extend { background: #fff; color: #7a5200; box-shadow: inset 0 0 0 2px #e9b93a; }
details.fold { margin: 10px 0; background: #fff6; border-radius: 8px; padding: 4px 6px; }
details.fold > summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ink-2); padding: 6px 4px; list-style: none; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before { content: '▸ '; }
details.fold[open] > summary::before { content: '▾ '; }
.item.tech.learned { opacity: .8; padding: 6px 9px; }

/* ---------- v8: верхняя панель ---------- */
#topbar { gap: 12px; padding: 8px 14px; flex-wrap: nowrap; }
.brand { min-width: 0; flex: none; }
.logos-medal { display: flex; align-items: center; gap: 8px; flex: none; padding: 4px 14px 4px 8px; border-radius: 26px; cursor: help;
  background: radial-gradient(circle at 30% 25%, #fff3c4, #f0cf6c 55%, #c99a2c); color: #3a2700;
  box-shadow: 0 2px 0 #8a6619, 0 0 0 2px rgba(255, 230, 150, .35), 0 0 14px rgba(255, 210, 100, .35); }
.lm-sign { width: 34px; height: 34px; border-radius: 50%; background: #3a2700; color: #ffe08a; display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; font-style: italic; }
.lm-v { display: flex; flex-direction: column; line-height: 1.05; }
.lm-v b { font-size: 22px; font-variant-numeric: tabular-nums; }
.lm-v small { font-size: 10.5px; letter-spacing: .04em; opacity: .8; }
.resbar { display: flex; flex: 1; min-width: 0; gap: 0; background: var(--parch); border-radius: 12px; padding: 3px;
  box-shadow: inset 0 1px 3px rgba(60, 35, 10, .35); overflow: hidden; }
.rs { position: relative; display: flex; align-items: center; gap: 5px; padding: 3px 8px 6px; min-width: 0; flex: 1 1 0; max-width: 104px;
  color: var(--ink); border-radius: 9px; cursor: help; }
.rs + .rs { box-shadow: -1px 0 0 var(--parch-3); }
.rs-ic { width: 26px; height: 26px; flex: none; display: flex; }
.rs-ic .ico { width: 26px; height: 26px; }
.rs-v { display: flex; flex-direction: column; line-height: 1.05; min-width: 0; }
.rs-v b { font-size: 15px; font-variant-numeric: tabular-nums; }
.rs-v small { font-size: 10.5px; color: var(--good); font-variant-numeric: tabular-nums; white-space: nowrap; }
.rs-v small.neg { color: var(--bad); }
.rs-bar { position: absolute; left: 8px; right: 8px; bottom: 2px; height: 3px; border-radius: 2px; background: var(--parch-3); overflow: hidden; }
.rs-bar > i { display: block; height: 100%; background: #8aa64c; border-radius: 2px; }
.rs.full .rs-bar > i { background: var(--bad); }
.rs.full .rs-v b { color: var(--bad); }
.rs.buffed { background: linear-gradient(180deg, #fff6d2, #ffe9a6); box-shadow: inset 0 0 0 2px #e9b93a; }
.rs.cap { flex: 0 0 auto; max-width: none; opacity: .85; }
.rs.cap .rs-v small { color: var(--ink-2); }
.popbox { display: flex; flex-direction: column; gap: 2px; flex: none; font-size: 13px; color: #fbf3e2; cursor: help; }
.popbox > div { display: flex; align-items: baseline; gap: 5px; white-space: nowrap; }
.popbox b { font-size: 15px; font-variant-numeric: tabular-nums; }
.popbox small { opacity: .8; font-size: 11px; }
.popbox .short { color: #ffc2b0; }
.buffbar { display: flex; flex-wrap: wrap; gap: 6px; align-self: stretch; margin-bottom: 8px; }
.bf { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 4px; border-radius: 16px; font-size: 13px;
  background: linear-gradient(135deg, #fff8dc, #ffe9a6); box-shadow: inset 0 0 0 1.5px #e9b93a, 0 0 10px rgba(240, 190, 60, .35); cursor: help; }
.bf .ico.inl { width: 24px; height: 24px; vertical-align: middle; }
.bf small { font-variant-numeric: tabular-nums; color: #7a5200; font-weight: 700; }
#map { width: min(100%, calc((100vh - 170px) * 18 / 11)); }
@media (max-width: 1250px) { .rs-v small { display: none; } .rs { padding-bottom: 7px; } .brand .epoch-sub { display: none; } }
.pedia-body .story { font-style: italic; color: #5a4632; border-left: 3px solid var(--accent); padding: 4px 0 4px 12px; margin: 4px 0 12px; }
.pedia-body code { background: #fffdf7; border: 1px solid var(--parch-3); border-radius: 4px; padding: 0 4px; }

/* ---------- v9: модуль «Обучение», кнопка «Учиться», награды ---------- */
.modal { z-index: 900; }                 /* подтверждения — поверх «Обучения» и Кипропедии */
.school { z-index: 650; }                /* Кипропедия (700) открывается поверх «Обучения» */
.study-btn { display: flex; flex-direction: column; align-items: center; line-height: 1.1; padding: 6px 16px; }
.study-btn .sb-main { font-size: 16px; }
.study-btn .sb-sub { font-size: 11px; font-weight: 600; color: #6b4a00; letter-spacing: .01em; }
.study-btn.quiet { animation: none; background: linear-gradient(180deg, #fff0c4, #e9c56e); }
.badge.val { background: var(--gold-l); color: #4a3200; font-weight: 700; }
.st-meta #stCombo { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.end .link { margin-top: 6px; }

.pn-foot { padding: 10px 10px 0; border-top: 1px solid var(--parch-3); margin-top: 6px; }
.school h2 { margin: 0 0 8px; font-size: 22px; }
.kpis { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.kpi { flex: 1 1 110px; background: #fff8; border-radius: 10px; padding: 8px 12px; display: flex; flex-direction: column; cursor: default; }
.kpi b { font-size: 24px; font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi small { font-size: 12px; color: var(--ink-2); }
.kpis.small .kpi b { font-size: 18px; }
.deck-bar { gap: 2px; height: 8px; border-radius: 4px; }
.deck-bar i { border-radius: 4px; }
.bar-legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-2); margin: 2px 0 8px; }
.bar-legend span { display: inline-flex; align-items: center; gap: 5px; }
.bar-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.bar-legend i.learned { background: var(--good); }
.bar-legend i.learning { background: var(--gold); }
.bar-legend i.fresh { background: var(--parch-3); box-shadow: inset 0 0 0 1px #c9b48e; }
.deck-bar i.fresh { background: #e3d3b0; }
.ov-go { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; margin: 4px 0 8px; }
table.days td, table.days th { text-align: right; font-variant-numeric: tabular-nums; }
table.days td:first-child, table.days th:first-child { text-align: left; }
table.days tr.dim td { color: var(--ink-2); opacity: .7; }
.sw-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.sw-filters select, .sw-filters input, .io-list select { font-family: inherit; font-size: 13px; padding: 5px 7px; border: 1px solid var(--parch-3); border-radius: 6px; background: #fffdf7; }
.sw-filters input { flex: 1 1 180px; }
.school .deck-table { max-height: none; }
.school .deck-table th { text-align: left; font-size: 12px; color: var(--ink-2); font-weight: 600; padding: 4px 6px; position: sticky; top: 0; background: var(--parch); }
.school .deck-table td.num { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.bad-n { color: var(--bad); font-weight: 700; }
.io-list { display: flex; flex-direction: column; gap: 10px; }
.io-list > div { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.reset-card { background: #fff8; border-radius: 10px; padding: 10px 14px; margin-bottom: 10px; }
.reset-card p { margin: 4px 0 8px; font-size: 13.5px; }
.school .deck { background: #fff8; }

/* Кипропедия: две части — игра и учёба */
.pn-parts { display: flex; gap: 4px; padding: 4px 4px 8px; position: sticky; top: -8px; background: var(--parch-2); z-index: 1; }
.pn-part { flex: 1; border: 0; border-radius: 8px; padding: 7px 6px; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
  background: rgba(255,255,255,.35); color: var(--ink-2); }
.pn-part.active { background: var(--head-bg); color: #fbf3e2; }

/* ---------- v10: написание — «Какая буква?», разбор ошибок набора ---------- */
.q-sub { font-size: 18px; color: var(--ink-2); margin-bottom: -6px; }
.spell-word { letter-spacing: .02em; }
.spell-word .gap { display: inline-block; min-width: 1.1em; padding: 0 4px; margin: 0 2px; border-bottom: 3px solid var(--gold); color: var(--gold); text-align: center; }
.spell-word .gap.ok { color: var(--good); border-color: var(--good); background: #e1ebcd; border-radius: 6px 6px 0 0; }
.spell-word .gap.bad { color: var(--bad); border-color: var(--bad); background: #f6d8cf; border-radius: 6px 6px 0 0; }
.spell-opts { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
.spell-opts .opt span { font-size: 26px; font-weight: 700; }
.slots.wrong .slot.ok { border-color: var(--good); color: var(--good); background: #e1ebcd; }
.slots.wrong .slot.bad { border-color: var(--bad); color: #fff; background: var(--bad); }
.slots.wrong .slot.acc { border-color: #d07a12; color: #fff; background: #d07a12; }
.fb-text { display: flex; flex-direction: column; gap: 4px; text-align: center; }
.diffword { font-size: 22px; letter-spacing: .02em; }
.diffword .ok { color: var(--good); }
.diffword .miss { color: var(--good); text-decoration: underline 3px; text-underline-offset: 4px; background: #e1ebcd; border-radius: 4px; padding: 0 2px; }
.steps.spell { color: #8a6619; }
.slot.next { border-bottom-color: var(--gold); box-shadow: 0 3px 0 -1px var(--gold); }
.fb-msg { text-align: center; }

/* ---------- v10: красные предупреждения, полоса благословений, склад чудес ---------- */
.popbox .short { background: #c0392b; color: #fff; border-radius: 8px; padding: 1px 8px 2px; margin-left: -8px;
  box-shadow: 0 0 0 2px rgba(255,255,255,.25); animation: shortPulse 1.6s ease-in-out infinite; }
.popbox .short small { opacity: 1; font-weight: 700; }
@keyframes shortPulse { 50% { box-shadow: 0 0 0 2px rgba(255,255,255,.25), 0 0 12px 2px rgba(255,90,60,.75); } }
.rs.falling { background: #fbe1d8; box-shadow: inset 0 0 0 1.5px #e3a08c; }
.rs.falling .rs-v small.neg { color: var(--bad); font-weight: 700; }
.rs.falling.buffed { background: linear-gradient(180deg, #fff6d2, #fbe1d8); }
.buffbar { flex-wrap: nowrap; overflow: hidden; height: 32px; min-height: 32px; align-items: center; margin-bottom: 8px; }
.buffbar .bf { flex: none; white-space: nowrap; }
.bf-slot { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 1.5px dashed #c9b48e; opacity: .7; }
.bf-empty { font-size: 12px; color: var(--ink-2); opacity: .75; font-style: italic; white-space: nowrap; margin-left: 4px; }
.buffbar.compact .bf b { display: none; }
.buffbar.compact .bf { padding-right: 8px; }
.item-stash { font-size: 12.5px; color: #6b4a00; background: #fff3cf; border-radius: 6px; padding: 4px 8px; margin-top: 4px; }
.item-retire { font-size: 12.5px; color: #5a3d12; background: #f3e4c4; border-left: 3px solid var(--accent); border-radius: 6px; padding: 5px 8px; margin-top: 6px; line-height: 1.4; }
.rest { color: #6b4a00; background: #fff3cf; border-radius: 6px; padding: 6px 10px; font-size: 13.5px; }
/* облик растёт с уровнем: скромный размер на 1–3, полный — с 4-го */
.tile.stage-0:not(.bt-field) .bw .b1 .ico { transform: scale(.82); transform-origin: 50% 60%; }
.tile.stage-1:not(.bt-field) .bw .b1 .ico, .tile.stage-2:not(.bt-field) .bw .b1 .ico { transform: scale(1.05); transform-origin: 50% 60%; }
#map { width: min(100%, calc((100vh - 212px) * 18 / 11)); }

/* клетка карты всегда квадратная: содержимое (коза, группы построек) не может её растянуть и сдвинуть карту */
.tile { contain: size; }

/* ---------- v11: телефон в альбомной ориентации ----------
   Раскладка та же, что на компьютере (карта слева, панель справа), только плотнее.
   В портретной ориентации на телефоне — просьба повернуть экран. */
.rotate-hint { display: none; }
@media (orientation: portrait) and (max-width: 700px) {
  .rotate-hint { display: flex; position: fixed; inset: 0; z-index: 5000; flex-direction: column; align-items: center; justify-content: center;
    gap: 14px; padding: 24px; text-align: center; background: var(--head-bg); color: #fbf3e2; font-size: 17px; }
  .rotate-hint .rh-ic { font-size: 56px; animation: rhTurn 2.4s ease-in-out infinite; }
  .rotate-hint small { opacity: .8; font-size: 13px; }
  body > *:not(.rotate-hint) { display: none !important; }   /* в портрете играть нельзя — и ничего не растягивает экран */
  @keyframes rhTurn { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }
}
@media (orientation: landscape) and (max-height: 520px) {
  body { font-size: 13px; }
  /* шапка */
  #topbar { gap: 6px; padding: 4px 8px; flex-wrap: nowrap; }
  #topbar::after { bottom: -5px; height: 5px; background-size: 10px 5px; }
  .brand .logo, .brand .epoch-sub { display: none; }
  .brand .epoch-name { font-size: 12px; line-height: 1.1; max-width: 88px; }
  .logos-medal { padding: 2px 8px 2px 3px; gap: 4px; }
  .lm-sign { width: 24px; height: 24px; font-size: 15px; }
  .lm-v b { font-size: 15px; }
  .lm-v small { display: none; }
  .resbar { padding: 2px; border-radius: 9px; }
  .rs { padding: 2px 4px 5px; gap: 3px; max-width: 74px; }
  .rs-ic, .rs-ic .ico { width: 18px; height: 18px; }
  .rs-v b { font-size: 12px; }
  .rs-v small { display: none; }
  .rs-bar { left: 4px; right: 4px; bottom: 1px; height: 2px; }
  .popbox { font-size: 11px; }
  .popbox b { font-size: 12px; }
  .popbox small { font-size: 9.5px; }
  .pedia-btn { width: 30px; height: 30px; font-size: 15px; flex: none; }
  .study-btn { padding: 3px 10px; flex: none; }
  .study-btn .sb-main { font-size: 13px; }
  .study-btn .sb-sub { font-size: 9px; }
  /* карта и панель рядом */
  main { flex-direction: row; gap: 8px; padding: 8px 8px 6px; }
  #map { width: min(100%, calc((100vh - 86px) * 18 / 11)); border-radius: 10px; }
  .tile .lvl { font-size: 8px; padding: 0 2px; }
  .buffbar { height: 24px; min-height: 24px; margin-bottom: 4px; gap: 4px; }
  .buffbar .bf b { display: none; }
  .bf { padding: 1px 6px 1px 2px; font-size: 11px; }
  .bf .ico.inl { width: 18px; height: 18px; }
  .bf-slot { width: 18px; height: 18px; }
  .bf-empty { display: none; }
  #log { display: none; }
  .place-hint { font-size: 11px; padding: 4px 8px; }
  #side { width: min(320px, 42vw); min-height: 0; }
  .tabs { padding: 4px 4px 0; gap: 2px; }
  .tabs button { font-size: 11.5px; padding: 6px 2px; }
  #panel { padding: 6px; margin: 0 4px 4px; }
  #panel h3 { margin: 10px 2px 6px; font-size: 12px; }
  .item { padding: 6px; gap: 6px; }
  .item-ic { width: 34px; height: 34px; }
  .item-ic .ico { width: 34px; height: 34px; }
  .item-title { font-size: 13px; }
  .chip { font-size: 11px; }
  .btn.small { padding: 4px 8px; font-size: 12px; }
  /* окна и раунд — на весь экран */
  .modal { padding: 6px; }
  .modal-box { max-height: calc(100vh - 12px); padding: 12px 14px; }
  .study { padding: 4px; }
  .st-box { min-height: 0; max-height: calc(100vh - 8px); overflow-y: auto; padding: 8px 14px 12px; border-radius: 12px; }
  .st-body { gap: 8px; }
  .q-word { font-size: 26px; }
  .flash { padding: 10px 22px; }
  .flash-back { font-size: 18px; }
  .options { grid-template-columns: 1fr 1fr; gap: 6px; }
  .opt { padding: 7px 10px; }
  .slot { width: 32px; height: 38px; font-size: 21px; }
  .slots.syl .slot { min-width: 42px; font-size: 18px; }
  .tile-l { width: 36px; height: 38px; font-size: 19px; }
  .tiles.syl .tile-l { width: auto; min-width: 46px; padding: 0 8px; font-size: 17px; }
  .pedia, .school { padding: 0; }
  .pedia-box { width: 100%; height: 100%; border-radius: 0; }
  .pedia-top { padding: 4px 10px 4px 14px; }
  .pedia-title { font-size: 15px; }
  .pedia-main { flex-direction: row; }
  .pedia-nav { width: 170px; max-height: none; }
  .pn-item { font-size: 12px; padding: 4px 6px; }
  .pedia-body { padding: 10px 14px 20px; font-size: 13.5px; }
}

/* ---------- v12: телефон — карта на весь экран ----------
   Вкладки — полоской у правого края; панель выезжает поверх карты и уезжает, когда выбрали, что строить,
   или коснулись карты. Благословения — столбиком у левого края карты. */
.rail, .mob-only { display: none; }
@media (orientation: landscape) and (max-height: 520px) {
  main { padding: 6px; gap: 0; }
  #mapWrap { margin-right: 60px; justify-content: center; }
  #map { width: min(100%, calc((100vh - var(--top-h, 40px) - 18px) * 18 / 11)); }
  @supports (height: 100dvh) { #map { width: min(100%, calc((100dvh - var(--top-h, 40px) - 18px) * 18 / 11)); } }
  /* благословения — столбиком слева, только значки и таймеры */
  .buffbar { position: absolute; left: 0; top: 0; z-index: 5; flex-direction: column; align-items: flex-start;
    height: auto; min-height: 0; margin: 0; gap: 4px; overflow: visible; }
  .buffbar .bf { box-shadow: inset 0 0 0 1.5px #e9b93a, 0 2px 6px rgba(0,0,0,.2); }
  /* вкладки */
  .rail { display: flex; flex-direction: column; gap: 6px; position: fixed; z-index: 40; right: 6px; top: calc(var(--top-h, 40px) + 10px); }
  .rail button { width: 52px; padding: 6px 0 4px; border: 0; border-radius: 12px; background: var(--parch-2); color: var(--ink);
    box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; gap: 2px; font: inherit; cursor: pointer; }
  .rail button i { font-style: normal; font-size: 20px; line-height: 1; }
  .rail button span { font-size: 9.5px; line-height: 1.1; }
  body.drawer-open .rail button.active { background: var(--accent); color: #fff; }
  /* панель выезжает поверх карты */
  #side { position: fixed; z-index: 30; top: calc(var(--top-h, 40px) + 6px); bottom: 6px; right: 64px; width: min(340px, calc(100vw - 150px));
    transform: translateX(calc(100% + 80px)); visibility: hidden; transition: transform .22s ease, visibility 0s .22s;
    box-shadow: 0 10px 30px rgba(40, 25, 10, .35); }
  body.drawer-open #side { transform: none; visibility: visible; transition: transform .22s ease; }
  #side .tabs { display: none; }
  #panel { margin: 4px; }
  /* «куда поставить» — плашкой поверх карты, с кнопкой отмены */
  .place-hint { position: absolute; z-index: 6; left: 50%; bottom: 4px; transform: translateX(-50%); margin: 0; max-width: calc(100% - 8px);
    display: flex; align-items: center; gap: 8px; box-shadow: 0 4px 14px rgba(0,0,0,.3); }
  .place-hint.hidden { display: none; }
  .mob-only { display: inline-flex; }
  .desk-only { display: none; }
}
/* узкий телефон (iPhone SE и т. п.): шапке не хватает места — убираем название эпохи и подписи */
@media (orientation: landscape) and (max-height: 520px) and (max-width: 680px) {
  .brand { display: none; }
  .popbox small { display: none; }
  #topbar { gap: 4px; padding: 4px 6px; }
}
/* Кипропедия: «Доход по ресурсам» */
table.pt.income td.calc { font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 12.5px; }
table.pt.income td:last-child { white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
table.pt.income tr.sum td { border-top: 2px solid var(--parch-3); }
ul.income-notes { font-size: 12.5px; color: var(--ink-2); margin: 2px 0 10px; }
