:root {
  --bg: #0b1020;
  --panel: #151c33;
  --panel-2: #1c2544;
  --gold: #e8c36a;
  --gold-dim: #9a7b32;
  --text: #f3ead7;
  --muted: #9aa3c0;
  --feu: #ff5a2b;
  --eau: #3aa0ff;
  --terre: #7bc96f;
  --air: #c9d6e8;
  --foudre: #c9a6ff;
  --maudite: #c45c7a;
  --direct: #ffb347;
  --danger: #ff5d6c;
  --ok: #6ee7a8;
  --shadow: 0 12px 40px rgba(0,0,0,.45);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  background:
    radial-gradient(1200px 600px at 20% -10%, #2a1a4a 0%, transparent 50%),
    radial-gradient(900px 500px at 100% 0%, #1a3a4a 0%, transparent 45%),
    var(--bg);
  color: var(--text);
  min-height: 100%;
}

#app { min-height: 100%; }

.screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

h1 {
  font-size: clamp(2rem, 5vw, 3.4rem);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--gold);
  text-shadow: 0 0 24px rgba(232,195,106,.35);
  margin-bottom: .3em;
}
.subtitle { color: var(--muted); margin-bottom: 1.6rem; text-align: center; max-width: 640px; }

.panel {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid rgba(232,195,106,.25);
  border-radius: 16px;
  padding: 22px;
  box-shadow: var(--shadow);
  width: min(920px, 100%);
}

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.col { display: flex; flex-direction: column; gap: 8px; }

label { font-size: .9rem; color: var(--muted); }
input, select {
  background: #0e1428;
  border: 1px solid #3a456e;
  color: var(--text);
  padding: 8px 10px;
  border-radius: 8px;
  font: inherit;
}
button {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  background: linear-gradient(180deg, #d4b15a, #8b6a22);
  color: #1a1204;
  font-weight: 700;
  letter-spacing: .04em;
}
button:hover { filter: brightness(1.08); }
button.ghost {
  background: transparent;
  border: 1px solid var(--gold-dim);
  color: var(--gold);
}
button.danger { background: linear-gradient(180deg, #e36a6a, #8a2a2a); color: #fff; }
button:disabled { opacity: .45; cursor: not-allowed; filter: none; }

.rules {
  margin-top: 16px;
  color: var(--muted);
  font-size: .92rem;
  line-height: 1.45;
}
.rules strong { color: var(--gold); }
.cycle { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 14px; }
.chip {
  padding: 4px 10px;
  border-radius: 999px;
  background: #0e1428;
  border: 1px solid #3a456e;
  font-size: .85rem;
}

/* GAME LAYOUT */
.game {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 10px;
  gap: 8px;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.brand { color: var(--gold); letter-spacing: .12em; text-transform: uppercase; font-weight: 700; }
.status { color: var(--muted); }

.board {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 10px;
  min-height: 0;
}
@media (max-width: 900px) {
  .board { grid-template-columns: 1fr; }
}

.arena {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 8px;
}
.opponents {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
@media (max-width: 700px) {
  .opponents { grid-template-columns: 1fr; }
}

.player-card {
  background: #121933;
  border: 1px solid #31406a;
  border-radius: 14px;
  padding: 10px;
  position: relative;
}
.player-card.active {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold), 0 0 22px rgba(232,195,106,.25);
}
.player-card.targetable { outline: 2px dashed var(--ok); cursor: pointer; }
.player-card.locked { opacity: .7; }
.player-card.dead { opacity: .45; filter: grayscale(.6); }
.pname { font-weight: 700; }
.meta { font-size: .85rem; color: var(--muted); }
.hpbar {
  height: 8px;
  background: #0b1020;
  border-radius: 99px;
  overflow: hidden;
  margin: 6px 0;
}
.hpbar > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #6ee7a8, #e8c36a, #ff5d6c);
  width: 50%;
}

.center {
  min-height: 180px;
  background: radial-gradient(circle at 50% 40%, #24305a 0%, #121933 70%);
  border: 1px dashed #3a456e;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 12px;
  flex-wrap: wrap;
}
.vs { color: var(--gold); font-size: 1.4rem; letter-spacing: .2em; }

.hand-wrap {
  background: #121933;
  border: 1px solid #31406a;
  border-radius: 14px;
  padding: 10px;
}
.hand {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
}
.actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

.sidebar {
  background: #121933;
  border: 1px solid #31406a;
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  min-height: 280px;
}
.log {
  flex: 1;
  overflow-y: auto;
  font-size: .88rem;
  line-height: 1.4;
  color: #c9d0e8;
  max-height: 52vh;
}
.log p { margin: 0 0 8px; }
.log .sys { color: var(--gold); }
.log .dmg { color: var(--danger); }
.log .ok { color: var(--ok); }

/* CARD */
.card {
  width: 110px;
  height: 154px;
  border-radius: 10px;
  position: relative;
  flex: 0 0 auto;
  background: #1a140c;
  border: 2px solid #c9a35a;
  box-shadow: 0 8px 18px rgba(0,0,0,.4);
  user-select: none;
  overflow: hidden;
}
.card.small { width: 86px; height: 120px; }
.card.selected { outline: 3px solid #6ee7a8; transform: translateY(-6px); }
.card.clickable { cursor: pointer; }
.card.clickable:hover { transform: translateY(-4px); }

.card .corner {
  position: absolute;
  font-weight: 800;
  font-size: 13px;
  color: #f8e7b0;
  line-height: 1;
  z-index: 2;
}
.card .tl { top: 4px; left: 6px; }
.card .tr { top: 4px; right: 6px; }
.card .bl { bottom: 4px; left: 6px; }
.card .br { bottom: 4px; right: 6px; }

.card .rows {
  position: absolute;
  inset: 22px 10px 22px 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  align-items: center;
}
.card .symrow {
  display: flex;
  gap: 3px;
  font-size: 14px;
  letter-spacing: 1px;
}
.card.small .symrow { font-size: 11px; }
.card .banner {
  position: absolute;
  bottom: 18px;
  left: 0; right: 0;
  text-align: center;
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #f8e7b0;
}
.card.feu { background: linear-gradient(#3a1208, #1a0a06); border-color: var(--feu); }
.card.eau { background: linear-gradient(#08243a, #061018); border-color: var(--eau); }
.card.terre { background: linear-gradient(#163016, #0a160a); border-color: var(--terre); }
.card.air { background: linear-gradient(#2a3344, #12161e); border-color: var(--air); }
.card.foudre { background: linear-gradient(#2a1844, #12081c); border-color: var(--foudre); }
.card.maudite { background: linear-gradient(#3a1020, #14060c); border-color: var(--maudite); }
.card.direct { background: linear-gradient(#3a2a10, #161006); border-color: var(--direct); }
.card.soin { background: linear-gradient(#10301c, #06140c); border-color: var(--ok); }
.card.poison { background: linear-gradient(#1c3010, #0c1406); border-color: #a3d46a; }
.low-hp { animation: pulsehp 1.1s ease-in-out infinite; }
@keyframes pulsehp {
  0%, 100% { box-shadow: 0 0 0 1px #ff5d6c, 0 0 10px rgba(255,93,108,.25); }
  50% { box-shadow: 0 0 0 2px #ff8a96, 0 0 22px rgba(255,93,108,.5); }
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(5,8,16,.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 16px;
}
.modal {
  background: #151c33;
  border: 1px solid var(--gold-dim);
  border-radius: 16px;
  padding: 22px;
  width: min(520px, 100%);
  box-shadow: var(--shadow);
}
.modal h2 { color: var(--gold); margin-bottom: 10px; }
.hidden { display: none !important; }
.toast {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: #1c2544;
  border: 1px solid var(--gold-dim);
  padding: 10px 16px;
  border-radius: 10px;
  z-index: 30;
}
.stats-line { color: var(--gold); margin: 6px 0 14px; }
.code-big {
  font-size: 2rem;
  letter-spacing: .35em;
  color: var(--gold);
  text-align: center;
  padding: 8px 0 14px;
  font-family: ui-monospace, Consolas, monospace;
}
.seat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  background: #0e1428;
  border-radius: 8px;
  border: 1px solid #3a456e;
  margin-bottom: 6px;
}
.seat.empty { color: var(--muted); font-style: italic; }
.board-mini { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: .92rem; }
.board-mini th, .board-mini td { text-align: left; padding: 6px 8px; border-bottom: 1px solid #2a3558; }
.board-mini th { color: var(--gold); font-weight: 600; }
.err { color: var(--danger); margin-top: 8px; }
