/* Terminal iz 1984. koji je neko ostavio da radi na dnu mora: tamna tirkizna, fosfor, sken-linije. */
:root {
  color-scheme: dark;
  --ink: #05171a;
  --panel: #082226;
  --line: #1b4a4c;
  --text: #a9dccf;
  --dim: #5f9a92;
  --bright: #e8fff6;
  --gold: #ffd24d;
  --hp: #2fa84f;
  --mp: #2b7fc9;
  --xp: #4c6b78;
  --bad: #ff6a5a;
  --good: #6fe39a;
  --quest: #6fe3ff;
  --mono: 'VT323', 'Cascadia Mono', 'Consolas', ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--ink); color: var(--text); font: 20px/1.15 var(--mono); overflow: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
[hidden] { display: none !important; }
.gold { color: var(--gold); }

#app { height: 100%; display: grid; grid-template-rows: auto 1fr auto; padding-left: env(safe-area-inset-left, 0); padding-right: env(safe-area-inset-right, 0); }
#top { display: flex; gap: 10px; padding: 6px 14px; background: var(--ink); border-bottom: 1px solid var(--line); white-space: nowrap; overflow: hidden; }
#top i { color: var(--line); font-style: normal; }
#tName { color: var(--good); }
#tPlace { margin-left: auto; color: var(--dim); overflow: hidden; text-overflow: ellipsis; }
main { display: grid; grid-template-columns: 1fr 300px; min-height: 0; }

#view { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #040f11; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; image-rendering: pixelated; cursor: crosshair; }
#crt { position: absolute; inset: 0; pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, rgba(0,0,0,.2) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 58%, rgba(0,0,0,.55) 100%); }
#bossbar { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); width: min(460px, 80%); height: 24px; border: 1px solid var(--bad); background: #1c0a0c; z-index: 2; text-align: center; }
#bossFill { position: absolute; inset: 0 auto 0 0; background: #8c2230; }
#bossName { position: relative; z-index: 1; color: var(--bright); line-height: 22px; }

#mini { position: absolute; top: 8px; right: 8px; z-index: 3; max-width: calc(100% - 16px); border: 1px solid var(--dim); background: rgba(3,16,18,.72); image-rendering: pixelated; cursor: pointer; }
#mission p { margin: 3px 0 0; }
#mission .rdy { color: var(--good); }
.mats { color: var(--gold); margin: 0 0 10px; }
.quest { border: 1px solid var(--line); background: var(--ink); padding: 8px 10px; margin-bottom: 6px; }
.quest strong { display: block; color: var(--quest); font-weight: 400; font-size: 22px; }
.quest p { margin: 2px 0 4px; }
.pick { border-color: var(--gold); color: var(--gold); }

