
/* Mesa de juego: tapete de tinta oscura, latón para lo importante, una franja de color por clase. Tema único (oscuro) a propósito. */
:root {
  --mat: #14181f; --mat-2: #1b2029; --mat-3: #232a35; --line: #313a48; --ink: #e8e3d6; --ink-2: #a9a497; --ink-3: #7a776e;
  --brass: #d3a85a; --brass-2: #8f6e33; --danger: #e0644f; --ok: #6fbf8e; --info: #7fa7d9;
  --forest: #4f9a63; --dragon: #d0773a; --abyss: #8d5bc2; --haven: #d8b75a; --sword: #5b8fd0; --rune: #4fa3b8; --neutral: #9a958a;
  --f-display: "Marcellus", "Palatino Linotype", Georgia, serif;
  --f-body: "IBM Plex Sans Condensed", "Arial Narrow", system-ui, sans-serif;
  --f-num: "IBM Plex Mono", ui-monospace, monospace;
  --card-w: 118px; --card-h: 166px; --r: 8px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { background: var(--mat); color: var(--ink); font-family: var(--f-body); font-size: 14px; line-height: 1.35;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 12px; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, .card:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--f-display); font-weight: 400; margin: 0; text-wrap: balance; }
.num { font-family: var(--f-num); font-variant-numeric: tabular-nums; }
.btn { background: var(--mat-3); border: 1px solid var(--line); border-radius: 6px; padding: 7px 12px; }
.btn:hover { border-color: var(--brass-2); }
.btn.primary { background: var(--brass); color: #1a1408; border-color: var(--brass); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .45; cursor: default; }

/* --- inicio --- */
#setup { max-width: 760px; margin: 4vh auto; display: grid; gap: 22px; }
#setup h1 { font-size: clamp(30px, 6vw, 46px); letter-spacing: .02em; }
#setup .lede { color: var(--ink-2); max-width: 60ch; }
.decks { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.deck-opt { text-align: left; background: var(--mat-2); border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: grid; gap: 6px; border-left: 5px solid var(--c); }
.deck-opt[aria-pressed="true"] { border-color: var(--brass); border-left-color: var(--c); box-shadow: 0 0 0 1px var(--brass) inset; }
.deck-opt b { font-family: var(--f-display); font-size: 18px; font-weight: 400; }
.deck-opt span { color: var(--ink-2); font-size: 13px; }
.deck-opt small { color: var(--c); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
#deckChoice, #oppChoice { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.card .from { position: absolute; left: 4px; bottom: 22px; font-size: 9px; background: var(--brass); color: #1a1406; border-radius: 4px; padding: 1px 4px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: 11px; color: var(--ink-3); }
.vs { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; background: var(--mat-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.vs .x { font-family: var(--f-display); color: var(--brass); font-size: 20px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.seg button { background: var(--mat-2); border: 0; padding: 7px 12px; }
.seg button[aria-pressed="true"] { background: var(--brass); color: #1a1408; }
.note { color: var(--ink-3); font-size: 12.5px; max-width: 70ch; }

/* --- mesa --- */
#table { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 14px; max-width: 1280px; margin: 0 auto; }
@media (max-width: 900px) { #table { grid-template-columns: minmax(0, 1fr); } :root { --card-w: 96px; --card-h: 136px; } }
@media (max-width: 520px) { :root { --card-w: 78px; --card-h: 110px; } }
.side { display: grid; gap: 10px; align-content: start; }
.board { display: grid; gap: 8px; min-width: 0; }
.player { display: grid; gap: 8px; background: var(--mat-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px; border-top: 3px solid var(--c); min-width: 0; }
.player.active { box-shadow: 0 0 0 1px var(--brass-2); }
.hud { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.leader { display: flex; gap: 10px; align-items: center; background: var(--mat-3); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px 6px 6px; }
.leader.target { border-color: var(--danger); box-shadow: 0 0 0 2px var(--danger); cursor: pointer; }
.life { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: radial-gradient(circle at 35% 30%, #4a2a26, #2a1715); border: 2px solid var(--danger); font-family: var(--f-num); font-size: 19px; }
.leader h3 { font-size: 15px; }
.leader small { color: var(--ink-3); display: block; font-size: 11.5px; }
.stats { display: flex; gap: 8px; flex-wrap: wrap; }
.stat { background: var(--mat); border: 1px solid var(--line); border-radius: 6px; padding: 3px 8px; font-size: 12px; color: var(--ink-2); }
.stat b { color: var(--ink); font-family: var(--f-num); font-weight: 500; }
.stat.pp b { color: var(--ok); }
.lane { display: flex; gap: 8px; align-items: center; min-height: calc(var(--card-h) + 8px); overflow-x: auto; padding: 4px 2px; }
.lane.ex { min-height: calc(var(--card-h) * .62 + 8px); }
.lane-label { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); flex: 0 0 auto; }
.slot { flex: 0 0 auto; width: var(--card-w); height: var(--card-h); border: 1px dashed var(--line); border-radius: var(--r); opacity: .5; }
.hand { display: flex; gap: 6px; overflow-x: auto; padding: 6px 2px 2px; }
.middle { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 2px 4px; }
.turninfo { font-family: var(--f-display); font-size: 17px; }
.turninfo small { font-family: var(--f-body); color: var(--ink-3); font-size: 12px; margin-left: 6px; }

/* --- carta --- */
.card { position: relative; flex: 0 0 auto; width: var(--card-w); height: var(--card-h); border-radius: var(--r); background: linear-gradient(170deg, var(--mat-3), #191e26); border: 1px solid var(--line); border-top: 4px solid var(--c, var(--neutral));
  padding: 5px 5px 4px; display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; gap: 2px; text-align: left; transition: transform .18s ease, box-shadow .18s ease; overflow: hidden; }
.card.small { width: calc(var(--card-w) * .82); height: calc(var(--card-h) * .62); }
.card .nm { font-size: 11px; font-weight: 600; line-height: 1.15; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card .cost { position: absolute; top: -1px; right: -1px; width: 21px; height: 21px; border-radius: 0 var(--r) 0 8px; background: #234a33; color: #cfeedd; font-family: var(--f-num); font-size: 12px; display: grid; place-items: center; }
.card .ty { font-size: 9px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; align-self: start; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .tx { font-size: 9px; line-height: 1.22; color: var(--ink-2); overflow-y: auto; min-height: 0; white-space: pre-line; overscroll-behavior: contain; touch-action: pan-y; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.card.small .tx { -webkit-line-clamp: 3; }
.ic { display: inline-block; font-family: var(--f-num); font-size: .82em; line-height: 1.25; padding: 0 3px; margin: 0 1px; border-radius: 3px; background: var(--mat); border: 1px solid var(--line); color: var(--brass); vertical-align: baseline; }
.ic.f { color: #f0a94e; border-color: #6b4a22; } .ic.l { color: #c79cf0; border-color: #4f3a6b; } .ic.e { color: #e6d27a; border-color: #6b5f22; }
.ic.a { color: #7fd6a1; border-color: #2c5a3e; } .ic.pp { color: #cfeedd; background: #234a33; border-color: #234a33; border-radius: 50%; min-width: 1.4em; text-align: center; }
.ic.q { color: #f3e38b; } .ic.atk { color: #f0c76e; } .ic.def { color: #ef8e7d; } .ic.cls { color: var(--ink); }
.big { width: 100%; max-width: 300px; justify-self: center; aspect-ratio: 63 / 88; border-radius: 12px; border: 1px solid var(--brass-2); border-top: 8px solid var(--c, var(--neutral));
  background: linear-gradient(165deg, var(--mat-3), #171b22 70%); padding: 12px 13px; display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; gap: 8px; position: relative; overflow: hidden; }
.big.evolved { background: linear-gradient(165deg, #3d3323, #1b1813 70%); }
.big .bcost { position: absolute; top: 8px; right: 10px; width: 34px; height: 34px; border-radius: 50%; background: #234a33; color: #cfeedd; display: grid; place-items: center; font-family: var(--f-num); font-size: 18px; border: 2px solid #3d7a55; }
.big .bname { font-family: var(--f-display); font-size: 19px; line-height: 1.15; padding-right: 40px; }
.big .btype { font-size: 11.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .07em; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.big .btext { font-size: 13px; line-height: 1.42; white-space: pre-line; overflow-y: auto; }
.big .btok { font-size: 11.5px; color: var(--ink-2); border-top: 1px dashed var(--line); padding-top: 6px; margin-top: 4px; white-space: pre-line; }
.big .bpw { display: flex; justify-content: space-between; align-items: end; font-family: var(--f-num); font-size: 26px; }
.big .bpw .a { color: #f0c76e; } .big .bpw .d { color: #ef8e7d; }
.big .bcode { font-size: 10.5px; color: var(--ink-3); font-family: var(--f-num); }
.offlink { font-size: 12.5px; color: var(--info); }
.card .kw { display: flex; flex-wrap: wrap; gap: 2px; align-self: end; }
.card .kw i { font-style: normal; font-size: 9px; background: var(--mat); border: 1px solid var(--line); border-radius: 3px; padding: 0 3px; color: var(--ink-2); }
.card .pw { display: flex; justify-content: space-between; font-family: var(--f-num); font-size: 15px; }
.card .pw .a { color: #f0c76e; } .card .pw .d { color: #ef8e7d; }
.card .pw .d.hurt { color: var(--danger); text-decoration: underline; }
.card.evolved { background: linear-gradient(170deg, #3a3122, #1d1a14); border-color: var(--brass-2); }
.card.evolved::after { content: "EVO"; position: absolute; right: 5px; bottom: 22px; font-size: 9px; letter-spacing: .1em; color: var(--brass); }
.card.engaged { transform: rotate(90deg) scale(.74); margin-inline: calc((var(--card-h) * .74 - var(--card-w)) / 2); }
.card.engaged:hover { transform: rotate(90deg) scale(.74); }
.card.back { background: repeating-linear-gradient(45deg, #2a2236, #2a2236 6px, #241d2f 6px, #241d2f 12px); border-top-color: var(--abyss); }
.card.can { box-shadow: 0 0 0 2px var(--ok); cursor: pointer; }
.card.sel { box-shadow: 0 0 0 3px var(--brass); }
.card.pick { box-shadow: 0 0 0 2px var(--info); cursor: pointer; }
.card.picked { box-shadow: 0 0 0 3px var(--brass); transform: translateY(-4px); }
.card:hover:not(.engaged):not(.back) { transform: translateY(-2px); }
.card.stack::before { content: attr(data-stack); position: absolute; left: 4px; bottom: 4px; font-size: 10px; color: var(--info); }
.c-Forestcraft { --c: var(--forest); } .c-Dragoncraft { --c: var(--dragon); } .c-Abysscraft { --c: var(--abyss); } .c-Havencraft { --c: var(--haven); } .c-Swordcraft { --c: var(--sword); } .c-Runecraft { --c: var(--rune); } .c-Neutral { --c: var(--neutral); }

@media (max-width: 520px) { .card .tx { display: none; } #choice .opts .card .tx { display: block; } #choice .opts .card { --card-w: 140px; --card-h: 200px; } }
#choice .mull .card { --card-w: 150px; --card-h: 214px; }
#choice .mull .card .tx { display: block; font-size: 10.5px; }
/* elecciones: cartas más grandes y con el texto completo, que se puede deslizar */
#choice .opts .card { --card-w: 150px; --card-h: 214px; }
#choice .opts .card .tx { display: block; font-size: 10.5px; line-height: 1.3; }
#choice .scrollhint { font-size: 11.5px; color: var(--ink-3); }
@media (max-height: 520px) { #choice { max-height: 88vh; } #detail.open { max-height: 92vh; } }
@media (max-width: 700px) { #choice .opts.mull { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); } #choice .opts.mull .card { width: auto; height: auto; min-height: 190px; } #choice .opts.mull .card .tx { font-size: 10px; } }
.card .nm { padding-right: 18px; }
/* --- panel lateral --- */
.panel { background: var(--mat-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: grid; gap: 8px; min-width: 0; }
.panel h2 { font-size: 16px; }
.detail .txt { white-space: pre-wrap; font-size: 13px; color: var(--ink); }
.detail .meta { color: var(--ink-3); font-size: 12px; }
.acts { display: grid; gap: 6px; }
.acts .btn { text-align: left; }
.log { max-height: 340px; overflow-y: auto; font-size: 12px; color: var(--ink-2); display: grid; gap: 2px; }
.log div.t { color: var(--brass); margin-top: 6px; }
.bubble { background: #1f2533; border: 1px solid #3a4560; border-radius: 10px; padding: 9px 11px; font-size: 13px; color: #cfd8ea; }
.bubble b { color: var(--info); font-weight: 600; }
.thinking::after { content: " …"; animation: blink 1s steps(3) infinite; }
@keyframes blink { 50% { opacity: .3; } }
/* --- ilustraciones oficiales (solo en la versión web) --- */
.card.art { padding: 0; border-top-width: 1px; background: #0d1015; }
.card.art .art-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: calc(var(--r) - 1px); }
.card.art .nm, .card.art .ty, .card.art .tx { display: none; }
.card.art .cost { z-index: 2; }
.card.art > div:last-child { position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; padding: 14px 4px 3px; background: linear-gradient(transparent, rgba(8,10,14,.88) 55%); border-radius: 0 0 var(--r) var(--r); }
.card.art .pw { font-size: 14px; text-shadow: 0 1px 2px #000; }
.card.art.evolved::after { z-index: 2; bottom: 24px; background: rgba(8,10,14,.75); padding: 0 3px; border-radius: 3px; }
.card.art.small .art-img { object-position: center 18%; }
#choice .opts .card.art .tx, #choice .mull .card.art .tx { display: none; }
.bigwrap { display: grid; gap: 10px; justify-items: center; }
.bigart { width: 100%; max-width: 300px; aspect-ratio: 63 / 88; object-fit: cover; border-radius: 12px; border: 1px solid var(--brass-2); background: #0d1015; }
.big.withart { aspect-ratio: auto; }
/* escritorio: la mesa y el panel lateral se desplazan por separado y nada cambia de tamaño al cargar una imagen */
@media (min-width: 901px) and (min-height: 521px) {
  html:has(#table:not([hidden])), html:has(#table:not([hidden])) body { overflow: hidden; }
  #table { height: calc(100dvh - 24px); grid-template-rows: minmax(0, 1fr); }
  #table > .board, #table > .side { min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; padding-right: 4px; }
  #table > .board { align-content: start; grid-auto-rows: max-content; }
  #table > .board > .hand { position: sticky; bottom: 0; z-index: 3; background: var(--mat); padding-block: 6px 2px; }
  #choice.docked { position: static; inset: auto; z-index: auto; max-height: none; overflow: visible; border: 1px solid var(--brass-2); border-top: 3px solid var(--brass); border-radius: 12px; padding: 12px; background: var(--mat-2); }
  #choice.docked .opts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #choice.docked .opts .btn { grid-column: 1 / -1; }
  #choice.docked .opts .card { --card-w: 100%; width: 100%; height: auto; aspect-ratio: 63 / 88; }
  #choice.docked .scrollhint, #choice.docked .verMesa { display: none; }
}
@media (min-width: 1200px) { #table { grid-template-columns: minmax(0, 1fr) 340px; } }
/* móvil: la elección ocupa como mucho media pantalla y se puede plegar para ver la mesa */
#choice .chead { display: flex; gap: 10px; align-items: start; justify-content: space-between; }
#choice .verMesa { flex: none; }
#choice.min > :not(.chead) { display: none; }
@media (max-width: 900px), (max-height: 520px) { #choice:not(:has(.mull)) { max-height: 48vh; } }
@media (prefers-reduced-motion: reduce) { .card { transition: none; } .thinking::after { animation: none; } }

@media (max-width: 900px), (max-height: 520px) {
  #detail.open { display: flex; flex-direction: column; align-items: stretch; position: fixed; inset: auto 0 0 0; z-index: 35; border-radius: 14px 14px 0 0; max-height: 75vh; overflow-y: auto; border-color: var(--brass-2);
    padding: 14px max(16px, env(safe-area-inset-right, 0px)) calc(14px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); box-shadow: 0 -10px 30px rgba(0,0,0,.5); }
}
.closex { justify-self: end; }
#detail .dtop { display: grid; gap: 8px; }
#detail .dtop .closex { justify-self: end; }
@media (max-width: 900px), (max-height: 520px) {
  #detail.open .dtop { position: sticky; top: -14px; z-index: 2; background: var(--mat-2); padding: 6px 0 10px; margin-top: -6px; }
  #detail.open > * { flex: none; }
  #detail.open .big { aspect-ratio: auto; max-width: 420px; align-self: center; overflow: visible; }
  #detail.open .big .btext { overflow: visible; }
}
/* --- elección --- */
#choice { position: fixed; inset: auto 0 0 0; z-index: 30; background: color-mix(in srgb, var(--mat) 92%, black); border-top: 2px solid var(--brass);
  padding: 12px max(16px, env(safe-area-inset-right, 0px)) calc(12px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); display: grid; gap: 10px; max-height: 60vh; overflow-y: auto; }
#choice:has(.mull) { max-height: 88vh; }
#choice .opts { display: flex; flex-wrap: wrap; gap: 8px; }
#choice .prompt { font-family: var(--f-display); font-size: 17px; }
.banner { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(8,10,14,.7); z-index: 40; }
.banner .box { background: var(--mat-2); border: 1px solid var(--brass-2); border-radius: 14px; padding: 26px; text-align: center; display: grid; gap: 12px; max-width: 420px; }
.banner h2 { font-size: 30px; color: var(--brass); }
details summary { cursor: pointer; color: var(--ink-2); }

.mb8 { margin-bottom: 8px; }
