/* ============================================================
   IMPERIJE I SAVEZNICI — moderni izgled (glass HUD)
   ============================================================ */
:root {
  --bg-panel: rgba(14, 20, 34, 0.78);
  --bg-panel-solid: #131a2c;
  --border: rgba(255, 255, 255, 0.1);
  --txt: #eef2f8;
  --txt-dim: #9aa7bd;
  --accent: #4da3ff;
  --accent-2: #7c5cff;
  --gold: #ffd54a;
  --ok: #55d97c;
  --err: #ff6b5e;
  --radius: 16px;
  --shadow: 0 10px 34px rgba(0, 0, 0, 0.45);
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  font-family: var(--font);
  color: var(--txt);
  background: #173d5c;
  user-select: none;
}

#game {
  position: fixed; inset: 0;
  width: 100vw; height: 100vh;
  display: block;
  cursor: grab;
}
#game:active { cursor: grabbing; }

/* ================= GORNJA TRAKA ================= */
#topbar {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px;
  padding: 8px 16px;
  background: var(--bg-panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow);
  z-index: 40;
  max-width: calc(100vw - 24px);
  flex-wrap: wrap;
  justify-content: center;
}
.tb-group { display: flex; align-items: center; gap: 10px; }

.level-ring {
  width: 42px; height: 42px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center;
  font-weight: 800; font-size: 18px;
  box-shadow: 0 0 14px rgba(77, 163, 255, 0.55);
}
.xp-wrap { display: flex; flex-direction: column; gap: 3px; min-width: 110px; }
.xp-bar {
  height: 8px; border-radius: 6px; overflow: hidden;
  background: rgba(255, 255, 255, 0.12);
}
.xp-bar i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 6px;
  transition: width 0.4s ease;
}
.xp-text { font-size: 11px; color: var(--txt-dim); }

.tb-res { gap: 6px; }
.res {
  display: flex; align-items: center; gap: 5px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border);
  padding: 5px 11px; border-radius: 999px;
  font-size: 14px;
}
.res em { font-style: normal; font-size: 15px; }
.res b { font-weight: 700; min-width: 20px; text-align: right; }
.res-gold { border-color: rgba(255, 213, 74, 0.45); background: rgba(255, 213, 74, 0.1); }
.res-gold b { color: var(--gold); }

.tb-energy { gap: 7px; }
.tb-energy > em { font-style: normal; font-size: 18px; }
.energy-wrap { display: flex; flex-direction: column; gap: 2px; }
.energy-bar {
  width: 120px; height: 10px; border-radius: 6px; overflow: hidden;
  background: rgba(255, 255, 255, 0.12);
}
.energy-bar i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, #ffd54a, #ff9f43);
  border-radius: 6px;
  transition: width 0.4s ease;
}
.energy-labels { display: flex; justify-content: space-between; font-size: 11px; }
.energy-labels b { font-size: 12px; }
.energy-labels span { color: var(--txt-dim); }

/* ================= KARTICA ZADATKA ================= */
#quest-card {
  position: fixed; top: 84px; right: 14px;
  width: 250px;
  background: var(--bg-panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 13px 15px;
  z-index: 30;
  display: flex; flex-direction: column; gap: 7px;
}
.quest-head { font-size: 11px; letter-spacing: 1.6px; text-transform: uppercase; color: var(--txt-dim); font-weight: 700; }
.quest-name { font-weight: 800; font-size: 15px; }
.quest-desc { font-size: 13px; color: var(--txt-dim); line-height: 1.35; }
.quest-bar {
  position: relative; height: 16px; border-radius: 8px; overflow: hidden;
  background: rgba(255, 255, 255, 0.1);
}
.quest-bar i {
  position: absolute; inset: 0 auto 0 0;
  background: linear-gradient(90deg, var(--ok), #a8e063);
  border-radius: 8px;
  transition: width 0.4s ease;
}
.quest-bar span {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
.quest-claim { animation: pulse 1.4s infinite; }
.quest-done-all { font-size: 14px; padding: 6px 0; }
@keyframes pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(85, 217, 124, 0.5); }
  50% { transform: scale(1.03); box-shadow: 0 0 0 8px rgba(85, 217, 124, 0); }
}

