/* bastion.css — Bastion : thème « la dernière veille ».
   Palette : nuit d'encre (#0a1020), or de garnison (#ffc95e), braise (#ff7a45),
   givre (#6fd3ff). Typo Georgia, identité commune du portail. */

:root {
  --bg-deep: #0a1020;
  --bg-mid: #101a30;
  --panel: #141f38;
  --panel-2: #1a2745;
  --border: #2b3a5e;
  --border-gold: #8a712f;
  --gold: #ffc95e;
  --ember: #ff7a45;
  --blood: #e04545;
  --frost: #6fd3ff;
  --arcane: #b98cff;
  --leaf: #7fdb93;
  --text: #e8ecf7;
  --text-dim: #93a0bd;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.55);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: Georgia, 'Palatino Linotype', 'Times New Roman', serif;
  color: var(--text);
  background:
    radial-gradient(ellipse 80% 40% at 50% -8%, rgba(111, 211, 255, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse 90% 45% at 50% 115%, rgba(255, 122, 69, 0.12) 0%, transparent 60%),
    linear-gradient(180deg, var(--bg-mid) 0%, var(--bg-deep) 100%);
  background-attachment: fixed;
  min-height: 100vh;
}

button { font-family: inherit; }
input {
  font-family: inherit;
  background: #0c1426;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  font-size: 1rem;
}
input:focus { outline: 2px solid var(--border-gold); outline-offset: 1px; }

.hidden { display: none !important; }

.screen { display: none; min-height: 100vh; }
.screen.active { display: block; }

.panel {
  background: linear-gradient(180deg, var(--panel-2) 0%, var(--panel) 100%);
  border: 1px solid var(--border-gold);
  border-radius: 14px;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 201, 94, 0.12);
}

/* ── Boutons ────────────────────────────────────────────────────────────── */
.btn {
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: linear-gradient(180deg, #22314f, #182440);
  color: var(--text);
  font-size: 1rem;
  padding: 0.6rem 1.1rem;
  transition: transform 0.08s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.btn:hover:not(:disabled) { filter: brightness(1.18); box-shadow: 0 0 14px rgba(255, 201, 94, 0.22); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(180deg, #ffd97a, #cf9b2e);
  color: #241a03;
  font-weight: bold;
  border-color: #ffe4a3;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.25);
}
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-dim); }
.btn-icon { padding: 0.42rem 0.58rem; font-size: 1.05rem; line-height: 1; }

/* ── Accueil ────────────────────────────────────────────────────────────── */
.home-inner {
  max-width: 580px;
  margin: 0 auto;
  padding: 3rem 1.2rem 2rem;
  text-align: center;
}

.home-crest {
  font-size: 4.6rem;
  filter: drop-shadow(0 0 26px rgba(255, 201, 94, 0.5));
  animation: crest-breathe 3.8s ease-in-out infinite;
}
@keyframes crest-breathe {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 18px rgba(255, 201, 94, 0.4)); }
  50% { transform: scale(1.06); filter: drop-shadow(0 0 32px rgba(255, 140, 70, 0.6)); }
}

.game-title {
  font-size: clamp(2.6rem, 7vw, 3.8rem);
  letter-spacing: 0.12em;
  margin-top: 0.4rem;
  background: linear-gradient(180deg, #ffe9b0 20%, #d9a13c 75%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 2px 24px rgba(255, 180, 60, 0.18);
}

.tagline { color: var(--text-dim); font-style: italic; margin: 0.4rem 0 1.6rem; }

.home-box {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: 1.4rem;
  margin: 0 auto 1.4rem;
  max-width: 420px;
}
.field { display: flex; flex-direction: column; gap: 0.35rem; text-align: left; }
.field span { color: var(--text-dim); font-size: 0.92rem; }
.join-row { display: flex; gap: 0.6rem; }
.join-row input { width: 7.5rem; text-transform: uppercase; text-align: center; letter-spacing: 0.3em; }
.join-row .btn { flex: 1; }

.lore { color: var(--text-dim); max-width: 470px; margin: 0 auto; line-height: 1.55; font-size: 0.98rem; }
.lore strong { color: var(--ember); }
.home-footer { margin-top: 1.6rem; color: var(--text-dim); font-size: 0.9rem; }
.hub-link { color: var(--gold); text-decoration: none; }
.hub-link:hover { text-decoration: underline; }

/* ── Salon ──────────────────────────────────────────────────────────────── */
.lobby-inner { max-width: 860px; margin: 0 auto; padding: 2.2rem 1.2rem 3rem; text-align: center; }
.lobby-title { font-size: 1.9rem; color: var(--gold); }
.lobby-hint { color: var(--text-dim); margin: 0.5rem 0; }
.lobby-code {
  font-size: 2.6rem;
  letter-spacing: 0.5em;
  padding: 0.4rem 0 0.4rem 0.5em;
  color: var(--frost);
  text-shadow: 0 0 18px rgba(111, 211, 255, 0.45);
  user-select: all;
}

.lobby-players { list-style: none; max-width: 560px; margin: 0.8rem auto 1.4rem; text-align: left; }
.lobby-players li {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 0.4rem;
  background: rgba(20, 31, 56, 0.6);
}
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: none; box-shadow: 0 0 6px currentColor; }
.pname { font-weight: bold; }
.host-badge { font-size: 0.8rem; color: var(--gold); }
.prole { margin-left: auto; color: var(--text-dim); font-size: 0.92rem; }
.off { color: var(--blood); font-size: 0.85rem; }

