/* ============================================================
   IRONFALL — Reinos em Guerra
   Tema: medieval escuro, vidro e ouro
   ============================================================ */
:root {
  --bg: #0c0a07;
  --bg2: #14100a;
  --panel: rgba(24, 19, 12, .78);
  --panel-solid: #171208;
  --line: rgba(212, 169, 78, .22);
  --line-strong: rgba(212, 169, 78, .45);
  --gold: #d4a94e;
  --gold-hi: #f3d488;
  --gold-dk: #8a6a2a;
  --ink: #ead9b8;
  --muted: #a08c68;
  --red: #e05545;
  --red-dk: #7e2318;
  --green: #7fb96a;
  --blue: #7fb3c8;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0,0,0,.55);
  --font-title: 'Cinzel', 'Times New Roman', serif;
  --font-body: 'Alegreya Sans', 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-size: 16px;
  color: var(--ink);
  background:
    radial-gradient(1100px 500px at 50% -10%, rgba(212,169,78,.10), transparent 60%),
    radial-gradient(900px 600px at -10% 110%, rgba(120, 60, 20, .14), transparent 55%),
    radial-gradient(900px 600px at 110% 110%, rgba(60, 40, 90, .10), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
}
/* textura sutil */
body::before {
  content: '';
  position: fixed; inset: 0;
  pointer-events: none;
  opacity: .5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0.06 0 0 0 0 0.05 0 0 0 0 0.03 0 0 0 .35 0'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* tochas laterais */
.bg-torch {
  position: fixed; top: 12vh; width: 340px; height: 340px;
  border-radius: 50%;
  filter: blur(70px);
  background: radial-gradient(circle, rgba(255,140,40,.16), transparent 70%);
  animation: flicker 4s ease-in-out infinite alternate;
  pointer-events: none; z-index: 0;
}
.bg-torch-l { left: -120px; }
.bg-torch-r { right: -120px; animation-delay: 2s; }
@keyframes flicker {
  0% { opacity: .55; transform: scale(1); }
  50% { opacity: .9; transform: scale(1.08); }
  100% { opacity: .6; transform: scale(.96); }
}

a { color: var(--gold-hi); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.red { color: var(--red); }
.green { color: var(--green); }

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 18px;
  padding: 10px 18px;
  background: linear-gradient(180deg, rgba(20,15,8,.95), rgba(16,12,7,.88));
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 6px 24px rgba(0,0,0,.5);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none !important; }
.brand-ico { font-size: 26px; filter: drop-shadow(0 0 8px rgba(255,180,60,.5)); }
.brand-txt {
  font-family: var(--font-title); font-weight: 900; font-size: 20px;
  letter-spacing: .12em;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold) 60%, var(--gold-dk));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  display: flex; flex-direction: column; line-height: .95;
}
.brand-txt small { font-size: 9px; letter-spacing: .3em; color: var(--muted); -webkit-text-fill-color: var(--muted); }

.resbar { display: flex; gap: 14px; flex: 1; justify-content: center; flex-wrap: wrap; }
.res {
  display: flex; align-items: baseline; gap: 6px;
  padding: 6px 12px;
  background: rgba(255,255,255,.03);
  border: 1px solid var(--line);
  border-radius: 10px;
  transition: border-color .2s, transform .2s;
}
.res:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.res-ico { font-size: 15px; }
.res-val { font-weight: 800; font-size: 15px; color: var(--gold-hi); font-variant-numeric: tabular-nums; }
.res-cap { font-size: 11px; color: var(--muted); }

.userbox { display: flex; align-items: center; gap: 8px; }
.userbox-name { font-weight: 700; font-size: 14px; white-space: nowrap; }