/* ================= DONJA PALETA ================= */
#dock {
  position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 8px;
  padding: 8px 10px;
  background: var(--bg-panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  z-index: 40;
}
.dock-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  min-width: 74px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid transparent;
  border-radius: 14px;
  color: var(--txt);
  font-family: var(--font);
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.dock-btn span { font-size: 24px; line-height: 1; }
.dock-btn:hover {
  background: rgba(77, 163, 255, 0.16);
  border-color: rgba(77, 163, 255, 0.4);
  transform: translateY(-3px);
}
.dock-btn:active { transform: translateY(-1px); }

/* ================= RADNJA ================= */
#shop-panel {
  position: fixed; left: 14px; bottom: 14px; top: 84px;
  width: 348px;
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 45;
  display: flex; flex-direction: column;
  transform: translateX(-120%);
  opacity: 0;
  transition: transform 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.1), opacity 0.2s;
  pointer-events: none;
}
#shop-panel.open { transform: translateX(0); opacity: 1; pointer-events: auto; }
.shop-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 8px;
}
.shop-head h3 { font-size: 17px; }
#shop-tabs {
  display: flex; gap: 5px; padding: 4px 12px 10px; flex-wrap: wrap;
}
.shop-tab {
  padding: 6px 11px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--txt-dim);
  font-family: var(--font); font-size: 12px; font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.shop-tab.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; border-color: transparent;
}
#shop-items {
  flex: 1; overflow-y: auto;
  padding: 4px 12px 14px;
  display: flex; flex-direction: column; gap: 8px;
}
.shop-item {
  position: relative;
  display: flex; gap: 12px; align-items: center;
  padding: 11px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.15s;
}
.shop-item:hover:not(.locked) {
  background: rgba(77, 163, 255, 0.13);
  border-color: rgba(77, 163, 255, 0.45);
  transform: translateX(4px);
}
.shop-item.locked { opacity: 0.55; cursor: not-allowed; }
.shop-icon { font-size: 34px; width: 44px; text-align: center; flex-shrink: 0; }
.shop-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.shop-info b { font-size: 14px; }
.shop-info small { font-size: 11.5px; color: var(--txt-dim); line-height: 1.3; }
.shop-lock {
  position: absolute; right: 10px; top: 10px;
  background: rgba(0, 0, 0, 0.5);
  padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 700;
}

/* ================= ČIPOVI ================= */
.chip-row { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 3px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
}
.chip-miss { color: var(--err); border-color: rgba(255, 107, 94, 0.45); }
.chip-gain { color: var(--ok); border-color: rgba(85, 217, 124, 0.4); }
.chip-loss { color: var(--err); border-color: rgba(255, 107, 94, 0.4); }

/* ================= KONTEKSTNI MENI ================= */
#ctx-menu {
  position: fixed;
  min-width: 210px; max-width: 260px;
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 9px;
  z-index: 50;
  display: flex; flex-direction: column; gap: 5px;
}
#ctx-menu.hidden { display: none; }
.ctx-title { font-weight: 800; font-size: 14px; padding: 3px 6px 5px; }
.ctx-sub { font-size: 12px; color: var(--txt-dim); padding: 0 6px 3px; }
.ctx-btn {
  display: block; width: 100%;
  text-align: left;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--txt);
  font-family: var(--font); font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
}
.ctx-btn:hover { background: rgba(77, 163, 255, 0.18); border-color: rgba(77, 163, 255, 0.4); }
.ctx-btn small { color: var(--txt-dim); font-weight: 500; }
.ctx-main { background: rgba(85, 217, 124, 0.14); border-color: rgba(85, 217, 124, 0.35); }
.ctx-main:hover { background: rgba(85, 217, 124, 0.25); }
.ctx-danger:hover { background: rgba(255, 107, 94, 0.18); border-color: rgba(255, 107, 94, 0.4); }

