/* arcanes.css — L'Échiquier des Arcanes : plateau, HUD, écrans.
   Palette : indigo profond + or royal, bleu Auréal vs rouge Noctis, violet arcane. */

:root {
  --bg: #0d0b1e;
  --bg-panel: #171430;
  --bg-card: #1e1a3c;
  --border: #34305e;
  --text: #e8e6f5;
  --text-dim: #9b96c0;
  --gold: #e8c257;
  --gold-dark: #b28f2e;
  --arcane: #a97ff2;
  --blue: #4da3ff;
  --red: #ff5a6a;
  --success: #63d68b;
  --danger: #ff5a5a;
  --radius: 12px;
  --tile-light: #2a2650;
  --tile-dark: #211d43;
}

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

html, body { height: 100%; }

body {
  background:
    radial-gradient(ellipse 90% 60% at 50% -10%, #1c1740 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  line-height: 1.45;
}

button { font: inherit; cursor: pointer; color: inherit; background: none; border: none; }
input { font: inherit; }
.hidden { display: none !important; }

#app { min-height: 100vh; display: flex; flex-direction: column; }

.screen { display: none; flex: 1; flex-direction: column; }
.screen.active { display: flex; }

/* ── Boutons ── */
.btn {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
  padding: 0.6rem 1.2rem;
  font-weight: 700;
  transition: filter 0.15s ease, transform 0.08s ease, background 0.15s ease;
}
.btn:hover:not(:disabled) { filter: brightness(1.2); }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  border-color: var(--gold-dark);
  background: linear-gradient(180deg, var(--gold) 0%, var(--gold-dark) 100%);
  color: #241d05;
}
.btn-ghost { color: var(--text-dim); }
.btn-icon { padding: 0.4rem 0.6rem; font-size: 1.05rem; }

