/* =========================================================
   KINGDOM GRAM — CORE STYLESHEET (v3 — "Storybook Kingdom" identity)
   Build your empire. Rule your throne. Conquer the map.
   =========================================================

   DESIGN TOKENS — a condizer com o art style dos edifícios (cartoon
   vibrante, tipo Clash of Clans): azul-céu, dourado, madeira quente,
   creme/pergaminho, vermelho e verde saturados.

   Background : #eaf6ff (sky) — placas em madeira (#8b5a2b) e
                creme (#fff6e2)
   Gold       : #f5c542 (primary) / #ffe066 (bright) / #b8860b (texto)
   Red        : #e34b3f (war) / #ff6b5b (bright)
   Green      : #3d8b40 (growth) / #7ed957 (bright)
   Ink        : #4a2f18 (texto principal, castanho quente escuro)
   Ink dim    : #8a6a48 (texto secundário)

   Type       : Baloo 2   -> crista/wordmark, títulos, botões (redonda,
                             robusta, "storybook")
                Nunito     -> stats, números, HUD (amigável, legível)

   SHAPE LANGUAGE (assinatura)
   Círculos com anel dourado · pílulas com brilho vítreo · placas de
   madeira com bisel 3D (sombra inferior grossa) · botão central em
   moeda dourada. Tudo arredondado — nada de cortes/hexágonos aqui,
   isso era a linguagem do tema antigo (mais sério/sombrio).
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;600;700;800&family=Nunito:wght@500;600;700;800&display=swap');

:root {
  --sky: #eaf6ff;
  --sky-deep: #cfe9ff;

  --wood: #8b5a2b;
  --wood-dark: #5c3a1a;
  --wood-light: #c98a4b;

  --cream: #fff6e2;
  --cream-dim: #ffe9bd;

  --gold: #f5c542;
  --gold-bright: #ffe066;
  --gold-dim: #b8860b;
  --gold-line: linear-gradient(90deg, transparent, rgba(245, 197, 66, 0.85), transparent);

  --red: #e34b3f;
  --red-bright: #ff6b5b;
  --red-dark: #c62f28;

  --green: #3d8b40;
  --green-bright: #7ed957;

  --ink: #4a2f18;
  --ink-dim: #8a6a48;
  --white: #ffffff;

  --font-crest: 'Baloo 2', cursive;
  --font-head: 'Baloo 2', cursive;
  --font-hud: 'Nunito', sans-serif;

  --radius-s: 10px;
  --radius-m: 18px;
  --radius-l: 26px;
}

* {
  font-family: var(--font-hud);
  box-sizing: border-box;
  font-size: 11px;
  font-weight: 700;
}

body {
  margin: 0;
  background-color: var(--sky);
  background-image:
    radial-gradient(ellipse at 50% -10%, rgba(255, 224, 102, 0.25) 0%, transparent 45%),
    url('images/bg-web-main.jpg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--ink);
  overflow-x: hidden;
}
body:lang(ar), .content[dir="rtl"] { direction: rtl; text-align: right; }

/* =========================
   SCROLLBAR GLOBAL
========================= */

* {
  scrollbar-width: thin;
  scrollbar-color: var(--wood-light) var(--cream);
}

*::-webkit-scrollbar { width: 4px; }
*::-webkit-scrollbar-track { background: var(--cream); }
*::-webkit-scrollbar-thumb { background: var(--wood-light); border-radius: 4px; }
*::-webkit-scrollbar-thumb:hover { background: var(--gold); }

.text-justify { text-align: justify; }
.text-left { text-align: left; }

/* =========================
   2. APP LAYOUT
========================= */
.app {
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--sky);
  position: relative;
  isolation: isolate;
}

/* leve véu para garantir legibilidade sobre o fundo, sem escurecer tudo
   como no tema anterior — mantém a cena alegre e luminosa */
.app::before {
  content: "";
  position: fixed;
  inset: 0;
  max-width: 480px;
  margin: 0 auto;
  pointer-events: none;
  z-index: 1;
  background: linear-gradient(180deg, transparent 0%, transparent 12%, transparent 75%, rgba(92,58,26,0.25) 100%);
}

/* -------- HEADER -------- */
.header {
  position: fixed;
  width: 100%;
  max-width: 480px;
  z-index: 300;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: linear-gradient(180deg, rgba(139,90,43,0.97) 0%, rgba(139,90,43,0.95) 70%, rgba(139,90,43,0.0) 100%);
  border-bottom: none;
  box-shadow: none;
  padding-bottom: 30px;
  pointer-events: none;
}
.header::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 22px;
  height: 2px;
  background: var(--gold-line);
  opacity: 0.8;
}

