/* Forum Frontlines — core theme, layout and shared components. */
:root {
  --bg: #10150e;
  --bg2: #151c11;
  --panel: #1b2415;
  --panel2: #222d1a;
  --panel3: #2a3720;
  --line: #37452a;
  --line2: #455635;
  --ink: #ece9d8;
  --dim: #a3ae92;
  --dim2: #6f7a60;
  --gold: #e6b94f;
  --gold2: #f4d47c;
  --green: #93c353;
  --red: #e05b4b;
  --blue: #58aec7;
  --purple: #a37de0;
  --shadow: 0 6px 24px rgba(0, 0, 0, .45);
  --r: 14px;
  --nav-h: 62px;
  --top-h: 58px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background:
    radial-gradient(1200px 500px at 70% -10%, #1c2913 0%, transparent 60%),
    radial-gradient(900px 500px at -10% 110%, #16210f 0%, transparent 55%),
    var(--bg);
  color: var(--ink);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  overflow: hidden;
}
.hidden { display: none !important; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
a { color: inherit; text-decoration: none; }
input, select, textarea {
  font: inherit; color: var(--ink);
  background: #131a0e; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; width: 100%;
}
input:focus, textarea:focus { outline: 2px solid #5a7038; border-color: transparent; }
h1, h2, h3 { font-weight: 800; letter-spacing: .04em; }
h2 { font-size: 19px; text-transform: uppercase; letter-spacing: .09em; }
h3 { font-size: 16px; }
small { color: var(--dim); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #33402a; border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- app frame ---------- */
#app { display: flex; flex-direction: column; height: 100dvh; }
#topbar {
  height: var(--top-h); flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 0 12px;
  background: linear-gradient(180deg, #1c2614, #161f10);
  border-bottom: 1px solid var(--line);
  z-index: 30;
}
#layout { flex: 1; display: flex; min-height: 0; }
#sidenav {
  width: 216px; flex: 0 0 auto; overflow-y: auto;
  background: #141b0f; border-right: 1px solid var(--line);
  padding: 14px 10px; display: flex; flex-direction: column; gap: 2px;
}
#screen {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 18px clamp(12px, 3vw, 30px) 90px;
  scroll-behavior: smooth;
}
#screen > * { max-width: 1060px; margin-left: auto; margin-right: auto; }

.site-footer {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 14px;
  background: #12190e;
  border-top: 1px solid var(--line);
  color: var(--dim2);
  font-size: 12px;
  letter-spacing: .06em;
}
.site-footer .footer-brand {
  font-weight: 800;
  color: var(--dim);
}
.site-footer .footer-stat {
  display: inline-flex; align-items: center; gap: 7px;
  white-space: nowrap;
}
.site-footer .footer-stat b {
  color: var(--gold2);
  font-variant-numeric: tabular-nums;
}

.brand {
  display: flex; gap: 10px; align-items: center; padding: 6px 10px 16px;
  font-size: 15px; line-height: 1.15; letter-spacing: .12em;
}
.brand span { font-size: 26px; }
.side-btn {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 12px; border-radius: 10px; color: var(--dim);
  font-weight: 600; text-align: left; position: relative;
}
.side-btn span:first-child { width: 22px; text-align: center; }
.side-btn:hover { background: #1c2614; color: var(--ink); }
.side-btn.active { background: #26331a; color: var(--ink); box-shadow: inset 3px 0 0 var(--gold); }
.side-foot { margin-top: auto; padding: 12px; color: var(--dim2); font-size: 12px; letter-spacing: .1em; }

#bottomnav {
  display: none; flex: 0 0 auto; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: linear-gradient(0deg, #131a0e, #161f10);
  border-top: 1px solid var(--line);
  z-index: 30;
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--dim); font-size: 11px; font-weight: 700; position: relative;
}
.nav-btn .nav-ico { font-size: 21px; }
.nav-btn.active { color: var(--gold2); }
.nav-btn.nav-big .nav-ico {
  width: 52px; height: 52px; display: grid; place-items: center;
  background: linear-gradient(180deg, #45602a, #2c401b);
  border: 2px solid #6f8f45; border-radius: 50%;
  margin-top: -22px; font-size: 25px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .5);
}
.nav-btn.nav-big.active .nav-ico { border-color: var(--gold); }
.nav-badge {
  position: absolute; top: 4px; right: calc(50% - 22px);
  background: var(--red); color: #fff; border-radius: 9px;
  font-size: 10px; min-width: 17px; height: 17px; line-height: 17px;
  padding: 0 4px; text-align: center; font-weight: 800;
}
.side-btn .nav-badge { position: static; margin-left: auto; }

/* ---------- top bar widgets ---------- */
.player-chip { display: flex; align-items: center; gap: 9px; padding: 5px 8px; border-radius: 12px; }
.player-chip:hover { background: #222d16; }
.avatar {
  width: 38px; height: 38px; flex: 0 0 auto; display: grid; place-items: center;
  font-size: 21px; border-radius: 11px;
  background: linear-gradient(160deg, var(--c, #556b3a), #1c2415 130%);
  border: 1px solid #ffffff2b;
}
.avatar.lg { width: 62px; height: 62px; font-size: 36px; border-radius: 16px; }
.avatar.sm { width: 28px; height: 28px; font-size: 15px; border-radius: 8px; }
.skin-avatar { padding: 0; position: relative; background: #1c2415; }
.skin-avatar canvas { display: block; width: 100%; height: 100%; border-radius: inherit; }
.chip-txt { display: flex; flex-direction: column; line-height: 1.15; text-align: left; }
.chip-txt small { font-size: 11px; color: var(--gold); }

.res-pills { display: flex; gap: 7px; align-items: center; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: #141b0e; border: 1px solid var(--line);
  padding: 6px 11px; border-radius: 999px; font-size: 13px; white-space: nowrap;
}
.pill b { font-variant-numeric: tabular-nums; }
.pill.coin b { color: var(--gold2); }
.pill.sup b { color: var(--green); }
.pill.nrg small { font-size: 10px; color: var(--dim); }
.shield-pill { border-color: #3d6a8f; background: #14212b; }
.shield-pill b { color: var(--blue); font-size: 12px; }
.pips { display: inline-flex; gap: 3px; }
.pips i {
  width: 9px; height: 13px; border-radius: 2px;
  background: #26301c; border: 1px solid #3b4a28;
  transform: skewX(-12deg);
}
.pips i.on { background: linear-gradient(180deg, #ffd970, #e08c2d); border-color: #ffce62; }

/* ---------- shared components ---------- */
.panel {
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px; margin-bottom: 14px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.panel-head h2 { display: flex; align-items: center; gap: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 11px 18px; border-radius: 11px; font-weight: 800; letter-spacing: .03em;
  border: 1px solid transparent; transition: transform .06s, filter .15s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn.primary { background: linear-gradient(180deg, #57742f, #3c5420); border-color: #7a9a4c; color: #f2f5e6; }
.btn.primary:hover { filter: brightness(1.12); }
.btn.gold { background: linear-gradient(180deg, #d9a93e, #a97b1f); border-color: #ffd571; color: #221a05; }
.btn.gold:hover { filter: brightness(1.1); }
.btn.ghost { background: #1a2312; border-color: var(--line); color: var(--dim); }
.btn.ghost:hover { color: var(--ink); border-color: #55683c; }
.btn.danger { background: linear-gradient(180deg, #a63a2d, #7c281e); border-color: #d96a56; color: #ffe9e4; }
.btn.big { padding: 15px 26px; font-size: 17px; border-radius: 14px; }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 9px; }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: grayscale(.4); }
.btn-row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }

.bar { height: 9px; background: #131a0d; border: 1px solid #2c3820; border-radius: 6px; overflow: hidden; }
.bar > i {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, #7ba33f, #a7d160);
  border-radius: 6px; transition: width .5s linear;
}
.bar.gold > i { background: linear-gradient(90deg, #c99a2e, #ffd971); }
.bar.red > i { background: linear-gradient(90deg, #a8402f, #e0705b); }
.bar.blue > i { background: linear-gradient(90deg, #33718a, #6cc4de); }

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 999px;
  background: #222d17; border: 1px solid var(--line); color: var(--dim);
}
.tag.gold { color: var(--gold2); border-color: #6d5620; background: #2a2312; }
.tag.green { color: var(--green); border-color: #45602a; background: #1c2812; }
.tag.red { color: #f0907f; border-color: #6b3128; background: #2b1712; }
.tag.blue { color: #8fd4e8; border-color: #2d5a6e; background: #12242c; }
.tag.purple { color: #c7a8f0; border-color: #4f3d70; background: #201a2c; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }

.stat-row { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px dashed #2c3820; font-size: 14px; }
.stat-row:last-child { border-bottom: none; }
.stat-row b { font-variant-numeric: tabular-nums; }

.empty {
  text-align: center; color: var(--dim); padding: 26px 10px; font-size: 14px;
}
.empty .e-ico { font-size: 34px; display: block; margin-bottom: 8px; }

/* ---------- toasts ---------- */
#toasts {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 18px); transform: translateX(-50%);
  display: flex; flex-direction: column-reverse; gap: 8px; z-index: 90; pointer-events: none;
  width: min(92vw, 430px);
}
.toast {
  display: flex; gap: 9px; align-items: center;
  background: #232e16ee; border: 1px solid #4a5c31; border-radius: 12px;
  padding: 11px 15px; font-size: 14px; box-shadow: var(--shadow);
  opacity: 0; transform: translateY(12px); transition: all .3s;
  backdrop-filter: blur(6px);
}
.toast.in { opacity: 1; transform: none; }
.toast.good { border-color: #6d8f3f; }
.toast.bad { border-color: #a04a3b; background: #2e1a14ee; }
.toast .t-ico { font-size: 19px; }

/* ---------- modals ---------- */
#modal-layer { position: fixed; inset: 0; z-index: 80; }
#modal-layer.open .modal-back { opacity: 1; }
#modal-layer.open .modal { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.modal-back {
  position: absolute; inset: 0; background: #05080399;
  backdrop-filter: blur(3px); opacity: 0; transition: opacity .2s;
}
.modal {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -47%) scale(.97);
  width: min(calc(100vw - 24px), 470px);
  max-height: calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
  background: linear-gradient(180deg, #232e17, #1a2311);
  border: 1px solid #4a5c31; border-radius: 18px;
  padding: 22px; box-shadow: var(--shadow);
  opacity: 0; transition: all .2s;
}
.modal h3 { margin-bottom: 8px; font-size: 18px; }
.modal-msg { color: var(--dim); font-size: 14px; }
.modal-x {
  position: absolute; top: 10px; right: 12px; color: var(--dim);
  font-size: 15px; padding: 6px; z-index: 2;
}
.modal-x:hover { color: var(--ink); }

/* welcome screen: hide empty chrome until an army exists */
body.no-chrome #topbar, body.no-chrome #sidenav, body.no-chrome #bottomnav { display: none; }

/* ---------- reduced motion ---------- */
body.reduced-motion *, body.reduced-motion *::before, body.reduced-motion *::after {
  animation-duration: .01ms !important; animation-iteration-count: 1 !important;
  transition-duration: .01ms !important;
}

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  #sidenav { display: none; }
  #bottomnav { display: flex; }
  #screen { padding: 14px 12px calc(var(--nav-h) + 40px); }
  .site-footer { padding: 7px 10px; }
  .grid4 { grid-template-columns: 1fr 1fr; }
  .grid3 { grid-template-columns: 1fr; }
  .chip-txt small { display: none; }
  .pill { padding: 5px 9px; font-size: 12.5px; }
  #topbar { padding: 0 8px; }
}
@media (max-width: 480px) {
  .grid2 { grid-template-columns: 1fr; }
  #topbar { gap: 4px; overflow: hidden; }
  .site-footer { justify-content: center; text-align: center; }
  .site-footer .footer-brand { display: none; }
  .player-chip { min-width: 0; padding-inline: 4px; }
  .chip-txt { display: none; }
  .res-pills { min-width: 0; gap: 4px; }
  .pill { gap: 4px; padding: 4px 7px; font-size: 11.5px; }
  .pill.nrg small { display: none; }
  .modal {
    width: min(calc(100vw - 18px), 470px);
    padding: 18px;
    border-radius: 14px;
  }
  .modal .btn-row {
    flex-direction: column-reverse;
    align-items: stretch;
  }
  .modal .btn-row .btn {
    width: 100%;
    white-space: normal;
  }
  #toasts {
    width: calc(100vw - 18px);
    bottom: calc(var(--nav-h) + 10px + env(safe-area-inset-bottom));
  }
  .toast {
    align-items: flex-start;
    overflow-wrap: anywhere;
  }
}
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes popIn { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: scale(1); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