#side { display: flex; flex-direction: column; gap: 6px; padding: 10px; background: var(--panel); border-left: 1px solid var(--line); min-height: 0; min-width: 0; }
.meter { position: relative; height: 22px; background: #03100f; border: 1px solid var(--line); overflow: hidden; }
.meter b { position: absolute; inset: 0 auto 0 0; transition: width .12s linear; }
.meter span { position: relative; z-index: 1; padding-left: 6px; line-height: 20px; color: var(--bright); }
.rust b { background: #b4532a; }
.hp b { background: var(--hp); } .mp b { background: var(--mp); } .xp b { background: var(--xp); }
.xp { height: 18px; font-size: 17px; } .xp span { line-height: 16px; }
#tRust { color: #f09a63; display: none; }
#stats { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; color: var(--dim); font-size: 18px; padding: 2px; }
#stats b { color: var(--text); font-weight: 400; float: right; }
#mission { border: 1px solid var(--line); padding: 5px 7px; color: var(--quest); font-size: 18px; }
#mission small { display: block; font-size: 15px; color: var(--dim); letter-spacing: .08em; }
#mission.done { color: var(--good); }
#log { flex: 1; min-height: 0; overflow-y: auto; font-size: 18px; color: var(--text); padding-right: 4px; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
#log p { margin: 0 0 3px; }
#log p::before { content: ':: '; color: var(--line); }
#log .bad { color: var(--bad); } #log .good { color: var(--good); } #log .gold { color: var(--gold); }
#log .quest { color: var(--quest); } #log .story { color: #d9c29a; } #log .title { color: var(--bright); }

#overlay { position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(3,14,15,.86); overflow-y: auto; }
.box { width: min(860px, 100%); max-height: 100%; overflow-y: auto; background: var(--panel); border: 1px solid var(--dim); padding: 16px 20px; box-shadow: 0 0 0 4px var(--ink), 0 0 0 5px var(--line); }
.box.narrow { width: min(540px, 100%); }
.box h2 { margin: 0 0 10px; font: inherit; font-size: 30px; color: var(--bright); font-weight: 400; }
.box p { margin: 0 0 10px; max-width: 62ch; }
.box .muted { color: var(--dim); }
.btn { display: inline-block; padding: 6px 12px; border: 1px solid var(--dim); background: var(--ink); margin: 3px 6px 3px 0; }
.btn:hover { border-color: var(--gold); color: var(--gold); }
.btn[disabled] { opacity: .4; cursor: default; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

#title { text-align: center; }
#title h1 { margin: 0; font: inherit; font-size: clamp(56px, 13vw, 104px); line-height: .9; color: #c9713a; letter-spacing: .02em; text-shadow: 3px 3px 0 #4a1f12; }
#title .sub { color: var(--dim); margin: 8px auto 18px; }
.classes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; text-align: left; margin-top: 8px; }
.cls { border: 1px solid var(--line); background: var(--ink); padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.cls:hover { border-color: var(--gold); }
.cls img { width: 60px; height: 72px; image-rendering: pixelated; }
.cls strong { color: var(--bright); font-weight: 400; font-size: 24px; }
.cls span { color: var(--dim); font-size: 18px; }

.inv { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 16px; }
.slots { display: grid; gap: 3px; }
.slot { display: flex; align-items: center; gap: 8px; width: 100%; padding: 2px 6px; border: 1px solid var(--line); background: var(--ink); text-align: left; min-height: 42px; }
.slot:hover, .slot.sel { border-color: var(--gold); }
.slot img, .cell img { width: 30px; height: 36px; image-rendering: pixelated; flex: none; }
.slot span { min-width: 0; font-size: 18px; line-height: 1; }
.slot small { display: block; color: var(--dim); font-size: 15px; }
.bag { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 3px; }
.cell { aspect-ratio: 5/6; display: flex; align-items: center; justify-content: center; border: 1px solid var(--line); background: var(--ink); padding: 0; }
.cell:hover, .cell.sel { border-color: var(--gold); }
.detail { margin-top: 10px; min-height: 170px; border-top: 1px solid var(--line); padding-top: 8px; }
.detail h3 { margin: 0; font: inherit; font-size: 24px; font-weight: 400; }
.detail ul { list-style: none; margin: 4px 0 8px; padding: 0; }
.cell { position: relative; }
.cell i { position: absolute; top: 1px; right: 3px; font-style: normal; font-size: 16px; line-height: 1; }
.cell b { position: absolute; top: 1px; left: 3px; color: var(--gold); font-weight: 400; font-size: 16px; line-height: 1; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; }
.goods td:first-child { color: var(--text); }
.goods .hot { color: var(--gold); }
.powers { margin: 0 0 8px; padding: 0; list-style: none; color: var(--gold); font-size: 18px; }
.cmp { overflow-x: auto; margin: 6px 0 8px; }
.cmp table { width: 100%; border-collapse: collapse; font-size: 18px; font-variant-numeric: tabular-nums; }
.cmp th, .cmp td { padding: 2px 8px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; font-weight: 400; }
.cmp th { color: var(--dim); font-size: 16px; }
.cmp th:first-child, .cmp td:first-child { text-align: left; color: var(--dim); }
.cmp .pow { text-align: left; white-space: normal; color: var(--gold); }
.miles { list-style: none; margin: 0; padding: 0; font-size: 18px; }
.quest .meter { margin: 4px 0; }
select { font: inherit; color: var(--text); background: var(--ink); border: 1px solid var(--dim); padding: 3px 6px; }
.fm-head { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: center; color: var(--dim); margin-bottom: 8px; }
.fm-head b { color: var(--text); font-weight: 400; }
.ticker { border: 1px solid var(--line); background: var(--ink); padding: 4px 8px; margin-bottom: 8px; color: var(--gold); font-size: 18px; }
.ticker div + div { color: var(--dim); }
.fm-tools { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-bottom: 8px; }
.fm-tools input, .fm-form input { font: inherit; color: var(--text); background: var(--ink); border: 1px solid var(--dim); padding: 3px 6px; min-width: 0; }
.fm-tools input { flex: 1 1 130px; }
.fm-form input { width: 110px; }
.fm-list { display: grid; gap: 3px; max-height: 46vh; overflow-y: auto; }
.lot { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 8px; align-items: center; width: 100%; padding: 2px 6px; border: 1px solid var(--line); background: var(--ink); text-align: left; }
.lot:hover, .lot.sel { border-color: var(--gold); }
.lot img { width: 30px; height: 36px; image-rendering: pixelated; }
.lot span { min-width: 0; font-size: 18px; line-height: 1.05; }
.lot small { display: block; color: var(--dim); font-size: 15px; }
.lot .pr { text-align: right; white-space: nowrap; }
.fm-detail { border: 1px solid var(--gold); background: var(--panel); padding: 8px 10px; }
.fm-form { display: grid; gap: 6px; }
.fm-form label { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.spark { display: block; width: 100%; max-width: 320px; height: 44px; }
.spark polyline { fill: none; stroke: var(--gold); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.spark line { stroke: var(--line); vector-effect: non-scaling-stroke; }
.risk { color: #f09a63; }
.cell.hot { border-color: #e0863d; }
.note { color: var(--gold); margin: 0 0 8px; }
.up { color: var(--good); } .down { color: var(--bad); }
.shop { display: grid; gap: 4px; margin-bottom: 12px; }
.shop .slot span { flex: 1; }
.perks { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; }
.perk { border: 1px solid var(--line); background: var(--ink); padding: 12px; text-align: left; }
.perk:hover { border-color: var(--gold); }
.perk strong { display: block; color: var(--gold); font-weight: 400; font-size: 24px; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 2px 16px; }
.keys kbd { font: inherit; color: var(--gold); }

@media (max-width: 820px) {
  html, body { font-size: 18px; }
  main { grid-template-columns: 1fr; grid-template-rows: 1fr 92px; }
  #side { border-left: 0; border-top: 1px solid var(--line); padding: 5px 8px; gap: 3px; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 20px minmax(0, 1fr); }
  .meter { height: 20px; }
  .meter.xp, .meter.rust, #stats { display: none; }
  #tRust { display: inline; }
  #mission { display: none; }
  #log { grid-column: 1 / -1; font-size: 16px; }
  .inv { grid-template-columns: 1fr; }
  .classes, .perks { grid-template-columns: 1fr; }
  .cls { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .cls span { flex-basis: 100%; }
  #tPlace { display: none; }
}
@media (prefers-reduced-motion: reduce) { .meter b { transition: none; } }

/* ---- Akcijska traka: vjestine su glavna stvar, alati sekundarni, a stanje se cita iz forme ---- */
:root { --bevel-hi: rgba(233,255,246,.16); --bevel-lo: rgba(0,0,0,.55); --ember: #f09a63; }
#bar { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; align-items: flex-end; padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px)); background: linear-gradient(to bottom, #0a282c, var(--ink)); border-top: 2px solid var(--line); position: relative; z-index: 4; }
.hot, .tools { display: flex; gap: 5px; align-items: flex-end; }
.tools { padding-left: 10px; border-left: 1px solid var(--line); }
.skill, .tool { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; background: var(--panel); border: 1px solid var(--dim); box-shadow: inset 1px 1px 0 var(--bevel-hi), inset -2px -2px 0 var(--bevel-lo), 0 2px 0 #020a0b; padding: 0; transition: transform .07s, border-color .1s, background .1s, filter .1s; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.skill { width: 76px; height: 80px; }
.tool { width: 54px; height: 60px; background: var(--ink); }
.skill img { width: 40px; height: 48px; margin-top: 7px; image-rendering: pixelated; }
.tool img { width: 30px; height: 36px; margin-top: 3px; image-rendering: pixelated; }
.skill .cap, .tool .cap { position: absolute; left: 0; right: 0; bottom: 2px; text-align: center; font-size: 15px; line-height: 1; color: var(--text); white-space: nowrap; overflow: hidden; }
.tool .cap { font-size: 13px; color: var(--dim); }
.skill kbd, .tool kbd { position: absolute; top: 2px; left: 4px; font: inherit; font-size: 16px; line-height: 1; color: var(--gold); }
.tool kbd { font-size: 14px; }
.skill:hover, .tool:hover { transform: translateY(-3px); border-color: var(--gold); filter: brightness(1.2); }
.skill:active, .tool:active { transform: translateY(2px); box-shadow: inset 2px 2px 0 var(--bevel-lo), inset -1px -1px 0 var(--bevel-hi); }
.skill:focus-visible, .tool:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.skill.poor, .tool.poor { filter: grayscale(.8) brightness(.62); }
.skill.poor:hover, .tool.poor:hover { transform: none; }
.skill.live, .tool.live { border-color: var(--gold); animation: callout 1.15s ease-in-out infinite; }
.skill.sel { border-color: var(--gold); background: #1c3a2e; box-shadow: 0 0 0 2px var(--gold), 0 0 14px rgba(255,210,77,.5); transform: translateY(-4px); }
.skill.urgent { border-color: var(--bad); animation: urgent .7s ease-in-out infinite; }
.tool.new { border-color: var(--ember); animation: calloutE 1.3s ease-in-out infinite; }
@keyframes callout { 50% { box-shadow: inset 1px 1px 0 var(--bevel-hi), inset -2px -2px 0 var(--bevel-lo), 0 0 12px rgba(255,210,77,.55); } }
@keyframes calloutE { 50% { box-shadow: inset 1px 1px 0 var(--bevel-hi), 0 0 12px rgba(240,154,99,.6); } }
@keyframes urgent { 50% { background: #3c1516; box-shadow: 0 0 16px rgba(255,106,90,.8); } }
.sweep { position: absolute; inset: 0; pointer-events: none; background: conic-gradient(rgba(2,12,13,.84) var(--p, 0%), transparent 0); }
.skill.wait img { filter: grayscale(.7); }
.cdn { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 400; font-size: 34px; color: var(--bright); text-shadow: 2px 2px 0 #000; pointer-events: none; }
.badge { position: absolute; top: -6px; right: -5px; min-width: 19px; height: 19px; padding: 0 3px; background: var(--gold); color: #17140a; font-weight: 400; font-size: 16px; line-height: 19px; text-align: center; box-shadow: 0 1px 0 #000; }
.tool.charge { border-color: var(--ember); }
.tool.charge .sweep { background: conic-gradient(rgba(240,154,99,.62) var(--p, 0%), transparent 0); }
.tip { position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%) translateY(4px); width: 230px; padding: 7px 9px; background: #041416; border: 1px solid var(--gold); color: var(--text); font-size: 18px; line-height: 1.1; text-align: left; white-space: normal; opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .1s, transform .1s; z-index: 6; }
.tip strong { display: block; color: var(--gold); font-weight: 400; font-size: 22px; }
.tip em { display: block; margin-top: 4px; color: var(--quest); font-style: normal; font-size: 16px; }
.skill:hover .tip, .skill:focus-visible .tip { opacity: 1; visibility: visible; transform: translateX(-50%); }
.skill:first-child .tip { left: 0; transform: none; }
#ctx { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 3; padding: 9px 20px; background: var(--gold); color: #17140a; font-size: 24px; border: 0; box-shadow: 0 3px 0 #6f5a14, 0 0 22px rgba(255,210,77,.5); animation: bob 1s ease-in-out infinite; }
#ctx kbd { font: inherit; font-size: 16px; padding: 0 5px; border: 1px solid #6f5a14; margin-right: 6px; }
#ctx:active { box-shadow: 0 1px 0 #6f5a14; }
@keyframes bob { 50% { margin-bottom: 4px; } }

/* ---- Paneli i dugmad: isti reljef svuda, da sve sto se klika izgleda kao da se moze pritisnuti ---- */
#side { background: linear-gradient(to bottom, #0b2a2e, var(--panel)); }
.meter { height: 24px; box-shadow: inset 0 2px 0 rgba(0,0,0,.6); }
.meter b { background-image: repeating-linear-gradient(to right, transparent 0 9px, rgba(0,0,0,.28) 9px 10px), linear-gradient(to bottom, rgba(255,255,255,.2), transparent 45%); background-blend-mode: normal; }
.hp b { background-color: var(--hp); } .mp b { background-color: var(--mp); } .xp b { background-color: var(--xp); } .rust b { background-color: #b4532a; }
.meter span { text-shadow: 1px 1px 0 #000; }
.btn, .slot[data-x], .cell[data-x], .lot[data-x], .perk, .cls { box-shadow: inset 1px 1px 0 var(--bevel-hi), inset -1px -1px 0 var(--bevel-lo); transition: transform .07s, border-color .1s, background .1s; }
.btn:hover, .lot[data-x]:hover, .perk:hover, .cls:hover { transform: translateY(-1px); background: #123c3a; }
.btn:active, .perk:active, .cls:active, .lot[data-x]:active { transform: translateY(1px); box-shadow: inset 1px 1px 0 var(--bevel-lo); }
.btn.pick { background: #2c2b12; }
.btn[disabled] { box-shadow: none; transform: none; background: var(--ink); }
.box { background: linear-gradient(to bottom, #0b2a2e, var(--panel) 90px); }
.box h2 { padding-bottom: 6px; border-bottom: 1px solid var(--line); }
@media (prefers-reduced-motion: reduce) { .skill.live, .tool.new, .skill.urgent, #ctx { animation: none; } }
@media (max-width: 820px) {
  #bar { gap: 5px; padding: 5px 6px calc(5px + env(safe-area-inset-bottom, 0px)); }
  .hot, .tools { width: 100%; justify-content: space-between; gap: 3px; }
  .tools { padding-left: 0; border-left: 0; }
  .skill { flex: 1 1 0; width: auto; min-width: 0; height: 66px; }
  .tool { flex: 1 1 0; width: auto; min-width: 0; height: 46px; }
  .skill img { width: 30px; height: 36px; margin-top: 8px; }
  .tool img { width: 25px; height: 30px; margin-top: 1px; }
  .tool .cap { font-size: 12px; bottom: 0; }
  .skill .cap { font-size: 14px; }
  .tool kbd, .skill kbd { display: none; }
  .tip { display: none; }
  #ctx { bottom: 10px; font-size: 22px; }
  #ctx kbd { display: none; }
}