/* ================= MODALI ================= */
.modal-wrap {
  position: fixed; inset: 0;
  background: rgba(6, 10, 20, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: grid; place-items: center;
  z-index: 60;
  animation: fadeIn 0.18s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: min(560px, calc(100vw - 28px));
  max-height: min(78vh, 720px);
  background: var(--bg-panel-solid);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  animation: popIn 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.15);
}
@keyframes popIn { from { transform: scale(0.92) translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px 10px;
}
.modal-head h3 { font-size: 18px; }
.modal-x {
  width: 30px; height: 30px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--txt);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.modal-x:hover { background: rgba(255, 107, 94, 0.25); }
.modal-body { padding: 6px 18px 14px; overflow-y: auto; line-height: 1.5; font-size: 14px; }
.modal-body p { margin: 6px 0; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 10px 18px 16px;
}

/* ================= DUGMAD ================= */
.btn {
  padding: 9px 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-family: var(--font); font-size: 14px; font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--txt);
  background: rgba(255, 255, 255, 0.07);
}
.btn:hover { transform: translateY(-1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(77, 163, 255, 0.35);
}
.btn-primary:hover { box-shadow: 0 6px 18px rgba(77, 163, 255, 0.5); }
.btn-danger {
  background: linear-gradient(135deg, #ff6b5e, #d63a4a);
  border-color: transparent;
}
.btn-ghost { background: rgba(255, 255, 255, 0.07); }
.btn-sm { padding: 6px 13px; font-size: 12.5px; border-radius: 10px; }

/* ================= REDOVI (obuka, usjevi, tržnica) ================= */
.train-row, .crop-row, .squad-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 13px;
  margin-bottom: 7px;
}
.crop-row { cursor: pointer; transition: all 0.13s; }
.crop-row:hover:not(.locked) { background: rgba(85, 217, 124, 0.12); border-color: rgba(85, 217, 124, 0.4); }
.crop-row.locked { opacity: 0.5; cursor: not-allowed; }
.train-row.locked { opacity: 0.55; }
.u-icon { font-size: 28px; width: 38px; text-align: center; flex-shrink: 0; }
.u-name { flex: 1; font-weight: 700; font-size: 14px; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.u-name small { font-weight: 500; font-size: 11.5px; color: var(--txt-dim); }
.crop-econ { text-align: right; font-size: 12px; color: var(--txt-dim); }
.crop-econ b { color: var(--gold); font-size: 13px; }
.train-cost { display: flex; flex-wrap: wrap; gap: 3px; max-width: 150px; justify-content: flex-end; }
.train-queue { margin-bottom: 12px; font-size: 13px; }
.army-count { font-size: 17px; font-weight: 800; color: var(--accent); }
.dim { color: var(--txt-dim); font-size: 12.5px; }
.warn { color: var(--gold); font-size: 13px; }
.mkt-actions { display: flex; flex-direction: column; gap: 5px; }

/* ================= MISIJE ================= */
.mission-list { display: flex; flex-direction: column; gap: 8px; }
.mission-card {
  display: flex; align-items: center; gap: 13px;
  padding: 12px 13px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.mission-card.done { border-color: rgba(85, 217, 124, 0.35); }
.mission-card.locked { opacity: 0.45; }
.mission-icon { font-size: 32px; width: 42px; text-align: center; flex-shrink: 0; }
.mission-info { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.mission-info b { font-size: 14px; }
.mission-info small { font-size: 12px; color: var(--txt-dim); }

/* ================= ODABIR JEDINICA ================= */
.squad-head { font-size: 14px; margin-bottom: 4px; }
.squad-hint { font-size: 12px; color: var(--txt-dim); margin-bottom: 10px; }
.stepper { display: flex; align-items: center; gap: 8px; }
.step-btn {
  width: 30px; height: 30px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--txt);
  font-size: 17px; font-weight: 700;
  cursor: pointer;
  transition: all 0.12s;
}
.step-btn:hover { background: rgba(77, 163, 255, 0.2); }
.step-val { min-width: 22px; text-align: center; font-weight: 800; font-size: 15px; }
.squad-total { margin-top: 8px; font-weight: 700; font-size: 14px; text-align: right; }

/* ================= BITKA ================= */
#battle-overlay {
  position: fixed; inset: 0;
  background: rgba(6, 10, 20, 0.72);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: grid; place-items: center;
  z-index: 70;
}
#battle-overlay.hidden { display: none; }
.battle-box {
  position: relative;
  width: min(860px, calc(100vw - 24px));
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  background: var(--bg-panel-solid);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 20px 22px;
  animation: popIn 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.15);
}
.battle-head { margin-bottom: 14px; }
.battle-title { font-size: 19px; font-weight: 800; }
.battle-title small { color: var(--txt-dim); font-weight: 600; }
.battle-turn { font-size: 13px; color: var(--gold); margin-top: 4px; min-height: 18px; }
.battle-field {
  display: grid; grid-template-columns: 1fr auto 1fr;
  gap: 14px; align-items: start;
}
.battle-side h4 { font-size: 13px; color: var(--txt-dim); margin-bottom: 8px; }
.battle-vs { font-size: 26px; align-self: center; opacity: 0.7; }
.bgroup {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px;
  background: rgba(255, 255, 255, 0.05);
  border: 1.5px solid var(--border);
  border-radius: 13px;
  margin-bottom: 7px;
  cursor: pointer;
  transition: all 0.14s;
}
.bgroup .bg-icon { font-size: 26px; }
.bgroup .bg-info { flex: 1; display: flex; flex-direction: column; font-size: 13px; }
.bgroup .bg-info span { color: var(--txt-dim); font-size: 12px; }
.bgroup .bg-hp {
  width: 64px; height: 8px; border-radius: 5px; overflow: hidden;
  background: rgba(255, 255, 255, 0.12);
}
.bgroup .bg-hp i { display: block; height: 100%; background: linear-gradient(90deg, #55d97c, #a8e063); transition: width 0.3s; }
.bgroup.sel { border-color: var(--gold); background: rgba(255, 213, 74, 0.12); box-shadow: 0 0 12px rgba(255, 213, 74, 0.25); }
.bgroup.targetable { border-color: rgba(255, 107, 94, 0.55); }
.bgroup.targetable:hover { background: rgba(255, 107, 94, 0.16); transform: scale(1.02); }
.bgroup.dead { opacity: 0.32; cursor: default; filter: grayscale(1); }
.battle-log {
  margin-top: 14px;
  max-height: 92px; overflow-y: auto;
  background: rgba(0, 0, 0, 0.28);
  border-radius: 12px;
  padding: 9px 13px;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--txt-dim);
}
.battle-log b { color: var(--txt); }
.battle-actions { margin-top: 12px; display: flex; justify-content: flex-end; }
.battle-result {
  position: sticky; bottom: 0;
  margin-top: 14px;
  background: linear-gradient(180deg, rgba(20, 28, 48, 0.96), rgba(14, 20, 34, 0.98));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px 18px;
  text-align: center;
  animation: popIn 0.3s ease;
}
.battle-result-title { font-size: 24px; font-weight: 900; margin-bottom: 6px; }
.battle-result .chip-row { justify-content: center; margin: 7px 0; }
.battle-result .btn { margin-top: 8px; }

/* ================= TOAST ================= */
#toast-root {
  position: fixed; top: 76px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 7px;
  z-index: 80;
  pointer-events: none;
  align-items: center;
}
.toast {
  padding: 9px 18px;
  background: var(--bg-panel-solid);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13.5px; font-weight: 600;
  box-shadow: var(--shadow);
  opacity: 0; transform: translateY(-8px);
  transition: all 0.25s ease;
  max-width: min(520px, calc(100vw - 30px));
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-ok { border-color: rgba(85, 217, 124, 0.4); }
.toast-err { border-color: rgba(255, 107, 94, 0.5); color: #ffc7c0; }

/* ================= OSTALO ================= */
.levelup { text-align: center; }
.levelup-num {
  width: 84px; height: 84px; margin: 6px auto 12px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), #ff9f43);
  display: grid; place-items: center;
  font-size: 38px; font-weight: 900; color: #2c1d00;
  box-shadow: 0 0 30px rgba(255, 213, 74, 0.55);
  animation: pulse 1.6s infinite;
}
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin: 12px 0; font-size: 13px; }
.help-grid div {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 9px 11px;
  line-height: 1.4;
}
.settings-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 2px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  gap: 12px;
}

/* skrol trake */
::-webkit-scrollbar { width: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.16); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.28); }

@media (max-width: 900px) {
  .help-grid { grid-template-columns: 1fr; }
  #quest-card { width: 210px; }
  .battle-field { grid-template-columns: 1fr; }
  .battle-vs { display: none; }
}