.header-user { display: flex; align-items: center; gap: 10px; min-width: 0; }

/* avatar redondo com anel dourado grosso + brilho — amigável, sem cortes */
.header-avatar {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  object-fit: cover;
  background: linear-gradient(145deg, var(--cream-dim), var(--cream));
  border-radius: 50%;
  border: 3px solid var(--gold);
  box-shadow:
    0 0 0 2px rgba(255,255,255,0.6),
    0 3px 6px rgba(92,58,26,0.5);
}

.header-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.header-name {
  font-family: var(--font-head);
  font-size: 12px;
  letter-spacing: 0.2px;
  color: var(--gold-bright);
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}
.header-id {
  font-size: 9px;
  color: rgba(255,246,226,0.8);
  letter-spacing: 0.4px;
}

.header-right { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }

/* etiquetas em pílula com brilho vítreo no topo — moeda e idioma/som */
.header-currency {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 11px;
  background: linear-gradient(180deg, var(--cream), var(--cream-dim));
  border: 2px solid var(--wood);
  border-radius: 999px;
  font-family: var(--font-hud);
  font-size: 12px;
  font-weight: 800;
  color: var(--gold-dim);
  box-shadow: 0 3px 0 rgba(92,58,26,0.35), 0 4px 8px rgba(0,0,0,0.25);
  overflow: hidden;
}
.header-currency::before {
  content: "";
  position: absolute;
  top: 1px; left: 8%;
  width: 84%; height: 45%;
  background: linear-gradient(180deg, rgba(255,255,255,0.75), transparent);
  border-radius: 999px 999px 60% 60%;
  pointer-events: none;
}
.header-currency img { height: 13px; position: relative; z-index: 1; }

.header-user, .header-right, .header-right > * { pointer-events: auto; }

.lang-dropdown { position: relative; }
.lang-trigger {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 5px 10px;
  background: linear-gradient(180deg, var(--cream), var(--cream-dim));
  border: 2px solid var(--wood);
  border-radius: 999px;
  color: var(--ink);
  font-size: 10px;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(92,58,26,0.35), 0 4px 8px rgba(0,0,0,0.25);
  transition: 0.15s ease;
  overflow: hidden;
}
.lang-trigger::before {
  content: "";
  position: absolute;
  top: 1px; left: 10%;
  width: 80%; height: 45%;
  background: linear-gradient(180deg, rgba(255,255,255,0.75), transparent);
  border-radius: 999px 999px 60% 60%;
  pointer-events: none;
}
.lang-trigger:hover { transform: translateY(-1px); }
.lang-trigger:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(92,58,26,0.35); }

.lang-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 140px;
  background: linear-gradient(165deg, var(--cream), var(--cream-dim));
  border: 2px solid var(--wood);
  border-radius: var(--radius-s);
  box-shadow: 0 10px 24px rgba(92,58,26,0.35);
  overflow: hidden;
  z-index: 9999;
}
.lang-option {
  padding: 8px 10px;
  font-size: 8px;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: 0.15s ease;
  border-bottom: 1px solid rgba(139,90,43,0.15);
}
.lang-option:last-child { border-bottom: none; }
#lang-current { font-family: var(--font-head); letter-spacing: 0.3px; }
.lang-option:hover { background: rgba(245,197,66,0.25); color: var(--gold-dim); }
.lang-option.active { color: var(--green); font-weight: 800; }
.lang-name { font-size: 7px; opacity: 0.6; white-space: nowrap; }
.lang-option:hover .lang-name { opacity: 0.9; }
.lang-option.active .lang-name { opacity: 1; color: var(--green); }

/* -------- CONTENT -------- */
.content {
  margin-top: 50px;
  position: relative;
  z-index: 2;
  flex: 1;
  padding: 15px;
  background: url(images/bg_pvp.jpg);
  background-size: cover;
  padding-bottom: 78px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  color: var(--ink);
}
.content::-webkit-scrollbar { display: none; }

/* -------- FOOTER NAV -------- */
.nav {
  max-width: 480px;
  left: 50%;
  transform: translateX(-50%);
  position: fixed;
  bottom: 0;
  width: 100%;
  width: 100vw;
  height: 78px;
  display: flex;
  align-items: center;
  padding-bottom: env(safe-area-inset-bottom);
  background: linear-gradient(180deg, var(--wood-light) 0%, var(--wood) 55%, var(--wood-dark) 100%);
  border-top: 3px solid var(--gold-dim);
  box-shadow: 0 -8px 20px rgba(0,0,0,0.3);
  z-index: 100;
}
.nav::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 18px;
  right: 18px;
  height: 1px;
  background: rgba(255,255,255,0.25);
}
.nav button {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 4px;
  background: none;
  border: none;
  color: rgba(255,246,226,0.75);
  cursor: pointer;
  transition: 0.15s ease;
}