/* ---------- nav ---------- */
.mainnav {
  position: sticky; top: 57px; z-index: 40;
  display: flex; gap: 4px; flex-wrap: wrap;
  padding: 8px 14px;
  background: rgba(12, 10, 6, .82);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(212,169,78,.12);
}
.navitem {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px;
  border-radius: 10px;
  color: var(--muted);
  font-weight: 600; font-size: 14.5px;
  text-decoration: none !important;
  border: 1px solid transparent;
  transition: all .18s;
}
.navitem:hover { color: var(--ink); background: rgba(212,169,78,.08); }
.navitem.active {
  color: var(--gold-hi);
  background: linear-gradient(180deg, rgba(212,169,78,.18), rgba(212,169,78,.06));
  border-color: var(--line-strong);
  box-shadow: inset 0 0 18px rgba(212,169,78,.08), 0 2px 10px rgba(0,0,0,.35);
}
.navitem.alert { color: var(--red); animation: pulse-red 1.4s infinite; }
@keyframes pulse-red { 50% { box-shadow: 0 0 0 4px rgba(224,85,69,.15); } }
.nav-ico { font-size: 16px; }

.badge {
  font-size: 11px; font-weight: 800; padding: 1px 7px; border-radius: 99px;
  background: var(--gold-dk); color: #fff;
}
.badge.red { background: var(--red-dk); }

.alert-bar {
  margin: 14px 18px 0;
  padding: 10px 16px;
  border-radius: 12px;
  background: linear-gradient(90deg, rgba(224,85,69,.22), rgba(224,85,69,.08));
  border: 1px solid rgba(224,85,69,.5);
  color: #ffb4aa;
  font-size: 14.5px;
}
.anim-shake { animation: shake .6s ease-in-out; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-5px); } 40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); } 80% { transform: translateX(3px); }
}

/* ---------- layout ---------- */
.wrap { position: relative; z-index: 1; max-width: 1180px; margin: 0 auto; padding: 20px 18px 60px; }
.page-title {
  font-family: var(--font-title); font-weight: 700; font-size: 26px;
  color: var(--gold-hi);
  text-shadow: 0 2px 12px rgba(212,169,78,.25);
}
.coords { color: var(--muted); font-size: 14px; margin-top: 2px; }
.vhead { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } .resbar { order: 3; width: 100%; } }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
  animation: rise .35s ease both;
}
.panel-title {
  font-family: var(--font-title); font-size: 16px; font-weight: 700;
  color: var(--gold);
  letter-spacing: .06em;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

/* ---------- botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 18px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, rgba(212,169,78,.16), rgba(212,169,78,.05));
  color: var(--ink);
  font-family: var(--font-body); font-weight: 700; font-size: 14.5px;
  cursor: pointer;
  text-decoration: none !important;
  transition: all .18s;
}
.btn:hover:not(:disabled) {
  border-color: var(--gold);
  box-shadow: 0 0 16px rgba(212,169,78,.25);
  transform: translateY(-1px);
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-gold {
  background: linear-gradient(180deg, #e9c56b, #b98a2e 55%, #8a6a2a);
  color: #241a08;
  border-color: #f3d488;
  text-shadow: 0 1px 0 rgba(255,255,255,.3);
}
.btn-gold:hover:not(:disabled) { box-shadow: 0 0 22px rgba(233,197,107,.45); }
.btn-red {
  background: linear-gradient(180deg, #d9563f, #8e2415);
  color: #ffe9e2; border-color: #e98a76;
}
.btn-red:hover:not(:disabled) { box-shadow: 0 0 20px rgba(224,85,69,.4); }
.btn-ghost { background: rgba(255,255,255,.03); }
.btn-lg { padding: 12px 26px; font-size: 16px; }
.mini-btn {
  padding: 4px 10px; font-size: 12.5px; font-weight: 700;
  border-radius: 8px; border: 1px solid var(--line);
  color: var(--muted); background: rgba(255,255,255,.03);
  cursor: pointer; text-decoration: none !important;
  transition: all .15s;
}
.mini-btn:hover { color: var(--gold-hi); border-color: var(--line-strong); }
.mini-btn.danger:hover { color: var(--red); border-color: var(--red); }

/* ---------- formulários ---------- */
label { display: block; font-size: 13.5px; color: var(--muted); margin-bottom: 12px; font-weight: 600; }
input[type=text], input[type=password], input[type=email], input[type=number], select {
  width: 100%;
  margin-top: 5px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.35);
  color: var(--ink);
  font-family: var(--font-body); font-size: 15px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(212,169,78,.15); }
