/* =============================================
   CivilEdu Imperium — CSS Épico v3.0
   Archivo: css/style.css
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;700&family=Nunito:wght@400;600;700;800&display=swap');

:root {
  --gold:      #FFD700;
  --gold2:     #b8860b;
  --gold-glow: rgba(255,215,0,.35);
  --bg:        #04060e;
  --bg-header: rgba(4,6,14,.97);
  --bg-panel:  rgba(8,12,22,.97);
  --border:    rgba(255,215,0,.15);
  --text:      #e6e6e6;
  --green:     #66BB6A;
  --red:       #ef5350;
  --blue:      #42A5F5;

  /* Terrenos */
  --agua:      #071e38;
  --agua-brd:  #0d3a6e;
  --agua-deep: #040f1e;
  --pradera:   #0d3010;
  --pradera-b: #1b6e20;
  --bosque:    #052010;
  --bosque-b:  #145214;
  --montaña:   #1e1208;
  --montaña-b: #5d3d28;
  --desierto:  #2a1e00;
  --desierto-b:#8a6200;
  --tundra:    #0e1420;
  --tundra-b:  #2e4060;

  --h-w: 52px;
  --h-h: 58px;
}

* { box-sizing: border-box; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Nunito', 'Segoe UI', sans-serif;
  margin: 0; padding: 0;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--gold2); border-radius: 3px; }

/* ── HEADER ── */
.header {
  background: var(--bg-header);
  backdrop-filter: blur(12px);
  padding: 0 1.2rem;
  height: 52px;
  display: flex;
  align-items: center;
  gap: .7rem;
  border-bottom: 1px solid var(--border);
  position: fixed;
  width: 100%;
  z-index: 1000;
  box-shadow: 0 2px 20px rgba(0,0,0,.6);
}

.header-logo {
  font-family: 'Cinzel', serif;
  font-weight: 700;
  color: var(--gold);
  font-size: 1rem;
  letter-spacing: 1px;
  text-shadow: 0 0 20px var(--gold-glow);
  white-space: nowrap;
  margin-right: .3rem;
}

.res-pill {
  display: flex;
  align-items: center;
  gap: .3rem;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 20px;
  padding: .18rem .65rem;
  font-size: .72rem;
  color: #ccc;
  white-space: nowrap;
  transition: all .2s;
}
.res-pill:hover { border-color: rgba(255,215,0,.3); background: rgba(255,215,0,.07); }
.res-pill b { color: var(--gold); font-size: .8rem; }
.res-pill .icon { font-size: .85rem; }

.turn-badge {
  margin-left: auto;
  background: rgba(255,215,0,.12);
  border: 1px solid rgba(255,215,0,.35);
  border-radius: 20px;
  padding: .2rem .9rem;
  font-size: .78rem;
  color: var(--gold);
  font-weight: 800;
  white-space: nowrap;
  font-family: 'Cinzel', serif;
}

/* ── SCORE BADGE ── */
#score-badge {
  position: fixed;
  top: 58px;
  left: 1rem;
  background: rgba(255,215,0,.1);
  border: 1px solid rgba(255,215,0,.25);
  border-radius: 20px;
  padding: .18rem .75rem;
  font-size: .72rem;
  color: var(--gold);
  font-weight: 700;
  z-index: 900;
}

/* ── VIEWPORT / MAPA ── */
#viewport {
  position: fixed;
  top: 52px;
  left: 0;
  right: 220px;
  bottom: 0;
  overflow: auto;
  cursor: grab;
  background: radial-gradient(ellipse at 50% 50%, #060c1a 0%, var(--bg) 100%);
  scroll-behavior: auto;
}
#viewport:active { cursor: grabbing; }

/* Grid de agua de fondo */
#viewport::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(21,101,192,.08) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(21,101,192,.06) 0%, transparent 40%);
  pointer-events: none;
  z-index: 0;
}

/* ── MAPA HEX ── */
.mapa {
  position: relative;
  margin: 20px;
  /* ancho = cols * h-w * 0.75 + margen */
}

/* ── HEXÁGONOS ── */
.h {
  position: absolute;
  width:  var(--h-w);
  height: var(--h-h);
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  transition: filter .18s ease, transform .18s ease, z-index 0s;
  cursor: pointer;
  z-index: 1;
}

.h:hover {
  filter: brightness(1.55) saturate(1.4);
  transform: scale(1.14) translateY(-4px);
  z-index: 500 !important;
}