.lobby-sub { margin: 1.4rem 0 0.7rem; color: var(--text); font-size: 1.15rem; }

.role-grid, .map-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.7rem;
}
.role-card, .map-card {
  text-align: left;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.08s;
}
.role-card:hover:not(:disabled), .map-card:hover:not(:disabled) {
  border-color: var(--border-gold);
  box-shadow: 0 0 16px rgba(255, 201, 94, 0.18);
  transform: translateY(-2px);
}
.role-card.mine, .map-card.sel {
  border-color: var(--gold);
  box-shadow: 0 0 18px rgba(255, 201, 94, 0.35), inset 0 0 22px rgba(255, 201, 94, 0.07);
}
.role-card.taken { opacity: 0.55; cursor: not-allowed; }
.role-card:disabled:not(.taken), .map-card:disabled { cursor: default; opacity: 0.85; }
.role-icon, .map-icon { font-size: 1.7rem; }
.role-name, .map-name { font-weight: bold; color: var(--gold); }
.role-desc, .map-desc { font-size: 0.86rem; color: var(--text-dim); line-height: 1.35; }
.role-active { font-size: 0.82rem; color: var(--frost); line-height: 1.35; }
.role-taken { font-size: 0.8rem; color: var(--blood); }
.map-meta { font-size: 0.8rem; color: var(--text-dim); font-style: italic; }

.diff-row { display: flex; gap: 0.6rem; justify-content: center; flex-wrap: wrap; }
.diff-btn.sel {
  border-color: var(--gold);
  color: var(--gold);
  box-shadow: 0 0 14px rgba(255, 201, 94, 0.3);
}

.lobby-buttons { display: flex; gap: 0.8rem; justify-content: center; margin-top: 1.6rem; }
.lobby-note { margin-top: 0.8rem; color: var(--text-dim); font-style: italic; min-height: 1.2em; }

/* ── Écran de jeu ───────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.45rem 0.9rem;
  background: rgba(10, 16, 32, 0.92);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-title { font-weight: bold; color: var(--gold); white-space: nowrap; }
.hud-chip {
  padding: 0.22rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(20, 31, 56, 0.8);
  font-size: 0.95rem;
  white-space: nowrap;
}
.hud-lives.low { color: #fff; background: rgba(190, 40, 40, 0.5); border-color: var(--blood); animation: lives-pulse 0.9s ease-in-out infinite; }
@keyframes lives-pulse { 50% { box-shadow: 0 0 14px rgba(224, 69, 69, 0.7); } }
.topbar-actions { margin-left: auto; display: flex; gap: 0.4rem; }

.game-wrap {
  display: flex;
  gap: 0.8rem;
  padding: 0.8rem;
  max-width: 1660px;
  margin: 0 auto;
  align-items: flex-start;
}
.stage { flex: 1 1 auto; min-width: 0; }

.board-wrap { position: relative; }
#board {
  display: block;
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  background: #0d1526;
}

/* barre de boss */
.boss-bar {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: min(520px, 70%);
  text-align: center;
  z-index: 5;
  pointer-events: none;
}
.boss-name {
  font-size: 0.95rem;
  color: #ffb0a0;
  text-shadow: 0 1px 3px #000;
  letter-spacing: 0.08em;
}
.boss-track {
  height: 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 120, 90, 0.6);
  background: rgba(0, 0, 0, 0.55);
  overflow: hidden;
  margin-top: 3px;
}
.boss-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ff4530, #ff9a45);
  box-shadow: 0 0 12px rgba(255, 80, 40, 0.8);
  transition: width 0.2s linear;
}

