:root {
  --ink: #26344d;
  --dim: #7a8aa5;
  --card: #ffffff;
  --soft: #f1f5fb;
  --line: #dde5f0;
  --blue: #3d8bfd;
  --blue-d: #2563d9;
  --green: #35c75a;
  --green-d: #1f9a42;
  --gold: #ffc83d;
  --gold-d: #e39a00;
  --red: #ff5d62;
  --red-d: #d63a41;
  --good: #1f9a42;
  --bad: #d63a41;
  --shadow: 0 5px 0 rgba(38, 52, 77, .10);
}
/* Nunito (SIL Open Font License), laikomas šalia žaidimo, kad nebūtų kreipiamasi į Google Fonts. */
@font-face { font-family: "Nunito"; font-style: normal; font-weight: 600 900; font-display: swap;
  src: url(assets/fonts/nunito-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Nunito"; font-style: normal; font-weight: 600 900; font-display: swap;
  src: url(assets/fonts/nunito-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
* { box-sizing: border-box; }

/* Ikonos: pikselinės iš assets/icons.png (8 stulpeliai po 16 px; padėtis – em, todėl dydį keičia font-size) ir SVG ženklai. */
.ico {
  display: inline-block; width: 1em; height: 1em; font-size: 16px; vertical-align: -.22em; flex: none;
  background: url(assets/icons.png) no-repeat; background-size: 8em auto; image-rendering: pixelated; font-style: normal;
}
.ico.lg { font-size: 32px; vertical-align: -.3em; }
.ico.svg { background: none; }
.ico.svg svg { display: block; width: 100%; height: 100%; overflow: visible; }
img.bico { height: 1.75em; margin: -.45em 0 -.4em; vertical-align: middle; }
.adtag { display: inline-block; margin-left: 4px; padding: 0 6px; border-radius: 6px; font-size: 10.5px; font-weight: 900; letter-spacing: .04em;
  text-transform: uppercase; background: rgba(74, 50, 0, .14); vertical-align: 1px; }
aside button.gold, button.gold { background: var(--gold); color: #4a3200; box-shadow: 0 3px 0 var(--gold-d); }
button.gold:disabled { background: var(--soft); color: var(--dim); box-shadow: 0 3px 0 var(--line); }
body {
  margin: 0; min-height: 100vh; color: var(--ink);
  background: linear-gradient(180deg, #cfeaff 0%, #e8f6ff 45%, #f4fbf2 100%) fixed;
  font: 700 14px/1.4 "Nunito", "Segoe UI", system-ui, sans-serif;
}

header {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 10px 16px;
  background: linear-gradient(180deg, #55a2ff, #2f72e6);
  box-shadow: 0 4px 0 #2459bd;
  color: #fff;
}
h1 { font-size: 20px; font-weight: 900; margin: 0; text-shadow: 0 2px 0 rgba(0, 0, 0, .18); }
h3 { font-size: 12px; font-weight: 900; margin: 14px 0 7px; color: var(--blue-d); text-transform: uppercase; letter-spacing: .08em; }
h3:first-child { margin-top: 0; }
#speed { margin-left: auto; }

button {
  font: inherit; font-weight: 800; color: var(--ink); background: #fff;
  border: 0; border-radius: 12px; padding: 6px 12px; cursor: pointer;
  box-shadow: 0 3px 0 #c9d4e3; transition: transform .06s, box-shadow .06s;
}
button:hover { filter: brightness(1.04); }
button:active { transform: translateY(2px); box-shadow: 0 1px 0 #c9d4e3; }
button.on { background: var(--green); color: #fff; box-shadow: 0 3px 0 var(--green-d); text-shadow: 0 1px 0 rgba(0, 0, 0, .15); }
button:disabled { opacity: .45; cursor: default; transform: none; filter: none; }
button.danger { background: #ffe9ea; color: var(--red-d); box-shadow: 0 3px 0 #f3c2c5; }
aside button, .tech button { background: var(--soft); }
aside button.on { background: var(--green); }
aside button.danger { background: #ffe9ea; }
header button { background: rgba(255, 255, 255, .22); color: #fff; box-shadow: 0 3px 0 rgba(0, 0, 0, .18); }
header button.on { background: var(--gold); color: #4a3200; box-shadow: 0 3px 0 var(--gold-d); text-shadow: none; }
header button.danger { background: rgba(255, 93, 98, .9); color: #fff; box-shadow: 0 3px 0 var(--red-d); }

#resbar { display: flex; flex-wrap: wrap; gap: 7px; padding: 12px 16px 4px; }
.res {
  white-space: nowrap; background: #fff; border-radius: 999px; padding: 4px 12px;
  box-shadow: 0 3px 0 rgba(38, 52, 77, .10); font-weight: 800;
}
.res b { font-weight: 900; }
.res .cap { color: var(--dim); font-weight: 700; }
.res small { font-weight: 800; }
.up { color: var(--good); } .down { color: var(--bad); }
.sep { flex: 1; }

#alert:empty { display: none; }
#alert { display: flex; flex-direction: column; gap: 6px; margin: 8px 16px 0; }
.note { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; width: 100%; text-align: left; padding: 9px 14px; border-radius: 14px; font-weight: 800; }
.note.atk { color: #fff; background: linear-gradient(180deg, #ff7a6b, #e8433b); box-shadow: 0 4px 0 #b92f29; }
.note.demand { color: #5a3300; background: linear-gradient(180deg, #ffd27a, #ffb53d); box-shadow: 0 4px 0 #d98a12; }
.note.help { color: #12406b; background: linear-gradient(180deg, #d6ecff, #b7dcff); box-shadow: 0 4px 0 #86bdee; }
.note .go { margin-left: auto; background: rgba(255, 255, 255, .6); border-radius: 999px; padding: 2px 12px; font-weight: 900; white-space: nowrap; }
.ask { background: var(--soft); border-radius: 14px; padding: 12px 14px; margin: 10px 0 6px; font-size: 16px; }
.ask .dim { font-size: 13px; }

main { display: flex; gap: 14px; padding: 12px 16px 20px; align-items: flex-start; }
aside { background: var(--card); border-radius: 20px; padding: 14px; box-shadow: var(--shadow); }
#left { width: 250px; flex: none; }
#right { width: 300px; flex: none; }
#stage { flex: 1; min-width: 0; }
canvas {
  touch-action: none;
  display: block; width: 100%; margin: 0 auto; cursor: pointer;
  /* aukštis nepriklauso nuo pločio: drobė pati prisitaiko prie dėžutės (ui.js fit) */
  height: clamp(320px, calc(100vh - 190px), 760px);
  border: 5px solid #fff; border-radius: 24px; box-shadow: 0 8px 0 rgba(38, 52, 77, .12);
}
#hint { min-height: 22px; margin-top: 12px; text-align: center; color: var(--dim); }

.bgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.bitem {
  display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center;
  padding: 8px 4px 7px; box-shadow: 0 3px 0 var(--line); line-height: 1.2;
}
.bitem b { font-size: 12.5px; font-weight: 900; }
.bitem br { display: none; }
.bitem small { display: block; color: var(--dim); font-size: 12px; font-weight: 800; }
.bitem .ic { font-size: 26px; min-width: 40px; height: 44px; line-height: 44px; display: grid; place-items: center; }
aside .bitem.on { background: var(--gold); box-shadow: 0 3px 0 var(--gold-d); color: #4a3200; text-shadow: none; }
.bitem.on small { color: #6b4a00; }
.bitem.poor b, .bitem.poor .ic { opacity: .55; }
.bitem.locked {
  justify-content: center; border-radius: 12px; border: 2px dashed var(--line); background: transparent;
  box-shadow: none; color: var(--dim); font-size: 11.5px; padding: 8px 4px;
}
.bicon { display: block; height: 44px; margin: -2px auto 0; filter: drop-shadow(0 2px 0 rgba(38, 52, 77, .15)); }
.lack { color: var(--bad); }

.row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 9px; align-items: center; }
.row > span:first-child { width: 100%; color: var(--dim); font-size: 12px; font-weight: 800; }
.kv { display: flex; justify-content: space-between; gap: 8px; }
.kv span:last-child { font-variant-numeric: tabular-nums; }
.good { color: var(--good); } .bad { color: var(--bad); } .dim { color: var(--dim); }
.box { background: var(--soft); border-radius: 14px; padding: 10px 12px; margin-bottom: 10px; }
.box button { background: #fff; }
.box button.on { background: var(--green); }
.box button.danger { background: #ffe9ea; }
.log { font-size: 12.5px; max-height: 200px; overflow-y: auto; }
.log div { padding: 4px 0; border-bottom: 1px solid var(--line); }
.job { display: flex; align-items: center; gap: 6px; padding: 2px 0; }
.job > span:first-child { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job .pr button { padding: 0 6px; font-size: 11px; margin-left: 3px; border-radius: 8px; box-shadow: 0 2px 0 #c9d4e3; }
.job .pr button.on { box-shadow: 0 2px 0 var(--green-d); }

.techgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 12px; }
.branch { background: var(--card); border-radius: 20px; padding: 14px; box-shadow: var(--shadow); }
.tech { background: var(--soft); border: 2px solid transparent; border-radius: 14px; padding: 8px 10px; margin-bottom: 8px; font-size: 13px; }
.tech b { font-weight: 900; }
.tech.owned { border-color: var(--green); background: #eafaef; }
.tech.locked { opacity: .55; }
.tech button { margin-top: 6px; background: var(--gold); color: #4a3200; box-shadow: 0 3px 0 var(--gold-d); }
.prestige { background: #fff8e1; border: 2px solid var(--gold); border-radius: 20px; padding: 14px; box-shadow: var(--shadow); }
.prestige h3 { color: var(--gold-d); }

.unit { background: #fff; border-radius: 12px; padding: 7px 9px; margin-top: 6px; font-size: 12.5px; }
.unit .row { margin: 4px 0 0; }
.bar { position: relative; height: 12px; margin: 5px 0 8px; background: #fff; border-radius: 999px; overflow: hidden; box-shadow: inset 0 0 0 2px var(--line); }
.bar.plain i { background: linear-gradient(90deg, #ffc83d, #35c75a); }
.tech.busy { border-color: var(--blue); background: #eef6ff; }
.tech .unl { color: var(--blue-d); font-size: 12px; font-weight: 800; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, #ff7a6b, #ffc83d 45%, #35c75a 85%); }
.bar u { position: absolute; top: 0; width: 2px; height: 100%; background: rgba(38, 52, 77, .45); }
.lord { display: flex; justify-content: space-between; align-items: center; gap: 6px; width: 100%; margin-bottom: 6px; padding: 7px 10px; text-align: left; }
aside .lord.on { background: var(--gold); box-shadow: 0 3px 0 var(--gold-d); color: #4a3200; text-shadow: none; }
.lord small { font-weight: 800; white-space: nowrap; }
div.lord { justify-content: flex-start; font-size: 13px; }
div.lord.me { justify-content: space-between; background: #e6f1ff; border-radius: 12px; }
.lord small { text-align: right; }
canvas.world { cursor: grab; }
.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: rgba(20, 40, 70, .45); }
.modal .card { width: min(620px, 100%); max-height: 90vh; overflow-y: auto; background: #fff; border-radius: 22px; padding: 20px 22px; box-shadow: 0 10px 0 rgba(20, 40, 70, .25); }
.modal h2 { margin: 0 0 2px; font-size: 22px; font-weight: 900; }
.modal ul { margin: 4px 0 0; padding-left: 20px; }
.modal .card button { background: var(--soft); }
.modal .card button.on { background: var(--green); }
.modal .card.wide { width: min(760px, 100%); }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.setting .dim { font-size: 12px; }
.setting .opts { display: flex; gap: 5px; flex: none; }
.setting .opts button { padding: 4px 9px; font-size: 12.5px; }
@media (max-width: 640px) { .setting { flex-direction: column; align-items: flex-start; } .setting .opts { flex-wrap: wrap; } }
.tip { display: flex; gap: 8px; align-items: flex-start; width: 100%; text-align: left; margin-bottom: 6px; padding: 8px 10px; border-radius: 12px;
       background: #fff6dc; box-shadow: 0 3px 0 #f0dca0; font-size: 12.5px; font-weight: 700; line-height: 1.35; }
aside button.tip { background: #fff6dc; }
.tip > span:first-child { font-size: 17px; line-height: 1.1; }
.note.offer { color: #1d5a2e; background: linear-gradient(180deg, #d9f7df, #b9eec3); box-shadow: 0 4px 0 #86cf96; }
.legacy { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.legacy .tech { background: #fff; margin: 0; }
.legacy .tech.owned { background: #eafaef; }
ol.intro { margin: 10px 0 0; padding-left: 22px; }
ol.intro li { margin-bottom: 7px; }
table.emp td, table.emp th { padding: 5px 4px; }
.setting .opts.wrap { flex-wrap: wrap; justify-content: flex-end; flex: 1; }
@media (max-width: 900px) { .legacy { grid-template-columns: 1fr; } }
.versus { display: flex; align-items: center; justify-content: center; gap: 18px; margin: 12px 0 8px; }
.versus > div { flex: 1; text-align: center; background: var(--soft); border-radius: 14px; padding: 8px; }
.versus big { display: block; font-size: 26px; font-weight: 900; }
.versus span { color: var(--dim); }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
table.rep { width: 100%; border-collapse: collapse; font-size: 13px; }
table.rep th { color: var(--dim); font-size: 11px; text-align: right; font-weight: 800; }
table.rep td { padding: 3px 0; text-align: right; border-top: 1px solid var(--line); }
table.rep td:first-child { text-align: left; }
.chip { display: inline-block; background: var(--soft); border-radius: 999px; padding: 2px 10px; margin: 2px 0; font-weight: 800; }
@media (max-width: 560px) { .cols { grid-template-columns: 1fr; } }
table.trade { width: 100%; border-collapse: collapse; font-size: 13px; }
table.trade td { padding: 3px 0; }
table.trade button { padding: 2px 7px; font-size: 12px; border-radius: 9px; }

@media (max-width: 1150px) {
  main { flex-wrap: wrap; }
  #stage { order: -1; flex-basis: 100%; }
  #left, #right { flex: 1; width: auto; min-width: 250px; }
  .bgrid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
}
@media (max-width: 900px) { .techgrid { grid-template-columns: 1fr; } }

/* ---------- telefonas: žemėlapis per visą ekraną, skydeliai – ištraukiami lapai iš apačios ---------- */
#mnav { display: none; }
@media (max-width: 760px) {
  header { flex-wrap: nowrap; overflow-x: auto; gap: 6px; padding: 6px 8px; scrollbar-width: none; }
  header::-webkit-scrollbar, #resbar::-webkit-scrollbar { display: none; }
  h1 { font-size: 16px; white-space: nowrap; }
  header > div { display: flex; gap: 4px; flex: none; white-space: nowrap; }
  header button { padding: 5px 9px; font-size: 13px; }
  #speed { margin-left: 0; }
  #resbar { flex-wrap: nowrap; overflow-x: auto; gap: 5px; padding: 6px 8px 2px; scrollbar-width: none; }
  .res { padding: 3px 9px; font-size: 13px; }
  .sep { display: none; }
  #alert { margin: 6px 8px 0; }
  .note { padding: 7px 10px; font-size: 13px; }
  main { display: block; padding: 6px 8px 66px; }
  #stage { width: 100%; }
  canvas { height: calc(100dvh - 176px); min-height: 280px; border-width: 3px; border-radius: 16px; box-shadow: none; }
  #hint { margin-top: 6px; font-size: 12.5px; min-height: 18px; }
  #left, #right {
    position: fixed; left: 0; right: 0; bottom: 58px; z-index: 15; width: auto; min-width: 0; max-height: 64dvh; overflow-y: auto;
    border-radius: 20px 20px 0 0; box-shadow: 0 -6px 24px rgba(20, 40, 70, .25);
    transform: translateY(115%); visibility: hidden; transition: transform .2s ease, visibility 0s .2s;
  }
  body.sheet-left #left, body.sheet-right #right { transform: none; visibility: visible; transition: transform .2s ease; }
  #mnav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 16; gap: 8px; padding: 8px; background: #fff; box-shadow: 0 -3px 0 rgba(38, 52, 77, .08); }
  #mnav button { flex: 1; padding: 9px; background: var(--soft); }
  #mnav button.on { background: var(--gold); color: #4a3200; box-shadow: 0 3px 0 var(--gold-d); }
  #mnav .badge { display: inline-block; min-width: 18px; margin-left: 4px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; line-height: 18px; }
  .bgrid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  .modal { padding: 8px; }
  .modal .card { padding: 16px; max-height: 94dvh; }
}

/* dabartinio tikslo mygtukas švyti; įvykdytas tikslas – juostelė viršuje */
@keyframes goalGlow { 0%, 100% { box-shadow: 0 3px 0 var(--gold-d), 0 0 0 0 rgba(255, 200, 61, .9); } 50% { box-shadow: 0 3px 0 var(--gold-d), 0 0 0 6px rgba(255, 200, 61, 0); } }
button.goal, aside button.goal, header button.goal { background: #fff3c4; color: #4a3200; animation: goalGlow 1.4s ease-in-out infinite; }
#toast { position: fixed; left: 50%; top: 14px; z-index: 30; transform: translate(-50%, -140%); transition: transform .35s cubic-bezier(.2, .9, .3, 1.2);
  background: #fff; border: 3px solid var(--gold); border-radius: 16px; padding: 10px 18px; text-align: center; box-shadow: 0 8px 0 rgba(38, 52, 77, .15);
  max-width: min(92vw, 420px); pointer-events: none; }
#toast.show { transform: translate(-50%, 0); }
#toast .tt { font-weight: 900; color: var(--green-d); font-size: 15px; }
#toast .rw { font-weight: 900; margin-top: 2px; }