/* soquete circular creme atrás de cada ícone — "moeda" entalhada na madeira */
.nav button::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 50%;
  width: 45px;
  height: 45px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255,255,255,0.18), rgba(0,0,0,0.15) 75%);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.35), inset 0 -1px 0 rgba(255,255,255,0.08);
  transform: translateX(-50%);
  transition: 0.15s ease;
  z-index: 0;
}
.nav button:hover::before, .nav button:active::before {
  background: radial-gradient(circle at 35% 30%, rgba(255,255,255,0.3), rgba(0,0,0,0.1) 75%);
}

.nav button img {
  position: relative;
  z-index: 1;
  height: 36px;
  object-fit: contain;
  transition: 0.15s ease;
  filter: brightness(0.95) saturate(0.85);
}
.nav button span {
  position: relative;
  z-index: 1;
  font-family: var(--font-head);
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  line-height: 1;
  margin-top: 2px;
}
.nav button:hover img, .nav button:active img {
  transform: translateY(-2px) scale(1.1);
  filter: brightness(1.1) saturate(1.15);
}
.nav button:hover span { color: var(--white); }

.nav button.active span {
  color: var(--gold-bright);
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}
.nav button.active img {
  filter: brightness(1.15) saturate(1.2) drop-shadow(0 0 6px rgba(255,224,102,0.7));
  transform: translateY(-3px) scale(1.12);
}
.nav button.active::before {
  background: radial-gradient(circle at 35% 30%, rgba(255,224,102,0.35), rgba(0,0,0,0.1) 75%);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.3), inset 0 -1px 0 rgba(255,255,255,0.1), 0 0 12px rgba(245,197,66,0.5);
}
.nav button.active::after {
  content: "";
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 3px;
  border-radius: 3px;
}

/* -------- BOTÃO CENTRAL (HOME) — moeda dourada elevada -------- */
.nav button.nav-btn-main {
  flex: 0 0 78px;
  transform: translateY(-20px);
  z-index: 6;
}
.nav button.nav-btn-main img {
  height: 36px;
  width: 36px;
  filter: brightness(1.05) saturate(1.1) !important;
  z-index: 2;
}
.nav button.nav-btn-main span {
  margin-top: 3px;
  font-size: 7px;
  z-index: 2;
}
/* moeda dourada com bisel e brilho — substitui por completo o soquete
   circular dos botões normais (mesma especificidade, ganha por vir
   depois no ficheiro) */
.nav button.nav-btn-main::before {
  content: "";
  position: absolute;
  top: -10px;
  left: 50%;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 26%, rgba(255,255,255,0.8), transparent 30%),
    radial-gradient(circle at 40% 35%, var(--gold-bright), var(--gold) 60%, var(--gold-dim));
  box-shadow:
    inset 0 3px 4px rgba(255,255,255,0.5),
    inset 0 -5px 8px rgba(139,90,43,0.4),
    0 0 0 4px var(--cream),
    0 0 0 7px var(--wood),
    0 10px 12px -4px rgba(0,0,0,0.4);
  transform: translateX(-50%);
  transition: 0.15s ease;
}
.nav button.nav-btn-main:hover::before,
.nav button.nav-btn-main:active::before {
  transform: translateX(-50%) scale(1.07);
}
.nav button.nav-btn-main.active::before {
  box-shadow:
    inset 0 3px 4px rgba(255,255,255,0.55),
    inset 0 -5px 8px rgba(139,90,43,0.35),
    0 0 0 4px var(--cream),
    0 0 0 7px var(--gold-bright),
    0 10px 12px -4px rgba(0,0,0,0.4),
    0 0 26px rgba(255,224,102,0.75);
}
.nav button.nav-btn-main::after { content: none; }
.nav button.nav-btn-main span { color: var(--gold-bright); }
.nav button.nav-btn-main:hover span,
.nav button.nav-btn-main.active span { color: var(--gold-bright); text-shadow: 0 1px 3px rgba(0,0,0,0.5); }

.hidden { display: none !important; }