/* TERRENOS */
.h.agua        { background: linear-gradient(160deg, var(--agua-deep) 0%, var(--agua) 100%); outline: 1px solid var(--agua-brd); outline-offset: -2px; }
.h.pradera     { background: linear-gradient(160deg, #0a2a0e 0%, var(--pradera) 100%); outline: 1px solid var(--pradera-b); outline-offset: -2px; }
.h.bosque      { background: linear-gradient(160deg, #030e06 0%, var(--bosque) 100%); outline: 1px solid var(--bosque-b); outline-offset: -2px; }
.h.montaña     { background: linear-gradient(160deg, #100a04 0%, var(--montaña) 100%); outline: 1px solid var(--montaña-b); outline-offset: -2px; }
.h.desierto    { background: linear-gradient(160deg, #1a1200 0%, var(--desierto) 100%); outline: 1px solid var(--desierto-b); outline-offset: -2px; }
.h.tundra      { background: linear-gradient(160deg, #080e16 0%, var(--tundra) 100%); outline: 1px solid var(--tundra-b); outline-offset: -2px; }

/* EMOJIS DE TERRENO */
.h::after {
  content: attr(data-icon);
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -44%);
  font-size: 1.3rem;
  pointer-events: none;
  opacity: .65;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,.6));
}

/* CIUDAD PROPIA */
.h.ciudad-propia {
  outline: 2.5px solid var(--gold) !important;
  outline-offset: -2px;
  box-shadow: 0 0 18px rgba(255,215,0,.45), inset 0 0 10px rgba(255,215,0,.08);
  z-index: 10;
}
.h.ciudad-propia::after { opacity: 1; font-size: 1.5rem; }

/* CIUDAD ENEMIGA */
.h.ciudad-enemiga {
  outline: 2px solid var(--red) !important;
  outline-offset: -2px;
  box-shadow: 0 0 14px rgba(239,83,80,.35);
  z-index: 10;
}

/* CIUDAD NEUTRAL */
.h.ciudad-neutral {
  outline: 2px solid var(--blue) !important;
  outline-offset: -2px;
  box-shadow: 0 0 12px rgba(66,165,245,.3);
  z-index: 10;
}

/* UNIDADES */
.h.unidad-propia  { filter: drop-shadow(0 0 6px var(--gold)); }
.h.unidad-enemiga { filter: drop-shadow(0 0 6px var(--red)); }

/* FOG OF WAR */
.h.fog {
  filter: brightness(.22) saturate(.3);
  pointer-events: none;
}

/* SELECCIONADO */
.h.selected {
  outline: 3px solid var(--gold) !important;
  outline-offset: -1px;
  filter: brightness(1.4);
  z-index: 20 !important;
  animation: pulse-sel .8s ease-in-out infinite alternate;
}
@keyframes pulse-sel {
  from { box-shadow: 0 0 12px rgba(255,215,0,.4); }
  to   { box-shadow: 0 0 28px rgba(255,215,0,.8); }
}

/* RESALTADO MOVIMIENTO */
.h.move-hint {
  outline: 2px dashed rgba(255,215,0,.5) !important;
  animation: dash-anim 1s linear infinite;
}
@keyframes dash-anim { to { outline-offset: -4px; } }

/* ── ETIQUETA CIUDAD ── */
.city-label {
  position: absolute;
  background: rgba(0,0,0,.75);
  border: 1px solid var(--gold);
  border-radius: 6px;
  padding: 1px 7px;
  font-size: 10px;
  font-weight: 700;
  color: var(--gold);
  white-space: nowrap;
  pointer-events: none;
  transform: translate(-50%, 0);
  z-index: 50;
  text-shadow: 0 0 8px rgba(255,215,0,.5);
}
.city-label.enemy { border-color: var(--red); color: var(--red); text-shadow: none; }

/* ── SIDEBAR ── */
#sidebar {
  position: fixed;
  top: 52px;
  right: 0;
  width: 220px;
  bottom: 0;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  padding: .75rem .7rem;
  display: flex;
  flex-direction: column;
  gap: .55rem;
  overflow-y: auto;
  z-index: 800;
}

.sb-title {
  font-size: .58rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(255,215,0,.4);
  margin-bottom: .3rem;
  padding-bottom: .25rem;
  border-bottom: 1px solid rgba(255,215,0,.08);
}

.civ-badge {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .4rem;
}
.civ-flag  { font-size: 1.5rem; }
.civ-name  { font-weight: 800; font-size: .85rem; color: var(--gold); line-height: 1.1; }
.civ-leader{ font-size: .62rem; color: rgba(255,255,255,.3); }

/* BOTONES DE ACCIÓN */
.action-btn {
  width: 100%;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 8px;
  padding: .48rem .65rem;
  color: #bbb;
  font-size: .75rem;
  cursor: pointer;
  margin-bottom: .25rem;
  text-align: left;
  transition: all .15s;
  display: flex;
  align-items: center;
  gap: .45rem;
  font-family: 'Nunito', inherit;
  position: relative;
  overflow: hidden;
}
.action-btn::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  border-radius: 3px 0 0 3px;
  background: var(--gold);
  opacity: 0;
  transition: opacity .15s;
}
.action-btn:hover {
  background: rgba(255,215,0,.09);
  border-color: rgba(255,215,0,.35);
  color: var(--gold);
  transform: translateX(2px);
}
.action-btn:hover::before { opacity: 1; }
.action-btn .ab-icon { font-size: .95rem; }

/* TECNOLOGÍAS */
.tech-row {
  font-size: .68rem;
  padding: .22rem .3rem;
  border-bottom: 1px solid rgba(255,255,255,.04);
  color: rgba(255,255,255,.28);
  display: flex;
  align-items: center;
  gap: .3rem;
  transition: color .2s;
}
.tech-row.unlocked { color: var(--green); }
.tech-row.researching { color: var(--gold); animation: pulse-tech .8s ease-in-out infinite alternate; }
@keyframes pulse-tech { from { opacity:.6 } to { opacity:1 } }

/* EVENTOS */
.ev-box { max-height: 100px; overflow-y: auto; }
.ev-line {
  font-size: .67rem;
  padding: .22rem 0;
  border-bottom: 1px solid rgba(255,255,255,.04);
  color: rgba(255,255,255,.38);
  line-height: 1.4;
}
.ev-line .ev-gold { color: var(--gold); }
.ev-line .ev-red  { color: var(--red); }
.ev-line .ev-green{ color: var(--green); }

/* BOTÓN TERMINAR TURNO */
#endturn-btn {
  width: 100%;
  background: linear-gradient(135deg, var(--gold2), var(--gold));
  color: #04060e;
  border: none;
  border-radius: 10px;
  padding: .65rem;
  font-size: .88rem;
  font-weight: 800;
  cursor: pointer;
  font-family: 'Nunito', inherit;
  transition: all .2s;
  margin-top: auto;
  letter-spacing: .3px;
  box-shadow: 0 4px 16px rgba(255,215,0,.2);
}
#endturn-btn:hover {
  transform: scale(1.04);
  box-shadow: 0 6px 24px rgba(255,215,0,.4);
}

/* ── TOOLBAR ── */
#toolbar {
  position: fixed;
  top: 60px;
  left: 1rem;
  z-index: 900;
  display: flex;
  gap: .4rem;
}
.tool-btn {
  background: rgba(8,12,22,.9);
  color: #ccc;
  border: 1px solid var(--border);
  padding: .3rem .75rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: .72rem;
  transition: all .2s;
  font-family: 'Nunito', inherit;
  backdrop-filter: blur(4px);
}
.tool-btn:hover {
  background: rgba(255,215,0,.1);
  border-color: rgba(255,215,0,.4);
  color: var(--gold);
}

/* ── MINIMAP ── */
#minimap {
  position: fixed;
  bottom: .8rem;
  left: .8rem;
  width: 160px;
  height: 100px;
  background: rgba(4,6,14,.92);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  z-index: 900;
  box-shadow: 0 4px 16px rgba(0,0,0,.5);
}
#minimap canvas { width: 100%; height: 100%; }
#minimap-label {
  position: absolute;
  top: 3px; left: 5px;
  font-size: 8px;
  color: rgba(255,215,0,.4);
  letter-spacing: 1px;
  text-transform: uppercase;
  pointer-events: none;
}