/* bannière de vague */
.wave-banner {
  position: absolute;
  top: 38%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(1.4rem, 3.6vw, 2.4rem);
  font-weight: bold;
  color: var(--gold);
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  opacity: 0;
  z-index: 6;
  white-space: nowrap;
}
.wave-banner.boss { color: #ff6a5a; letter-spacing: 0.06em; }
.wave-banner.clear { color: var(--leaf); }
.wave-banner.anim { animation: banner-pop 2.6s ease forwards; }
@keyframes banner-pop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.7); }
  12% { opacity: 1; transform: translate(-50%, -50%) scale(1.06); }
  22% { transform: translate(-50%, -50%) scale(1); }
  78% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -62%) scale(1); }
}

/* appel de vague + aperçu */
.call-box {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.7rem;
  background: rgba(10, 16, 32, 0.88);
  border: 1px solid var(--border-gold);
  border-radius: 12px;
  padding: 0.45rem 0.7rem;
  z-index: 5;
}
.call-count { color: var(--text); font-size: 0.95rem; white-space: nowrap; }
.btn-call {
  background: linear-gradient(180deg, #ff9a5e, #d05a20);
  border-color: #ffb98a;
  color: #2a0f02;
  font-weight: bold;
  white-space: nowrap;
}
.next-preview {
  position: absolute;
  top: 10px;
  right: 12px;
  background: rgba(10, 16, 32, 0.85);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.35rem 0.6rem;
  font-size: 0.92rem;
  z-index: 5;
  max-width: 46%;
}
.prev-chip { margin-left: 0.3rem; white-space: nowrap; cursor: help; }

.target-hint {
  position: absolute;
  top: 52px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(200, 80, 20, 0.9);
  color: #fff;
  border-radius: 10px;
  padding: 0.4rem 0.9rem;
  font-size: 0.95rem;
  z-index: 6;
  pointer-events: none;
  text-shadow: 0 1px 2px #000;
}

/* ── Barre latérale ─────────────────────────────────────────────────────── */
.sidebar {
  flex: 0 0 300px;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  max-height: calc(100vh - 76px);
}

.players-panel {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  background: rgba(20, 31, 56, 0.55);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.6rem;
}
.player-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.94rem;
}
.player-row.me { background: rgba(255, 201, 94, 0.07); border-radius: 8px; padding: 0.15rem 0.3rem; margin: -0.15rem -0.3rem; }
.pr-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 7.5em; }
.pr-gold { margin-left: auto; color: var(--gold); white-space: nowrap; font-variant-numeric: tabular-nums; }
.pr-power { font-size: 0.8rem; padding: 0.3rem 0.5rem; white-space: nowrap; }
.pr-power.mine-power:not(:disabled) {
  border-color: var(--ember);
  box-shadow: 0 0 10px rgba(255, 122, 69, 0.45);
  animation: power-ready 1.6s ease-in-out infinite;
}
@keyframes power-ready { 50% { box-shadow: 0 0 18px rgba(255, 122, 69, 0.75); } }
.pr-gift { font-size: 0.85rem; padding: 0.3rem 0.4rem; }