.qty { width: 90px !important; display: inline-block; margin-top: 0 !important; }

/* ---------- toast ---------- */
.toast {
  padding: 11px 16px; border-radius: 12px; margin-bottom: 12px;
  font-weight: 600;
  animation: toast-in .3s ease;
  border: 1px solid;
}
.toast-ok { background: rgba(127,185,106,.12); border-color: rgba(127,185,106,.45); color: #c9e8bb; }
.toast-bad { background: rgba(224,85,69,.12); border-color: rgba(224,85,69,.45); color: #ffc4bb; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

/* ---------- tiles de recursos ---------- */
.res-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.res-tile {
  padding: 12px;
  border-radius: 12px;
  background: rgba(255,255,255,.03);
  border: 1px solid var(--line);
}
.res-tile-top { display: flex; align-items: baseline; gap: 6px; margin-bottom: 8px; }
.res-tile-top b { color: var(--gold-hi); font-size: 17px; }

/* ---------- barras ---------- */
.bar {
  height: 8px; border-radius: 99px;
  background: rgba(0,0,0,.45);
  border: 1px solid rgba(255,255,255,.06);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--gold-dk), var(--gold), var(--gold-hi));
  transition: width .5s ease;
}
.bar-fill.bar-anim {
  background: linear-gradient(90deg, var(--gold-dk), var(--gold), var(--gold-hi), var(--gold));
  background-size: 200% 100%;
  animation: shimmer 2.2s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- filas ---------- */
.queue-item {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255,255,255,.03);
  border: 1px solid var(--line);
  margin-bottom: 10px;
}
.queue-item.hostile { border-color: rgba(224,85,69,.55); background: rgba(224,85,69,.08); }
.queue-top { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 7px; font-size: 14.5px; }

