:root {
  --blue: #2b86c5;
  --blue-dark: #1b5f8f;
  --cream: #f3e7c8;
  --brown: #6b4a2e;
  --orange: #f08a24;
  --green: #5f9e45;
  --red: #d93a3a;
  --purple: #8a52c7;
  --ink: #2a1d12;
  --felt: #1f4a3a;
  --felt-2: #173a2d;
  --panel: #241a12;
  --ch: min(14.5vh, 140px);         /* alto de carta en mesa */
  --cw: calc(var(--ch) * 63 / 88);  /* ancho de carta */
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Open Sans', system-ui, sans-serif;
  color: var(--cream);
  background: var(--felt-2);
  overflow: hidden;
}
h1, h2, h3, .btn, .banner, .pname, .room-code { font-family: 'Fredoka', system-ui, sans-serif; }
.hidden { display: none !important; }
.muted { opacity: .7; font-size: .9em; }

/* ---------- botones ---------- */
.btn {
  border: 3px solid var(--brown);
  background: var(--cream);
  color: var(--brown);
  font-weight: 600;
  font-size: 1rem;
  padding: .55em 1.1em;
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--brown);
  transition: transform .08s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--brown); }
.btn.primary { background: var(--blue); color: #fff; border-color: var(--blue-dark); box-shadow: 0 3px 0 var(--blue-dark); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.big { font-size: 1.3rem; padding: .7em 1.4em; }

/* ---------- lobby ---------- */
#lobby, #waiting {
  height: 100%;
  overflow: auto;
  background: url(img/fondo.png) center / cover no-repeat, var(--blue);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px;
}
.lobby-box {
  background: rgba(243, 231, 200, .95);
  color: var(--ink);
  border: 4px solid var(--brown);
  border-radius: 24px;
  padding: 20px 24px;
  max-width: 860px;
  width: 100%;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,.35);
}
.logo { width: min(340px, 80%); }
.logo.small { width: 200px; }
.lobby-box h3 { margin: 14px 0 6px; color: var(--brown); }
.field { display: block; font-weight: 600; margin: 6px 0; }
.field input, .join input {
  font: inherit; padding: .5em .8em; border-radius: 10px; border: 2px solid var(--brown); margin-left: 6px;
}
.pick-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.pick {
  border: 3px solid transparent; background: none; padding: 4px; border-radius: 12px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px; font-weight: 600; color: var(--ink);
}
.pick img { width: 120px; border-radius: 8px; box-shadow: 0 3px 8px rgba(0,0,0,.3); }
.pick.sel { border-color: var(--blue); background: rgba(43,134,197,.15); }
.lobby-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; align-items: center; margin-top: 18px; }
.join { display: flex; gap: 6px; }
.join input { width: 110px; text-transform: uppercase; text-align: center; letter-spacing: 3px; margin: 0; }
.msg { color: var(--red); font-weight: 600; min-height: 1.2em; }
.room-code { font-size: 4rem; letter-spacing: 12px; color: var(--blue); font-weight: 700; }

