/* Hexagonia — estilos */
:root {
  --ocean: #0b3550;
  --ocean-2: #072233;
  --panel: #fbf5e9;
  --panel-2: #f3e9d6;
  --panel-3: #e6d8bc;
  --ink: #2b241e;
  --muted: #7b6d5f;
  --line: #dccfb4;
  --accent: #de6530;
  --accent-2: #b94c1b;
  --gold: #f2b544;
  --good: #2e7d32;
  --bad: #c62828;
  --warn-ink: #7a4800;
  --warn-bg: #fff3d1;
  --warn-line: #efd38a;
  --sel-bg: #ffe6d6;
  --off-bg: #f8d9d9;
  --input-bg: #fff;
  --bar: rgba(4, 22, 34, .58);
  --shadow: 0 10px 30px rgba(0, 0, 0, .28);
  --radius: 14px;
  --font: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display: 'Baloo 2', 'Nunito', system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --panel: #27211c;
    --panel-2: #322b24;
    --panel-3: #43392f;
    --ink: #f4ecdf;
    --muted: #b8a993;
    --line: #4b4137;
    --warn-ink: #ffd88a;
    --warn-bg: #3d2f12;
    --warn-line: #6b5420;
    --sel-bg: #4a2d1e;
    --off-bg: #4a2323;
    --input-bg: #1d1915;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --panel: #27211c; --panel-2: #322b24; --panel-3: #43392f; --ink: #f4ecdf; --muted: #b8a993; --line: #4b4137;
  --warn-ink: #ffd88a; --warn-bg: #3d2f12; --warn-line: #6b5420; --sel-bg: #4a2d1e; --off-bg: #4a2323; --input-bg: #1d1915;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.4;
  color: var(--ink);
  background-color: var(--ocean);
  background-image: radial-gradient(ellipse at 50% 30%, #155d86 0%, var(--ocean) 55%, var(--ocean-2) 100%);
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
button { font-family: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.warn { color: var(--warn-ink); background: var(--warn-bg); border: 1px solid var(--warn-line); padding: 8px 10px; border-radius: 10px; margin: 10px 0 0; }
svg.defs { position: absolute; width: 0; height: 0; overflow: hidden; }

.screen { position: fixed; inset: 0; display: none; overflow-y: auto; }
.screen.active { display: block; }

/* ---------- botones y campos ---------- */
.btn {
  font: 700 17px var(--font); color: var(--ink); background: var(--panel); border: 2px solid var(--line);
  border-radius: 12px; padding: 10px 16px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  box-shadow: 0 2px 0 var(--line); transition: transform .12s ease-out, background .15s, border-color .15s; white-space: nowrap; min-height: 48px;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:active:not(:disabled) { transform: translateY(1px); box-shadow: 0 1px 0 var(--line); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent-2); color: #fff; box-shadow: 0 3px 0 var(--accent-2); }
.btn.primary:hover:not(:disabled) { background: #ea7240; border-color: var(--accent-2); }
.btn.big { font-size: 19px; padding: 13px 22px; min-height: 56px; }
.btn.sm { font-size: 15px; padding: 5px 12px; min-height: 38px; border-radius: 10px; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 12px; border: 0; background: rgba(255, 255, 255, .13); color: #fff;
  font-size: 21px; cursor: pointer; display: inline-grid; place-items: center; position: relative; flex: none;
}
.icon-btn:hover { background: rgba(255, 255, 255, .24); }
.link { background: none; border: 0; color: var(--accent); font: 700 14px var(--font); cursor: pointer; text-decoration: underline; padding: 4px; }
input, select {
  font: 600 17px var(--font); color: var(--ink); background: var(--input-bg); border: 2px solid var(--line);
  border-radius: 12px; padding: 10px 13px; min-height: 50px; width: 100%;
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(222, 101, 48, .22); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ---------- textos con fichas e íconos ---------- */
.pn {
  display: inline-block; padding: 0 7px; border-radius: 99px; font-weight: 800; font-size: .92em; line-height: 1.5;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .2); white-space: nowrap; max-width: 11em; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom;
}
.ico { width: 1.25em; height: 1.25em; vertical-align: -.3em; display: inline-block; flex: none; }
.ico.c { width: 18px; height: 18px; margin: 0 -1px; }
.rq { white-space: nowrap; font-weight: 800; }
.dv { white-space: nowrap; }

/* ---------- inicio ---------- */
.home-wrap { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; gap: 14px; }
.home-card { width: 100%; max-width: 470px; background: var(--panel); border-radius: 22px; padding: 26px 22px; box-shadow: var(--shadow); }
.logo { display: flex; align-items: center; justify-content: center; gap: 12px; }
.logo-mark { width: 58px; height: 50px; flex: none; }
.logo h1 { font: 900 44px/1 'Cinzel', var(--display); margin: 0; letter-spacing: -.5px; }
.tagline { text-align: center; color: var(--muted); margin: 10px 0 18px; }
.tagline b { color: var(--ink); }
.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-weight: 800; font-size: 12px; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .05em; }
.join-hint { margin: -2px 0 12px; color: var(--accent-2); font-weight: 700; }
.join-hint:empty { display: none; }
.home-actions { display: grid; gap: 10px; }
.join-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
#in-code { text-transform: uppercase; letter-spacing: .3em; font-weight: 800; text-align: center; }
#scr-home.invited .home-actions { display: flex; flex-direction: column-reverse; }
#scr-home.invited #btn-create { background: var(--panel); color: var(--ink); border-color: var(--line); box-shadow: 0 2px 0 var(--line); font-size: 17px; min-height: 48px; }
#scr-home.invited #btn-join { background: var(--accent); color: #fff; border-color: var(--accent-2); box-shadow: 0 3px 0 var(--accent-2); }
.recent-box h3 { font: 800 12px var(--font); text-transform: uppercase; color: var(--muted); margin: 18px 0 6px; letter-spacing: .05em; }
.recent {
  display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; width: 100%; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin-bottom: 6px; cursor: pointer; font: 600 14px var(--font); color: var(--ink); text-align: left;
}
.recent:hover { border-color: var(--accent); }
.recent b { letter-spacing: .15em; }
.recent small { color: var(--muted); }
.home-links { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px 18px; margin-top: 12px; }
.home-foot { color: rgba(255, 255, 255, .72); font-size: 13px; text-align: center; max-width: 420px; margin: 0; }

/* ---------- espera ---------- */
#scr-wait.active { display: flex; align-items: center; justify-content: center; padding: 16px; }
.wait-card { background: var(--panel); border-radius: 20px; padding: 28px 24px; max-width: 440px; width: 100%; text-align: center; box-shadow: var(--shadow); }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 5px solid var(--panel-3); border-top-color: var(--accent); margin: 0 auto 14px; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.wait-actions { display: flex; gap: 8px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }

/* ---------- sala ---------- */
.lobby { max-width: 980px; margin: 0 auto; padding: 18px 16px 40px; display: grid; gap: 14px; }
.lobby-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: #fff; }
.eyebrow { font-weight: 800; text-transform: uppercase; font-size: 12px; letter-spacing: .14em; opacity: .75; }
.code { font: 800 54px/1 var(--display); letter-spacing: .14em; margin: 0; }
.card { background: var(--panel); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 8px; font: 800 21px var(--display); }
.card > p { margin: 0 0 10px; }
.invite-row { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; }
.lobby-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.lobby-players { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 6px; }
.lobby-players li { display: flex; align-items: center; gap: 8px; background: var(--panel-2); border-radius: 10px; padding: 8px 10px; min-height: 48px; }
.lobby-players li.muted { background: none; min-height: 0; padding: 0 4px; }
.sw { width: 18px; height: 18px; border-radius: 50%; border: 2px solid; flex: none; }
.tag { font-size: 12px; font-weight: 800; padding: 2px 7px; border-radius: 99px; background: var(--panel-3); color: var(--muted); text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
.tag.me { background: var(--gold); color: #3a2a00; }
.tag.off { background: var(--off-bg); color: var(--bad); }
.tag.crown { background: none; padding: 0; font-size: 13px; }
.lobby-players .x { margin-left: auto; border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 16px; width: 32px; height: 32px; border-radius: 8px; }
.lobby-players .x:hover { background: var(--panel-3); color: var(--bad); }
.color-pick { border-top: 1px solid var(--line); padding-top: 10px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.swatch { width: 40px; height: 40px; border-radius: 50%; border: 3px solid; cursor: pointer; padding: 0; }
.swatch.on { outline: 3px solid var(--accent); outline-offset: 2px; }
.swatch:disabled { opacity: .22; cursor: not-allowed; }
.settings { display: grid; gap: 10px; }
.set { display: grid; grid-template-columns: 1fr 1.3fr; align-items: center; gap: 10px; }
.set > span { font-weight: 700; }
.set small { display: block; font-weight: 600; color: var(--muted); font-size: 12px; }
.set > b { text-align: right; }
.set.chk input { width: 24px; height: 24px; min-height: 0; justify-self: end; accent-color: var(--accent); }
.set-note { margin: -6px 0 0; font-size: 12px; color: var(--muted); text-align: right; }
.lobby-actions { text-align: center; }
.lobby-actions .btn { min-width: 260px; }
#lobby-wait { color: rgba(255, 255, 255, .88); margin: 10px 0 0; }
.lobby-chat .chat-list { max-height: 190px; min-height: 40px; }
.lobby-foot { display: flex; justify-content: center; gap: 18px; }
.lobby-foot .link { color: #ffd4bf; }

.net-status { font-size: 12px; font-weight: 800; padding: 4px 10px; border-radius: 99px; background: rgba(255, 255, 255, .16); color: #fff; white-space: nowrap; }
.net-status[data-s="online"] { background: #2e7d32; }
.net-status[data-s="connecting"], .net-status[data-s="reconnecting"], .net-status[data-s="id-wait"], .net-status[data-s="no-host"] { background: #b46a00; }
.net-status[data-s="offline"] { background: #5b6770; }
.net-status.dot { width: 12px; height: 12px; padding: 0; display: inline-block; flex: none; }
#btn-add-bot { margin: -4px 0 12px; }

/* ---------- chat ---------- */
.chat-list { overflow-y: auto; display: grid; gap: 6px; align-content: start; padding: 4px 2px; }
.cm { font-size: 16px; line-height: 1.4; overflow-wrap: anywhere; }
.chat-form { display: grid; grid-template-columns: 1fr auto; gap: 6px; margin-top: 8px; }
.chat-form input { min-height: 38px; padding: 6px 10px; font-size: 15px; }

/* ---------- partida: estructura ---------- */
#scr-game { overflow: hidden; }
#scr-game.active { display: grid; }
#scr-game {
  grid-template-columns: minmax(0, 1fr) 390px;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  grid-template-areas: "top top" "board players" "board side" "hand side";
}
.g-top {
  grid-area: top; display: flex; align-items: center; gap: 12px; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top));
  color: #fff; background: var(--bar); min-width: 0;
}
.g-brand { display: flex; align-items: baseline; gap: 8px; flex: none; }
.g-logo { font: 900 23px 'Cinzel', var(--display); }
.g-code { font-size: 12px; opacity: .72; font-weight: 800; letter-spacing: .1em; }
.g-turn { flex: 1; min-width: 0; text-align: center; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-turn .muted { color: rgba(255, 255, 255, .7); }
.g-tools { display: flex; align-items: center; gap: 6px; flex: none; }
.g-timer { font-weight: 800; background: rgba(255, 255, 255, .16); padding: 4px 10px; border-radius: 99px; font-variant-numeric: tabular-nums; }
.g-timer.low { background: var(--bad); animation: blink 1s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .55; } }
.badge {
  position: absolute; top: -4px; right: -4px; background: var(--bad); color: #fff; font: 800 10px var(--font); font-style: normal;
  min-width: 17px; height: 17px; border-radius: 99px; display: grid; place-items: center; padding: 0 4px;
}
.tab .badge { position: static; display: inline-grid; margin-left: 4px; }
.g-players { grid-area: players; padding: 10px 10px 4px; display: grid; gap: 6px; max-height: 46vh; overflow-y: auto; }
.g-board { grid-area: board; position: relative; min-height: 0; min-width: 0; overflow: hidden; }
.g-side {
  grid-area: side; display: flex; flex-direction: column; min-height: 0; margin: 4px 10px 10px; background: var(--panel);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.g-hand {
  grid-area: hand; padding: 8px 10px; padding-bottom: max(8px, env(safe-area-inset-bottom)); background: var(--bar);
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap; min-width: 0;
}

/* ---------- jugadores ---------- */
.pl {
  display: flex; gap: 10px; align-items: flex-start; background: var(--panel); border-radius: 12px; padding: 8px 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .18); border: 2px solid transparent; transition: border-color .2s, box-shadow .2s;
}
.pl.active { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(242, 181, 68, .35), 0 2px 8px rgba(0, 0, 0, .18); }
.pl.off { opacity: .72; }
.pl-dot { width: 26px; height: 26px; border-radius: 6px; border: 2px solid; flex: none; margin-top: 2px; }
.pl-body { min-width: 0; flex: 1; }
.pl-top { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.pl-name { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 11em; }
.pl-stats { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 15px; font-weight: 700; margin-top: 2px; white-space: nowrap; }
.st.vp { color: var(--accent); font-weight: 800; }
.st.risk { color: var(--bad); }
.st small { color: var(--muted); margin-left: 2px; }
.pl-badges { display: flex; gap: 4px; flex-wrap: wrap; }
.pl-badges:empty { display: none; }
.bdg { font-size: 12px; font-weight: 800; padding: 1px 8px; border-radius: 99px; margin-top: 4px; white-space: nowrap; }
.bdg.r40 { background: #3a3a3a; color: #fff; }
.bdg.fm { background: #1f4f7a; color: #fff; }
.bdg.wait { background: #fde2a6; color: #6b4300; }

/* ---------- tablero ---------- */
#board { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; display: block;
  /* Se mueve como una imagen ya dibujada mientras se arrastra o se hace zoom (ver BoardView.moveVB). */
  overflow: visible; transform-origin: 0 0; will-change: transform; }
#board.picking { cursor: default; }
.sea-hex { fill: #17618c; stroke: #2a80b2; stroke-width: 3; opacity: .5; }
.shore { fill: #e7d3a0; stroke: #d2b878; stroke-width: 3; }
.tile-bg { stroke: rgba(50, 35, 20, .38); stroke-width: 3; }
.tok-bg { fill: #f8efd9; stroke: #6b5332; stroke-width: 3; }
.tok-n { font-family: var(--display); font-weight: 800; font-size: 30px; text-anchor: middle; fill: #3a2c1c; }
.pip { fill: #3a2c1c; }
.tok.red .tok-n, .tok.red .pip { fill: #c62828; }
.tok.hot .tok-bg { animation: hot .45s ease-in-out 5 alternate; }
@keyframes hot { to { fill: #ffd76a; stroke: #e07b00; stroke-width: 7; } }
.tok.blocked .tok-bg { fill: #b9ab94; }
.robbed { fill: rgba(16, 10, 6, .42); pointer-events: none; }
.pier { stroke: #7a5634; stroke-width: 6; stroke-linecap: round; }
.port-bg { fill: #fff8e7; stroke: #7a5634; stroke-width: 3; }
.port-t { font-family: var(--font); font-weight: 800; font-size: 13px; text-anchor: middle; fill: #4a3520; }
.port-t.big { font-size: 17px; }
.road-o { stroke-width: 20; stroke-linecap: round; }
.road-f { stroke-width: 12; stroke-linecap: round; }
.bld path { stroke-width: 3; stroke-linejoin: round; }
.fresh { animation: fresh .55s ease-in-out 4 alternate; }
@keyframes fresh { from { opacity: .3; } to { opacity: 1; } }
.hl-v { fill: #fffbe9; stroke: #f2b544; stroke-width: 5; pointer-events: none; animation: pulse 1s ease-in-out infinite alternate; }
.hl-e { stroke: #fff6d6; stroke-width: 10; stroke-linecap: round; stroke-dasharray: 10 8; pointer-events: none; animation: pulse 1s ease-in-out infinite alternate; }
@keyframes pulse { from { opacity: .45; } to { opacity: 1; } }
.hit { fill: transparent; stroke: none; cursor: pointer; pointer-events: all; }
.hit-e { stroke: transparent; stroke-width: 34; stroke-linecap: round; pointer-events: stroke; }
.spot-v:hover .hl-v { fill: #f2b544; opacity: 1; }
.spot-e:hover .hl-e { stroke: #f2b544; opacity: 1; }
.hl-h { fill: rgba(255, 196, 60, .38); stroke: #ffd24d; stroke-width: 9; stroke-dasharray: 22 10; cursor: pointer; animation: hlRob 1s ease-in-out infinite alternate; }
@keyframes hlRob { from { fill-opacity: .45; stroke-opacity: .6; } to { fill-opacity: 1; stroke-opacity: 1; } }
.hl-h:hover, .hl-h.sel { fill: rgba(255, 170, 30, .62); stroke: #fff; }
.ghost { opacity: .85; pointer-events: none; animation: pulse .6s ease-in-out infinite alternate; }
.robber { pointer-events: none; }

.hint {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%); background: var(--panel); color: var(--ink);
  border-radius: 99px; padding: 6px 8px 6px 16px; display: flex; gap: 8px; align-items: center; box-shadow: var(--shadow);
  font-weight: 700; max-width: calc(100% - 20px); z-index: 5; min-height: 46px;
}
.hint.mine { background: var(--gold); color: #2b1d00; }
.hint:empty { display: none; }
.hint > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 8px; }
.hint .btn { flex: none; }
.dice { position: absolute; top: 60px; right: 12px; display: flex; gap: 8px; align-items: center; z-index: 4; pointer-events: none; }
.dnum {
  min-width: 56px; height: 56px; padding: 0 10px; border-radius: 13px; background: #fffdf7; color: #2b241e; text-align: center;
  font: 800 34px/56px var(--display); box-shadow: 0 3px 0 #c9bba0, 0 4px 10px rgba(0, 0, 0, .3);
}
.dnum.hot { color: #c62828; }
.dnum.seven { background: #3a2c1c; color: #ffd0c8; box-shadow: 0 3px 0 #1d150d, 0 4px 10px rgba(0, 0, 0, .3); }
/* Mientras ruedan los dados la suma no se ve (así nunca aparece un número con otro color): cae al final. */
.dice.rolling .dnum { opacity: 0; transform: scale(.4); }
.dice.landed .dnum { animation: dnumPop .5s cubic-bezier(.2, 1.5, .4, 1); }
@keyframes dnumPop { 0% { opacity: 0; transform: scale(.4); } 60% { opacity: 1; } 100% { opacity: 1; transform: scale(1); } }
/* Los dados: cubos de verdad (seis caras con sus puntos) que giran en 3D con la placa de video. */
.die { --s: 38px; position: relative; flex: none; width: var(--s); height: var(--s); perspective: 240px; }
.die .cube { position: absolute; inset: 0; transform-style: preserve-3d; }
.die .f {
  position: absolute; inset: 0; display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); padding: 13%; border-radius: 21%;
  background: linear-gradient(150deg, #fffef9, #f1e7d1); box-shadow: inset 0 0 0 1px rgba(90, 66, 34, .14), inset 0 -2px 5px rgba(130, 100, 60, .22);
  backface-visibility: hidden; -webkit-backface-visibility: hidden; outline: 1px solid transparent; /* bordes suaves al girar */
}
.die .f i { width: 74%; height: 74%; place-self: center; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #4a3d31, #1f1813 70%); }
.die .p1 { grid-area: 1 / 1; } .die .p3 { grid-area: 1 / 3; } .die .p4 { grid-area: 2 / 1; } .die .p5 { grid-area: 2 / 2; }
.die .p6 { grid-area: 2 / 3; } .die .p7 { grid-area: 3 / 1; } .die .p9 { grid-area: 3 / 3; }
.die .f1 { transform: translateZ(calc(var(--s) / 2)); }
.die .f6 { transform: rotateY(180deg) translateZ(calc(var(--s) / 2)); }
.die .f2 { transform: rotateY(90deg) translateZ(calc(var(--s) / 2)); }
.die .f5 { transform: rotateY(-90deg) translateZ(calc(var(--s) / 2)); }
.die .f3 { transform: rotateX(90deg) translateZ(calc(var(--s) / 2)); }
.die .f4 { transform: rotateX(-90deg) translateZ(calc(var(--s) / 2)); }
/* Relleno de adentro: tapa los huecos de las esquinas redondeadas cuando el dado está de canto. */
.die .core { position: absolute; inset: 1px; border-radius: 12%; background: #e3d5b8; outline: 1px solid transparent; }
.die .core.cx { transform: rotateX(90deg); }
.die .core.cy { transform: rotateY(90deg); }
/* Cara que queda arriba (de frente) para cada número. */
.die[data-v="2"] .cube { transform: rotateY(-90deg); }
.die[data-v="3"] .cube { transform: rotateX(-90deg); }
.die[data-v="4"] .cube { transform: rotateX(90deg); }
.die[data-v="5"] .cube { transform: rotateY(90deg); }
.die[data-v="6"] .cube { transform: rotateY(180deg); }
.die .dsh {
  position: absolute; left: 2%; top: 14%; width: 104%; height: 100%; border-radius: 30%;
  background: radial-gradient(closest-side, rgba(0, 0, 0, .42), rgba(0, 0, 0, .26) 62%, rgba(0, 0, 0, 0));
}
.zoom { position: absolute; right: 10px; bottom: 10px; display: grid; gap: 6px; z-index: 4; }
.zoom .icon-btn { background: var(--bar); }
.bank-info {
  position: absolute; left: 10px; bottom: 10px; z-index: 3; display: flex; gap: 8px; align-items: center; font-size: 13px; font-weight: 800;
  color: #fff; background: var(--bar); padding: 5px 10px; border-radius: 10px; flex-wrap: wrap; max-width: calc(100% - 80px);
}
.bank-info .muted { color: rgba(255, 255, 255, .7); }
.bq { white-space: nowrap; }
.offer {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 56px; width: min(640px, calc(100% - 20px)); background: var(--panel);
  border-radius: 14px; padding: 10px 12px; box-shadow: var(--shadow); z-index: 6; border: 2px solid var(--gold); max-height: 55%; overflow-y: auto;
}
.of-head { font-weight: 700; }
.of-st { font-size: 16px; margin-top: 4px; }
.of-st.yes { color: var(--good); font-weight: 700; }
.of-st.no { color: var(--muted); }
.of-act { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.resp { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; font-size: 16px; }
.resp li { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.resp .yes { color: var(--good); font-weight: 800; }
.resp .no { color: var(--muted); }

/* ---------- mano y acciones ---------- */
.hand-cards { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; flex: 1 1 auto; min-width: 0; }
.res-cards { display: flex; gap: 6px; }
.rc { width: 72px; background: var(--panel); border-radius: 10px; padding: 5px 4px 4px; text-align: center; box-shadow: 0 2px 0 var(--line); }
.rc .rc-i { width: 40px; height: 40px; display: block; margin: 0 auto; }
.rc b { display: block; font: 800 22px/1.1 var(--display); }
.rc span { display: block; font-size: 11px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; }
.rc.zero { opacity: .45; }
.dev-cards { display: flex; gap: 6px; flex-wrap: wrap; }
.dc {
  position: relative; display: inline-flex; align-items: center; gap: 6px; background: #2c3e66; color: #fff; border: 2px solid #44598a;
  border-radius: 10px; padding: 6px 10px; font: 700 15px var(--font); cursor: pointer; min-height: 46px;
}
.dc.playable { background: #3949ab; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(242, 181, 68, .3); }
.dc.vp { background: #6d4c2f; border-color: #8d6a48; }
.dc-i { font-size: 22px; line-height: 1; }
.dc-x { background: rgba(255, 255, 255, .22); border-radius: 99px; padding: 0 6px; font-size: 12px; }
.dc-new { position: absolute; top: -8px; right: -6px; background: var(--gold); color: #3a2a00; font: 800 10px var(--font); font-style: normal; padding: 1px 6px; border-radius: 99px; }
.hand-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; flex: 1 1 auto; }
.builds { display: flex; gap: 6px; flex-wrap: wrap; }
.btn.build { flex-direction: column; gap: 3px; padding: 5px 12px; min-height: 62px; }
.btn.build .b-l { font-size: 16px; }
.btn.build .b-c { display: flex; }
.btn.build.on { background: var(--gold); border-color: #c48a12; color: #2b1d00; }
.turn-btns { display: flex; gap: 6px; }
.btn.end { background: #2b241e; color: #fff; border-color: #0d0b09; box-shadow: 0 2px 0 #0d0b09; }
.btn.roll { animation: glow 1.2s ease-in-out infinite alternate; }
@keyframes glow { to { box-shadow: 0 3px 0 var(--accent-2), 0 0 0 6px rgba(242, 181, 68, .5); } }
.act-msg { color: #fff; font-weight: 700; }
.act-msg .pn { font-size: .95em; }
.spect { color: #fff; font-weight: 700; padding: 8px; }

/* ---------- panel lateral ---------- */
.side-tabs { display: flex; align-items: center; gap: 4px; padding: 8px 8px 0; border-bottom: 1px solid var(--line); }
.tab { border: 0; background: none; font: 800 14px var(--font); color: var(--muted); padding: 8px 12px; border-radius: 10px 10px 0 0; cursor: pointer; position: relative; }
.tab.on { color: var(--ink); background: var(--panel-2); }
.side-close { margin-left: auto; display: none !important; color: var(--ink); background: var(--panel-2); }
.side-body { flex: 1; min-height: 0; display: flex; }
.side-pane { display: none; flex: 1; min-height: 0; flex-direction: column; padding: 8px 10px 10px; }
.side-pane.on { display: flex; }
.log-list { overflow-y: auto; flex: 1; font-size: 15px; display: grid; gap: 2px; align-content: start; }
.le { padding: 4px 0; border-bottom: 1px dashed var(--line); line-height: 1.5; }
.side-pane .chat-list { flex: 1; }

/* ---------- ventanas ---------- */
.modal { position: fixed; inset: 0; background: rgba(5, 16, 24, .55); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal-card { background: var(--panel); border-radius: 18px; padding: 18px; width: min(640px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; box-shadow: var(--shadow); }
@keyframes pop { from { transform: scale(.96); opacity: 0; } }
.modal-card h3 { margin: 0 0 6px; font: 800 25px var(--display); }
.modal-card h4 { margin: 14px 0 6px; font: 800 16px var(--display); }
.mh { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.mh h3 { margin: 0; }
.modal .icon-btn { color: var(--ink); background: var(--panel-2); }
.modal-act { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 14px; align-items: center; }
.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tabs .tab { border-radius: 10px; background: var(--panel-2); color: var(--ink); }
.tabs .tab.on { background: var(--accent); color: #fff; }
.lbl { font-weight: 800; font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: .05em; margin: 8px 0 4px; }
.steppers, .pick-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.stp { background: var(--panel-2); border-radius: 12px; padding: 6px 4px; display: grid; justify-items: center; gap: 3px; border: 2px solid transparent; }
.stp.on { border-color: var(--gold); }
.stp-v { display: grid; justify-items: center; }
.stp-v .ico { width: 38px; height: 38px; }
.stp-v b { font: 800 21px/1 var(--display); }
.stp-v small { font-size: 10px; color: var(--muted); }
.stp-b { width: 100%; border: 0; border-radius: 8px; background: var(--panel-3); color: var(--ink); font: 800 21px var(--font); min-height: 38px; cursor: pointer; }
.stp-b:disabled { opacity: .3; cursor: default; }
.pick {
  display: grid; justify-items: center; gap: 2px; background: var(--panel-2); border: 2px solid transparent; border-radius: 12px;
  padding: 9px 4px; cursor: pointer; font: 700 14px var(--font); color: var(--ink); position: relative; min-width: 0;
}
.pick .ico { width: 38px; height: 38px; }
.pick small { color: var(--muted); font-size: 10px; }
.pick.on { border-color: var(--accent); background: var(--sel-bg); }
.pick:disabled { opacity: .35; cursor: default; }
.pick b { position: absolute; top: 2px; right: 6px; color: var(--accent); }
.victims { display: grid; gap: 8px; }
.victim { justify-content: space-between; }
.dev-big { font-size: 48px; text-align: center; line-height: 1.2; }
.k-dev h3, .k-dev > p { text-align: center; }
.tr-resp { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 6px; }
.ask { font-size: 16px; font-weight: 600; margin: 4px 0; }
.modal-card.blocking { border: 3px solid var(--gold); }
.win-banner { font-size: 56px; text-align: center; animation: bounce .9s ease-in-out infinite alternate; }
@keyframes bounce { to { transform: translateY(-6px); } }
.win-title { text-align: center; }
.score-wrap { overflow-x: auto; }
.score { width: 100%; border-collapse: collapse; font-size: 16px; }
.score th, .score td { padding: 6px; text-align: center; border-bottom: 1px solid var(--line); }
.score th:first-child, .score td:first-child { text-align: left; }
.hist { display: grid; grid-template-columns: repeat(11, 1fr); gap: 4px; height: 130px; }
.hb { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; font-size: 11px; font-weight: 800; min-height: 0; }
.hb i { width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; }
.hb span { color: var(--muted); }
.rules p, .rules li { font-size: 16px; }
.rules ol, .rules ul { padding-left: 20px; margin: 4px 0; }
.rules .costs .ico { width: 18px; height: 18px; }

/* ---------- menú y avisos ---------- */
.menu { position: fixed; top: 54px; right: 10px; background: var(--panel); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; z-index: 60; display: grid; min-width: 260px; }
.menu button { text-align: left; border: 0; background: none; font: 700 16px var(--font); color: var(--ink); padding: 10px 12px; border-radius: 8px; cursor: pointer; }
.menu button:hover { background: var(--panel-2); }
.toasts { position: fixed; top: 62px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 80; width: min(420px, calc(100% - 24px)); pointer-events: none; }
.toast {
  background: var(--panel); color: var(--ink); border-radius: 12px; padding: 10px 14px; box-shadow: var(--shadow); font-weight: 700; font-size: 16px;
  border-left: 5px solid var(--muted); animation: tin .2s ease-out; transition: opacity .4s, transform .4s;
}
.toast.good { border-left-color: var(--good); }
.toast.error { border-left-color: var(--bad); }
.toast.warn { border-left-color: var(--gold); }
.toast.info { border-left-color: #1e66f5; }
.toast.chat { border-left-color: #9b4dca; }
.toast.out { opacity: 0; transform: translateY(-8px); }
@keyframes tin { from { opacity: 0; transform: translateY(-8px); } }

/* ---------- celular ---------- */
@media (max-width: 860px) {
  #scr-game {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    grid-template-areas: "top" "players" "board" "hand";
  }
  .g-top { gap: 6px; padding: 6px 8px; padding-top: max(6px, env(safe-area-inset-top)); }
  .g-logo, .g-code { display: none; }
  .g-turn { text-align: left; font-size: 15px; }
  .icon-btn { width: 38px; height: 38px; font-size: 18px; }
  .g-players { display: flex; overflow-x: auto; padding: 6px 8px; gap: 6px; max-height: none; scrollbar-width: none; }
  .g-players::-webkit-scrollbar { display: none; }
  .pl { flex: none; padding: 4px 8px; gap: 6px; align-items: center; }
  .pl-dot { width: 16px; height: 16px; border-radius: 4px; margin: 0; }
  .pl-name { max-width: 6.5em; font-size: 13px; }
  .pl-stats { font-size: 13px; margin: 0; gap: 0 8px; }
  .pl-stats .st:nth-child(n+3) { display: none; }
  .pl-top .tag.me { display: none; }
  .bdg { margin-top: 1px; font-size: 10px; padding: 0 6px; }
  .g-side {
    position: fixed; left: 0; right: 0; bottom: 0; height: 72dvh; margin: 0; border-radius: 18px 18px 0 0; z-index: 40;
    transform: translateY(105%); transition: transform .25s ease;
  }
  .g-side.open { transform: none; }
  .side-close { display: inline-grid !important; }
  .g-hand { gap: 6px; padding: 6px 8px; padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  .hand-cards { width: 100%; gap: 6px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-top: 6px; }
  .res-cards { gap: 4px; flex: none; }
  .rc { width: 54px; padding: 3px 2px; }
  .rc .rc-i { width: 27px; height: 27px; }
  .rc b { font-size: 18px; }
  .rc span { display: none; }
  .dev-cards { flex-wrap: nowrap; flex: none; }
  .dc { min-height: 38px; padding: 4px 8px; }
  .dc-n { display: none; }
  .hand-actions { width: 100%; justify-content: stretch; gap: 6px; }
  .builds { display: grid; grid-template-columns: repeat(4, 1fr); width: 100%; gap: 4px; }
  .btn.build { min-height: 52px; padding: 3px 4px; }
  .btn.build .b-l { font-size: 13px; }
  .ico.c { width: 14px; height: 14px; }
  .turn-btns { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .g-hand > *, .hand-actions > *, .turn-btns > * { min-width: 0; }
  .turn-btns .btn, .hand-actions > .btn { font-size: 15px; padding: 8px 10px; overflow: hidden; text-overflow: ellipsis; }
  .hand-actions > .btn { flex: 1; }
  .act-msg { font-size: 15px; width: 100%; }
  .hint { top: 6px; font-size: 15px; padding: 5px 6px 5px 12px; border-radius: 14px; width: calc(100% - 16px); justify-content: space-between; }
  .hint > span { white-space: normal; }
  .dice { top: auto; bottom: 10px; right: 52px; }
  .dnum { min-width: 46px; height: 46px; font-size: 28px; line-height: 46px; }
  .dice { gap: 6px; }
  .die { --s: 31px; }
  #z-in, #z-out { display: none; }
  .bank-info { display: none; }
  .offer { bottom: 8px; }
  .modal { place-items: end center; padding: 0; }
  .modal-card { border-radius: 18px 18px 0 0; max-height: 88dvh; width: 100%; padding: 16px 14px calc(16px + env(safe-area-inset-bottom)); }
  .steppers, .pick-row { gap: 4px; }
  .stp-v .ico, .pick .ico { width: 28px; height: 28px; }
  .menu { top: 46px; }
  .toasts { top: 52px; }
}
@media (max-width: 720px) {
  .lobby-grid { grid-template-columns: 1fr; }
  .invite-row { grid-template-columns: 1fr 1fr; }
  #invite-link { grid-column: 1 / -1; }
  .code { font-size: 40px; }
  .lobby-actions .btn { min-width: 0; width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}

/* ---------- v2: tablero 3D, mapa boca abajo y sorteo ---------- */
.board3d { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.board3d:active { cursor: grabbing; }
.vig3d { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(130% 100% at 50% 44%, transparent 56%, rgba(2, 14, 26, .42) 100%); }
body.view3d #board { display: none; }
body:not(.view3d) #z-rot { display: none; }
.tile.flip { animation: tileFlip .52s ease-in-out both; transform-box: fill-box; transform-origin: center; }
@keyframes tileFlip { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.tok.letter .tok-bg { fill: #eadcbc; }
.bdg.roll { background: #2e7d32; color: #fff; }
.bdg.out { background: var(--panel-3); color: var(--muted); }
.win-title { font-family: 'Cinzel', var(--display); }
@media (max-width: 860px) {
  body { font-size: 16px; }
}

/* ---------- botón 2D/3D y estadísticas ---------- */
.zoom .view-btn { background: var(--accent); color: #fff; font: 900 15px var(--display); letter-spacing: .5px; }
.side-pane[data-pane="stats"] { overflow-y: auto; }
.stats { display: grid; gap: 14px; align-content: start; }
.st-sec h4 { margin: 2px 0 6px; font: 800 17px var(--display); }
.st-sec h4 small { font: 700 13px var(--font); color: var(--muted); margin-left: 4px; }
.st-sec h5 { margin: 10px 0 4px; font: 800 14px var(--font); color: var(--muted); }
.dchart { display: grid; grid-template-columns: repeat(11, minmax(0, 1fr)); gap: 4px; height: 150px; }
.dcol { display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 0; }
.dcol b { font-size: 12px; line-height: 1.2; }
.dbar { position: relative; flex: 1; width: 100%; background: var(--panel-2); border-radius: 6px 6px 3px 3px; display: flex; align-items: flex-end; }
.dbar i { display: block; width: 100%; background: #6b8fb5; border-radius: 6px 6px 0 0; }
.dcol.hot .dbar i { background: #d9534f; }
.dcol.seven .dbar i { background: #3a2c1c; }
.dbar u { position: absolute; left: -2px; right: -2px; height: 2px; background: var(--ink); opacity: .5; }
.dcol span { font-weight: 800; font-size: 13px; }
.st-facts { margin: 8px 0 2px; }
.mynums { display: flex; flex-wrap: wrap; gap: 6px; }
.mynum { display: inline-flex; align-items: center; gap: 6px; background: var(--panel-2); border-radius: 99px; padding: 3px 10px 3px 3px; }
.mynum b { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: #f8efd9; color: #3a2c1c; border: 2px solid #6b5332; font-size: 14px; }
.mynum.hot b { color: #c62828; }
.mynum em { font-style: normal; display: inline-flex; align-items: center; gap: 1px; font-weight: 800; font-size: 13px; }
.mynum em.blocked { opacity: .4; text-decoration: line-through; }
.mynum .ico { width: 20px; height: 20px; }
.st-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.st-table th { font-size: 12px; color: var(--muted); font-weight: 800; padding: 2px; }
.st-table td { text-align: center; padding: 4px 2px; border-top: 1px dashed var(--line); }
.st-table td:first-child { text-align: left; }
.st-table tr.me td { background: var(--sel-bg); }
.byres { display: grid; gap: 4px; font-size: 14px; }
@media (max-width: 860px) {
  .side-tabs .tab { padding: 8px 9px; }
}

/* ---------- pantalla de victoria ---------- */
.victory {
  position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; overflow: hidden; cursor: pointer;
  background: radial-gradient(ellipse at 50% 40%, rgba(40, 28, 6, .55), rgba(3, 6, 12, .93) 72%); animation: vcIn .45s ease-out both;
}
.victory.lose { background: radial-gradient(ellipse at 50% 40%, rgba(20, 28, 38, .6), rgba(2, 4, 8, .95) 72%); }
.victory.out { animation: vcOut .45s ease-in forwards; pointer-events: none; }
@keyframes vcIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes vcOut { to { opacity: 0; transform: scale(1.04); } }
.vc-fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.vc-rays {
  position: absolute; left: 50%; top: 36%; width: 240vmax; height: 240vmax; margin: -120vmax 0 0 -120vmax; pointer-events: none;
  background: repeating-conic-gradient(from 0deg, rgba(255, 214, 110, .18) 0deg 5deg, rgba(255, 214, 110, 0) 5deg 15deg);
  -webkit-mask-image: radial-gradient(circle, #000 0, rgba(0, 0, 0, .55) 14%, transparent 42%); mask-image: radial-gradient(circle, #000 0, rgba(0, 0, 0, .55) 14%, transparent 42%);
  animation: vcSpin 30s linear infinite, vcFade 1.4s ease-out both;
}
.victory.lose .vc-rays { background: repeating-conic-gradient(from 0deg, rgba(150, 175, 200, .08) 0deg 5deg, transparent 5deg 15deg); }
@keyframes vcSpin { to { transform: rotate(360deg); } }
@keyframes vcFade { from { opacity: 0; } to { opacity: 1; } }
.vc-glow {
  position: absolute; left: 50%; top: 36%; width: 76vmin; height: 76vmin; margin: -38vmin 0 0 -38vmin; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(255, 222, 130, .6), rgba(255, 176, 60, .2) 40%, transparent 70%); animation: vcPulse 2.6s ease-in-out infinite;
}
.victory.lose .vc-glow { background: radial-gradient(circle, rgba(140, 170, 200, .35), rgba(90, 110, 140, .12) 40%, transparent 70%); }
@keyframes vcPulse { 0%, 100% { transform: scale(.9); opacity: .8; } 50% { transform: scale(1.06); opacity: 1; } }
.vc-box { position: relative; display: grid; justify-items: center; text-align: center; padding: 16px; margin-top: -4vh; }
.vc-crest {
  width: min(64vmin, 360px); height: auto; overflow: visible;
  filter: drop-shadow(0 0 20px rgba(255, 200, 80, .6)) drop-shadow(0 14px 18px rgba(0, 0, 0, .6));
  animation: vcCrest 1s cubic-bezier(.2, 1.5, .4, 1) .1s both;
}
.victory.lose .vc-crest { filter: drop-shadow(0 0 14px rgba(140, 170, 200, .35)) drop-shadow(0 14px 18px rgba(0, 0, 0, .6)); animation: vcDrop 1.1s ease-out .1s both; }
@keyframes vcCrest { 0% { opacity: 0; transform: scale(2.6) rotate(-10deg); } 55% { opacity: 1; } 100% { transform: none; } }
@keyframes vcDrop { 0% { opacity: 0; transform: translateY(-50px) scale(1.15); } 100% { opacity: 1; transform: none; } }
.vc-wing { transform-box: fill-box; animation: vcWing .9s cubic-bezier(.2, 1.3, .4, 1) .55s both; }
.vc-wing.l { transform-origin: 100% 50%; }
.vc-wing.r { transform-origin: 0% 50%; }
.victory.lose .vc-wing { animation: vcWingDown 1s ease-out .5s both; }
@keyframes vcWing { from { transform: scaleX(.1) rotate(0); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes vcWingDown { from { opacity: 0; } to { opacity: .75; transform: translateY(14px); } }
.vc-crown { animation: vcCrown .7s cubic-bezier(.2, 1.6, .4, 1) .9s both; }
@keyframes vcCrown { from { transform: translateY(-60px); opacity: 0; } to { transform: none; opacity: 1; } }
.vc-star { transform-box: fill-box; transform-origin: center; animation: vcStar 4s ease-in-out 1s infinite; }
@keyframes vcStar { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
.vc-title {
  position: relative; margin: -6px 0 0; text-transform: uppercase; font: 900 clamp(44px, 11vw, 116px)/1.05 'Cinzel', var(--display); letter-spacing: .12em;
  color: #ffd45e; text-shadow: 0 2px 0 #fff3c4, 0 4px 0 #d39226, 0 7px 0 #6d4510, 0 11px 14px rgba(0, 0, 0, .65), 0 0 36px rgba(255, 196, 70, .85);
  max-width: 94vw; overflow-wrap: anywhere;
}
.vc-title::after {
  content: attr(data-text); position: absolute; inset: 0; color: transparent; pointer-events: none; text-shadow: none;
  background: linear-gradient(100deg, transparent 42%, rgba(255, 255, 255, .95) 50%, transparent 58%); background-size: 320% 100%;
  -webkit-background-clip: text; background-clip: text; animation: vcShine 3s ease-in-out 1.6s infinite;
}
.victory.lose .vc-title { color: #d4dde6; text-shadow: 0 2px 0 #ffffff, 0 4px 0 #7d8d9c, 0 7px 0 #1e2833, 0 11px 14px rgba(0, 0, 0, .65), 0 0 28px rgba(190, 60, 60, .6); }
@keyframes vcShine { 0% { background-position: 150% 0; } 60%, 100% { background-position: -50% 0; } }
.vc-sub { margin: 10px 0 0; color: #ffeec2; font: 800 clamp(18px, 3.4vw, 28px) var(--display); text-shadow: 0 2px 6px rgba(0, 0, 0, .75); animation: vcUp .6s ease-out 1.15s both; }
.victory.lose .vc-sub { color: #d9e3ec; }
@keyframes vcUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.vc-go { margin-top: 24px; opacity: 0; transform: translateY(10px); transition: opacity .4s, transform .4s; pointer-events: none; }
.victory.ready .vc-go { opacity: 1; transform: none; pointer-events: auto; animation: vcBtn 1.8s ease-in-out infinite; }
@keyframes vcBtn { 0%, 100% { box-shadow: 0 3px 0 var(--accent-2), 0 0 0 0 rgba(255, 200, 80, .55); } 50% { box-shadow: 0 3px 0 var(--accent-2), 0 0 0 14px rgba(255, 200, 80, 0); } }
@media (prefers-reduced-motion: reduce) {
  .vc-rays, .vc-glow, .vc-star, .vc-title::after, .victory.ready .vc-go { animation: none; }
}

/* ---------- ícono de la Caballería y mazo de cartas ---------- */
.dico { display: inline-block; width: 1.25em; height: 1.25em; vertical-align: -.28em; }
.deck-t { width: 100%; border-collapse: collapse; margin: 6px 0 4px; font-size: 15px; }
.deck-t th { text-align: left; font-size: 13px; color: var(--muted); padding: 4px 6px; border-bottom: 1px solid var(--line); }
.deck-t th:not(:first-child), .deck-t td:not(:first-child) { text-align: right; }
.deck-t td { padding: 6px; border-bottom: 1px dashed var(--line); }
.deck-t tr.tot td { font-weight: 800; border-bottom: 0; }

/* ---------- ficha de un jugador ---------- */
.pl { cursor: pointer; }
.pl:hover { box-shadow: 0 4px 14px rgba(0, 0, 0, .3); transform: translateY(-1px); }
.pl:focus-visible { outline: 3px solid var(--gold); outline-offset: 1px; }
.pp-head { gap: 8px; border-bottom: 4px solid var(--pc); padding-bottom: 8px; }
.pp-head h3 { margin: 0; }
.pp-head .icon-btn { margin-left: auto; }
.pp-head .pl-dot { width: 22px; height: 22px; border-radius: 6px; border: 2px solid; flex: none; }
.pp-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; margin: 12px 0 8px; }
.pp-t { display: grid; justify-items: center; gap: 1px; background: var(--panel-2); border-radius: 12px; padding: 8px 4px; text-align: center; }
.pp-t .pp-i { font-size: 22px; line-height: 1.1; }
.pp-t b { font: 800 22px/1.1 var(--display); }
.pp-t small { font-size: 11px; color: var(--muted); font-weight: 700; }
.pp-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.pp-sec { margin-top: 12px; }
.pp-sec h4 { margin: 0 0 6px; font: 800 15px var(--display); }
.pp-row { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.pp-port { background: var(--panel-2); border-radius: 99px; padding: 3px 10px; font-size: 14px; }
.pp-devs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.pp-devs .dv { background: var(--panel-2); border-radius: 8px; padding: 3px 8px; font-weight: 700; }
.pp-got { margin-top: 6px; font-size: 14px; }
@media (max-width: 520px) {
  .pp-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ---------- atajos de teclado ---------- */
.keys { width: 100%; border-collapse: collapse; margin: 6px 0 10px; }
.keys td { padding: 6px; border-bottom: 1px dashed var(--line); vertical-align: middle; }
.keys td:first-child { width: 1%; white-space: nowrap; }
kbd {
  display: inline-block; min-width: 28px; padding: 3px 9px; border-radius: 7px; text-align: center; font: 800 14px var(--font);
  background: var(--panel); color: var(--ink); border: 1px solid var(--line); box-shadow: 0 3px 0 var(--line);
}

/* ---------- carta nueva ---------- */
.card-reveal {
  --c1: #4f6d8f; --c2: #22344a; --glow: rgba(120, 170, 230, .7);
  position: fixed; inset: 0; z-index: 85; display: grid; place-items: center; align-content: center; gap: 14px; cursor: pointer;
  background: radial-gradient(circle at 50% 45%, rgba(10, 14, 22, .35), rgba(3, 6, 12, .78) 70%); animation: vcIn .3s ease-out both;
}
.card-reveal.out { animation: vcOut .35s ease-in forwards; pointer-events: none; }
.card-reveal.k-gendarme { --c1: #5b7898; --c2: #263a52; --glow: rgba(140, 180, 235, .75); }
.card-reveal.k-obra { --c1: #f0a03c; --c2: #8a4a12; --glow: rgba(255, 170, 60, .75); }
.card-reveal.k-cosecha { --c1: #78b84a; --c2: #2f5e1d; --glow: rgba(150, 220, 90, .7); }
.card-reveal.k-corralito { --c1: #9a6ad0; --c2: #3e2266; --glow: rgba(190, 140, 255, .7); }
.card-reveal.k-monumento { --c1: #f2c14e; --c2: #8a5a12; --glow: rgba(255, 210, 90, .8); }
.cr-glow { position: absolute; width: 70vmin; height: 70vmin; border-radius: 50%; background: radial-gradient(circle, var(--glow), transparent 65%); animation: vcPulse 2.4s ease-in-out infinite; pointer-events: none; }
.cr-card { position: relative; width: min(260px, 76vw); perspective: 1000px; animation: crIn .45s cubic-bezier(.2, 1.4, .4, 1) both; }
/* La cara de adelante define el alto (crece si el texto es largo); el dorso la cubre por detrás. */
.cr-inner { position: relative; transform-style: preserve-3d; animation: crFlip .8s cubic-bezier(.3, .8, .3, 1) .45s both; }
.cr-face {
  border-radius: 18px; backface-visibility: hidden; -webkit-backface-visibility: hidden; overflow: hidden;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .55), 0 0 0 4px #f5e6c4 inset;
}
.cr-back { position: absolute; inset: 0; transform: rotateY(180deg); display: grid; place-items: center; background: radial-gradient(circle at 50% 40%, #3a6489, #1b3450); }
.cr-back svg { width: 62%; }
.cr-front {
  position: relative; min-height: 350px; display: grid; grid-template-rows: auto 1fr auto auto auto; justify-items: center; text-align: center; padding: 14px 14px 16px;
  background: linear-gradient(170deg, var(--c1), var(--c2)); color: #fff;
}
.cr-top { font: 800 12px var(--font); letter-spacing: .14em; text-transform: uppercase; opacity: .85; }
.cr-art {
  display: grid; place-items: center; width: 58%; aspect-ratio: 1; margin: 8px 0; border-radius: 50%; font-size: 64px; line-height: 1;
  background: radial-gradient(circle at 50% 40%, rgba(255, 255, 255, .95), rgba(255, 255, 255, .55) 60%, rgba(255, 255, 255, .15));
  box-shadow: 0 0 0 4px rgba(255, 255, 255, .35), 0 8px 18px rgba(0, 0, 0, .35); align-self: center;
}
.cr-art .dico { width: 88px; height: 88px; vertical-align: 0; }
.cr-name { margin: 6px 0 4px; font: 900 21px/1.15 'Cinzel', var(--display); text-shadow: 0 2px 4px rgba(0, 0, 0, .45); }
.cr-desc { margin: 0; font: 700 13px/1.35 var(--font); opacity: .95; }
.cr-note { margin-top: 8px; font: 700 11px/1.3 var(--font); background: rgba(0, 0, 0, .25); border-radius: 8px; padding: 5px 8px; }
.cr-label { position: relative; margin: 0; color: #fff3cf; font: 900 24px var(--display); text-shadow: 0 2px 8px rgba(0, 0, 0, .7); animation: vcUp .5s ease-out 1s both; }
@keyframes crIn { from { opacity: 0; transform: translateY(40px) scale(.6); } to { opacity: 1; transform: none; } }
@keyframes crFlip { from { transform: rotateY(180deg); } to { transform: rotateY(0); } }
@media (prefers-reduced-motion: reduce) { .cr-inner, .cr-card, .cr-glow { animation: none; } }

/* ---------- Punto especial (Mayor ruta comercial / Mayor ejército) ---------- */
/* No tapa el juego para tocar: solo la medalla recibe el toque (para cerrarla antes). */
.award {
  --pc: #f2b544;
  position: fixed; inset: 0; z-index: 84; display: grid; place-items: start center; padding-top: 12vh; pointer-events: none;
  background: radial-gradient(circle at 50% 34%, rgba(255, 214, 110, .22), rgba(3, 6, 12, .45) 62%); animation: vcIn .3s ease-out both;
}
.award.out { animation: vcOut .4s ease-in forwards; }
.aw-fx { position: absolute; inset: 0; width: 100%; height: 100%; }
.aw-rays {
  position: absolute; left: 50%; top: 34%; width: 120vmin; height: 120vmin; margin: -60vmin 0 0 -60vmin; border-radius: 50%;
  background: repeating-conic-gradient(rgba(255, 226, 140, .32) 0 7deg, transparent 7deg 22deg);
  -webkit-mask: radial-gradient(circle, #000 12%, transparent 62%); mask: radial-gradient(circle, #000 12%, transparent 62%);
  animation: awSpin 14s linear infinite;
}
.aw-box { position: relative; display: grid; justify-items: center; text-align: center; pointer-events: auto; cursor: pointer; max-width: min(460px, 92vw); }
.aw-medal { position: relative; width: 150px; height: 150px; filter: drop-shadow(0 10px 22px rgba(0, 0, 0, .55)) drop-shadow(0 0 26px rgba(255, 210, 90, .65)); }
.aw-medal svg { width: 100%; height: 100%; }
.aw-ico { position: absolute; inset: 0; display: grid; place-items: center; font-size: 58px; line-height: 1; }
.aw-ico .dico { width: 70px; height: 70px; vertical-align: 0; }
.aw-plus {
  position: absolute; right: -14px; top: -6px; min-width: 50px; padding: 4px 10px; border-radius: 99px; border: 3px solid #fff3c4;
  background: linear-gradient(#ffd96b, #e09a1c); color: #3a2400; font: 900 22px var(--display); box-shadow: 0 4px 12px rgba(0, 0, 0, .45);
}
.aw-kicker { margin: 12px 0 0; color: #ffe7a6; font: 800 12px var(--font); letter-spacing: .2em; text-transform: uppercase; text-shadow: 0 2px 6px rgba(0, 0, 0, .8); }
.aw-title {
  margin: 2px 0 6px; font: 900 clamp(28px, 6vw, 44px)/1.05 'Cinzel', var(--display); color: #ffe08a;
  text-shadow: 0 2px 0 #8a5a12, 0 4px 14px rgba(0, 0, 0, .8), 0 0 28px rgba(255, 200, 80, .55);
}
.aw-who, .aw-took { margin: 0; padding: 5px 14px; border-radius: 99px; background: rgba(8, 14, 24, .78); color: #fff; font: 800 15px var(--font); box-shadow: 0 4px 12px rgba(0, 0, 0, .35); }
.aw-took { margin-top: 6px; font-size: 13px; color: #ffd9a8; }
.award.lost .aw-took { color: #ffb4a8; }
@keyframes awSpin { to { transform: rotate(360deg); } }
/* La tarjeta del jugador en la lista brilla con su color mientras dura el aviso. */
.pl.got-award { animation: awCard 1.1s ease-in-out 3; }
@keyframes awCard { 50% { box-shadow: 0 0 0 4px #ffd24d, 0 0 26px rgba(255, 200, 70, .9); transform: translateY(-2px); } }
@media (prefers-reduced-motion: reduce) { .aw-rays, .pl.got-award { animation: none; } }

/* ---------- Movimiento suave de la interfaz ---------- */
/* La ventana aparece con un fundido y la tarjeta con un pequeño salto solo al abrirse (no cada vez que
   cambia su contenido); al cerrarse se desvanece. */
.modal { animation: mFade .16s ease-out; }
.modal-card.opening { animation: pop .22s cubic-bezier(.2, .9, .3, 1.15); }
.modal.closing { animation: mFadeOut .15s ease-in forwards; pointer-events: none; }
.modal.closing .modal-card { animation: popOut .15s ease-in forwards; }
@keyframes mFade { from { opacity: 0; } }
@keyframes mFadeOut { to { opacity: 0; } }
@keyframes popOut { to { transform: scale(.97); opacity: 0; } }
/* El menú se despliega desde el botón. */
.menu:not(.hidden) { animation: menuIn .16s cubic-bezier(.2, .9, .3, 1.1); transform-origin: top right; }
@keyframes menuIn { from { opacity: 0; transform: translateY(-6px) scale(.96); } }
/* Cartas de la mano que suben (rebote con brillo verde) o bajan (se achican un instante). */
.rc.gain { animation: rcGain .5s cubic-bezier(.2, .9, .3, 1.2); }
.rc.spend { animation: rcSpend .4s ease-out; }
@keyframes rcGain { 35% { transform: translateY(-6px) scale(1.1); box-shadow: 0 2px 0 var(--line), 0 0 0 3px rgba(67, 160, 71, .55), 0 0 14px rgba(67, 160, 71, .6); } }
@keyframes rcSpend { 35% { transform: scale(.9); opacity: .7; } }
/* Las líneas nuevas del registro entran deslizándose. */
.le.fresh { animation: leIn .3s ease-out; }
@keyframes leIn { from { opacity: 0; transform: translateY(8px); } }
/* Botones: al pasar el mouse se levantan apenas (solo en la compu) y al tocarlos se hunden. */
@media (hover: hover) { .btn:not(:disabled):hover { transform: translateY(-1px); } }
.btn:not(:disabled):active { transform: translateY(1px) scale(.98); }

/* ---------- Botón de tema claro / oscuro ---------- */
.theme-fab { position: absolute; top: max(12px, env(safe-area-inset-top)); right: 12px; z-index: 5; }
.lobby-tools { display: flex; align-items: center; gap: 8px; }
/* En celulares angostos la barra de la partida no tiene lugar: ahí el tema se cambia desde el menú ⋯. */
@media (max-width: 520px) { .g-tools .theme-btn { display: none; } }
/* En el tema oscuro, las partes oscuras de los íconos (la cara y las patas de la oveja, los bordes de la
   piedra) se perdían contra el fondo: un contorno claro y fino las recorta. */
:root[data-theme="dark"] .ico { filter: drop-shadow(0 0 1px rgba(255, 246, 225, .7)); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ico { filter: drop-shadow(0 0 1px rgba(255, 246, 225, .7)); } }