/* ═══════════════ ACCUEIL ═══════════════ */
.home-inner {
  max-width: 560px;
  margin: 0 auto;
  padding: 3.5rem 1.2rem 2rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.home-crest {
  font-size: 4.2rem;
  color: var(--gold);
  text-shadow: 0 0 34px rgba(169, 127, 242, 0.65);
  animation: crest-glow 2.6s ease-in-out infinite;
}
@keyframes crest-glow {
  0%, 100% { transform: translateY(0); text-shadow: 0 0 22px rgba(169, 127, 242, 0.4); }
  50% { transform: translateY(-6px); text-shadow: 0 0 40px rgba(169, 127, 242, 0.85); }
}

.game-title {
  font-size: clamp(1.9rem, 6vw, 2.8rem);
  background: linear-gradient(180deg, #f6e3a5 20%, var(--gold) 60%, var(--gold-dark) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: 0.02em;
}

.tagline { color: var(--text-dim); font-style: italic; }

.home-box {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.3rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.field { display: flex; flex-direction: column; gap: 0.3rem; text-align: left; font-size: 0.9rem; color: var(--text-dim); }
.field input, .join-row input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.55rem 0.8rem;
}
.field input:focus, .join-row input:focus { outline: 1px solid var(--gold-dark); }

.join-row { display: flex; gap: 0.6rem; }
.join-row input { flex: 1; text-transform: uppercase; letter-spacing: 0.35em; text-align: center; font-weight: 800; }

.lore { font-size: 0.9rem; color: var(--text-dim); }
.home-footer { font-size: 0.85rem; color: var(--text-dim); }
.hub-link { color: var(--text-dim); }
.hub-link:hover { color: var(--gold); }

/* ═══════════════ SALON ═══════════════ */
.lobby-inner {
  max-width: 460px;
  margin: 0 auto;
  padding: 4rem 1.2rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.lobby-title { color: var(--gold); }
.lobby-hint { color: var(--text-dim); }
.lobby-code {
  font-size: 3rem;
  font-weight: 900;
  letter-spacing: 0.45em;
  padding: 0.6rem 0 0.6rem 0.45em;
  background: var(--bg-panel);
  border: 1px dashed var(--gold-dark);
  border-radius: var(--radius);
  color: var(--gold);
}
.lobby-players { list-style: none; display: flex; flex-direction: column; gap: 0.4rem; }
.lobby-players li {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  display: flex;
  justify-content: space-between;
}
.lobby-players .p-status { color: var(--text-dim); font-size: 0.85rem; }
.lobby-buttons { display: flex; gap: 0.7rem; justify-content: center; flex-wrap: wrap; }
.lobby-note { font-size: 0.85rem; color: var(--text-dim); }

/* ═══════════════ JEU ═══════════════ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.55rem 1rem;
  background: rgba(13, 11, 30, 0.9);
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-weight: 800; color: var(--gold); font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.turn-info { color: var(--text-dim); font-size: 0.9rem; text-align: center; }
.topbar-actions { display: flex; gap: 0.35rem; }

.game-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 1rem;
  padding: 1rem;
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
  flex: 1;
}

.board-side { display: flex; flex-direction: column; align-items: center; gap: 0.6rem; }

.active-banner {
  font-weight: 800;
  padding: 0.35rem 1.2rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  font-size: 0.95rem;
}
.active-banner.mine { border-color: var(--gold-dark); color: var(--gold); box-shadow: 0 0 18px rgba(232, 194, 87, 0.25); }

/* ── Le Grand Plateau ── */
.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  width: min(92vw, 66vh, 560px);
  aspect-ratio: 1;
  border: 3px solid var(--gold-dark);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 12px 50px rgba(0, 0, 0, 0.55), 0 0 40px rgba(169, 127, 242, 0.12);
  position: relative;
  user-select: none;
}

.tile { position: relative; display: flex; align-items: center; justify-content: center; }
.tile.light { background: var(--tile-light); }
.tile.dark { background: var(--tile-dark); }

/* rangées de promotion : liseré doré discret */
.tile.promo::before {
  content: '';
  position: absolute; inset: 0;
  box-shadow: inset 0 0 10px rgba(232, 194, 87, 0.22);
  pointer-events: none;
}

.tile.obstacle { background: #12101f; }
.tile.obstacle::after {
  content: '🏛️';
  font-size: 1.4em;
  filter: grayscale(0.4) brightness(0.8);
}

/* dangers du Plateau */
.tile.warn { background: #4d3a14; animation: warn-pulse 1.2s ease-in-out infinite; }
.tile.warn::after { content: '⚠️'; position: absolute; font-size: 0.85em; opacity: 0.85; top: 2px; right: 3px; }
@keyframes warn-pulse { 0%, 100% { box-shadow: inset 0 0 0 rgba(255, 190, 60, 0); } 50% { box-shadow: inset 0 0 18px rgba(255, 190, 60, 0.55); } }

.tile.danger { background: #58151c; animation: danger-pulse 0.7s ease-in-out infinite; }
.tile.danger::after { content: '🔥'; position: absolute; font-size: 0.85em; top: 2px; right: 3px; }
@keyframes danger-pulse { 0%, 100% { box-shadow: inset 0 0 4px rgba(255, 70, 70, 0.4); } 50% { box-shadow: inset 0 0 22px rgba(255, 70, 70, 0.85); } }

/* pièges : les miens (violet) et ceux repérés par mon Fou (rouge) */
.tile.trap-mine::after, .tile.trap-spotted::after {
  content: '✦';
  position: absolute;
  font-size: 1em;
  color: var(--arcane);
  text-shadow: 0 0 8px var(--arcane);
  animation: trap-blink 1.6s ease-in-out infinite;
}
.tile.trap-spotted::after { color: var(--red); text-shadow: 0 0 8px var(--red); }
@keyframes trap-blink { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }

/* surbrillances d'action */
.tile.opt-move { cursor: pointer; }
.tile.opt-move::before {
  content: '';
  position: absolute; inset: 0;
  background: rgba(99, 214, 139, 0.16);
  box-shadow: inset 0 0 0 2px rgba(99, 214, 139, 0.55);
  pointer-events: none;
}
.tile.opt-attack { cursor: pointer; }
.tile.opt-attack::before {
  content: '';
  position: absolute; inset: 0;
  background: rgba(255, 90, 90, 0.18);
  box-shadow: inset 0 0 0 2px rgba(255, 90, 90, 0.75);
  pointer-events: none;
}
.tile.opt-cast { cursor: pointer; }
.tile.opt-cast::before {
  content: '';
  position: absolute; inset: 0;
  background: rgba(169, 127, 242, 0.2);
  box-shadow: inset 0 0 0 2px rgba(169, 127, 242, 0.8);
  pointer-events: none;
}
.tile.selected::before {
  content: '';
  position: absolute; inset: 0;
  box-shadow: inset 0 0 0 3px var(--gold);
  pointer-events: none;
  z-index: 2;
}

/* ── Unités ── */
.unit {
  position: relative;
  width: 84%;
  height: 84%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.55em;
  line-height: 1;
  cursor: pointer;
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.6));
  z-index: 1;
}
.unit.blue { color: var(--blue); }
.unit.red { color: var(--red); }
.unit.acted { opacity: 0.92; }

.unit .hpbar {
  position: absolute;
  bottom: -2%;
  left: 8%;
  right: 8%;
  height: 9%;
  background: rgba(0, 0, 0, 0.65);
  border-radius: 3px;
  overflow: hidden;
}
.unit .hpbar i {
  display: block;
  height: 100%;
  background: var(--success);
  transition: width 0.25s ease;
}
.unit .hpbar i.low { background: #ffb347; }
.unit .hpbar i.crit { background: var(--danger); }

.unit .fx-badge {
  position: absolute;
  top: -6%;
  right: -4%;
  font-size: 0.42em;
  filter: none;
}
.unit .cd-badge {
  position: absolute;
  top: -6%;
  left: -4%;
  font-size: 0.38em;
  background: rgba(0, 0, 0, 0.7);
  border-radius: 999px;
  padding: 0 0.35em;
  color: var(--arcane);
}

/* texte flottant */
.float {
  position: absolute;
  z-index: 30;
  font-weight: 900;
  font-size: 0.95rem;
  pointer-events: none;
  animation: float-up 1.1s ease-out forwards;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}
.float.dmg { color: #ff7a7a; }
.float.good { color: var(--success); }
.float.arcane { color: var(--arcane); }
.float.gold { color: var(--gold); }
@keyframes float-up {
  0% { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(-34px); opacity: 0; }
}

/* ── Panneau latéral ── */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  min-width: 0;
}

.unit-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  font-size: 0.9rem;
}
.unit-card.empty { color: var(--text-dim); font-size: 0.85rem; }
.uc-head { display: flex; align-items: center; gap: 0.6rem; }
.uc-symbol { font-size: 2rem; line-height: 1; filter: drop-shadow(0 2px 2px rgba(0,0,0,0.6)); }
.uc-symbol.blue { color: var(--blue); }
.uc-symbol.red { color: var(--red); }
.uc-names { display: flex; flex-direction: column; }
.uc-name { font-weight: 800; }
.uc-title { font-size: 0.78rem; color: var(--text-dim); font-style: italic; }

.uc-bars { display: flex; flex-direction: column; gap: 0.3rem; }
.uc-hp { height: 10px; background: rgba(0, 0, 0, 0.5); border-radius: 5px; overflow: hidden; }
.uc-hp i { display: block; height: 100%; background: var(--success); }
.uc-stats { display: flex; gap: 0.9rem; color: var(--text-dim); font-size: 0.85rem; flex-wrap: wrap; }
.uc-stats strong { color: var(--text); }

.uc-passive { font-size: 0.8rem; color: var(--arcane); }
.uc-atk { font-size: 0.82rem; color: var(--text-dim); }

.btn-ability {
  border-color: #7a58c8;
  background: rgba(169, 127, 242, 0.14);
  color: #cdb6ff;
  text-align: left;
  padding: 0.55rem 0.9rem;
  line-height: 1.3;
}
.btn-ability.armed { background: rgba(169, 127, 242, 0.38); box-shadow: 0 0 14px rgba(169, 127, 242, 0.4); }
.btn-ability small { display: block; color: var(--text-dim); font-weight: 400; font-size: 0.75rem; }

.btn-endturn { border-color: var(--gold-dark); color: var(--gold); }
.btn-endturn kbd {
  font-size: 0.72rem; background: rgba(0, 0, 0, 0.4); border-radius: 4px;
  padding: 0 0.35em; margin-left: 0.3em; border: 1px solid var(--border);
}

.log-title { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-dim); }
.log {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.8rem;
  font-size: 0.8rem;
  overflow-y: auto;
  flex: 1;
  min-height: 120px;
  max-height: 300px;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.log .t-blue { color: var(--blue); font-weight: 700; }
.log .t-red { color: var(--red); font-weight: 700; }
.log .l-sys { color: var(--text-dim); font-style: italic; }

/* ═══════════════ OVERLAYS ═══════════════ */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 6, 20, 0.82);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}

.end-box, .help-box {
  background: var(--bg-panel);
  border: 1px solid var(--gold-dark);
  border-radius: var(--radius);
  padding: 1.6rem;
  max-width: 520px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.6);
}
.end-crest { font-size: 3.4rem; animation: crest-glow 2.4s ease-in-out infinite; }
.end-title { color: var(--gold); }
.end-sub { color: var(--text-dim); }