/* panneau contextuel */
.ctx-panel {
  background: rgba(20, 31, 56, 0.55);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
}
.ctx-empty { color: var(--text-dim); font-size: 0.92rem; text-align: center; padding: 0.6rem 0; }
.pad-dot {
  display: inline-block;
  width: 14px; height: 11px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #beb9af, #69645c);
  border: 1px solid #ebe6d7;
  vertical-align: middle;
}
.ctx-title { font-size: 1.05rem; color: var(--gold); display: flex; align-items: baseline; gap: 0.5rem; }
.ctx-lvl { font-size: 0.85rem; color: var(--text-dim); }
.ctx-owner { font-size: 0.85rem; }
.ctx-stats { font-size: 0.85rem; color: var(--text-dim); line-height: 1.5; }
.ctx-btn { width: 100%; }
.ctx-branch-label { font-size: 0.9rem; color: var(--frost); }
.ctx-row { display: flex; gap: 0.5rem; }
.ctx-mode { flex: 1; font-size: 0.85rem; padding: 0.4rem 0.4rem; }
.ctx-sell { font-size: 0.85rem; padding: 0.4rem 0.5rem; border-color: #6e3a2a; color: #ffb08a; }

.build-card {
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  color: var(--text);
  cursor: pointer;
  padding: 0.5rem 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.build-card:hover:not(:disabled) { border-color: var(--border-gold); box-shadow: 0 0 12px rgba(255, 201, 94, 0.2); }
.build-card:disabled { opacity: 0.55; cursor: not-allowed; }
.bc-head { display: flex; align-items: center; gap: 0.45rem; }
.bc-icon { font-size: 1.2rem; }
.bc-name { font-weight: bold; font-size: 0.95rem; }
.bc-cost { margin-left: auto; color: var(--gold); font-size: 0.9rem; white-space: nowrap; }
.bc-cost.poor { color: var(--blood); }
.bc-desc { font-size: 0.82rem; color: var(--text-dim); line-height: 1.35; }
.bc-stats { font-size: 0.78rem; color: var(--frost); line-height: 1.4; }
.branch-card { border-color: var(--border-gold); }

/* chat */
.chat-block { display: flex; flex-direction: column; gap: 0.4rem; min-height: 0; }
.chat-log {
  background: rgba(10, 16, 32, 0.6);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.5rem 0.6rem;
  height: 150px;
  overflow-y: auto;
  font-size: 0.88rem;
  line-height: 1.45;
}
.chat-msg.sys { color: var(--text-dim); font-style: italic; }
.chat-row { display: flex; gap: 0.4rem; }
.chat-row input { flex: 1; min-width: 0; font-size: 0.92rem; padding: 0.45rem 0.6rem; }

/* ── Overlays ───────────────────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 18, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 1rem;
}
.end-box, .help-box, .gift-box {
  max-width: 640px;
  width: 100%;
  padding: 1.6rem;
  text-align: center;
  max-height: 92vh;
  overflow-y: auto;
}
.end-crest { font-size: 4rem; filter: drop-shadow(0 0 22px rgba(255, 201, 94, 0.5)); }
.end-title { font-size: 2rem; color: var(--gold); margin: 0.4rem 0; }
.end-sub { color: var(--text-dim); margin-bottom: 1rem; }

.stats-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; margin: 0.6rem 0 1rem; }
.stats-table th, .stats-table td { padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--border); text-align: center; }
.stats-table td:first-child, .stats-table th:first-child { text-align: left; }
.stats-table th { color: var(--text-dim); font-weight: normal; font-size: 0.82rem; }

.help-title { color: var(--gold); margin-bottom: 0.8rem; }
.help-content { text-align: left; font-size: 0.94rem; line-height: 1.55; margin-bottom: 1rem; }
.help-content h3 { color: var(--frost); margin: 1rem 0 0.4rem; }
.help-content p { color: var(--text-dim); margin-bottom: 0.5rem; }
.help-item { margin-bottom: 0.5rem; color: var(--text-dim); }
.help-item strong { color: var(--text); }
.help-item small { color: var(--text-dim); }

.gift-to { color: var(--text-dim); margin: 0.6rem 0 1rem; }
.gift-row { display: flex; gap: 0.6rem; justify-content: center; margin-bottom: 0.8rem; }
.gift-row input { width: 8rem; text-align: center; font-size: 1.1rem; }

/* toasts */
.toasts {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 90;
  pointer-events: none;
  align-items: center;
}
.toast {
  background: rgba(20, 31, 56, 0.95);
  border: 1px solid var(--border-gold);
  border-radius: 10px;
  padding: 0.55rem 1rem;
  font-size: 0.95rem;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s, transform 0.3s;
  max-width: 82vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.err { border-color: var(--blood); color: #ffb9b0; }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 1080px) {
  .game-wrap { flex-direction: column; }
  .sidebar { flex: none; width: 100%; max-height: none; }
  .players-panel { flex-direction: row; flex-wrap: wrap; }
  .player-row { flex: 1 1 46%; }
  .chat-log { height: 110px; }
}
@media (max-width: 560px) {
  .topbar { flex-wrap: wrap; }
  .topbar-name { display: none; }
  .lobby-code { font-size: 2rem; }
  .next-preview { font-size: 0.8rem; }
  .call-box { flex-direction: column; gap: 0.3rem; padding: 0.4rem 0.6rem; }
}