/* ── TOOLTIP ── */
#tile-tooltip {
  position: fixed;
  background: rgba(6,10,22,.97);
  border: 1px solid rgba(255,215,0,.3);
  border-radius: 10px;
  padding: .5rem .85rem;
  font-size: .72rem;
  pointer-events: none;
  display: none;
  z-index: 1100;
  max-width: 200px;
  line-height: 1.7;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
#tile-tooltip b { color: var(--gold); }

/* ── OVERLAY ── */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.88);
  backdrop-filter: blur(5px);
  z-index: 1200;
}
.overlay.show { display: block; }

/* ── MODALES ── */
.modal {
  display: none;
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(.95);
  background: #080e1c;
  border: 2px solid var(--gold);
  border-radius: 18px;
  padding: 1.8rem;
  z-index: 1300;
  width: 90%;
  max-width: 500px;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 0 60px rgba(255,215,0,.18);
  animation: modalIn .25s ease-out forwards;
}
@keyframes modalIn {
  from { opacity:0; transform: translate(-50%,-50%) scale(.9); }
  to   { opacity:1; transform: translate(-50%,-50%) scale(1); }
}
.modal.show { display: block; }
.modal h3 { color: var(--gold); margin-bottom: 1rem; font-family: 'Cinzel', serif; font-size: 1rem; }

