@import url('https://fonts.googleapis.com/css2?family=Oswald:wght@400;500;600;700&family=Inter:wght@400;500;600&display=swap');

:root {
  --ink: #0B0D14;
  --surface: #12151F;
  --surface-2: #191D2B;
  --border: #262B3D;
  --text: #E7E8EE;
  --text-muted: #8A8FA3;
  --gold: #F2B705;       /* XP / energía */
  --ember: #E4573D;      /* fuerza / daño / alertas */
  --steel: #3E7CB1;      /* defensa / info */
  --moss: #4E9A63;       /* aprobado / éxito */
  --radius: 4px;
  --notch: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--ink);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

h1, h2, h3, .display {
  font-family: 'Oswald', sans-serif;
  font-weight: 600;
  letter-spacing: 0.01em;
  margin: 0;
}

a { color: var(--gold); text-decoration: none; }

/* Fondo con textura sutil tipo campo de batalla */
body {
  background-image:
    radial-gradient(circle at 15% 0%, rgba(62, 124, 177, 0.10), transparent 45%),
    radial-gradient(circle at 100% 20%, rgba(242, 183, 5, 0.07), transparent 40%);
  background-attachment: fixed;
}

.shell {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px 80px;
}

/* Panel con esquina cortada — el elemento HUD recurrente del sistema */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  clip-path: polygon(0 0, calc(100% - var(--notch)) 0, 100% var(--notch), 100% 100%, var(--notch) 100%, 0 calc(100% - var(--notch)));
  padding: 20px;
}

.panel + .panel { margin-top: 16px; }

.panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
}

.panel-header h2 { font-size: 1.05rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }

/* Barras de progreso (XP, pasos, vida...) */
.bar {
  height: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--gold), #F7D060);
  transition: width 0.4s ease;
}
.bar.ember > span { background: linear-gradient(90deg, var(--ember), #F17A5F); }
.bar.steel > span { background: linear-gradient(90deg, var(--steel), #6AA7D6); }

.bar-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.bar-row .label { width: 96px; font-size: 0.82rem; color: var(--text-muted); }
.bar-row .value { width: 56px; text-align: right; font-variant-numeric: tabular-nums; font-size: 0.85rem; }

/* Estadísticas del guerrero en grid */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.stat {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 10px 12px;
}
.stat .n { font-family: 'Oswald', sans-serif; font-size: 1.6rem; }
.stat .l { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }

/* Botones */
.btn {
  font-family: 'Oswald', sans-serif;
  font-size: 0.92rem;
  letter-spacing: 0.03em;
  border: 1px solid var(--gold);
  background: transparent;
  color: var(--gold);
  padding: 10px 18px;
  cursor: pointer;
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
  transition: background 0.15s ease, color 0.15s ease;
}
.btn:hover { background: var(--gold); color: #17140A; }
.btn.primary { background: var(--gold); color: #17140A; }
.btn.primary:hover { background: #F7D060; }
.btn.ghost { border-color: var(--border); color: var(--text-muted); }
.btn.danger { border-color: var(--ember); color: var(--ember); }
.btn.danger:hover { background: var(--ember); color: #1a0d0a; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:disabled:hover { background: transparent; color: var(--gold); }

/* Formularios */
label { display: block; font-size: 0.82rem; color: var(--text-muted); margin: 12px 0 5px; }
input, textarea, select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  border-radius: var(--radius);
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--steel); outline-offset: 1px; }

/* Estados/badges */
.badge { display: inline-block; padding: 3px 9px; font-size: 0.75rem; border-radius: 2px; font-family: 'Oswald', sans-serif; letter-spacing: 0.03em; }
.badge.pending { background: rgba(242,183,5,0.15); color: var(--gold); }
.badge.approved { background: rgba(78,154,99,0.18); color: var(--moss); }
.badge.rejected { background: rgba(228,87,61,0.18); color: var(--ember); }

/* Ranking */
.rank-row { display: grid; grid-template-columns: 32px 1fr auto; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--border); }
.rank-row:last-child { border-bottom: none; }
.rank-row .pos { font-family: 'Oswald', sans-serif; color: var(--text-muted); }
.rank-row.me { background: rgba(242,183,5,0.06); }

/* Tablas del admin */
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 500; text-transform: uppercase; font-size: 0.72rem; letter-spacing: 0.06em; }

.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }
.topbar .brand { font-family: 'Oswald', sans-serif; font-size: 1.15rem; }
.topbar .brand span { color: var(--gold); }

.msg { padding: 10px 12px; border-left: 3px solid var(--steel); background: var(--surface-2); font-size: 0.88rem; margin-bottom: 14px; }
.msg.error { border-color: var(--ember); color: #F5B7AA; }
.msg.ok { border-color: var(--moss); color: #A9D6B4; }

.muted { color: var(--text-muted); font-size: 0.85rem; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 18px; }
.tabs button { flex: none; }
.hidden { display: none !important; }

/* Título de nivel: cuanto más alto, más llamativo (como un rango
   competitivo). El color en sí se fija por JS según el nivel. */
.level-badge { font-family: 'Oswald', sans-serif; transition: color 0.3s ease; }
.level-tier-mid { font-weight: 700; letter-spacing: 0.03em; }
.level-tier-high { font-weight: 700; letter-spacing: 0.05em; text-shadow: 0 0 8px currentColor; }
.level-tier-max {
  font-weight: 700;
  letter-spacing: 0.06em;
  text-shadow: 0 0 10px currentColor;
  animation: legendaryPulse 2.2s ease-in-out infinite;
}
@keyframes legendaryPulse {
  0%, 100% { text-shadow: 0 0 6px currentColor; }
  50% { text-shadow: 0 0 18px currentColor, 0 0 6px currentColor; }
}

/* Tienda compacta: chips agrupados por tipo de habilidad */
.coins-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.coins-banner .label { font-size: 0.82rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.coins-banner .amount { font-family: 'Oswald', sans-serif; font-size: 1.7rem; color: var(--gold); }

.shop-group { margin-bottom: 18px; }
.shop-group:last-child { margin-bottom: 0; }
.shop-group h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 4px; }
.chip {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.82rem;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.chip:hover { border-color: var(--gold); }
.chip.selected { border-color: var(--gold); color: var(--gold); }
.chip.locked { opacity: 0.5; }
.chip.owned { border-color: var(--moss); }
.chip .chip-effect { color: var(--text-muted); font-size: 0.72rem; }
.chip.selected .chip-effect { color: inherit; }

.skill-detail {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 12px 14px;
  margin-top: 8px;
}

/* Tarjeta simple (sin el recorte de .panel) para listas dentro de un panel:
   varios retos del mismo periodo, o combates en el historial. */
.mini-panel {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 14px 16px;
}
.mini-panel + .mini-panel { margin-top: 10px; }

@media (max-width: 560px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .shell { padding: 16px 14px 60px; }
}

/* ---------- ARENA 3D (Fase 3: visor de combates en 3D) ---------- */

.arena3d-modal {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(5,6,10,0.82);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.arena3d-card {
  position: relative; width: 100%; max-width: 720px;
  background: linear-gradient(180deg, #1b2030 0%, #12151f 60%, #0d0f17 100%);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; max-height: 92vh; overflow-y: auto;
}
.arena3d-close {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  cursor: pointer; font-size: 0.85rem; line-height: 1;
}
.arena3d-close:hover { border-color: var(--gold); color: var(--gold); }

.arena3d-canvas-wrap { position: relative; width: 100%; aspect-ratio: 16 / 10; border-radius: var(--radius); overflow: hidden; }
.arena3d-canvas-wrap canvas { display: block; width: 100%; height: 100%; touch-action: none; }

.arena3d-hud { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; justify-content: space-between; gap: 12px; pointer-events: none; }
.arena3d-hp-block { flex: 1; max-width: 260px; }
.arena3d-hp-block.right { text-align: right; margin-left: auto; }
.arena3d-hp-name { font-family: 'Oswald', sans-serif; font-size: 0.8rem; letter-spacing: 0.03em; margin-bottom: 3px; text-shadow: 0 1px 3px rgba(0,0,0,0.6); }
.arena3d-hp-name b { color: var(--gold); }
.arena3d-hp-track { height: 9px; border-radius: 5px; background: rgba(10,11,17,0.75); border: 1px solid rgba(255,255,255,0.08); overflow: hidden; }
.arena3d-hp-fill { height: 100%; border-radius: 5px; transition: width 0.35s ease; }
.arena3d-hp-fill.a { background: linear-gradient(90deg, #2c5f88, var(--steel)); }
.arena3d-hp-fill.b { background: linear-gradient(90deg, var(--ember), #a83422); margin-left: auto; }
.arena3d-hp-fill.flash { filter: brightness(1.8); }
.arena3d-hp-num { font-size: 0.68rem; color: var(--text-muted); margin-top: 2px; }

.arena3d-round-banner {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-60%);
  font-family: 'Oswald', sans-serif; font-size: 1.2rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--gold); text-shadow: 0 2px 10px rgba(0,0,0,0.7); opacity: 0; pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.arena3d-round-banner.show { opacity: 1; transform: translate(-50%,-70%); }

.arena3d-winner-banner {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(11,13,20,0.55); opacity: 0; pointer-events: none; transition: opacity 0.35s ease;
}
.arena3d-winner-banner.show { opacity: 1; }
.arena3d-winner-banner .msg {
  font-family: 'Oswald', sans-serif; font-size: 1.2rem; text-align: center;
  background: var(--surface); border: 1px solid var(--gold); border-radius: var(--radius); padding: 12px 22px;
}

.arena3d-controls { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.arena3d-round-counter { font-size: 0.78rem; color: var(--text-muted); margin-left: auto; }
.arena3d-round-counter b { color: var(--text); font-family: 'Oswald', sans-serif; }

.arena3d-log { list-style: none; margin: 10px 0 0; padding: 0; max-height: 160px; overflow-y: auto; font-size: 0.8rem; border-top: 1px solid var(--border); }
.arena3d-log li { padding: 6px 0; border-bottom: 1px solid var(--border); display: flex; gap: 8px; align-items: baseline; }
.arena3d-log li:last-child { border-bottom: none; }
.arena3d-log .log-round { color: var(--text-muted); font-family: 'Oswald', sans-serif; min-width: 30px; }
.arena3d-log .log-side { font-weight: 600; }
.arena3d-log .log-side.a { color: var(--steel); }
.arena3d-log .log-side.b { color: var(--ember); }
.arena3d-log .log-dmg { margin-left: auto; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.arena3d-log .log-special { color: var(--gold); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; }

.arena3d-scene-toggle { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; font-size: 0.82rem; color: var(--text-muted); }

.switch { width: 38px; height: 20px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); position: relative; cursor: pointer; flex-shrink: 0; }
.switch > span { position: absolute; top: 1px; left: 1px; width: 16px; height: 16px; border-radius: 50%; background: var(--text-muted); transition: transform 0.15s ease, background 0.15s ease; }
.switch.on { border-color: var(--gold); }
.switch.on > span { transform: translateX(18px); background: var(--gold); }

/* ---------- CLAN (Fase 4) ---------- */
.clan-empty { text-align: center; padding: 10px 0 4px; }
.clan-empty-icon { font-size: 2.4rem; line-height: 1; margin-bottom: 8px; }
.clan-empty .muted { max-width: 420px; margin: 6px auto 0; }
.clan-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 16px; }
.clan-form .clan-actions { justify-content: flex-start; }

.clan-card-head { display: flex; align-items: center; gap: 14px; }
.clan-card-title h3 { font-size: 1.35rem; }
.clan-crest {
  width: 52px; height: 52px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 1.6rem;
  background: linear-gradient(180deg, rgba(242,183,5,0.28), rgba(242,183,5,0.08));
  clip-path: polygon(50% 0, 100% 18%, 100% 62%, 50% 100%, 0 62%, 0 18%);
}
.clan-crest.small { width: 38px; height: 38px; font-size: 1.1rem; }
.clan-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.clan-stats .n { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.clan-leader { font-size: 0.72rem; color: var(--gold); font-family: 'Oswald', sans-serif; letter-spacing: 0.03em; }

.clan-search { display: flex; gap: 8px; margin: 10px 0 12px; }
.clan-search input { flex: 1; min-width: 0; }
.clan-reco {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 10px 12px;
}
.clan-reco + .clan-reco { margin-top: 8px; }
.clan-reco-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.clan-reco-info .muted { font-size: 0.78rem; }

/* ---------- PASE DE BATALLA: línea de tiempo (Fase 4) ---------- */
.bp-summary { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.bp-xp { font-family: 'Oswald', sans-serif; font-size: 1.8rem; color: var(--gold); line-height: 1.1; font-variant-numeric: tabular-nums; }
.bp-xp span { font-size: 0.8rem; color: var(--text-muted); letter-spacing: 0.06em; text-transform: uppercase; }

.bp-scroll {
  overflow-x: auto; overflow-y: hidden;
  margin: 16px -4px 0; padding: 0 4px 6px;
  scroll-behavior: smooth;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.bp-track { position: relative; height: 192px; }
.bp-line, .bp-line-fill {
  position: absolute; left: 0; top: 126px; height: 6px; border-radius: 3px;
}
.bp-line { right: 0; background: var(--surface-2); border: 1px solid var(--border); }
.bp-line-fill {
  background: linear-gradient(90deg, #B98A00, var(--gold));
  box-shadow: 0 0 10px rgba(242,183,5,0.45);
  transition: width 0.5s ease;
}

.bp-tier {
  position: absolute; top: 8px; width: 116px; margin-left: -58px;
  height: calc(100% - 8px);
  display: flex; flex-direction: column; align-items: center;
  background: none; border: 0; padding: 0; cursor: pointer; color: var(--text);
  font: inherit;
}
.bp-tier:focus-visible { outline: 2px solid var(--steel); outline-offset: 2px; }

.bp-bubble {
  position: relative;
  height: 72px; width: 108px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 8px 8px; font-size: 0.78rem; line-height: 1.3;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.bp-bubble-text {
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden; overflow-wrap: anywhere;
}
.bp-bubble::after {
  content: ""; position: absolute; left: 50%; bottom: -7px;
  width: 12px; height: 12px; margin-left: -6px;
  background: inherit; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  transform: rotate(45deg);
}
.bp-node {
  margin-top: 30px;
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center; font-size: 1rem;
  background: var(--surface); border: 2px solid var(--border); color: var(--text-muted);
  position: relative; z-index: 1;
  transition: transform 0.15s ease;
}
.bp-label { margin-top: 8px; font-family: 'Oswald', sans-serif; font-size: 0.8rem; letter-spacing: 0.04em; color: var(--text-muted); }

.bp-tier.locked .bp-bubble { opacity: 0.6; }
.bp-tier.ready .bp-bubble { border-color: var(--gold); }
.bp-tier.ready .bp-bubble::after { border-color: var(--gold); }
.bp-tier.ready .bp-node { border-color: var(--gold); background: #2a2208; animation: bpPulse 1.8s ease-in-out infinite; }
.bp-tier.claimed .bp-node { border-color: var(--moss); background: var(--moss); color: #0d1a11; font-weight: 700; }
.bp-tier.claimed .bp-bubble { border-color: rgba(78,154,99,0.5); }
.bp-tier.claimed .bp-bubble::after { border-color: rgba(78,154,99,0.5); }

.bp-tier:hover .bp-bubble, .bp-tier.selected .bp-bubble { transform: translateY(-3px); }
.bp-tier.selected .bp-node { transform: scale(1.12); }
.bp-tier.selected .bp-label { color: var(--gold); }

@keyframes bpPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(242,183,5,0.55); }
  50% { box-shadow: 0 0 0 8px rgba(242,183,5,0); }
}
@media (prefers-reduced-motion: reduce) {
  .bp-tier.ready .bp-node { animation: none; }
  .bp-line-fill, .bp-bubble, .bp-node { transition: none; }
}

.bp-detail {
  margin-top: 12px; padding: 14px 16px;
  background: var(--surface-2); border: 1px solid var(--border); border-left: 3px solid var(--gold);
}
