/* ===== El Mensajero del Rey — Estilos ===== */

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

:root {
  --bg: #171226;
  --bg-panel: #221b37;
  --bg-cell: #2c2447;
  --bg-cell-hover: #362c56;
  --text: #f2e9d6;
  --text-dim: #b8aecd;
  --gold: #d4a017;
  --terracotta: #b23a48;
  --border: #3a2f55;
  --aire: #8fd3c7;
  --agua: #4c8fc0;
  --tierra: #a9773f;
  --calor: #e07a45;
  --frio: #b7e0ec;
  --animal: #7fa65a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  min-height: 100%;
}

.hidden { display: none !important; }

h1, h2, h3 {
  font-family: 'Yeseva One', serif;
  font-weight: 400;
  margin: 0 0 8px;
}

.chevron-strip {
  height: 10px;
  background-image: linear-gradient(135deg, var(--gold) 25%, transparent 25%),
    linear-gradient(225deg, var(--gold) 25%, transparent 25%),
    linear-gradient(45deg, var(--gold) 25%, transparent 25%),
    linear-gradient(315deg, var(--gold) 25%, transparent 25%);
  background-position: 10px 0, 10px 0, 0 0, 0 0;
  background-size: 20px 20px;
  background-repeat: repeat-x;
  opacity: 0.85;
}

/* ---------- Setup screen ---------- */

#setup-screen {
  max-width: 640px;
  margin: 0 auto;
  padding: 40px 24px 60px;
}

.setup-header {
  text-align: center;
  margin-bottom: 28px;
}
.setup-header h1 { font-size: 2.2em; color: var(--gold); }
.setup-header .subtitle { color: var(--text-dim); font-style: italic; margin-top: 4px; }

.setup-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
}

.player-row {
  display: grid;
  grid-template-columns: 36px 1fr 180px 32px;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}
.p-num {
  font-family: 'JetBrains Mono', monospace;
  color: var(--gold);
  text-align: center;
}
.p-name, .p-token {
  background: var(--bg-cell);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 6px;
  font-family: 'Inter', sans-serif;
  font-size: 0.95em;
}
.p-remove {
  background: transparent;
  border: 1px solid var(--terracotta);
  color: var(--terracotta);
  border-radius: 6px;
  cursor: pointer;
  height: 32px;
}

.setup-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
}

button {
  cursor: pointer;
  font-family: 'Inter', sans-serif;
}
button:disabled { cursor: not-allowed; opacity: 0.5; }

.btn-secondary {
  background: transparent;
  border: 1px solid var(--gold);
  color: var(--gold);
  padding: 8px 16px;
  border-radius: 6px;
}
.btn-primary {
  background: var(--gold);
  border: none;
  color: #241a08;
  font-weight: 700;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 1.05em;
}

.setup-note {
  margin-top: 18px;
  color: var(--text-dim);
  font-size: 0.85em;
  line-height: 1.5;
}

/* ---------- Game screen ---------- */

#game-screen {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px;
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.game-header h1 { font-size: 1.5em; color: var(--gold); margin: 0; }

.game-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 18px;
}

@media (max-width: 860px) {
  .game-layout { grid-template-columns: 1fr; }
}

.board-wrap {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}

#board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(9, 1fr);
  gap: 4px;
  aspect-ratio: 1 / 1;
  width: 100%;
}

.cell {
  background: var(--bg-cell);
  border: 1px solid var(--border);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 0;
  font-size: 0.65em;
  overflow: hidden;
}

.cell-nat {
  background: color-mix(in srgb, var(--nat-color) 22%, var(--bg-cell));
  border-color: var(--nat-color);
}
.cell-trampa {
  background: color-mix(in srgb, var(--terracotta) 30%, var(--bg-cell));
  border-color: var(--terracotta);
}
.cell-inicio {
  background: color-mix(in srgb, var(--gold) 30%, var(--bg-cell));
  border-color: var(--gold);
}
.cell-emoji { font-size: 1.3em; line-height: 1; }
.cell-label { font-size: 0.75em; color: var(--text-dim); margin-top: 2px; }

.cell-tokens {
  position: absolute;
  bottom: 2px;
  left: 2px;
  right: 2px;
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  justify-content: center;
}
.token { font-size: 1em; filter: drop-shadow(0 1px 1px rgba(0,0,0,0.6)); }

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#ciclo-info {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  justify-content: space-between;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85em;
}
.ciclo-badge { color: var(--gold); font-weight: 600; }
.objetivo-badge { color: var(--text-dim); }

#controls-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}
#turn-banner { font-family: 'Yeseva One', serif; color: var(--gold); margin-bottom: 8px; font-size: 1.1em; }
.controls-row { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
#dice-result { font-family: 'JetBrains Mono', monospace; font-size: 1.4em; align-self: center; min-width: 50px; }

#players-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 420px;
  overflow-y: auto;
}

.player-card {
  background: var(--bg-cell);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  font-size: 0.85em;
}
.player-card.active { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.player-card.eliminado { opacity: 0.4; }
.pc-head { display: flex; align-items: center; gap: 6px; font-weight: 600; margin-bottom: 4px; }
.pc-tok { font-size: 1.2em; }
.pc-stats { display: flex; gap: 10px; font-family: 'JetBrains Mono', monospace; font-size: 0.9em; color: var(--text-dim); margin-bottom: 4px; }
.pc-nats { display: flex; gap: 4px; flex-wrap: wrap; min-height: 20px; }
.nat-chip { border-radius: 4px; padding: 1px 4px; font-size: 1em; }
.nat-favor { background: rgba(127, 166, 90, 0.35); }
.nat-contra { background: rgba(178, 58, 72, 0.35); }
.pc-none { color: var(--text-dim); font-size: 0.8em; font-style: italic; }
.pc-flag { margin-top: 4px; font-size: 0.8em; color: var(--gold); }
.pc-flag.pc-elim { color: var(--terracotta); }

#log-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  max-height: 220px;
  overflow-y: auto;
  font-size: 0.8em;
}
.log-line { padding: 3px 0; border-bottom: 1px dashed var(--border); color: var(--text-dim); }
.log-line:first-child { color: var(--text); }

/* ---------- Modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 7, 18, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal-box {
  background: var(--bg-panel);
  border: 1px solid var(--gold);
  border-radius: 12px;
  padding: 22px;
  max-width: 460px;
  width: 100%;
}
.modal-box h3 { color: var(--gold); margin-bottom: 10px; }
.modal-body p { margin: 0 0 10px; line-height: 1.5; }
.modal-body .muted { color: var(--text-dim); font-size: 0.85em; }
.modal-buttons { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.modal-btn {
  background: var(--bg-cell);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 8px;
  text-align: left;
}
.modal-btn:hover:not(:disabled) { background: var(--bg-cell-hover); border-color: var(--gold); }