.help-box { max-width: 680px; text-align: left; max-height: 88vh; }
.help-title { color: var(--gold); text-align: center; }
.help-content { overflow-y: auto; font-size: 0.86rem; display: flex; flex-direction: column; gap: 0.75rem; }
.help-content h3 { color: var(--gold); font-size: 0.95rem; margin-top: 0.4rem; }
.help-content p, .help-content li { color: var(--text-dim); }
.help-content ul { padding-left: 1.1rem; }
.help-unit {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
}
.help-unit .hu-head { display: flex; gap: 0.5rem; align-items: baseline; flex-wrap: wrap; }
.help-unit .hu-sym { font-size: 1.2rem; color: var(--gold); }
.help-unit .hu-name { font-weight: 800; color: var(--text); }
.help-unit .hu-title { font-size: 0.78rem; font-style: italic; color: var(--text-dim); }
.help-unit .hu-stats { font-size: 0.78rem; color: var(--text-dim); margin: 0.2rem 0; }
.help-unit .hu-ab { font-size: 0.8rem; color: #cdb6ff; }
.help-unit .hu-pass { font-size: 0.78rem; color: var(--arcane); }

/* ── Toasts ── */
.toasts {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  z-index: 200;
  align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.5rem 1rem;
  font-size: 0.88rem;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  animation: toast-in 0.25s ease;
}
.toast.err { border-color: var(--danger); color: #ffb3b3; }
.toast.gold { border-color: var(--gold-dark); color: var(--gold); }
@keyframes toast-in { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ═══════════════ Responsive ═══════════════ */
@media (max-width: 860px) {
  .game-wrap { grid-template-columns: 1fr; }
  .sidebar { order: 2; }
  .log { max-height: 180px; }
  .board { width: min(94vw, 60vh); }
}
