/* FallAbyss Digital */
:root {
  --bg: #17130f; --panel: #241d17; --panel2: #2f261e; --line: #4a3b2d; --ink: #efe4d0; --muted: #b5a68e;
  --gold: #e3b257; --you: #3b8fe0; --foe: #d9493e; --good: #5fc46b; --bad: #e0675c;
  --parch: #ead9b5; --parch-ink: #2a1d10;
  --serif: 'Palatino Linotype', 'Book Antiqua', Palatino, Georgia, serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--serif); font-size: 15px; }
a { color: var(--gold); }
button, select, input, textarea { font-family: inherit; font-size: 14px; }
button {
  background: linear-gradient(#5a4632, #3d2f22); color: var(--ink); border: 1px solid #7a6247; border-radius: 6px;
  padding: 7px 12px; cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--gold); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: linear-gradient(#b0802f, #7d5719); border-color: #e3b257; color: #fff8e6; font-weight: bold; }
button.danger { background: linear-gradient(#8c3a32, #5e231d); }
input, select, textarea { background: #120f0c; color: var(--ink); border: 1px solid var(--line); border-radius: 5px; padding: 5px 7px; }
h1, h2, h3 { font-weight: normal; margin: 0 0 8px; }
.muted { color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 8px 14px; background: #0f0c09; border-bottom: 1px solid var(--line); }
.topbar img { height: 34px; }
.topbar .title { font-size: 20px; color: var(--gold); letter-spacing: .5px; }
.topbar nav { margin-left: auto; display: flex; gap: 12px; }
.topbar nav a { text-decoration: none; }

/* ---------- Cartes ---------- */
.card {
  --cw: 220px; width: var(--cw); aspect-ratio: 961 / 1320; font-size: calc(var(--cw) / 21);
  position: relative; border-radius: calc(var(--cw) * .035); background: #3b3b3b;
  background-image: radial-gradient(circle at 30% 20%, #555 0, #333 70%);
  box-shadow: 0 0 0 calc(var(--cw) * .012) #1a1a1a, 0 4px 12px rgba(0,0,0,.5);
  color: var(--parch-ink); overflow: hidden; flex: none; user-select: none;
}
.card .cost {
  position: absolute; left: 2%; top: 1.5%; width: 15%; aspect-ratio: 1; border-radius: 50%; z-index: 3;
  background: var(--lvl); border: calc(var(--cw) * .012) solid #eee; color: #fff; display: grid; place-items: center;
  font-weight: bold; font-size: 1.55em; text-shadow: 0 1px 2px #000;
}
.card .stats {
  position: absolute; left: 6%; right: 5%; top: 3%; height: 14%; display: flex; justify-content: space-around; align-items: center;
  padding-left: 9%; background: linear-gradient(#6b4528, #4a2e19); border-radius: 4px; border-bottom: calc(var(--cw) * .025) solid var(--lvl);
}
.card .stat { position: relative; width: 19%; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; background: #2a2a2a; border: 2px solid #999; color: #fff; }
.card .stat .ico { position: absolute; inset: 14%; color: rgba(255,255,255,.18); }
.card .stat .ico svg { width: 100%; height: 100%; }
.card .stat b { position: relative; font-size: 1.4em; text-shadow: 0 1px 2px #000; }
.card .stat.t1 { border-color: #46c556; } .card .stat.t2 { border-color: #3b8fe0; } .card .stat.t3 { border-color: #a55ee0; } .card .stat.t4 { border-color: #f39c32; }
.card .stat.up b { color: #8dff9a; } .card .stat.down b { color: #ff8f86; }
.card .name {
  position: absolute; left: 8%; right: 8%; top: 18.5%; height: 6.2%; background: var(--parch); display: grid; place-items: center;
  font-weight: bold; font-size: 1.05em; text-align: center; line-height: 1; padding: 0 3%; border-radius: 2px; white-space: nowrap; overflow: hidden;
}
.card .art { position: absolute; left: 6%; right: 6%; top: 25.5%; height: 41%; background: #222 center/cover no-repeat; border: 2px solid #222; }
.card .art.empty { display: grid; place-items: center; background: repeating-linear-gradient(135deg, #2a2420 0 10px, #241f1b 10px 20px); color: #9c8b72; font-style: italic; font-size: .85em; }
.card .type {
  position: absolute; left: 6%; right: 6%; top: 66.5%; height: 5.2%; background: #3a3a3a; color: #f2eadb; font-style: italic;
  display: flex; align-items: center; justify-content: flex-end; gap: 4%; padding-right: 2%; font-size: .78em; white-space: nowrap; overflow: hidden;
}
.card .type .gem { color: var(--rar); font-size: 1.5em; font-style: normal; text-shadow: 0 0 4px #000; }
.card .text {
  position: absolute; left: 6%; right: 6%; top: 72.5%; bottom: 3%; background: var(--parch); padding: 2.5% 3.5%;
  font-size: .72em; line-height: 1.22; overflow: hidden;
}
.card .text p { margin: 0 0 .35em; }
.card .text i { font-style: italic; }
.card .text .king { color: #5b4524; }
.card .text .quote { font-style: italic; color: #5d4a33; }
.card .cbub { display: inline-grid; place-items: center; width: 1.35em; height: 1.35em; border-radius: 50%; background: #4a4a4a; color: #fff; font-weight: bold; font-size: .95em; vertical-align: -.15em; }
.card .badge { position: absolute; right: 3%; top: 2%; background: rgba(0,0,0,.75); color: #fff; padding: 1px 6px; border-radius: 8px; font-size: .8em; z-index: 4; font-family: sans-serif; }
.card.spell .sname { position: absolute; left: 6%; right: 6%; top: 4%; height: 10%; background: #b97a4b; display: grid; place-items: center; font-weight: bold; font-size: 1.1em; border-radius: 3px; text-align: center; }
.card.spell .sname i { font-weight: normal; }
.card.spell .text { top: 16%; bottom: 47%; font-size: .78em; }
.card.spell .art { top: 55%; height: 42%; }
.card.spell .tier.dim { opacity: .45; }
.card.small { --cw: 120px; } .card.mini { --cw: 92px; } .card.big { --cw: 300px; } .card.huge { --cw: 360px; }
.card.mini .text, .card.small .text { font-size: .66em; }

/* ---------- Page d'accueil ---------- */
.home { max-width: 980px; margin: 30px auto; padding: 0 16px; }
.home .hero { display: flex; gap: 24px; align-items: center; }
.home .hero img { width: 180px; }
.home .tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-top: 24px; }
.home .tile { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; text-decoration: none; color: var(--ink); }
.home .tile:hover { border-color: var(--gold); }
.home .tile h2 { color: var(--gold); }

/* ---------- Jeu ---------- */
.game { display: grid; grid-template-columns: 270px 1fr 330px; grid-template-rows: 1fr auto; height: calc(100vh - 51px); }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 10px; overflow: auto; display: flex; flex-direction: column; gap: 10px; }
.side.right { border-right: 0; border-left: 1px solid var(--line); }
.pbox { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.pbox h3 { font-size: 16px; margin-bottom: 4px; }
.pbox.you h3 { color: var(--you); } .pbox.foe h3 { color: var(--foe); }
.cpbar { display: flex; gap: 10px; font-size: 14px; flex-wrap: wrap; }
.cpbar b { color: var(--gold); }
.zones { font-size: 13px; color: var(--muted); margin-top: 4px; }
.log { flex: 1; min-height: 120px; overflow: auto; font-size: 12.5px; line-height: 1.35; background: #120f0c; border: 1px solid var(--line); border-radius: 6px; padding: 6px; }
.log div { padding: 1px 0; }
.log .turn { color: var(--gold); margin-top: 4px; } .log .bad { color: var(--bad); } .log .good { color: var(--good); }
.log .king { color: #f1c75a; font-weight: bold; } .log .loot { color: #9ecbff; } .log .summon { color: #c9b6ff; } .log .atk { color: #ffb08a; }
.center { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 6px; overflow: hidden; position: relative; }
.phasebar { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; justify-content: center; }
.phase { padding: 3px 9px; border-radius: 12px; background: #2d241c; color: var(--muted); font-size: 13px; }
.phase.on { background: var(--gold); color: #2a1d10; font-weight: bold; }
.board {
  position: relative; height: calc(100vh - 51px - 190px - 52px); aspect-ratio: 2 / 3; max-width: 100%;
  background: url('../assets/ui/board.jpg') center/100% 100% no-repeat; border-radius: 6px; box-shadow: 0 6px 24px #000;
}
.grid { position: absolute; left: 12.74%; right: 12.67%; top: 0; bottom: 0; display: grid; grid-template-columns: repeat(6, 1fr); grid-template-rows: repeat(8, 1fr); }
.cell { position: relative; border: 1px solid rgba(0,0,0,.12); }
.cell.hl-move { background: rgba(80, 160, 255, .33); box-shadow: inset 0 0 0 2px rgba(120,190,255,.8); cursor: pointer; }
.cell.hl-atk { box-shadow: inset 0 0 0 3px #ff5a4a; cursor: pointer; }
.cell.hl-target { background: rgba(255, 210, 90, .3); box-shadow: inset 0 0 0 2px #ffd25a; cursor: pointer; }
.cell.hl-sel { background: rgba(255, 210, 90, .55); }
.cell.hl-summon { background: rgba(120, 230, 140, .3); box-shadow: inset 0 0 0 2px #7fe08f; cursor: pointer; }
.cell.zone::after { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(45deg, rgba(160,80,255,.25) 0 6px, transparent 6px 12px); pointer-events: none; }
.tok {
  position: absolute; inset: 4%; border-radius: 6px; background: #222 center/cover no-repeat; border: 3px solid var(--you);
  box-shadow: 0 2px 6px #000; cursor: pointer; overflow: hidden; transition: transform .15s;
}
.tok.foe { border-color: var(--foe); }
.tok.active { transform: scale(1.06); box-shadow: 0 0 0 3px var(--gold), 0 0 16px var(--gold); z-index: 2; }
.tok.done { filter: saturate(.35) brightness(.75); }
.tok .tname { position: absolute; left: 0; right: 0; top: 0; background: rgba(0,0,0,.65); color: #fff; font-size: 10px; line-height: 1.15; padding: 1px 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: sans-serif; }
.tok .tstats { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; background: rgba(0,0,0,.72); font: bold 11px sans-serif; color: #fff; padding: 1px 3px; }
.tok .tstats .l { color: #ff8f86; } .tok .tstats .a { color: #bcd3ff; } .tok .tstats .m { color: #ffd59a; }
.tok .crown { position: absolute; right: 2px; top: 13px; width: 26%; filter: drop-shadow(0 0 3px #000); }
.tok .flags { position: absolute; left: 2px; top: 14px; font-size: 12px; text-shadow: 0 0 3px #000; }
.handbar { grid-column: 1 / 4; background: #100c09; border-top: 1px solid var(--line); height: 190px; display: flex; gap: 8px; padding: 6px 10px; align-items: center; overflow-x: auto; }
.handbar .card { cursor: pointer; transition: transform .12s; }
.handbar .card:hover { transform: translateY(-6px); }
.handbar .card.playable { box-shadow: 0 0 0 3px #7fe08f, 0 4px 12px #000; }
.handbar .card.selected { box-shadow: 0 0 0 4px var(--gold), 0 0 18px var(--gold); }
.handbar .label { writing-mode: vertical-rl; transform: rotate(180deg); color: var(--muted); font-size: 13px; }
.detail { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.actions { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.actions button { text-align: left; }
.actions .hint { font-size: 13px; color: var(--muted); }
.banner { position: absolute; top: 44px; left: 50%; transform: translateX(-50%); background: rgba(20,15,10,.92); border: 1px solid var(--gold); border-radius: 8px; padding: 8px 12px; z-index: 20; display: flex; gap: 10px; align-items: center; max-width: 92%; }
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 50; }
.modal { background: var(--panel); border: 1px solid var(--gold); border-radius: 10px; padding: 16px; max-width: min(860px, 94vw); max-height: 88vh; overflow: auto; box-shadow: 0 10px 40px #000; }
.modal p { margin-top: 0; line-height: 1.4; }
.modal .opts { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.modal .cards { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.modal .cards .card { cursor: pointer; }
.modal .cards .card.sel { box-shadow: 0 0 0 4px var(--gold); }
.toast { position: fixed; bottom: 210px; left: 50%; transform: translateX(-50%); background: #000c; padding: 8px 14px; border-radius: 8px; z-index: 60; }
.over { text-align: center; } .over h2 { font-size: 32px; color: var(--gold); }

/* ---------- Generateur ---------- */
.gen { display: grid; grid-template-columns: 420px 1fr; gap: 16px; padding: 14px; max-width: 1500px; margin: 0 auto; }
.gen .panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.gen label { display: block; font-size: 13px; color: var(--muted); margin: 8px 0 3px; }
.gen .two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; } .gen .three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.gen .five { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.gen input, .gen select, .gen textarea { width: 100%; }
.gen .preview { display: flex; gap: 18px; flex-wrap: wrap; align-items: flex-start; }
table.calc { border-collapse: collapse; font-size: 13.5px; min-width: 300px; }
table.calc td, table.calc th { border-bottom: 1px solid var(--line); padding: 3px 8px; text-align: right; }
table.calc td:first-child, table.calc th:first-child { text-align: left; }
table.calc tr.tot td { font-weight: bold; color: var(--gold); border-top: 2px solid var(--line); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { background: #3a2e23; border: 1px solid var(--line); border-radius: 12px; padding: 2px 8px; font-size: 12.5px; cursor: pointer; }
.chip.on { background: #6b4f22; border-color: var(--gold); }
.gallery { display: flex; flex-wrap: wrap; gap: 12px; }
.gallery .item { display: flex; flex-direction: column; gap: 4px; align-items: center; }
.tabs { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.tabs button.on { border-color: var(--gold); color: var(--gold); }
table.audit { border-collapse: collapse; width: 100%; font-size: 13px; }
table.audit td, table.audit th { border-bottom: 1px solid var(--line); padding: 4px 6px; text-align: left; }
.ok { color: var(--good); } .warn { color: #f0b85a; } .err { color: var(--bad); }

/* ---------- Deck ---------- */
.deck { padding: 14px; max-width: 1400px; margin: 0 auto; }
.deck .grid2 { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.deck .slot { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.deck .ctr { display: flex; gap: 4px; align-items: center; }
.deck .ctr b { min-width: 22px; text-align: center; }
.rules { max-width: 900px; margin: 20px auto; padding: 0 16px 40px; line-height: 1.5; }
.rules h2 { color: var(--gold); margin-top: 26px; }
.rules li { margin: 3px 0; }

/* ---------- Impression : 9 cartes par page ---------- */
@media print {
  @page { size: letter portrait; margin: 8mm; }
  body { background: #fff; }
  .noprint, .topbar { display: none !important; }
  .printsheet { display: grid !important; grid-template-columns: repeat(3, 63mm); gap: 0; }
  .printsheet .card { --cw: 63mm; box-shadow: none; border-radius: 0; break-inside: avoid; }
  .printsheet canvas { width: 63mm !important; height: auto !important; break-inside: avoid; display: block; }
}
.printsheet { display: none; }