/* ---------- partida ---------- */
#game { display: grid; grid-template-columns: 1fr 300px; height: 100%; }
#board {
  position: relative; isolation: isolate;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: 6px;
  padding: 8px 10px 0;
  background: radial-gradient(ellipse at center, var(--felt) 0%, var(--felt-2) 75%);
  min-width: 0;
  overflow: hidden;
}
.side {
  display: flex; gap: 14px; align-items: center;
  padding: 5px 12px; border-radius: 16px;
  background: rgba(12,22,16,.62); backdrop-filter: blur(6px);
  box-shadow: 0 4px 18px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.06);
  border: 2px solid transparent;
}
.side.active { border-color: rgba(240,138,36,.7); box-shadow: 0 0 18px rgba(240,138,36,.25); }
.info { width: 200px; flex-shrink: 0; }
.pname { font-size: 1.25rem; font-weight: 700; }
.turn-tag { font-size: .7rem; background: var(--orange); color: #fff; padding: 2px 6px; border-radius: 6px; vertical-align: middle; }
.hand-count { font-size: .85rem; opacity: .8; min-height: 1em; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.chip { font-size: .8rem; padding: 2px 7px; border-radius: 8px; background: rgba(255,255,255,.12); font-weight: 600; }
.chip.life { background: var(--red); }
.chip.f { background: var(--green); }
.chip.d { background: var(--blue); }
.chip.e { background: #b8a018; }
.chip.sh { background: var(--purple); }
.energy { display: flex; gap: 2px; }
.energy i {
  font-style: normal; font-size: .7rem; width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center; background: rgba(255,255,255,.1); color: rgba(255,255,255,.4);
}
.energy i.on { background: linear-gradient(#ffe066, #f08a24); color: var(--ink); font-weight: 700; }

.heroes, .slots, .traps { display: flex; gap: 8px; }
.slots, .traps { padding-left: 10px; border-left: 1px dashed rgba(255,255,255,.15); }

/* cartas */
.card {
  width: var(--cw); height: var(--ch);
  border-radius: calc(var(--ch) * .05);
  background: #333 center / cover no-repeat;
  box-shadow: 0 3px 8px rgba(0,0,0,.45);
  position: relative;
  flex-shrink: 0;
  transition: transform .12s, box-shadow .12s;
}
.card.small { width: calc(var(--cw) * .8); height: calc(var(--ch) * .8); }
.card.tiny { width: 46px; height: 64px; }
.card.land { aspect-ratio: 88 / 63; }
.card.tiny.land { width: 64px; height: 46px; }
.card.big { width: 100%; height: auto; aspect-ratio: 63 / 88; border-radius: 14px; }
.card.big.land { aspect-ratio: 88 / 63; }
.card.back {
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-dark) 100%);
  border: 3px solid var(--cream);
  display: grid; place-items: center;
}
.card.back img { width: 80%; }
.card.back b { position: absolute; bottom: 4px; right: 6px; font-family: 'Fredoka'; font-size: .9rem; }
.card.back.adv { background: linear-gradient(135deg, #c43b3b 0%, #7a1e1e 100%); }
.card.pile.empty { display: grid; place-items: center; font-size: .75rem; background: rgba(255,255,255,.06); box-shadow: none; border: 2px dashed rgba(255,255,255,.2); }
.card .count { position: absolute; bottom: 4px; right: 6px; background: rgba(0,0,0,.7); padding: 0 6px; border-radius: 6px; font-size: .85rem; }
.card.hero.unmounted { filter: grayscale(.85) brightness(.6); }
.card.notready { filter: brightness(.55); }
.card.playable { box-shadow: 0 0 0 3px var(--orange), 0 0 16px var(--orange); cursor: pointer; }
.card.playable:hover { transform: translateY(-4px); }
.card.unmounted.playable { filter: grayscale(.3); }
.badge {
  position: absolute; left: 50%; bottom: -8px; transform: translateX(-50%);
  background: var(--red); color: #fff; font-family: 'Fredoka'; font-weight: 700;
  padding: 1px 10px; border-radius: 10px; border: 2px solid #fff; white-space: nowrap; font-size: .95rem;
}
.badge.off { background: #555; font-size: .7rem; }

.slot {
  width: calc(var(--cw) * .8); height: calc(var(--ch) * .8);
  border-radius: 8px; border: 2px dashed rgba(255,255,255,.18);
  display: grid; place-items: center; position: relative; flex-shrink: 0;
}
.slot > .slot-ico { font-size: 1.4rem; opacity: .35; }
.slot > .slot-name { position: absolute; bottom: 4px; font-size: .65rem; opacity: .45; }
.slot > .card { position: absolute; inset: -2px; }
.slot.trap { border-color: rgba(138,82,199,.4); }

/* fondo: tu ilustración, desenfocada y oscurecida */
#board::before {
  content: ''; position: absolute; inset: -30px; z-index: -1;
  background: url(img/fondo.png) center / cover; filter: blur(14px) saturate(1.1) brightness(.45);
}
.center::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  background: radial-gradient(ellipse at 50% 55%, transparent 55%, rgba(10,5,0,.55) 100%);
  box-shadow: inset 0 0 0 2px rgba(212,168,42,.35);
}
.audio-btns { display: flex; gap: 6px; }
.btn.small { font-size: .8rem; padding: .3em .7em; border-width: 2px; box-shadow: 0 2px 0 var(--brown); flex: 1; }
.btn.small.off { opacity: .6; }

/* centro: escena 3D con la interfaz encima */
.center { position: relative; min-height: 0; border-radius: 16px; overflow: hidden; background: #2b1c10; box-shadow: inset 0 0 30px rgba(0,0,0,.6); }
.arena-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.arena-overlay, #center-ui { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
#center-ui > * { pointer-events: auto; }
.decks { position: absolute; left: 10px; bottom: 8px; display: flex; gap: 12px; }
.decks .card { width: calc(var(--cw) * .6); height: calc(var(--ch) * .6); }
.labeled { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .7rem; opacity: .9; text-shadow: 0 1px 2px #000; }
.mid { position: absolute; inset: 0; pointer-events: none; }
.banner {
  position: absolute; top: 8px; left: 10px;
  font-size: 1.2rem; font-weight: 700; padding: 5px 16px; border-radius: 14px;
  background: rgba(0,0,0,.55); white-space: nowrap; pointer-events: auto;
}
.banner.mine { background: var(--orange); color: #fff; box-shadow: 0 0 16px rgba(240,138,36,.6); }
.stack {
  position: absolute; right: 10px; top: 10px; pointer-events: auto;
  background: rgba(20,12,30,.8); border: 2px solid var(--purple); border-radius: 12px; padding: 8px; max-height: calc(100% - 20px); overflow: auto; min-width: 260px; max-width: 340px;
}
.life-tag, .pile-tag {
  position: absolute; left: 0; top: 0; white-space: nowrap; pointer-events: none;
  font-family: 'Fredoka'; font-weight: 700; color: #fff; text-shadow: 0 2px 3px rgba(0,0,0,.8);
}
.life-tag { background: var(--red); border: 2px solid #fff; border-radius: 12px; padding: 0 8px; font-size: .95rem; box-shadow: 0 2px 6px rgba(0,0,0,.5); }
.life-tag.mount { background: #3d7a2e; font-size: .8rem; }
.life-tag.bump { animation: bump .45s ease-out; }
@keyframes bump { 30% { scale: 1.45; } }
.pile-tag { font-size: .7rem; opacity: .9; background: rgba(0,0,0,.45); padding: 0 6px; border-radius: 6px; }
.float-text {
  position: absolute; transform: translate(-50%, -50%); pointer-events: none;
  font-family: 'Fredoka'; font-weight: 700; font-size: 2rem; color: #fff;
  -webkit-text-stroke: 2px rgba(0,0,0,.6); text-shadow: 0 3px 8px rgba(0,0,0,.6);
  animation: floatUp 1.5s ease-out forwards;
}
.float-text.dmg { color: #ff4a3a; font-size: 2.6rem; }
.float-text.heal { color: #5dff7a; }
.float-text.gold { color: #ffd75a; }
.float-text.ice { color: #8fe3ff; font-size: 1.6rem; }
.float-text.magic { color: #d6a8ff; }
@keyframes floatUp {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(.5); }
  15% { opacity: 1; transform: translate(-50%, -60%) scale(1.25); }
  30% { transform: translate(-50%, -70%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -190%) scale(1); }
}

/* carta jugada en grande */
.cast { position: fixed; inset: 0; pointer-events: none; z-index: 45; display: grid; place-items: center; }
.cast-card {
  width: min(260px, 30vh); aspect-ratio: 63 / 88; border-radius: 14px; background: center / cover;
  box-shadow: 0 0 0 4px #fff, 0 0 40px 10px rgba(255,215,90,.75);
  animation: castIn .35s cubic-bezier(.2,1.4,.4,1) both;
}
.cast.opp .cast-card { --from: -60vh; }
.cast.me .cast-card { --from: 60vh; }
.cast.trap .cast-card { box-shadow: 0 0 0 4px #fff, 0 0 50px 14px rgba(180,107,255,.85); }
.cast-tag { position: absolute; margin-top: calc(min(260px, 30vh) * 1.5); font-family: 'Fredoka'; font-weight: 700; font-size: 1.6rem; color: #d6a8ff; text-shadow: 0 2px 6px #000; }
.cast.out .cast-card { animation: castOut .22s ease-in both; }
@keyframes castIn { from { transform: translateY(var(--from)) scale(.4) rotate(-8deg); opacity: 0; } }
@keyframes castOut { to { transform: scale(.3); opacity: 0; } }

/* chispas HTML */
.burst-p {
  position: fixed; width: var(--s); height: var(--s); border-radius: 50%; pointer-events: none; z-index: 46;
  transform: translate(-50%, -50%); box-shadow: 0 0 8px currentColor; animation: burstFly ease-out forwards;
}
@keyframes burstFly { to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(.2); opacity: 0; } }
.burst-flash {
  position: fixed; width: 20px; height: 20px; border-radius: 50%; transform: translate(-50%, -50%); pointer-events: none; z-index: 46;
  animation: flashRing .55s ease-out forwards;
}
.burst-flash.fire { box-shadow: 0 0 0 6px #ffb347, 0 0 40px 20px rgba(255,106,26,.8); }
.burst-flash.gold { box-shadow: 0 0 0 4px #ffd75a, 0 0 30px 12px rgba(255,215,90,.6); }
.burst-flash.magic { box-shadow: 0 0 0 4px #c08aff, 0 0 30px 12px rgba(138,82,199,.7); }
@keyframes flashRing { from { opacity: 1; } to { width: 160px; height: 160px; opacity: 0; } }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-5px) rotate(-2deg); } 40%, 80% { transform: translateX(5px) rotate(2deg); } }
.stack-title { font-size: .75rem; opacity: .7; margin-bottom: 4px; }
.stack-item { display: flex; align-items: center; gap: 8px; padding: 4px; font-size: .85rem; border-radius: 8px; }
.stack-item.opp { background: rgba(217,58,58,.15); }
.stack-item.me { background: rgba(43,134,197,.15); }
.adv-now { height: calc(var(--ch) * .9); width: auto; }

/* mano */
.hand {
  display: flex; justify-content: center; align-items: flex-end;
  padding: 10px 10px 18px; min-height: calc(var(--ch) * 1.05 + 34px);
  perspective: 900px;
}
/* abanico de cartas */
.hand-slot {
  margin: 0 calc(var(--cw) * -1 * var(--overlap, .12));
  transform: translateY(var(--lift)) rotate(var(--rot));
  transform-origin: 50% 260%;
  transition: transform .18s ease-out, margin .18s;
  position: relative;
}
.hand-slot:hover { transform: translateY(-34px) rotate(0deg) scale(1.22); z-index: 50 !important; margin: 0 calc(var(--cw) * .12); }
.card.in-hand {
  width: calc(var(--cw) * 1.05); height: calc(var(--ch) * 1.05); cursor: pointer;
  transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform .12s ease-out, box-shadow .2s;
  transform-style: preserve-3d; overflow: hidden;
}
.card.in-hand::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity .2s;
  background: radial-gradient(circle at var(--mx, 50%) var(--my, 50%), rgba(255,255,255,.45), rgba(255,255,255,0) 45%),
              linear-gradient(115deg, transparent 30%, rgba(255,240,180,.18) 45%, rgba(160,220,255,.18) 55%, transparent 70%);
  mix-blend-mode: screen;
}
.card.in-hand:hover::after { opacity: 1; }
.card.in-hand.playable { animation: glowPulse 1.8s ease-in-out infinite; }
.card.in-hand.playable:hover { transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); }
@keyframes glowPulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--orange), 0 0 10px rgba(240,138,36,.6); }
  50% { box-shadow: 0 0 0 3px #ffc46b, 0 0 24px rgba(255,180,80,.95); }
}
.flip-back {
  position: absolute; inset: 0; border-radius: inherit; z-index: 3;
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-dark) 100%); border: 3px solid var(--cream);
  display: grid; place-items: center;
}
.flip-back img { width: 80%; }

/* mano del rival */
.opp-hand { position: relative; height: 34px; margin-top: 4px; display: flex; align-items: flex-end; padding-left: 6px; }
.mini-back {
  width: 22px; height: 31px; margin-left: -9px; border-radius: 3px;
  background: linear-gradient(135deg, var(--blue), var(--blue-dark)); border: 2px solid var(--cream);
  transform: rotate(var(--r)); transform-origin: 50% 120%; box-shadow: 0 2px 4px rgba(0,0,0,.4);
}
.mini-back.pop { animation: popIn .45s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes popIn { from { transform: translateY(30px) rotate(var(--r)) scale(.2); opacity: 0; } }
.oh-count { margin-left: 8px; font-family: 'Fredoka'; font-weight: 700; font-size: .9rem; opacity: .85; }

/* objetos y trampas que entran en juego */
.card.enter { animation: dropIn .55s cubic-bezier(.2,1.5,.4,1) both; }
@keyframes dropIn {
  0% { transform: translateY(-60px) scale(1.7) rotate(-10deg); opacity: 0; box-shadow: 0 0 40px 10px rgba(255,215,90,.9); }
  60% { opacity: 1; }
  100% { box-shadow: 0 3px 8px rgba(0,0,0,.45); }
}
.card.enter-trap { animation: trapIn .5s ease-out both; }
@keyframes trapIn { from { transform: rotateY(180deg) translateY(-30px) scale(1.4); opacity: 0; box-shadow: 0 0 30px 8px rgba(180,107,255,.9); } }
.card.foreign { box-shadow: 0 0 0 3px var(--purple), 0 0 12px rgba(138,82,199,.8); }
.card.foreign::before {
  content: 'rival'; position: absolute; top: -8px; left: 50%; transform: translateX(-50%); z-index: 2;
  background: var(--purple); color: #fff; font-size: .6rem; font-weight: 700; padding: 0 5px; border-radius: 6px;
}

/* panel lateral */
#panel { background: var(--panel); display: flex; flex-direction: column; gap: 10px; padding: 10px; min-height: 0; border-left: 3px solid var(--brown); }
#preview { min-height: 200px; }
.preview-empty { opacity: .5; font-size: .85rem; text-align: center; padding: 60px 10px; border: 2px dashed rgba(255,255,255,.15); border-radius: 12px; }
.preview-text { font-size: .8rem; margin-top: 6px; opacity: .85; }
#actions { flex: none; display: flex; flex-direction: column; gap: 8px; }
#log { flex: 1; overflow: auto; font-size: .78rem; line-height: 1.35; background: rgba(0,0,0,.25); border-radius: 10px; padding: 8px; min-height: 80px; }
#log div { padding: 2px 0; border-bottom: 1px solid rgba(255,255,255,.04); }
#log div.turn { color: var(--orange); font-weight: 600; margin-top: 4px; }

/* menú */
.menu {
  position: fixed; z-index: 50; background: var(--cream); color: var(--ink);
  border: 3px solid var(--brown); border-radius: 12px; padding: 6px; min-width: 240px; max-width: 360px;
  box-shadow: 0 8px 24px rgba(0,0,0,.5); max-height: 70vh; overflow: auto;
}
.menu-title { font-family: 'Fredoka'; font-weight: 700; padding: 4px 8px; color: var(--brown); }
.menu button {
  display: block; width: 100%; text-align: left; font: inherit; font-size: .9rem;
  padding: 7px 10px; border: 0; background: none; border-radius: 8px; cursor: pointer; color: var(--ink);
}
.menu button:hover { background: rgba(43,134,197,.2); }
.menu button.disabled { opacity: .55; cursor: default; }
.menu button.disabled:hover { background: none; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; z-index: 40; padding: 16px; }
.modal-box {
  background: var(--cream); color: var(--ink); border: 4px solid var(--brown); border-radius: 20px;
  padding: 18px 22px; max-width: 760px; width: 100%; max-height: 92vh; overflow: auto; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.modal-box h2 { margin: 0; color: var(--brown); }
.adv-modal { width: min(420px, 100%); height: auto; }
.reveal { background: rgba(107,74,46,.1); border-radius: 10px; padding: 6px 12px; width: 100%; text-align: left; font-size: .9rem; }
.reveal p { margin: 4px 0; }
.ask { font-weight: 700; font-size: 1.1rem; margin: 4px 0; }
.opts { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.numpick { display: flex; align-items: center; gap: 10px; }
.numpick .num { font-family: 'Fredoka'; font-size: 2.4rem; font-weight: 700; min-width: 60px; color: var(--blue); }
.pickhand { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.pickhand .card { cursor: pointer; }
.pickhand .card.sel { box-shadow: 0 0 0 4px var(--blue), 0 0 16px var(--blue); transform: translateY(-6px); }
.pickhand .card[data-order]:not([data-order=""])::after {
  content: attr(data-order); position: absolute; top: -8px; right: -8px; width: 26px; height: 26px; border-radius: 50%;
  background: var(--blue); color: #fff; display: grid; place-items: center; font-weight: 700;
}

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 60;
  background: var(--red); color: #fff; padding: 10px 18px; border-radius: 12px; font-weight: 600;
  box-shadow: 0 6px 20px rgba(0,0,0,.4);
}

/* pantallas estrechas: panel abajo */
@media (max-width: 1100px) {
  :root { --ch: min(13vh, 120px); }
  #game { grid-template-columns: 1fr; grid-template-rows: 1fr 160px; }
  #panel { flex-direction: row; border-left: 0; border-top: 3px solid var(--brown); }
  #preview { display: none; }
  #actions { width: 220px; }
  .info { width: 150px; }
}

/* ---------- lobby a dos columnas + taller de pintura ---------- */
.lobby-wrap { display: grid; grid-template-columns: minmax(340px, 520px) minmax(380px, 1fr); gap: 18px; width: 100%; max-width: 1400px; align-items: stretch; }
.lobby-left { max-width: none; }
.lobby-left .logo { width: min(260px, 70%); }
.lobby-left .pick img { width: 84px; }
.lobby-left .pick { font-size: .8rem; }
#lobby-wait .room-code { margin: 6px 0 10px; }
.studio-box { max-width: none; display: flex; flex-direction: column; padding: 14px 16px; text-align: left; }
.studio-title { margin: 0 0 8px; color: var(--brown); }
.studio { display: flex; flex-direction: column; gap: 8px; flex: 1; min-height: 0; }
.studio-tabs { display: flex; gap: 6px; }
.studio-tabs .btn.tab { flex: 1; }
.studio-tabs .btn.tab.active, .tool-row .btn.tool.active { background: var(--blue); color: #fff; border-color: var(--blue-dark); box-shadow: 0 2px 0 var(--blue-dark); }
.studio-view {
  position: relative; flex: 1; min-height: 340px; border-radius: 14px; overflow: hidden; cursor: crosshair;
  background: radial-gradient(ellipse at 50% 35%, #4a6a8a 0%, #24303f 70%, #161c24 100%);
  box-shadow: inset 0 0 0 3px var(--brown);
}
.studio-view canvas { display: block; width: 100%; height: 100%; position: absolute; inset: 0; }
.studio-status { position: absolute; left: 10px; top: 8px; z-index: 2; color: #fff; font-size: .8rem; background: rgba(0,0,0,.45); padding: 2px 8px; border-radius: 8px; pointer-events: none; }
.studio-tools { display: flex; flex-direction: column; gap: 8px; }
.tool-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tool-row .btn.small { flex: 0 0 auto; }
.tool-row .size { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: .85rem; color: var(--brown); margin-left: auto; }
.palette { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(0,0,0,.25); cursor: pointer; padding: 0; box-shadow: inset 0 -3px 0 rgba(0,0,0,.18); }
.swatch:hover { transform: scale(1.12); }
.swatch.active { outline: 3px solid var(--blue); outline-offset: 2px; }
.custom-color { width: 34px; height: 30px; border: 2px solid var(--brown); border-radius: 8px; padding: 0; cursor: pointer; background: none; }
.studio-hint { font-size: .75rem; opacity: .7; }

/* ---------- salir / rendirse ---------- */
.quit-row { display: flex; gap: 6px; margin-top: 4px; }
.quit-row .btn.small { background: rgba(243,231,200,.85); }
.away-note { background: rgba(217,58,58,.18); border: 2px solid var(--red); border-radius: 10px; padding: 8px; font-size: .85rem; display: flex; flex-direction: column; gap: 6px; }

@media (max-width: 1000px) {
  .lobby-wrap { grid-template-columns: 1fr; }
  .studio-view { min-height: 300px; }
}

/* ---------- inicio de partida: dados ---------- */
.intro-block { position: fixed; inset: 0; z-index: 44; cursor: wait; }
.intro-caption {
  position: absolute; left: 50%; bottom: 10%; transform: translate(-50%, 10px); opacity: 0;
  transition: opacity .25s, transform .25s; text-align: center; pointer-events: none;
  background: linear-gradient(#f3e7c8, #e6d2a6); color: var(--ink); border: 4px solid var(--brown);
  border-radius: 18px; padding: 10px 26px; box-shadow: 0 8px 30px rgba(0,0,0,.5); max-width: 80%;
}
.intro-caption.show { opacity: 1; transform: translate(-50%, 0); }
.intro-caption b { display: block; font-family: 'Fredoka'; font-size: 1.7rem; color: var(--brown); }
.intro-caption span { display: block; font-size: 1rem; margin-top: 2px; }
.dice-num {
  position: absolute; transform: translate(-50%, -100%); text-align: center; pointer-events: none;
  font-family: 'Fredoka'; color: #fff; text-shadow: 0 2px 6px #000; animation: popIn .4s cubic-bezier(.2,1.6,.4,1) both;
}
.dice-num b { display: block; font-size: 2.6rem; line-height: 1; -webkit-text-stroke: 2px rgba(0,0,0,.5); }
.dice-num span { font-size: .85rem; background: rgba(0,0,0,.55); padding: 1px 8px; border-radius: 8px; }
.dice-num.me b { color: #ffd75a; }
.dice-num.opp b { color: #ff8a7a; }
.dice-num.win b { animation: winPulse .6s ease-in-out 3; }
.dice-num.lose { opacity: .55; }
@keyframes winPulse { 50% { transform: scale(1.35); text-shadow: 0 0 20px #ffd75a; } }

/* ---------- texto bajo la carta jugada ---------- */
.cast { grid-auto-flow: row; align-content: center; gap: 10px; }
.cast-info { text-align: center; max-width: min(520px, 90vw); animation: castIn .35s .1s cubic-bezier(.2,1.4,.4,1) both; --from: 0; }
.cast-info .cast-tag { position: static; margin: 0 0 4px; }
.cast-name { font-family: 'Fredoka'; font-weight: 700; font-size: 1.5rem; color: #fff; text-shadow: 0 2px 6px #000; }
.cast-text { display: inline-block; margin-top: 4px; padding: 6px 14px; border-radius: 12px; background: rgba(0,0,0,.72); color: var(--cream); font-size: 1.05rem; }
.cast.out .cast-info { animation: castOut .22s ease-in both; }

/* ---------- carteles grandes (combate, descanso, contrarrestar) ---------- */
.announce {
  position: fixed; left: 50%; top: 16%; transform: translateX(-50%); z-index: 55; pointer-events: none;
  text-align: center; padding: 12px 28px; border-radius: 18px; background: rgba(20,12,8,.82);
  border: 3px solid #ffd75a; box-shadow: 0 8px 30px rgba(0,0,0,.6);
  animation: anIn .35s cubic-bezier(.2,1.5,.4,1) both;
}
.announce.out { animation: anOut .35s ease-in both; }
.announce .an-title { font-family: 'Fredoka'; font-weight: 700; font-size: 2rem; color: #ffd75a; text-shadow: 0 3px 0 #2a1608; }
.announce .an-sub { margin-top: 4px; font-size: 1.15rem; color: var(--cream); }
.announce.fight { border-color: #ff6a1a; }
.announce.fight .an-title { color: #ffb347; }
.announce.counter { border-color: #b46bff; }
.announce.counter .an-title { color: #d6a8ff; }
.announce.rest { border-color: #8fe3ff; }
.announce.rest .an-title { color: #8fe3ff; }
.cb { font-family: 'Fredoka'; font-weight: 700; padding: 1px 8px; border-radius: 8px; white-space: nowrap; }
.cb.f { background: #7a2a12; }
.cb.d { background: #1b5f8f; }
.cb.x { background: #d93a3a; }
@keyframes anIn { from { transform: translateX(-50%) scale(.3); opacity: 0; } }
@keyframes anOut { to { transform: translateX(-50%) translateY(-30px); opacity: 0; } }

/* ---------- revelación de la carta de aventura ---------- */
.adv-reveal {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; align-content: center; gap: 14px;
  background: radial-gradient(circle at 50% 50%, rgba(30,15,5,.55), rgba(0,0,0,.88));
  animation: arFade .35s ease-out both; cursor: pointer; overflow: hidden; perspective: 1200px;
}
.adv-reveal.out { animation: arFadeOut .38s ease-in both; }
.ar-who { font-family: 'Fredoka'; font-weight: 600; font-size: 1.5rem; color: var(--cream); text-shadow: 0 2px 6px #000; }
.ar-card { position: relative; width: min(560px, 80vw, 62vh * 88 / 63); aspect-ratio: 88 / 63; transform-style: preserve-3d; transition: transform .52s cubic-bezier(.3,1.4,.5,1); }
.ar-card.flip { transform: rotateY(180deg) scale(1.08); }
.ar-face { position: absolute; inset: 0; border-radius: 18px; backface-visibility: hidden; box-shadow: 0 0 0 5px #fff, 0 20px 50px rgba(0,0,0,.7); }
.ar-back { background: linear-gradient(135deg, #2b86c5, #1b5f8f); display: grid; place-items: center; }
.ar-back img { width: 55%; filter: drop-shadow(0 4px 8px rgba(0,0,0,.5)); }
.ar-front { background: center / cover; transform: rotateY(180deg); }
.adv-reveal.luchar.revealed .ar-front { box-shadow: 0 0 0 5px #fff, 0 0 60px 20px rgba(255,106,26,.85), 0 0 140px 40px rgba(217,45,10,.55); }
.adv-reveal.mg.revealed .ar-front { box-shadow: 0 0 0 5px #fff, 0 0 60px 20px rgba(192,138,255,.85), 0 0 140px 40px rgba(255,215,90,.4); }
.ar-rays {
  position: absolute; left: 50%; top: 50%; width: 220vmax; height: 220vmax; margin: -110vmax 0 0 -110vmax; opacity: 0;
  background: repeating-conic-gradient(from 0deg, rgba(255,215,90,.22) 0deg 7deg, transparent 7deg 18deg);
  mask-image: radial-gradient(circle, #000 0%, transparent 45%); -webkit-mask-image: radial-gradient(circle, #000 0%, transparent 45%);
  transition: opacity .4s; animation: arSpin 14s linear infinite; pointer-events: none;
}
.adv-reveal.luchar .ar-rays { background: repeating-conic-gradient(from 0deg, rgba(255,106,26,.3) 0deg 7deg, transparent 7deg 18deg); }
.adv-reveal.revealed .ar-rays { opacity: 1; }
.ar-title, .ar-sub, .ar-skip { opacity: 0; text-align: center; padding: 0 16px; }
.ar-title { font-family: 'Fredoka'; font-weight: 700; font-size: clamp(2.2rem, 7vw, 4.6rem); line-height: 1; color: #ffd75a; -webkit-text-stroke: 3px #2a1608; text-shadow: 0 6px 0 #2a1608, 0 0 30px rgba(255,215,90,.6); }
.adv-reveal.luchar .ar-title { color: #ff7a2a; text-shadow: 0 6px 0 #2a1608, 0 0 40px rgba(255,80,20,.9); }
.ar-sub { font-size: 1.3rem; color: #fff; text-shadow: 0 2px 6px #000; }
.ar-skip { font-size: .8rem; color: var(--cream); }
.adv-reveal.revealed .ar-title { animation: arSlam .5s cubic-bezier(.2,1.6,.4,1) both; }
.adv-reveal.revealed .ar-sub { animation: arUp .4s .25s ease-out both; }
.adv-reveal.revealed .ar-skip { animation: arUp .4s .8s ease-out both; opacity: .6; }
@keyframes arFade { from { opacity: 0; } }
@keyframes arFadeOut { to { opacity: 0; transform: scale(1.05); } }
@keyframes arSpin { to { transform: rotate(360deg); } }
@keyframes arSlam { from { opacity: 0; transform: scale(3) rotate(-6deg); } to { opacity: 1; transform: none; } }
@keyframes arUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.adv-reveal.revealed .ar-skip { opacity: .6; }
body.shake-screen #game { animation: screenShake .5s; }
@keyframes screenShake { 15% { transform: translate(-10px, 4px); } 30% { transform: translate(9px, -6px); } 45% { transform: translate(-7px, 5px); } 60% { transform: translate(6px, -3px); } 80% { transform: translate(-3px, 2px); } }

/* ---------- te toca responder ---------- */
.respond {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); pointer-events: auto; z-index: 5;
  text-align: center; padding: 10px 18px; border-radius: 16px; background: rgba(20,12,30,.9);
  border: 3px solid #ffd75a; box-shadow: 0 0 24px rgba(255,215,90,.55); animation: respondPulse 1.4s ease-in-out infinite;
  max-width: min(520px, 92%);
}
.respond-title { font-family: 'Fredoka'; font-weight: 700; font-size: 1.25rem; color: #ffd75a; }
.respond-sub { font-size: .95rem; margin: 4px 0 8px; }
@keyframes respondPulse { 50% { box-shadow: 0 0 40px rgba(255,215,90,.9); } }
.prompt-card { margin: 8px auto 0; }

/* ================= Mesa 3D a pantalla completa + HUD ================= */
#game { display: block; position: fixed; inset: 0; height: auto; background: #1a120b; }
#stage { position: absolute; inset: 0; overflow: hidden; }
#stage .arena-canvas { cursor: grab; }
#stage .arena-canvas:active { cursor: grabbing; }

.plate {
  position: absolute; left: 14px; z-index: 20; width: 340px; pointer-events: auto;
  padding: 12px 16px 12px; border-radius: 18px; color: var(--cream);
  background: linear-gradient(160deg, rgba(74,48,26,.95), rgba(40,25,13,.95));
  border: 3px solid rgba(212,168,42,.65); box-shadow: 0 8px 26px rgba(0,0,0,.55);
  transition: box-shadow .3s, border-color .3s;
}
.plate.opp { top: 14px; }
.plate.me { bottom: 14px; }
.plate.active { border-color: #ffd75a; box-shadow: 0 0 0 3px rgba(255,215,90,.3), 0 0 30px rgba(255,201,60,.55); }
.plate-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.plate-name { font-family: 'Fredoka'; font-weight: 700; font-size: 1.55rem; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 2px 4px rgba(0,0,0,.6); }
.plate .turn-tag { background: var(--orange); color: #fff; font-family: 'Fredoka'; font-weight: 700; font-size: .9rem; padding: 3px 10px; border-radius: 9px; flex: none; }
.plate-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.plate-row.small { font-size: .95rem; opacity: .9; gap: 14px; margin-top: 8px; }
.plate .chip { display: inline-flex; align-items: center; gap: 6px; font-family: 'Fredoka'; font-weight: 700; font-size: 1.6rem; line-height: 1; padding: 5px 14px; border-radius: 12px; background: rgba(0,0,0,.35); box-shadow: inset 0 -3px 0 rgba(0,0,0,.25); }
.plate .chip i { font-style: normal; font-size: 1.15rem; }
.plate .chip.life { background: linear-gradient(180deg, #e2483a, #a8231a); color: #fff; border: 2px solid #ff9a8a; }
.plate .chip.mount { background: linear-gradient(180deg, #4f9a3c, #2d6620); color: #fff; border: 2px solid #9ee08a; }
.plate .chip.off { font-weight: 400; font-size: .95rem; opacity: .75; padding: 6px 10px; box-shadow: none; }
.plate .chip.sh { background: linear-gradient(180deg, #2a7cb8, #154f78); color: #fff; border: 2px solid #8fd0ff; }
.plate-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.plate .stat { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; align-items: center; column-gap: 8px; padding: 6px 12px; border-radius: 12px; border: 2px solid; }
.plate .stat-ico { grid-row: 1 / 3; font-size: 1.9rem; line-height: 1; }
.plate .stat-val { font-family: 'Fredoka'; font-weight: 700; font-size: 2rem; line-height: 1; }
.plate .stat-lbl { font-family: 'Fredoka'; font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; opacity: .9; }
.plate .stat.atk { background: linear-gradient(180deg, rgba(196,74,28,.55), rgba(110,34,10,.55)); border-color: #ff9a55; }
.plate .stat.atk .stat-val { color: #ffcf9a; }
.plate .stat.def { background: linear-gradient(180deg, rgba(40,110,170,.55), rgba(16,52,90,.55)); border-color: #7fc4ff; }
.plate .stat.def .stat-val { color: #cfe9ff; }
.plate-energy { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.plate-energy b { font-family: 'Fredoka'; color: #ffd75a; font-size: 1.4rem; min-width: 52px; }
.plate-energy .pips { display: flex; gap: 6px; }
.plate-energy .pips i { width: 20px; height: 20px; border-radius: 50%; background: rgba(0,0,0,.4); border: 2px solid rgba(255,215,90,.35); }
.plate-energy .pips i.on { background: radial-gradient(circle at 35% 35%, #fff4b0, #ffc93c 55%, #c98a00); border-color: #fff1a8; box-shadow: 0 0 8px rgba(255,201,60,.7); }

.turn-pill {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%); z-index: 20; pointer-events: none;
  font-family: 'Fredoka'; font-weight: 700; font-size: 1.2rem; padding: 6px 20px; border-radius: 999px;
  background: rgba(20,12,8,.78); border: 2px solid rgba(243,231,200,.35); white-space: nowrap;
}
.turn-pill.mine { background: linear-gradient(180deg, #f6a03a, #d9761a); color: #fff; border-color: #ffe0a0; box-shadow: 0 0 22px rgba(240,138,36,.6); }

#respond-box { position: absolute; top: 60px; left: 50%; transform: translateX(-50%); z-index: 21; width: min(460px, calc(100vw - 780px)); min-width: 260px; }
#respond-box .respond { padding: 8px 14px; }
#respond-box .respond-title { font-size: 1.05rem; }
#respond-box .respond-sub { font-size: .85rem; margin: 2px 0 6px; }
#respond-box .btn.big { font-size: 1.05rem; padding: .45em 1.2em; }
#respond-box .respond { position: static; transform: none; margin: 0 auto; max-width: none; }
#respond-box .respond.wait { animation: none; border-color: rgba(192,138,255,.6); box-shadow: none; padding: 7px 14px; font-size: .9rem; }

.cam-bar { position: absolute; right: 14px; bottom: 14px; z-index: 20; display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.cam-btn {
  font-family: 'Fredoka'; font-weight: 600; font-size: .85rem; cursor: pointer; padding: 5px 10px; border-radius: 10px;
  color: var(--cream); background: rgba(20,12,8,.7); border: 2px solid rgba(243,231,200,.25);
}
.cam-btn:hover { border-color: #ffd75a; color: #ffd75a; }
.cam-hint { font-size: .7rem; opacity: .55; max-width: 140px; line-height: 1.2; text-align: right; }

#panel {
  position: absolute; right: 14px; top: 14px; width: 240px; max-height: calc(100% - 140px); z-index: 20;
  display: flex; flex-direction: column; gap: 10px; padding: 10px; border-radius: 16px; border: 2px solid rgba(212,168,42,.45);
  background: linear-gradient(170deg, rgba(58,38,20,.9), rgba(30,19,10,.9)); box-shadow: 0 8px 28px rgba(0,0,0,.5);
  pointer-events: auto; overflow: hidden;
}
#preview { flex: none; min-height: 0; }
#preview .card.big { width: min(100%, 30vh * 63 / 88); height: auto; aspect-ratio: 63 / 88; margin: 0 auto; display: block; }
#preview .card.big.land { width: 100%; aspect-ratio: 88 / 63; }
#preview .preview-empty { padding: 10px; font-size: .78rem; }
#log-wrap { margin-top: auto; font-size: .8rem; }
#log-wrap summary { cursor: pointer; opacity: .75; font-family: 'Fredoka'; padding: 4px 2px; }
#log-wrap[open] #log { max-height: 30vh; }
#log { min-height: 0; max-height: 30vh; }

/* rótulo de la carta jugada (la carta vuela en 3D) */
.cast.caption { place-items: end center; align-content: end; padding-bottom: 120px; }
.cast.caption .cast-info { background: rgba(20,12,8,.82); border: 2px solid rgba(255,215,90,.55); border-radius: 16px; padding: 8px 18px 10px; }
.cast.caption.trap .cast-info { border-color: rgba(192,138,255,.8); }
.cast.caption .cast-text { background: none; padding: 0; }

@media (max-width: 900px) {
  #panel { width: 200px; }
  .cam-hint { display: none; }
  .plate { width: 260px; padding: 9px 12px; }
  .plate-name { font-size: 1.2rem; }
  .plate .chip { font-size: 1.2rem; }
  .plate .stat-val { font-size: 1.5rem; }
  .plate .stat-ico { font-size: 1.4rem; }
}

.announce.lifeloss { border-color: #b46bff; }
.announce.lifeloss .an-title { color: #ff9ad0; }

/* ---------- cartas jugadas (panel derecho) ---------- */
#feed-wrap { flex: 0 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 6px; }
.feed-title { font-family: 'Fredoka'; font-weight: 600; font-size: .8rem; opacity: .7; text-transform: uppercase; letter-spacing: .05em; }
#feed { display: flex; flex-direction: column; gap: 6px; overflow: auto; min-height: 0; }
.feed-empty { font-size: .78rem; opacity: .5; }
.feed-item { display: flex; gap: 8px; align-items: flex-start; padding: 5px; border-radius: 10px; background: rgba(0,0,0,.25); border: 2px solid transparent; cursor: help; }
.feed-item .feed-thumb { width: 38px; height: 53px; flex: none; border-radius: 4px; box-shadow: 0 0 0 1.5px #0d0905; }
.feed-item .feed-text { min-width: 0; }
.feed-who { font-size: .7rem; opacity: .75; }
.feed-name { font-family: 'Fredoka'; font-weight: 700; font-size: .88rem; line-height: 1.15; }
.feed-eff { font-size: .74rem; opacity: .85; line-height: 1.2; display: none; }
.feed-item.opp .feed-who { color: #ffb08a; }
.feed-item.me .feed-who { color: #9fd8ff; }
.feed-item.new { border-color: #ffd75a; background: rgba(255,215,90,.12); animation: feedIn .45s cubic-bezier(.2,1.4,.4,1); }
.feed-item.new .feed-thumb { width: 72px; height: 100px; }
.feed-item.new .feed-eff { display: block; }
.feed-item.new .feed-name { font-size: 1rem; }
@keyframes feedIn { from { transform: translateX(40px); opacity: 0; } }

.arena-overlay { transition: opacity .25s; }
.arena-overlay.hush { opacity: 0; }

/* ================= Escenario 3D compartido y lobby nuevo ================= */
#stage { position: fixed; inset: 0; z-index: 0; overflow: hidden; background: #1a120b; }
.screen { position: relative; z-index: 1; }
#game { position: fixed; inset: 0; background: transparent; pointer-events: none; }
#game > * { pointer-events: auto; }
#game > .turn-pill { pointer-events: none; }
#lobby {
  position: fixed; inset: 0; overflow: auto; padding: 0; display: block; background: none; pointer-events: none;
  --parch-1: #f1e4c4; --parch-2: #e2cfa1; --wood: #4a2d17; --wood-2: #6b4423; --gold: #d9b65a; --gold-d: #8a6a22; --ink-d: #3a2414;
}
#lobby > * { pointer-events: auto; }
#lobby > .lobby-grid { pointer-events: none; }
#lobby > .lobby-grid > * { pointer-events: auto; }
#lobby > .lobby-grid > .lobby-center { pointer-events: none; }
#lobby > .lobby-grid > .lobby-center > * { pointer-events: auto; }
#lobby::before { /* viñeta para que los paneles destaquen sobre el mundo */
  content: ''; position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 55%, rgba(0,0,0,0) 35%, rgba(10,6,2,.55) 100%);
}
.topbar { position: relative; display: flex; align-items: center; justify-content: space-between; padding: 14px 22px 0; pointer-events: none; }
.topbar > * { pointer-events: auto; }
.top-logo { width: min(250px, 40vw); filter: drop-shadow(0 6px 14px rgba(0,0,0,.55)); }

/* textura de pergamino (ruido SVG) */
.panel {
  position: relative; color: var(--ink-d); border-radius: 18px; padding: 16px 18px;
  background:
    url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .25 0 0 0 0 .12 0 0 0 .22 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
    radial-gradient(ellipse at 30% 20%, rgba(255,255,255,.35), transparent 60%),
    radial-gradient(ellipse at 80% 90%, rgba(120,80,30,.25), transparent 55%),
    linear-gradient(160deg, var(--parch-1), var(--parch-2));
  border: 5px solid var(--wood-2);
  box-shadow: inset 0 0 0 2px var(--gold), inset 0 0 28px rgba(110,70,20,.35), 0 0 0 2px var(--wood), 0 14px 36px rgba(0,0,0,.55);
}
.panel-title {
  font-family: 'Cinzel', serif; font-weight: 800; font-size: 1.25rem; letter-spacing: .04em; margin: 0 0 10px; text-align: center;
  color: var(--ink-d); text-shadow: 0 1px 0 rgba(255,255,255,.6);
}
.panel-title::after { content: ''; display: block; height: 2px; margin: 8px auto 0; width: 70%; background: linear-gradient(90deg, transparent, var(--gold-d), transparent); }
.sub-title { font-family: 'Cinzel', serif; font-weight: 600; font-size: .9rem; margin: 10px 0 6px; color: var(--wood-2); letter-spacing: .06em; text-transform: uppercase; }

.lobby-grid {
  position: relative; display: grid; grid-template-columns: minmax(300px, 360px) 1fr minmax(320px, 430px); gap: 22px;
  padding: 18px 22px 22px; min-height: calc(100vh - 110px); align-items: start;
}
.lobby-center { display: flex; flex-direction: column; align-items: center; justify-content: space-between; min-height: calc(100vh - 150px); gap: 18px; }

/* elegir general y montura */
.pick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.pick-card {
  position: relative; border: none; padding: 0; border-radius: 10px; cursor: pointer; background: none;
  aspect-ratio: 63 / 88; overflow: hidden; box-shadow: 0 0 0 2px var(--wood), 0 4px 10px rgba(0,0,0,.35); transition: transform .15s, box-shadow .15s;
}
.pick-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pick-card:hover { transform: translateY(-3px); }
.pick-card.sel { box-shadow: 0 0 0 3px #f39a1e, 0 0 0 6px #ffe27a, 0 0 18px rgba(255,170,30,.8); }
.pick-card .pick-name {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 4px 4px; font-family: 'Fredoka'; font-weight: 600; font-size: .78rem; color: #fff;
  background: linear-gradient(transparent, rgba(0,0,0,.85)); text-align: center; font-size: .62rem; line-height: 1.1;
}
.pick-card.locked { cursor: not-allowed; }
.pick-card.locked img { filter: grayscale(1) brightness(.45); }
.pick-card.locked::after { content: '🔒'; position: absolute; inset: 0; display: grid; place-items: center; font-size: 1.4rem; text-shadow: 0 2px 8px #000; }
.pick-card.locked .pick-name { color: #ffcf7a; }

/* jugar */
.play-box { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: auto; }
.btn-play {
  font-family: 'Cinzel', serif; font-weight: 800; font-size: 1.55rem; letter-spacing: .03em; cursor: pointer; min-width: 330px;
  padding: 14px 34px 12px; border-radius: 16px; display: flex; flex-direction: column; align-items: center; gap: 2px; transition: transform .1s, filter .15s;
}
.btn-play small { font-family: 'Open Sans', sans-serif; font-weight: 600; font-size: .8rem; letter-spacing: 0; opacity: .85; }
.btn-play:hover { filter: brightness(1.08); transform: translateY(-2px); }
.btn-play:active { transform: translateY(1px); }
.btn-play.gold {
  color: #3a2208; border: 3px solid #7a5512;
  background: linear-gradient(180deg, #ffe8a3 0%, #f2c14e 45%, #c98f22 100%);
  box-shadow: inset 0 2px 0 rgba(255,255,255,.7), inset 0 -3px 0 rgba(0,0,0,.18), 0 0 0 2px #3a2208, 0 10px 26px rgba(0,0,0,.5), 0 0 30px rgba(255,190,60,.35);
  text-shadow: 0 1px 0 rgba(255,255,255,.5);
}
.btn-play.wood {
  color: #f3e7c8; border: 3px solid #2e1a0c; font-size: 1.2rem; min-width: 280px;
  background: linear-gradient(180deg, #8a5a34, #5e3a1e);
  box-shadow: inset 0 2px 0 rgba(255,255,255,.18), inset 0 0 0 1px rgba(217,182,90,.5), 0 8px 20px rgba(0,0,0,.5);
}
.btn-play.small { font-size: 1.1rem; min-width: 0; width: 100%; padding: 10px; }
.btn-play:disabled { filter: grayscale(.7) brightness(.8); cursor: not-allowed; transform: none; }
.guest-name { color: #f3e7c8; font-weight: 600; text-shadow: 0 1px 4px #000; font-size: .9rem; }
.guest-name input { font: inherit; padding: .35em .7em; border-radius: 10px; border: 2px solid var(--wood-2); margin-left: 6px; background: #f6ecd2; }
#lobby .play-box .msg { color: #ffb4a8; text-shadow: 0 1px 4px #000; }

/* cuenta */
.account { display: flex; align-items: center; gap: 10px; }
.account .who { font-family: 'Cinzel', serif; font-weight: 800; color: #f3e7c8; text-shadow: 0 2px 6px #000; font-size: 1.1rem; }
.btn-top {
  font-family: 'Fredoka'; font-weight: 600; cursor: pointer; padding: 7px 14px; border-radius: 12px; color: #f3e7c8;
  background: linear-gradient(180deg, #7a4f2c, #4a2d17); border: 2px solid #2e1a0c; box-shadow: inset 0 0 0 1px rgba(217,182,90,.55), 0 4px 12px rgba(0,0,0,.45);
}
.btn-top.gold { color: #3a2208; background: linear-gradient(180deg, #ffe8a3, #e0aa3a); border-color: #7a5512; }

/* tarjeta de liga */
.league-card { width: min(460px, 100%); display: flex; gap: 14px; align-items: center; }
.league-emblem {
  width: 74px; height: 84px; flex: none; display: grid; place-items: center; font-size: 2rem;
  clip-path: polygon(50% 0, 100% 18%, 100% 70%, 50% 100%, 0 70%, 0 18%);
  background: radial-gradient(circle at 40% 30%, rgba(255,255,255,.7), transparent 45%), var(--lc, #c07a43);
}
.league-info { flex: 1; min-width: 0; }
.league-name { font-family: 'Cinzel', serif; font-weight: 800; font-size: 1.2rem; }
.league-rating { font-size: .9rem; opacity: .85; }
.league-bar { height: 10px; border-radius: 6px; background: rgba(0,0,0,.2); margin: 6px 0 4px; overflow: hidden; box-shadow: inset 0 1px 2px rgba(0,0,0,.3); }
.league-bar i { display: block; height: 100%; background: linear-gradient(90deg, #c98f22, #ffe27a); }
.league-next { font-size: .75rem; opacity: .75; }
.league-card .link { background: none; border: none; color: var(--wood-2); font-weight: 700; cursor: pointer; text-decoration: underline; padding: 0; font-size: .85rem; }

/* taller de pintura dentro del panel */
.studio-box .studio-view { min-height: 380px; border-radius: 12px; box-shadow: inset 0 0 0 2px var(--wood-2); }
.studio-note { font-size: .78rem; opacity: .8; margin: 8px 0 0; text-align: center; }

/* capas: buscar rival, cuenta, clasificación */
.overlay { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: rgba(10,6,2,.55); backdrop-filter: blur(2px); padding: 16px; }
.search-box, .auth-box, .rank-box { width: min(420px, 100%); text-align: center; }
.rank-box { width: min(560px, 100%); max-height: 86vh; overflow: auto; }
.close-x { position: absolute; right: 10px; top: 8px; background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--wood-2); }
.search-box h2 { font-family: 'Cinzel', serif; margin: 10px 0 4px; }
.search-ring { width: 74px; height: 74px; margin: 6px auto; border-radius: 50%; border: 6px solid rgba(138,106,34,.25); border-top-color: #c98f22; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.auth-tabs { display: flex; gap: 6px; margin: 4px 0 14px; }
.auth-tabs button { flex: 1; font-family: 'Cinzel', serif; font-weight: 800; padding: 8px; border-radius: 10px; cursor: pointer; border: 2px solid var(--wood-2); background: rgba(255,255,255,.35); color: var(--wood-2); }
.auth-tabs button.active { background: var(--wood-2); color: #f3e7c8; }
#auth-form label { display: block; text-align: left; font-weight: 600; font-size: .9rem; margin: 8px 0; }
#auth-form input { display: block; width: 100%; margin-top: 4px; font: inherit; padding: .55em .8em; border-radius: 10px; border: 2px solid var(--wood-2); background: #fbf4e2; }
.auth-why { font-size: .8rem; margin-top: 10px; }
.rank-leagues { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 10px; }
.rank-leagues span { font-size: .75rem; font-weight: 700; padding: 2px 8px; border-radius: 8px; color: #2a1608; }
.rank-list { list-style: none; padding: 0; margin: 0; text-align: left; }
.rank-list li { display: grid; grid-template-columns: 34px 1fr auto auto; gap: 10px; align-items: center; padding: 6px 8px; border-bottom: 1px solid rgba(110,70,20,.2); }
.rank-list li.me { background: rgba(255,200,80,.3); border-radius: 8px; }
.rank-list .pos { font-family: 'Cinzel', serif; font-weight: 800; text-align: center; }
.rank-list .lg { font-size: .72rem; font-weight: 700; padding: 1px 7px; border-radius: 8px; color: #2a1608; }

/* resultado de liga al acabar una partida online */
.rank-result { margin: 8px 0 12px; font-size: 1.05rem; }
.rank-result b.up { color: #2e8b3a; }
.rank-result b.down { color: #c0392b; }

@media (max-width: 1100px) {
  .lobby-grid { grid-template-columns: 1fr; }
  .lobby-center { min-height: 0; order: -1; }
  .btn-play { min-width: 0; width: min(420px, 100%); }
}

/* ================= Publicidad del juego físico ================= */
.top-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.btn-buy {
  font-family: 'Fredoka'; font-weight: 700; font-size: 1.05rem; text-decoration: none; white-space: nowrap;
  padding: 9px 18px; border-radius: 14px; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.45);
  background: linear-gradient(180deg, #ff9b3d, #e2541c); border: 3px solid #fff1c9;
  box-shadow: 0 0 0 2px #7a2c08, 0 6px 16px rgba(0,0,0,.45), 0 0 22px rgba(255,140,40,.55);
  animation: buyPulse 2.4s ease-in-out infinite;
}
.btn-buy:hover { filter: brightness(1.1); animation-play-state: paused; transform: translateY(-1px); }
@keyframes buyPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }

.lobby-side { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.promo-card {
  position: relative; display: block; text-decoration: none; color: #fff; border-radius: 18px; overflow: hidden;
  background: linear-gradient(170deg, #2f8fd0 0%, #1d5f9a 55%, #173f6b 100%);
  border: 4px solid #ffd75a; box-shadow: 0 0 0 2px #4a2d17, 0 14px 36px rgba(0,0,0,.55), 0 0 30px rgba(255,200,60,.35);
  transition: transform .15s, box-shadow .15s;
}
.promo-card:hover { transform: translateY(-3px) rotate(-.4deg); box-shadow: 0 0 0 2px #4a2d17, 0 18px 40px rgba(0,0,0,.6), 0 0 40px rgba(255,200,60,.6); }
.promo-ribbon {
  position: absolute; z-index: 2; top: 14px; right: -38px; transform: rotate(35deg); width: 160px; text-align: center;
  font-family: 'Fredoka'; font-weight: 700; font-size: .78rem; letter-spacing: .04em; text-transform: uppercase;
  padding: 4px 0; color: #3a2208; background: linear-gradient(180deg, #ffe8a3, #f2b630); box-shadow: 0 3px 8px rgba(0,0,0,.4);
}
.promo-photo { aspect-ratio: 16 / 9; overflow: hidden; border-bottom: 3px solid #ffd75a; }
.promo-photo img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 40%; display: block; transition: transform .4s; }
.promo-card:hover .promo-photo img { transform: scale(1.05); }
.promo-body { padding: 10px 14px 14px; text-align: center; }
.promo-kicker { font-family: 'Fredoka'; font-weight: 600; font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: #bfe6ff; }
.promo-title { font-family: 'Fredoka'; font-weight: 700; font-size: 1.5rem; line-height: 1.1; margin: 4px 0 8px; color: #ffe27a; text-shadow: 0 2px 0 #0d3357, 0 3px 10px rgba(0,0,0,.5); }
.promo-feats { list-style: none; padding: 0; margin: 0 0 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 8px; font-size: .82rem; font-weight: 600; text-align: left; }
.promo-feats li { background: rgba(0,0,0,.22); border-radius: 8px; padding: 3px 7px; white-space: nowrap; }
.promo-cta {
  display: block; font-family: 'Fredoka'; font-weight: 700; font-size: 1.2rem; padding: 9px 12px; border-radius: 12px;
  color: #fff; background: linear-gradient(180deg, #ff9b3d, #e2541c); border: 2px solid #fff1c9; box-shadow: 0 4px 0 #8a3209, 0 6px 14px rgba(0,0,0,.35);
  text-shadow: 0 1px 2px rgba(0,0,0,.45);
}
.promo-card:hover .promo-cta { filter: brightness(1.1); }

/* buscando rival */
.promo-mini {
  display: flex; gap: 12px; align-items: center; margin-top: 16px; padding: 10px; border-radius: 12px; text-align: left;
  text-decoration: none; color: var(--ink-d); font-size: .85rem; line-height: 1.3;
  background: rgba(255,255,255,.45); border: 2px dashed var(--gold-d);
}
.promo-mini img { width: 96px; height: 64px; object-fit: cover; border-radius: 8px; flex: none; box-shadow: 0 2px 6px rgba(0,0,0,.3); }
.promo-mini b { display: block; font-family: 'Fredoka'; }
.promo-mini u { color: #c2511a; font-weight: 700; }
.promo-mini:hover { background: rgba(255,255,255,.7); }

/* partida: enlace fijo y discreto en el panel derecho */
.panel-buy { flex: none; display: block; text-align: center; font-family: 'Fredoka'; font-weight: 600; font-size: .8rem; text-decoration: none;
  color: #ffd75a; padding: 5px 8px; border-radius: 10px; border: 1px solid rgba(255,215,90,.35); background: rgba(0,0,0,.2); opacity: .8; }
.panel-buy:hover { opacity: 1; background: rgba(255,215,90,.12); }

/* partida: aviso que aparece de vez en cuando (solo en el turno del rival) */
.promo-pop {
  position: absolute; left: 14px; top: 50%; z-index: 19; width: 340px; transform: translateY(-50%);
  border-radius: 16px; overflow: hidden; border: 3px solid #ffd75a;
  background: linear-gradient(160deg, rgba(36,110,170,.96), rgba(20,60,104,.96)); box-shadow: 0 10px 30px rgba(0,0,0,.55);
  animation: promoIn .5s cubic-bezier(.2,1.3,.4,1);
}
.promo-pop.out { animation: promoOut .35s ease-in forwards; }
@keyframes promoIn { from { transform: translate(-120%, -50%); opacity: 0; } to { transform: translate(0, -50%); opacity: 1; } }
@keyframes promoOut { to { transform: translate(-120%, -50%); opacity: 0; } }
.promo-pop a { display: grid; grid-template-columns: 104px 1fr; gap: 6px 12px; padding: 10px 12px; color: #fff; text-decoration: none; align-items: center; }
.promo-pop img { grid-row: 1 / 3; width: 104px; height: 70px; object-fit: cover; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,.4); }
.promo-pop-text { font-size: .82rem; line-height: 1.25; padding-right: 14px; }
.promo-pop-text b { display: block; font-family: 'Fredoka'; font-size: 1rem; color: #ffe27a; }
.promo-pop-cta { justify-self: start; font-family: 'Fredoka'; font-weight: 700; font-size: .85rem; padding: 4px 12px; border-radius: 10px;
  background: linear-gradient(180deg, #ff9b3d, #e2541c); border: 2px solid #fff1c9; }
.promo-pop a:hover .promo-pop-cta { filter: brightness(1.12); }
.promo-x { position: absolute; top: 4px; right: 6px; z-index: 1; background: none; border: none; color: #fff; opacity: .7; font-size: .95rem; cursor: pointer; }
.promo-x:hover { opacity: 1; }

/* ventana de fin de partida */
.promo-end {
  display: flex; gap: 12px; align-items: center; margin-top: 14px; padding: 10px 12px; border-radius: 12px; text-align: left; text-decoration: none;
  color: #fff; background: linear-gradient(160deg, #2f8fd0, #1d5f9a); border: 2px solid #ffd75a; font-size: .85rem; line-height: 1.3;
}
.promo-end img { width: 110px; height: 72px; object-fit: cover; border-radius: 8px; flex: none; }
.promo-end b { display: block; font-family: 'Fredoka'; font-size: 1.05rem; color: #ffe27a; }
.promo-end .promo-cta { display: inline-block; font-size: .9rem; padding: 4px 12px; margin-top: 6px; box-shadow: 0 3px 0 #8a3209; }

@media (max-width: 1100px) {
  .btn-buy { font-size: .9rem; padding: 7px 12px; }
}
@media (max-width: 900px) {
  .promo-pop { width: 260px; }
  .promo-pop a { grid-template-columns: 1fr; }
  .promo-pop img { display: none; }
  .btn-buy { animation: none; }
}
@media (prefers-reduced-motion: reduce) {
  .btn-buy, .promo-pop, .promo-pop.out { animation: none; }
}
@media (max-height: 980px) and (min-width: 1101px) {
  .lobby-side { gap: 12px; }
  .promo-photo { aspect-ratio: 5 / 2; }
  .promo-feats { display: none; }
  .promo-title { font-size: 1.3rem; margin: 2px 0 6px; }
  .promo-body { padding: 6px 12px 10px; }
  .promo-cta { font-size: 1.05rem; padding: 6px 10px; }
}