/* ---------- chips / tags ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; margin: 3px;
  border-radius: 99px;
  background: rgba(212,169,78,.10);
  border: 1px solid var(--line);
  font-size: 13.5px; font-weight: 600;
}
.tag {
  display: inline-block; padding: 2px 9px; border-radius: 99px;
  font-size: 12px; font-weight: 700;
  background: rgba(212,169,78,.14); color: var(--gold-hi);
  border: 1px solid var(--line);
}
.tag.red { background: rgba(224,85,69,.16); color: #ffb0a5; border-color: rgba(224,85,69,.4); }
.tag.gold { background: linear-gradient(180deg,#e9c56b,#b98a2e); color:#241a08; border:none; }

/* ---------- tabelas ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.tbl th {
  text-align: left; font-size: 12px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); padding: 7px 8px; border-bottom: 1px solid var(--line);
}
.tbl td { padding: 8px; border-bottom: 1px solid rgba(212,169,78,.08); }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr.me td { background: rgba(212,169,78,.08); }
.tbl tr:hover td { background: rgba(255,255,255,.025); }

/* ---------- cards de edifício ---------- */
.bld-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 14px; }
.bld-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  transition: transform .2s, border-color .2s, box-shadow .2s;
  animation: rise .4s ease both;
}
.bld-card:hover { transform: translateY(-3px); border-color: var(--line-strong); box-shadow: 0 14px 34px rgba(0,0,0,.6), 0 0 18px rgba(212,169,78,.08); }
.bld-card.locked { opacity: .55; filter: saturate(.6); }
.bld-head { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.bld-head h3 { font-family: var(--font-title); font-size: 16.5px; color: var(--gold-hi); }
.bld-ico {
  font-size: 26px; width: 52px; height: 52px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
  background: radial-gradient(circle at 30% 25%, rgba(212,169,78,.28), rgba(212,169,78,.06));
  border: 1px solid var(--line-strong);
  box-shadow: inset 0 0 14px rgba(0,0,0,.4);
}
.bld-desc { font-size: 13.5px; color: var(--muted); margin-bottom: 10px; min-height: 34px; }
.bld-cost { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.cost { font-size: 13.5px; font-weight: 700; color: var(--green); }
.cost.lack { color: var(--red); }
.unit-stats { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; font-size: 13px; color: var(--ink); }
.train-form { display: flex; gap: 8px; align-items: center; margin-top: 8px; }

/* ---------- grid mini da aldeia ---------- */
.bld-mini-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.bld-mini {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px 8px;
  border-radius: 12px;
  background: rgba(255,255,255,.03);
  border: 1px solid var(--line);
  text-decoration: none !important;
  color: var(--ink);
  transition: all .18s;
}
.bld-mini:hover { border-color: var(--gold); background: rgba(212,169,78,.08); transform: translateY(-2px); }
.bld-mini.locked { opacity: .5; }
.bld-mini-ico { font-size: 24px; }
.bld-mini-name { font-size: 12.5px; font-weight: 600; text-align: center; }
.bld-mini-lvl { font-size: 12px; color: var(--gold-hi); font-weight: 800; }

/* ---------- ataque ---------- */
.attack-target { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.attack-target label { margin-bottom: 0; min-width: 160px; }
.unit-select { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; margin-bottom: 16px; }
.unit-pick {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; margin: 0;
  border-radius: 12px;
  background: rgba(255,255,255,.03);
  border: 1px solid var(--line);
}
.unit-pick input { width: 74px; margin: 0; padding: 7px 8px; }
.unit-pick-name { font-weight: 700; font-size: 14px; flex: 1; }

/* ---------- mapa ---------- */
.map-layout { display: grid; grid-template-columns: 1fr 300px; gap: 16px; align-items: start; }
@media (max-width: 900px) { .map-layout { grid-template-columns: 1fr; } }
.map-wrap { padding: 14px; }
.map-grid {
  display: grid;
  grid-template-columns: repeat(var(--size), 1fr);
  gap: 2px;
  aspect-ratio: 1;
}
.tile {
  position: relative;
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  cursor: default;
  transition: transform .12s, box-shadow .12s;
  min-width: 0;
}
.t-grass0 { background: #22341c; }
.t-grass1 { background: #27391f; }
.t-grass2 { background: #1e2f19; }
.t-forest { background: #17290f; box-shadow: inset 0 0 6px rgba(0,0,0,.6); }
.t-hill { background: #3a3323; }
.t-dark { background: #241f16; }
.t-void { background: #0a0906; }
.tile.has-village { cursor: pointer; }
.tile.has-village:hover { transform: scale(1.25); z-index: 5; box-shadow: 0 0 0 2px var(--gold), 0 6px 16px rgba(0,0,0,.6); }
.vil-ico { font-size: clamp(8px, 1.4vw, 15px); filter: drop-shadow(0 1px 2px #000); }
.tile.mine { box-shadow: 0 0 0 2px var(--gold-hi), 0 0 12px rgba(243,212,136,.6); border-radius: 6px; }
.tile.under-attack::after {
  content: '';
  position: absolute; inset: -3px;
  border-radius: 6px;
  border: 2px solid var(--red);
  animation: pulse-ring 1s infinite;
}
@keyframes pulse-ring {
  0% { opacity: 1; transform: scale(.85); }
  100% { opacity: 0; transform: scale(1.25); }
}
.map-legend { display: flex; gap: 16px; margin-top: 10px; font-size: 13px; color: var(--muted); }
.lg-mine { color: var(--gold-hi); }
.lg-atk { color: var(--red); }
.map-jump { display: flex; gap: 8px; align-items: center; }
.map-jump .qty { width: 74px !important; }
.map-nav-arrows { display: flex; gap: 10px; justify-content: center; margin-top: 14px; }

.map-side .side-vil h3 { font-family: var(--font-title); color: var(--gold-hi); font-size: 18px; margin-bottom: 4px; }
.side-row { display: flex; justify-content: space-between; font-size: 14px; padding: 5px 0; border-bottom: 1px dashed rgba(212,169,78,.12); }
.side-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }

/* ---------- relatórios ---------- */
.report { cursor: default; }
.report summary {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; list-style: none;
  font-weight: 600;
}
.report summary::-webkit-details-marker { display: none; }
.report summary::before {
  content: '▸'; color: var(--gold); transition: transform .2s;
}
.report[open] summary::before { transform: rotate(90deg); }
.report.unread { border-color: var(--line-strong); box-shadow: 0 0 16px rgba(212,169,78,.12), var(--shadow); }
.report.unread .rep-title::after { content: ' ● novo'; color: var(--gold); font-size: 11px; }
.rep-title { flex: 1; }
.rep-body { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.rep-body h4 { font-family: var(--font-title); color: var(--gold-hi); margin-bottom: 6px; font-size: 15px; }
.rep-body p { margin-bottom: 6px; }

/* ---------- landing ---------- */
body.landing { display: flex; align-items: center; justify-content: center; }
.hero { width: 100%; min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 30px 16px; position: relative; z-index: 1; }
.hero-inner { max-width: 640px; width: 100%; text-align: center; }
.hero-brand { margin-bottom: 26px; }
.hero-ico {
  font-size: 54px; display: inline-block;
  filter: drop-shadow(0 0 24px rgba(255,170,50,.55));
  animation: floaty 4s ease-in-out infinite;
}
@keyframes floaty { 50% { transform: translateY(-8px); } }
.hero-title {
  font-family: var(--font-title); font-weight: 900;
  font-size: clamp(44px, 9vw, 74px);
  letter-spacing: .14em;
  color: #f0e2c0;
  text-shadow: 0 0 40px rgba(212,169,78,.4), 0 4px 18px rgba(0,0,0,.8);
}
.hero-title span {
  background: linear-gradient(180deg, var(--gold-hi), var(--gold) 55%, var(--gold-dk));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-tag {
  margin-top: 6px; letter-spacing: .42em; text-transform: uppercase;
  font-size: 13px; color: var(--muted); font-weight: 700;
}
.hero-stats { display: flex; justify-content: center; gap: 26px; margin-bottom: 26px; }
.hstat { display: flex; flex-direction: column; }
.hstat b { font-family: var(--font-title); font-size: 22px; color: var(--gold-hi); }
.hstat span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.login-panel { text-align: left; max-width: 420px; margin: 0 auto 26px; }
.panel-title { margin-bottom: 14px; }
.swap { margin-top: 14px; font-size: 14px; color: var(--muted); text-align: center; }
.hero-feats { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.feat {
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(255,255,255,.03);
  border: 1px solid var(--line);
  font-size: 13.5px; color: var(--muted);
}
.feat span { margin-right: 6px; }

/* animações de entrada escalonadas */
.anim-rise { animation: rise-big .6s ease both; }
.anim-rise.d1 { animation-delay: .12s; }
.anim-rise.d2 { animation-delay: .24s; }
.anim-rise.d3 { animation-delay: .36s; }
@keyframes rise-big { from { opacity: 0; transform: translateY(22px); } }

/* ---------- rodapé ---------- */
.foot {
  text-align: center; padding: 22px;
  color: var(--muted); font-size: 13px;
  border-top: 1px solid rgba(212,169,78,.1);
  position: relative; z-index: 1;
}

/* ---------- scrollbar ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #3a2f1c; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-dk); }