/* =========================
   POPUP
========================= */
.popup {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 200;
  background: rgba(74, 47, 24, 0.55);
  backdrop-filter: blur(3px);
}
.popup-box {
  position: relative;
  width: min(420px, 90%);
  padding: 26px 20px 20px;
  background: linear-gradient(165deg, var(--cream), var(--cream-dim) 85%);
  border: 3px solid var(--wood);
  border-radius: var(--radius-m);
  box-shadow:
    0 16px 0 -6px rgba(92,58,26,0.25),
    0 20px 40px rgba(74,47,24,0.4),
    inset 0 1px 0 rgba(255,255,255,0.6);
  text-align: center;
  overflow: hidden;
}
.popup-box::before {
  content: "";
  position: absolute;
  top: 0; left: 16px; right: 16px;
  height: 2px;
  background: var(--gold-line);
}
.popup-text {
  font-family: var(--font-head);
  line-height: 22px;
  margin-bottom: 18px;
  color: var(--ink);
  letter-spacing: 0.1px;
}
.popup-text img { height: 14px; vertical-align: middle; margin-left: 2px; }
.popup-actions { display: flex; gap: 10px; }
.popup-close-btn {
  position: sticky;
  top: 0;
  float: right;
  background: var(--cream-dim);
  border: 2px solid var(--wood);
  border-radius: 50%;
  color: var(--ink);
  font-size: 12px;
  cursor: pointer;
  width: 26px;
  height: 26px;
  padding: 0;
  margin: 0;
  line-height: 1;
  z-index: 10;
}
.popup-close-btn:hover { background: var(--red-bright); color: var(--white); border-color: var(--red-dark); }

/* =========================
   BTN — placa de madeira com bisel 3D
========================= */
.btn {
  font-family: var(--font-head);
  line-height: 12px;
  font-size: 11px;
  width: 100%;
  padding: 13px;
  margin: 6px 0 10px;
  background: linear-gradient(180deg, var(--cream), var(--cream-dim));
  color: var(--ink);
  border: 2px solid var(--wood);
  border-radius: var(--radius-s);
  box-shadow: 0 4px 0 var(--wood-dark), 0 6px 10px rgba(0,0,0,0.25);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  cursor: pointer;
  position: relative;
  transition: 0.1s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--wood-dark), 0 2px 4px rgba(0,0,0,0.25);
}

/* primary call-to-action / confirm — moeda de ouro */
.btn-glow {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: #5c3a1a;
  border: 2px solid var(--gold-dim);
  box-shadow: 0 4px 0 var(--gold-dim), 0 6px 14px rgba(184,134,11,0.4);
}
.btn-glow:hover { filter: brightness(1.05); }
.btn-glow:active { box-shadow: 0 1px 0 var(--gold-dim), 0 2px 4px rgba(184,134,11,0.4); }

/* danger / war action */
.btn-war {
  background: linear-gradient(180deg, var(--red-bright), var(--red));
  color: #fff6f0;
  border: 2px solid var(--red-dark);
  box-shadow: 0 4px 0 var(--red-dark), 0 6px 14px rgba(198,47,40,0.4);
}
.btn-war:active { box-shadow: 0 1px 0 var(--red-dark), 0 2px 4px rgba(198,47,40,0.4); }

.btn-notallowed {
  cursor: not-allowed;
  background: linear-gradient(180deg, #e4dccb, #d4c9b0);
  color: var(--ink-dim);
  border: 2px solid #c3b393;
  box-shadow: 0 4px 0 #b3a17c;
  filter: saturate(0.5);
}
.btn-notallowed:hover, .btn-notallowed:active { transform: none !important; }

/* =========================
   PVP — RADAR DE ATAQUE
========================= */
.pvp-radar {
  position: relative;
  width: 220px;
  height: 220px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pvp-radar-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid var(--wood);
  background: rgba(255,255,255,0.35);
}
.pvp-radar-ring-2 { inset: 26px; border-color: rgba(139,90,43,0.35); background: transparent; }
.pvp-radar-core {
  position: relative;
  z-index: 2;
  font-size: 42px;
  filter: drop-shadow(0 2px 4px rgba(92,58,26,0.4));
}
.pvp-radar-sweep {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 0deg, rgba(245,197,66,0.5), transparent 35%);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.pvp-radar.scanning .pvp-radar-sweep {
  opacity: 1;
  animation: pvpSweep 1.1s linear infinite;
}
.pvp-radar.scanning .pvp-radar-ring   { animation: pvpPulse 1.6s ease-out infinite; }
.pvp-radar.scanning .pvp-radar-ring-2 { animation: pvpPulse 1.6s ease-out infinite 0.4s; }
.pvp-radar.scanning .pvp-radar-core   { animation: pvpCorePulse 1.1s ease-in-out infinite; }

@keyframes pvpSweep {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
@keyframes pvpPulse {
  0%   { box-shadow: 0 0 0 0 rgba(245,197,66,0.4); }
  100% { box-shadow: 0 0 0 18px rgba(245,197,66,0); }
}
@keyframes pvpCorePulse {
  0%, 100% { transform: scale(1);    opacity: 1;   }
  50%      { transform: scale(1.12); opacity: 0.8; }
}

.panel-main { padding:20px; overflow-y: scroll; padding-bottom: 130px; height: 100vh; }