/* Pregunta */
.q-category { font-size: .62rem; letter-spacing: 2px; text-transform: uppercase; color: rgba(255,215,0,.55); margin-bottom: .55rem; }
#m-pregunta { font-size: .95rem; line-height: 1.6; margin-bottom: 1.1rem; color: var(--text); }
#m-opciones { display: flex; flex-direction: column; gap: .4rem; }

.opt {
  display: block;
  width: 100%;
  padding: .6rem .9rem;
  background: #060c18;
  color: #ccc;
  border: 2px solid #1e2d42;
  cursor: pointer;
  border-radius: 9px;
  font-size: .83rem;
  transition: all .15s;
  text-align: left;
  font-family: 'Nunito', inherit;
}
.opt:hover:not(:disabled) { border-color: var(--gold); background: #1a2744; color: var(--gold); }
.opt.correct  { border-color: var(--green)!important; background: #0d2010!important; color: #a5d6a7!important; }
.opt.incorrect{ border-color: var(--red)!important;   background: #1a0808!important; color: #ef9a9a!important; }

#m-feedback {
  display: none;
  margin-top: .85rem;
  padding: .65rem;
  border-radius: 8px;
  font-size: .78rem;
  line-height: 1.5;
}
#m-feedback.correct  { display:block; background:#0d2010; border:1px solid #2e7d32; color:#a5d6a7; }
#m-feedback.incorrect{ display:block; background:#1a0808; border:1px solid #b71c1c; color:#ef9a9a; }

#m-close {
  margin-top: .85rem;
  width: 100%;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px;
  padding: .55rem;
  color: #ccc;
  cursor: pointer;
  font-family: 'Nunito', inherit;
  font-size: .82rem;
  transition: all .15s;
}
#m-close:hover { background: rgba(255,215,0,.1); color: var(--gold); border-color: rgba(255,215,0,.3); }

/* Modal ciudad */
#modal-city h3, #modal-tech h3 { font-family: 'Cinzel', serif; }

.build-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin: .7rem 0; }
.build-card {
  background: #060c18;
  border: 1px solid #1e2d42;
  border-radius: 10px;
  padding: .65rem;
  cursor: pointer;
  transition: all .18s;
  text-align: center;
}
.build-card:hover { border-color: var(--gold); background: #1a2744; }
.build-icon { font-size: 1.4rem; margin-bottom: .25rem; }
.build-name { font-size: .75rem; font-weight: 700; color: var(--gold); }
.build-cost { font-size: .62rem; color: rgba(255,255,255,.3); margin-top: .15rem; }

.tech-item {
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.08);
  padding: .6rem .8rem;
  margin: .4rem 0;
  border-radius: 8px;
  transition: all .15s;
}
.tech-item:hover { border-color: rgba(255,215,0,.3); }
.tech-item strong { color: var(--gold); font-size: .82rem; }
.tech-item small  { color: rgba(255,255,255,.35); font-size: .7rem; display: block; margin: .2rem 0; }
.tech-item .opt   { margin-top: .5rem; }

/* ── ANIMACIONES DE TURNO ── */
@keyframes turnFlash {
  0%  { opacity:0; transform:translate(-50%,-50%) scale(.5); }
  40% { opacity:1; transform:translate(-50%,-50%) scale(1.1); }
  100%{ opacity:0; transform:translate(-50%,-50%) scale(1.3); }
}
#turn-flash {
  display: none;
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  font-family: 'Cinzel', serif;
  font-size: 3rem;
  font-weight: 700;
  color: var(--gold);
  text-shadow: 0 0 40px var(--gold);
  z-index: 2000;
  pointer-events: none;
  white-space: nowrap;
}
#turn-flash.show {
  display: block;
  animation: turnFlash 1.3s ease-out forwards;
}

/* ── PROGRESS BARS RECURSOS ── */
.res-progress {
  width: 100%;
  height: 3px;
  background: rgba(255,255,255,.08);
  border-radius: 2px;
  margin-top: .2rem;
  overflow: hidden;
}
.res-progress-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--gold);
  transition: width .5s ease;
}

/* ── BATTLE EFFECTS ── */
@keyframes battlePop {
  0%  { transform:translate(-50%,-50%) scale(0); opacity:1; }
  100%{ transform:translate(-50%,-50%) scale(3); opacity:0; }
}
.battle-fx {
  position: absolute;
  width: 60px; height: 60px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,100,50,.9) 0%, transparent 70%);
  pointer-events: none;
  z-index: 100;
  animation: battlePop .5s ease-out forwards;
}

/* ── RESPONSIVE ── */
@media (max-width: 700px) {
  #sidebar { display: none; }
  #viewport { right: 0; }
  :root { --h-w: 38px; --h-h: 42px; }
}
</style>