:root {
  --bg: #1d140d;
  --panel: #2b1f15;
  --panel-2: #3a2a1c;
  --line: #5a4330;
  --text: #f5ead8;
  --muted: #b9a58c;
  --accent: #e8893c;
  --accent-2: #ffb35c;
  --danger: #e04848;
  --good: #7cc95a;
  --cell: #4a3423;
  --cell-sel: #6a4a30;
}
body[data-race="abejas"] {
  --bg: #1f1806;
  --panel: #2e2410;
  --panel-2: #3f3215;
  --line: #6b5520;
  --accent: #f2b01e;
  --accent-2: #ffd45c;
  --cell: #5a4510;
  --cell-sel: #7a5e18;
}

body[data-race="escarabajos"] {
  --bg: #0f1a17;
  --panel: #182823;
  --panel-2: #213832;
  --line: #2f5a4d;
  --accent: #3fae8c;
  --accent-2: #6fd8b4;
  --cell: #1f3b33;
  --cell-sel: #2d5548;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}
button { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.warn { color: #ffb0a0; min-height: 1em; }
small { font-size: 0.8em; }

.btn {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 14px; cursor: pointer; transition: transform .08s, background .15s;
}
.btn:hover:not(:disabled) { background: var(--line); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent-2); color: #1a1007; font-weight: 700; }
.btn.primary:hover:not(:disabled) { background: var(--accent-2); }
.btn.danger { background: var(--danger); border-color: #ff7a7a; }
.btn.sm { padding: 6px 10px; font-size: .9em; }
.btn.xs { padding: 2px 8px; font-size: .8em; }
.btn.big { padding: 12px 28px; font-size: 1.2em; }

.screen { position: fixed; inset: 0; overflow: auto; }

/* ---------- Ingresar / cargando ---------- */
#screen-loading, #screen-login {
  display: flex; flex-direction: column; align-items: center; justify-content: safe center; padding: 24px 16px;
  background: radial-gradient(ellipse at top, #4a3020, #140c06 70%);
}
.login-box {
  width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 20px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 10px 30px #000a;
}
.login-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--bg); padding: 4px; border-radius: 10px; }
.login-tabs button {
  background: none; border: 0; color: var(--muted); padding: 8px; border-radius: 8px; font: inherit; font-weight: 700; cursor: pointer;
}
.login-tabs button.sel { background: var(--accent); color: #1a1007; }
#login-form { display: flex; flex-direction: column; gap: 10px; }
#login-form label { display: flex; flex-direction: column; gap: 4px; font-size: .9em; color: var(--muted); }
#login-form input {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; color: var(--text);
  padding: 10px 12px; font: inherit; font-size: 1rem;
}
#login-form input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
#login-form .warn { margin: 0; font-size: .9em; }
.link-btn { background: none; border: 0; color: var(--accent-2); font: inherit; font-size: .85em; cursor: pointer; text-decoration: underline; }
.login-or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .85em; }
.login-or::before, .login-or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.login-box > small { text-align: center; }
.account { margin: 0 0 4px; }

/* ---------- Elegir raza ---------- */
#screen-race {
  display: flex; flex-direction: column; align-items: center; justify-content: safe center; padding: 24px;
  background: radial-gradient(ellipse at top, #4a3020, #140c06 70%);
}
.logo { font-size: clamp(2.2rem, 7vw, 4.5rem); margin: 0; letter-spacing: 2px; color: #ffcf7a; text-shadow: 0 4px 0 #6b3a12, 0 8px 20px #000; text-align: center; }
.subtitle { color: var(--muted); margin: 8px 0 32px; text-align: center; }
.race-cards { display: flex; gap: 24px; flex-wrap: wrap; justify-content: center; }
.race-card {
  width: 280px; padding: 24px; border-radius: 18px; cursor: pointer; text-align: center;
  border: 2px solid transparent; transition: transform .15s, border-color .15s;
}
.race-card:hover { transform: translateY(-6px) scale(1.02); }
.race-card.r-hormigas { background: linear-gradient(160deg, #5a3320, #2a160c); border-color: #d9682b; }
.race-card.r-fuego { background: linear-gradient(160deg, #6a1f12, #2a0c06); border-color: #e0452a; }
.race-card.r-bala { background: linear-gradient(160deg, #3a2a1e, #120c08); border-color: #8a6a4a; }
.race-card h5.sci { margin: 2px 0 0; text-align: center; font-style: italic; font-weight: 400; color: var(--muted); }
.race-card p.fact { font-size: .85em; color: #ffd9a0; background: rgba(0,0,0,.25); border-radius: 8px; padding: 6px 8px; margin: 4px 0 8px; }
.race-card.r-abejas { background: linear-gradient(160deg, #6b5214, #2a2008); border-color: #f2b01e; }
.race-card.r-escarabajos { background: linear-gradient(160deg, #1f4a3e, #0c1d18); border-color: #3fae8c; }
.race-card { text-align: left; display: flex; flex-direction: column; justify-content: flex-start; }
.race-card .race-emoji, .race-card h2, .race-card h4 { text-align: center; }
ul.pros, ul.cons { list-style: none; padding: 0; margin: 6px 0; font-size: .88em; display: flex; flex-direction: column; gap: 3px; }
ul.pros li::before { content: '✔ '; color: #7cd95a; font-weight: 700; }
ul.cons li::before { content: '✖ '; color: #ff7a6a; font-weight: 700; }
.race-traits h3 { font-size: 1em; }
.race-emoji { font-size: 5rem; animation: bob 1.6s ease-in-out infinite; }
.race-card h2 { margin: 8px 0 0; }
.race-card h4 { margin: 2px 0 12px; color: var(--muted); font-weight: 500; }
.race-card p { color: #e8dcc8; font-size: .95em; line-height: 1.4; }
@keyframes bob { 50% { transform: translateY(-8px) rotate(-4deg); } }

/* ---------- Base ---------- */
#screen-base { display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 10px 16px;
  background: var(--panel); border-bottom: 2px solid var(--line); flex-wrap: wrap;
}
.brand { font-size: 1.4em; font-weight: 800; }
.resources { display: flex; gap: 10px; flex: 1; flex-wrap: wrap; }
.res { background: var(--panel-2); padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); white-space: nowrap; }
.res small { color: var(--muted); margin-left: 3px; }
.top-actions { display: flex; gap: 8px; }

.base-layout { flex: 1; display: grid; grid-template-columns: 1fr 340px; min-height: 0; }
/* ===== Colonia en corte (estilo Fallout Shelter) ===== */
.res { position: relative; overflow: hidden; }
.res .fill { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--accent); opacity: .85; transition: width .6s; }

.colony-wrap {
  overflow: auto; padding: 0 16px 28px; position: relative;
  background:
    radial-gradient(circle at 20% 30%, rgba(0,0,0,.22) 0 3px, transparent 4px) 0 0/46px 46px,
    radial-gradient(circle at 70% 60%, rgba(255,255,255,.05) 0 2px, transparent 3px) 0 0/34px 34px,
    radial-gradient(ellipse 22px 9px at 50% 50%, rgba(0,0,0,.2), transparent) 0 0/130px 96px,
    linear-gradient(#6b4626, #4a2f18 25%, #2e1c0e 65%, #170d06);
}
body[data-race="abejas"] .colony-wrap {
  background:
    radial-gradient(circle at 50% 50%, rgba(255,214,100,.08) 0 9px, transparent 10px) 0 0/26px 22px,
    radial-gradient(circle at 50% 50%, rgba(255,214,100,.08) 0 9px, transparent 10px) 13px 11px/26px 22px,
    linear-gradient(#8a6516, #5c420c 35%, #2e2006);
}
body[data-race="escarabajos"] .colony-wrap {
  background:
    repeating-linear-gradient(90deg, rgba(0,0,0,.14) 0 3px, transparent 3px 52px),
    repeating-linear-gradient(0deg, rgba(255,255,255,.035) 0 2px, transparent 2px 19px),
    linear-gradient(#6a4a2c, #43301b 35%, #1f150b);
}
.colony { max-width: 1000px; margin: 0 auto; }

/* superficie */
.surface {
  position: relative; height: 150px; margin: 0 -16px 14px; overflow: hidden;
  background: linear-gradient(#5fb0ea, #bfe6fa 78%); border-bottom: 6px solid #2f5f1f;
}
.surface::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 26px; background: linear-gradient(#72c04c, #3f7f2a); }
.s-abejas::after { background: linear-gradient(#9cc84a, #5f8a24); }
.s-escarabajos { background: linear-gradient(#4f9cc8, #a8d8ee 78%); }
.s-escarabajos::after { background: linear-gradient(#4f9a3a, #2c5f1e); }
.sun { position: absolute; right: 12%; top: 18px; width: 46px; height: 46px; border-radius: 50%; background: #fff3b0; box-shadow: 0 0 40px 14px rgba(255,240,170,.6); }
.cloud { position: absolute; left: -120px; height: 22px; width: 90px; background: rgba(255,255,255,.88); border-radius: 999px; animation: drift 70s linear infinite; }
.cloud::before { content: ''; position: absolute; width: 44px; height: 32px; background: inherit; border-radius: 50%; left: 18px; top: -14px; }
.cloud.c1 { top: 28px; }
.cloud.c2 { top: 60px; animation-duration: 100s; animation-delay: -55s; transform: scale(.7); }
@keyframes drift { to { left: 110%; } }
.flora { position: absolute; left: 150px; right: 0; bottom: 14px; display: flex; justify-content: space-around; font-size: 1.4em; z-index: 2; }
.entrance { position: absolute; bottom: 20px; left: 14px; z-index: 3; }
.entrance .door { position: absolute; background: #1a0f07; }
.e-hormigas {
  width: 124px; height: 66px; border-radius: 62px 62px 8px 8px / 66px 66px 8px 8px;
  background: radial-gradient(ellipse at 40% 30%, #b07a44, #7a4d24 60%, #5a3618); box-shadow: inset 0 -6px 10px rgba(0,0,0,.3);
}
.e-hormigas .door { left: 50%; bottom: 0; width: 34px; height: 22px; transform: translateX(-50%); border-radius: 17px 17px 0 0; }
.e-abejas {
  width: 84px; height: 92px; bottom: 26px; left: 30px; border-radius: 42px 42px 40px 40px / 50px 50px 42px 42px;
  background: repeating-linear-gradient(#f2b01e 0 10px, #c9850c 10px 13px); box-shadow: inset -8px -6px 14px rgba(0,0,0,.25);
}
.e-abejas::before { content: ''; position: absolute; top: -12px; left: -40px; width: 170px; height: 10px; background: #5a3a1c; border-radius: 6px; }
.e-abejas .door { left: 50%; bottom: 16px; width: 20px; height: 13px; transform: translateX(-50%); border-radius: 10px; }
.e-escarabajos {
  width: 150px; height: 52px; border-radius: 26px;
  background: linear-gradient(#946238, #5a3818 70%, #3e2610); box-shadow: inset 0 4px 0 rgba(255,255,255,.12);
}
.e-escarabajos::after { content: ''; position: absolute; right: -6px; top: 0; width: 48px; height: 52px; border-radius: 50%; background: repeating-radial-gradient(circle, #d2a46a 0 3px, #9a6a3a 3px 6px); }
.e-escarabajos .door { left: 30px; bottom: 0; width: 30px; height: 28px; border-radius: 15px 15px 0 0; }
.s-chinches::after { background: linear-gradient(#86c74a, #4a8a2a); }
.e-chinches { /* hoja grande sobre un tallo */
  width: 118px; height: 70px; border-radius: 60px 60px 10px 10px / 70px 70px 10px 10px;
  background: radial-gradient(ellipse at 40% 30%, #9be060, #4f9a2a 60%, #2f6b1c); box-shadow: inset 0 -6px 10px rgba(0,0,0,.3);
}
.e-chinches::before { content: ''; position: absolute; left: 50%; top: 8px; bottom: 18px; width: 3px; background: rgba(30,70,15,.55); transform: translateX(-50%); border-radius: 2px; }
.e-chinches .door { left: 50%; bottom: 0; width: 30px; height: 20px; transform: translateX(-50%); border-radius: 15px 15px 0 0; }

/* filas, pozo y túneles */
.colony-row { display: grid; grid-template-columns: 52px repeat(3, 1fr); gap: 10px; margin-bottom: 10px; position: relative; }
/* pasillo horizontal a la altura del piso: une el pozo con todas las salas de la fila */
.colony-row:has(.cell.room)::before {
  content: ''; position: absolute; left: 26px; right: 0; bottom: 0; height: 36px;
  background: linear-gradient(#120a05, #22150b 72%, #4a3018 72% 80%, #2a1b0e 80%);
  border-radius: 18px 18px 8px 8px; box-shadow: inset 0 4px 8px rgba(0,0,0,.75);
}
.shaft { position: relative; border-radius: 10px; }
.shaft.dug {
  margin: -10px 4px; z-index: 1;
  background:
    repeating-linear-gradient(0deg, transparent 0 16px, rgba(255,220,160,.28) 16px 19px),
    linear-gradient(90deg, #1c110a, #3a2512 50%, #1c110a);
  box-shadow: inset 0 0 12px rgba(0,0,0,.75);
}
.shaft .lift { display: none; }

/* celdas */
.cell { min-height: 140px; border-radius: 18px; position: relative; z-index: 1; }
.cell.dirt { background: transparent; }
.cell.empty {
  border: 2px dashed rgba(255,230,190,.22); display: flex; align-items: center; justify-content: center;
  color: rgba(255,240,210,.5); cursor: pointer; background: rgba(0,0,0,.25); font-weight: 600; transition: background .15s, color .15s, border-color .15s;
}
.cell.empty:hover { background: rgba(255,220,150,.1); color: #fff; border-color: rgba(255,230,190,.55); }
body[data-race="abejas"] .cell:not(.dirt) { border-radius: 6px; clip-path: polygon(5% 0, 95% 0, 100% 50%, 95% 100%, 5% 100%, 0 50%); }
body[data-race="escarabajos"] .cell:not(.dirt) { border-radius: 38px 38px 12px 12px; }

.cell.room {
  --w1: #6a4a30; --w2: #3d2a1a;
  cursor: pointer; overflow: hidden; padding: 8px 12px 0; display: flex; flex-direction: column; gap: 4px;
  background: radial-gradient(ellipse 60% 55% at 50% 0%, rgba(255,236,190,.33), transparent 70%), linear-gradient(var(--w1), var(--w2));
  border: 3px solid #1c120a;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.07), inset 0 -40px 30px rgba(0,0,0,.25), 0 4px 0 rgba(0,0,0,.35);
  transition: transform .12s, box-shadow .15s;
}
.cell.room:hover { transform: translateY(-2px); }
.cell.room.sel { border-color: var(--accent-2); box-shadow: 0 0 0 3px var(--accent), 0 0 26px rgba(255,190,90,.35), inset 0 -40px 30px rgba(0,0,0,.25); }
.t-reina      { --w1: #8f5ca6; --w2: #45274f; }
.t-comida     { --w1: #4f7f33; --w2: #26401a; }
.t-material   { --w1: #75624e; --w2: #3d3128; }
.t-criadero   { --w1: #8a4d6a; --w2: #44253a; }
.t-armeria    { --w1: #46607a; --w2: #222f3d; }
.t-almacen    { --w1: #846c44; --w2: #463820; }
.t-alas       { --w1: #4579a0; --w2: #203d4f; }
.t-coraza     { --w1: #66717c; --w2: #2f363d; }
.t-excavacion { --w1: #7a5838; --w2: #3a2a1b; }
.t-saltos     { --w1: #66872f; --w2: #334519; }
.t-tenazas    { --w1: #8a4a24; --w2: #4a2410; }
.t-kamikazes  { --w1: #9a6a12; --w2: #4f3306; }
.t-toxica     { --w1: #4f7a1a; --w2: #22380a; }

.room-decor { position: absolute; right: 8px; bottom: 22px; font-size: 64px; opacity: .14; pointer-events: none; line-height: 1; }
.room-lamp { position: absolute; top: 0; left: 50%; width: 22px; height: 6px; transform: translateX(-50%); background: #ffe9a8; border-radius: 0 0 8px 8px; box-shadow: 0 0 18px 6px rgba(255,225,150,.45); }
.room-head { display: flex; align-items: center; gap: 6px; position: relative; z-index: 1; }
.ri { font-size: 1.3em; filter: drop-shadow(0 1px 1px rgba(0,0,0,.5)); }
.rn { font-weight: 800; flex: 1; font-size: .9em; line-height: 1.1; text-shadow: 0 1px 2px rgba(0,0,0,.7); }
.lv { color: #ffd45c; font-size: .8em; letter-spacing: -1px; text-shadow: 0 1px 2px rgba(0,0,0,.6); white-space: nowrap; }
.lv .off { color: rgba(255,255,255,.18); }
.room-status { display: flex; align-items: center; justify-content: space-between; gap: 6px; position: relative; z-index: 1; min-width: 0; }
.room-info { font-size: .78em; color: #ffeccc; background: rgba(0,0,0,.38); padding: 1px 8px; border-radius: 999px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.pips { display: flex; gap: 3px; flex-shrink: 0; }
.pips i { width: 8px; height: 8px; border-radius: 50%; background: rgba(0,0,0,.45); border: 1px solid rgba(255,255,255,.25); }
.pips i.on { background: #8ee06a; border-color: #c8ff9e; box-shadow: 0 0 5px #8ee06a; }
.room-bar { height: 5px; background: rgba(0,0,0,.45); border-radius: 3px; overflow: hidden; position: relative; z-index: 1; }
.room-bar i { display: block; height: 100%; background: linear-gradient(90deg, #7fd35a, #c8ff9e); transition: width .9s linear; }
.room-floor { position: relative; margin: auto -12px 0; height: 42px; background: linear-gradient(transparent 0 70%, rgba(0,0,0,.4) 70% 76%, rgba(0,0,0,.22) 76%); }

/* bichos caminando por la sala */
.walker { position: absolute; bottom: 9px; left: var(--lo); width: 48px; height: 34px; animation: wander var(--dur) ease-in-out var(--delay) infinite; }
/* las patas se mueven solo mientras camina: UI.fxLegs marca .still en las pausas de "wander" */
.walker.still .bug-svg .legA, .walker.still .bug-svg .legB, .walker.still .bug-svg .knee { animation-play-state: paused; }
.walker.sleeper .bug-svg .legA, .walker.sleeper .bug-svg .legB, .walker.sleeper .bug-svg .knee,
.traveler.busy .bug-svg .legA, .traveler.busy .bug-svg .legB, .traveler.busy .bug-svg .knee,
.traveler.idle .bug-svg .legA, .traveler.idle .bug-svg .legB, .traveler.idle .bug-svg .knee { animation: none; }
.walker .bug-svg { width: 100%; height: 100%; overflow: visible; animation: face var(--dur) step-end var(--delay) infinite; filter: drop-shadow(0 2px 1px rgba(0,0,0,.45)); }
@keyframes wander { 0%, 6% { left: var(--lo); } 44%, 56% { left: var(--hi); } 94%, 100% { left: var(--lo); } }
@keyframes face { 0% { transform: scaleX(1); } 50% { transform: scaleX(-1); } }
/* patas articuladas: la cadera barre adelante/atrás y la rodilla se dobla para levantar el pie mientras la pata vuelve adelante */
.bug-svg .legA, .bug-svg .legB, .bug-svg .knee { transform-box: view-box; }
.bug-svg .legA, .bug-svg .legB { animation: legswing .64s linear infinite; }
.bug-svg .legA .knee, .bug-svg .legB .knee { animation: kneeflex .64s ease-in-out infinite; }
.bug-svg .legB, .bug-svg .legB .knee { animation-delay: -.32s; }
@keyframes legswing { 0% { transform: rotate(-13deg); } 50% { transform: rotate(13deg); } 100% { transform: rotate(-13deg); } }
@keyframes kneeflex { 0%, 50% { transform: rotate(0deg); } 75% { transform: rotate(var(--lift)); } 100% { transform: rotate(0deg); } }
/* en las cartas los bichos quedan quietos */
.bg-art .bug-svg *, .bc-art .bug-svg *, .bcard-art .bug-svg *, .sq .bug-svg * { animation: none !important; }
.bug-svg .ant { transform-box: fill-box; transform-origin: 0 100%; animation: antw 1.4s ease-in-out infinite alternate; }
@keyframes antw { to { transform: rotate(-14deg); } }
.bug-svg .wing { transform-box: fill-box; transform-origin: 70% 100%; animation: flap .12s linear infinite alternate; }
@keyframes flap { to { transform: rotate(-18deg); } }
.bar { height: 6px; background: rgba(0,0,0,.35); border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--good); transition: width .5s; }

.side { background: var(--panel); border-left: 2px solid var(--line); overflow-y: auto; padding: 12px; }
.panel { background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-bottom: 12px; }
.panel.hint { color: var(--muted); }
.panel h3 { margin: 0 0 6px; }
.panel h3 small { color: var(--muted); font-weight: 400; }
.panel h4 { margin: 12px 0 6px; }
.panel p { margin: 6px 0; font-size: .92em; }
.panel .btn { margin-top: 8px; width: 100%; }
.wlist, .blist { display: flex; flex-direction: column; gap: 6px; }
.wrow { display: flex; justify-content: space-between; align-items: center; background: rgba(0,0,0,.2); padding: 4px 8px; border-radius: 8px; }
.wrow .btn { width: auto; margin: 0; }
.craft-list { display: flex; flex-direction: column; gap: 6px; }
.craft {
  display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border-radius: 8px;
  background: rgba(0,0,0,.25); border: 1px solid var(--line); cursor: pointer; text-align: left;
}
.craft:hover:not(:disabled) { border-color: var(--accent); }
.craft:disabled { opacity: .5; cursor: not-allowed; }
.ammo { display: flex; gap: 10px; flex-wrap: wrap; margin: 6px 0 10px; font-size: 1.1em; }
.brow { display: flex; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 10px; background: rgba(0,0,0,.18); }
.brow.squad { background: rgba(255,200,80,.12); outline: 1px solid rgba(255,200,80,.35); }
.bmain { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.star { background: none; border: none; font-size: 1.3em; cursor: pointer; padding: 0 4px; }

/* ---------- Modal / toast ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal-box { background: var(--panel); border: 2px solid var(--line); border-radius: 16px; padding: 18px; width: min(460px, 100%); max-height: 85vh; overflow: auto; }
.modal-box h3 { margin-top: 0; }
.modal-box .btn { width: 100%; margin-top: 8px; }
.pick-list { display: flex; flex-direction: column; gap: 8px; }
.pick {
  text-align: left; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer;
  display: flex; flex-direction: column; gap: 3px;
}
.pick:hover:not(:disabled) { border-color: var(--accent); }
.pick:disabled { opacity: .45; cursor: not-allowed; }
.pick small { color: var(--muted); }
.pick .cost { color: var(--accent-2); }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 60; pointer-events: none; }
.toast-item { background: rgba(20,12,6,.92); border: 1px solid var(--accent); padding: 8px 16px; border-radius: 999px; animation: tin .25s ease-out; white-space: nowrap; }
@keyframes tin { from { opacity: 0; transform: translateY(10px); } }

/* ---------- Lobby ---------- */
#screen-lobby { background: radial-gradient(ellipse at top, var(--panel-2), var(--bg) 70%); }
.lobby { max-width: 760px; margin: 0 auto; padding: 24px 16px 40px; }
.lobby h1 { margin: 0 0 6px; }
.lobby-rank { font-size: 1.1em; margin-bottom: 8px; }
.choice { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.choice button {
  background: var(--panel); border: 2px solid var(--line); border-radius: 14px; padding: 14px; cursor: pointer;
  font-weight: 700; font-size: 1.05em; display: flex; flex-direction: column; gap: 4px;
}
.choice button small { font-weight: 400; color: var(--muted); }
.choice button.sel { border-color: var(--accent); background: var(--panel-2); box-shadow: 0 0 0 3px rgba(232,137,60,.25); }
.lobby-squad { display: flex; gap: 10px; flex-wrap: wrap; }
.sq { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; display: flex; flex-direction: column; align-items: center; font-size: 1.6em; min-width: 110px; }
.sq b { font-size: .55em; } .sq small { font-size: .45em; color: var(--muted); }
.lobby-ammo { margin-top: 10px; font-size: 1.1em; }
.lobby-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

/* ---------- Batalla ---------- */
#screen-battle { overflow: hidden; background: #000; }
#battle-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; }
.hud-top { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.hud-turn { background: rgba(0,0,0,.65); padding: 8px 18px; border-radius: 999px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.hud-turn .dot { width: 12px; height: 12px; border-radius: 50%; }
.timer { font-weight: 800; font-size: 1.2em; background: rgba(255,255,255,.1); padding: 0 10px; border-radius: 8px; }
.timer.low { color: #ff6b6b; }
.hud-wind { display: flex; align-items: center; gap: 8px; background: rgba(0,0,0,.55); padding: 4px 12px; border-radius: 999px; font-size: .85em; }
.wind { width: 160px; height: 8px; background: rgba(255,255,255,.15); border-radius: 4px; position: relative; overflow: hidden; }
.wind::after { content: ''; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: #fff; }
.wind-arrows { color: #7fd8ff; letter-spacing: -2px; display: inline-block; min-width: 28px; }
.wind i { position: absolute; top: 0; bottom: 0; background: #7fd8ff; }
.hud-mode { font-size: .8em; color: #ddd; background: rgba(0,0,0,.4); padding: 2px 10px; border-radius: 999px; }
.hud-teams { position: absolute; top: 10px; left: 10px; display: flex; flex-direction: column; gap: 4px; background: rgba(0,0,0,.5); padding: 8px; border-radius: 10px; font-size: .82em; min-width: 220px; }
.tm { display: grid; grid-template-columns: 1fr 80px 32px; gap: 6px; align-items: center; opacity: .8; }
.tm.cur { opacity: 1; font-weight: 700; }
.hpbar { height: 8px; background: rgba(255,255,255,.12); border-radius: 4px; overflow: hidden; }
.hpbar i { display: block; height: 100%; transition: width .4s; }
.hud-right { position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; }
.controls h4 { margin: 14px 0 4px; color: var(--accent-2); }
.controls table { width: 100%; border-collapse: collapse; font-size: .92em; }
.controls td { padding: 4px 6px; border-bottom: 1px solid rgba(255,255,255,.06); vertical-align: middle; }
.controls td:first-child { width: 42%; white-space: nowrap; }
kbd { display: inline-block; min-width: 24px; padding: 2px 7px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line);
  border-bottom-width: 3px; font: 600 .85em system-ui, sans-serif; text-align: center; }
.modal-box:has(.controls) { width: min(560px, 100%); }
.lines { display: flex; flex-direction: column; gap: 6px; }
.line { background: rgba(0,0,0,.22); border-radius: 8px; padding: 6px 8px; display: grid; grid-template-columns: 1fr auto; grid-template-rows: 1.7em 6px; align-items: center; gap: 4px; font-size: .88em; height: 3.6em; box-sizing: border-box; }
.line > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.line .bar { grid-column: 1 / -1; }
.line.idle { opacity: .7; }
.queue { display: flex; flex-wrap: wrap; gap: 6px; }
.qchip { position: relative; display: inline-flex; align-items: center; gap: 2px; padding: 3px 6px; border-radius: 8px; border: 1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.25); color: inherit; font: inherit; cursor: pointer; }
.qchip b { font-size: .85em; }
.qchip .wart { width: 1.7em; height: 1.7em; }
.qchip .qx { position: absolute; top: -6px; right: -6px; font-style: normal; font-size: 9px; line-height: 14px; width: 14px; height: 14px; border-radius: 50%;
  background: #8a2a20; color: #fff; text-align: center; opacity: 0; transition: opacity .15s; }
.qchip:hover .qx, .qchip:focus .qx { opacity: 1; }
@media (hover: none) { .qchip .qx { opacity: .85; } }
.qrow { display: flex; justify-content: space-between; align-items: center; background: rgba(0,0,0,.18); padding: 4px 8px; border-radius: 8px; font-size: .9em; }
.qrow .btn { width: auto; margin: 0; }
.qty { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; font-size: .9em; }
.qty .btn { width: auto; margin: 0; }
.qty .btn.sel { background: var(--accent); color: #1a1007; border-color: var(--accent-2); }
.weapon-bar { position: absolute; bottom: 34px; left: 50%; transform: translateX(-50%); display: flex; gap: 6px; background: rgba(0,0,0,.55); padding: 6px; border-radius: 14px; }
.wbtn { position: relative; width: 56px; height: 56px; border-radius: 10px; border: 2px solid rgba(255,255,255,.15); background: rgba(255,255,255,.06); font-size: 1.5em; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; }
.wbtn small { font-size: .45em; margin-top: 2px; color: #ddd; }
.wbtn .k { position: absolute; top: 2px; left: 4px; font-size: .4em; color: #aaa; }
.wbtn.tool { border-color: rgba(120,200,255,.35); background: rgba(90,170,255,.12); }
.wbtn:not(.tool) + .wbtn.tool { margin-left: 12px; }
.wbtn.sel { border-color: var(--accent-2); background: rgba(255,180,80,.25); }
.wbtn:disabled { opacity: .35; cursor: not-allowed; }
.hud-ability { position: absolute; bottom: 108px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.65); border: 1px solid var(--accent); padding: 5px 14px; border-radius: 999px; font-size: .82em; white-space: nowrap; max-width: 95vw; overflow: hidden; text-overflow: ellipsis; }
.hud-help { position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%); font-size: .75em; color: #eee; background: rgba(0,0,0,.45); padding: 3px 12px; border-radius: 999px; white-space: nowrap; }
.overlay { position: absolute; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; }
.over-box { background: var(--panel); border: 2px solid var(--accent); border-radius: 20px; padding: 28px 40px; text-align: center; min-width: 300px; animation: tin .3s; }
.over-box h2 { font-size: 2.2em; margin: 0 0 8px; }
.rewards { display: flex; gap: 14px; justify-content: center; margin: 14px 0 20px; font-size: 1.2em; flex-wrap: wrap; }

@media (max-width: 860px) {
  .base-layout { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .side { max-height: 42vh; border-left: none; border-top: 2px solid var(--line); }
  .cell { min-height: 118px; }
  .rn { font-size: .78em; }
  .colony-row { grid-template-columns: 30px repeat(3, 1fr); gap: 6px; }
  .room-decor { font-size: 42px; }
  .walker { width: 36px; height: 25px; }
  .flora { left: 120px; }
  .hud-ability { position: absolute; bottom: 108px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.65); border: 1px solid var(--accent); padding: 5px 14px; border-radius: 999px; font-size: .82em; white-space: nowrap; max-width: 95vw; overflow: hidden; text-overflow: ellipsis; }
.hud-help { display: none; }
  .hud-teams { font-size: .7em; min-width: 0; }
}

.cls-tag { font-size: .75em; background: rgba(0,0,0,.3); padding: 1px 7px; border-radius: 999px; margin-left: 4px; white-space: nowrap; }
.cls-info { background: rgba(0,0,0,.25); border-left: 3px solid var(--accent); padding: 6px 10px; border-radius: 6px; }
.workers sup { font-size: .45em; margin-left: -4px; }
.weapon-bar { width: max-content; max-width: 96vw; flex-wrap: wrap; justify-content: center; }
.wbtn { width: 50px; height: 50px; }
@media (max-width: 760px) { .wbtn { width: 40px; height: 40px; font-size: 1.2em; } .hud-ability { bottom: 92px; } }
.choice button.over { opacity: .45; }
.choice button .cap { font-size: .85em; }
.pow { color: var(--accent); font-weight: 700; }

/* ===== Cartas de armas ===== */
.modal-box.wide { width: min(1040px, 100%); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 14px; margin: 12px 0; }
.card {
  position: relative; border-radius: 14px; padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 5px;
  background: linear-gradient(165deg, color-mix(in srgb, var(--tc) 28%, #1d1610), #110c07 72%);
  border: 2px solid var(--tc);
  box-shadow: 0 0 0 1px rgba(0,0,0,.55), 0 6px 18px rgba(0,0,0,.45), inset 0 0 22px color-mix(in srgb, var(--tc) 22%, transparent);
  transition: transform .15s;
}
.card:hover { transform: translateY(-3px); }
.card.plain { opacity: .92; }
.card[data-t="3"] { animation: legend 2.4s ease-in-out infinite; }
@keyframes legend { 50% { box-shadow: 0 0 0 1px rgba(0,0,0,.55), 0 0 26px color-mix(in srgb, var(--tc) 70%, transparent), inset 0 0 30px color-mix(in srgb, var(--tc) 35%, transparent); } }
.card.flash { animation: cardflash .7s ease-out; }
@keyframes cardflash { 0% { transform: scale(1.12); box-shadow: 0 0 40px var(--tc); } 100% { transform: scale(1); } }
.card-top { display: flex; justify-content: space-between; align-items: center; font-size: .74em; }
.tier-badge { background: var(--tc); color: #15100a; font-weight: 800; padding: 1px 8px; border-radius: 999px; }
.card .own { font-weight: 800; color: var(--tc); font-size: 1.15em; }
.card-art { font-size: 3.1em; text-align: center; padding: 10px 0; border-radius: 10px;
  background: radial-gradient(circle, color-mix(in srgb, var(--tc) 38%, transparent), transparent 70%), rgba(0,0,0,.25); }
.card-name { font-weight: 800; text-align: center; font-size: 1.02em; }
.card-kind { text-align: center; font-size: .7em; color: var(--muted); }
.card-desc { font-size: .78em; color: #eadfcb; min-height: 3.4em; line-height: 1.35; }
.card-stats { width: 100%; font-size: .8em; border-collapse: collapse; }
.card-stats td { padding: 2px 4px; border-top: 1px solid rgba(255,255,255,.08); }
.card-stats td:last-child { text-align: right; font-weight: 700; color: var(--tc); }
.tier-tabs { display: flex; gap: 4px; margin-top: 4px; }
.tier-tabs button { flex: 1; background: rgba(0,0,0,.35); border: 1px solid var(--tc); color: var(--tc); border-radius: 6px; font-weight: 800;
  cursor: pointer; padding: 2px 0; display: flex; flex-direction: column; align-items: center; line-height: 1.15; font-size: .8em; }
.tier-tabs button small { color: #cfc4b2; font-weight: 400; }
.tier-tabs button.on { background: var(--tc); color: #15100a; }
.tier-tabs button.on small { color: #15100a; }
.card .merge { margin-top: 6px; width: 100%; }
.card .merge:not(:disabled) { background: var(--tc); color: #15100a; border-color: var(--tc); font-weight: 800; }
.tier-dot { font-style: normal; font-size: .7em; font-weight: 800; color: #15100a; padding: 0 5px; border-radius: 4px; margin-right: 2px; }
.craft-stats { display: block; color: var(--muted); font-size: .8em; }
.lob-card { display: inline-block; border: 2px solid; border-radius: 8px; padding: 0 6px; margin: 2px; }
.wbtn .tier { position: absolute; top: 2px; right: 3px; font-style: normal; font-size: .38em; font-weight: 800; color: #15100a; padding: 0 3px; border-radius: 3px; line-height: 1.4; }

/* ===== Armado de equipo y de armas ===== */
.styles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.style-btn { background: var(--panel); border: 2px solid var(--line); border-radius: 12px; padding: 8px 10px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; transition: border-color .15s, transform .1s; }
.style-btn:hover { border-color: var(--accent); transform: translateY(-2px); }
.style-btn .st-icon { font-size: 1.6em; }
.style-btn small { color: var(--muted); font-size: .72em; line-height: 1.3; }
.style-btn.mine { border-style: dashed; cursor: default; }
.style-btn.mine:hover { transform: none; }
.style-btn .st-load { background: none; border: none; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; padding: 0; }
.style-btn .st-load:disabled { cursor: default; opacity: .6; }
.style-btn.mine .btn { width: 100%; margin-top: 4px; }
.prep-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.prep-panel { background: rgba(0,0,0,.2); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.prep-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.prep-head h3 { margin: 0; }
.prep-head span { flex: 1; color: var(--muted); }
.lobby-squad .sq { font-size: 1em; min-width: 96px; gap: 1px; }
.sq .bug-svg { width: 55px; height: 38px; overflow: visible; }
.sq b { font-size: .85em; } .sq small { font-size: .7em; }
.dchip { display: inline-flex; align-items: center; gap: 2px; border: 2px solid var(--tc); border-radius: 8px; padding: 1px 6px; margin: 2px; font-size: 1.1em;
  background: color-mix(in srgb, var(--tc) 15%, transparent); }
.dchip i:not(.wart) { font-style: normal; font-size: .55em; font-weight: 800; color: #15100a; background: var(--tc); border-radius: 3px; padding: 0 3px; }
.basics { font-size: .8em; margin-top: 6px; }
.builder-sum { background: rgba(0,0,0,.3); border-radius: 10px; padding: 6px 10px; }
.pow.over { color: #ff6b5a; }
.style-row { display: flex; gap: 6px; flex-wrap: wrap; }
.style-row .btn { width: auto; margin: 0; }
.roster { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 8px; margin-bottom: 10px; }
.bcard { position: relative; background: var(--panel-2); border: 2px solid var(--line); border-radius: 12px; padding: 8px 6px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 1px; transition: transform .1s, border-color .15s; }
.bcard:hover { transform: translateY(-2px); border-color: var(--accent); }
.bcard.on { border-color: var(--accent-2); background: color-mix(in srgb, var(--accent) 22%, var(--panel-2)); box-shadow: 0 0 12px rgba(255,180,80,.25); }
.bcard small { color: var(--muted); font-size: .72em; }
.bcard-art .bug-svg { width: 70px; height: 48px; overflow: visible; }
.bcard-pos { position: absolute; top: 4px; left: 6px; width: 20px; height: 20px; border-radius: 50%; background: rgba(0,0,0,.4); font-size: .75em; font-weight: 800;
  display: flex; align-items: center; justify-content: center; }
.bcard.on .bcard-pos { background: var(--accent); color: #1a1007; }
.deck-slots, .mini-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; margin-bottom: 8px; }
.mcard { position: relative; min-height: 112px; border: 2px solid var(--tc); border-radius: 10px; padding: 6px 4px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center;
  background: linear-gradient(165deg, color-mix(in srgb, var(--tc) 26%, #1d1610), #110c07 75%); transition: transform .1s; }
.mcard:hover:not(:disabled) { transform: translateY(-2px); }
.mcard:disabled { opacity: .4; cursor: not-allowed; }
.mcard.empty { --tc: rgba(255,255,255,.15); border-style: dashed; color: var(--muted); justify-content: center; cursor: default; font-size: .8em; }
.mc-tier { position: absolute; top: 3px; left: 4px; font-size: .62em; font-weight: 800; color: #15100a; background: var(--tc); border-radius: 3px; padding: 0 3px; }
.mc-art { font-size: 1.8em; margin-top: 6px; }
.mc-name { font-size: .68em; font-weight: 700; line-height: 1.1; }
.mc-pow { font-size: .7em; color: var(--accent-2); font-weight: 700; }
.mc-n { position: absolute; top: 3px; right: 5px; font-size: .7em; font-weight: 800; color: var(--tc); }
.mc-x { position: absolute; top: 2px; right: 5px; font-size: .7em; color: #ff8a7a; }
@media (max-width: 760px) { .prep-grid { grid-template-columns: 1fr; } }
.modal-box h4 .btn { width: auto; margin: 0 0 0 8px; padding: 2px 8px; }
/* Mano de cartas en batalla */
.hand-info { display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 0 8px; color: #eee; font-size: .8em; line-height: 1.25; border-right: 1px solid rgba(255,255,255,.15); margin-right: 4px; white-space: nowrap; }
.hand-info small { color: #bbb; font-size: .85em; }
.wdis { position: absolute; bottom: -6px; right: -6px; width: 18px; height: 18px; border-radius: 50%; background: #c0392b; color: #fff; font-size: 10px; line-height: 18px; text-align: center; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.5); }
.wdis:hover { background: #e74c3c; transform: scale(1.15); }

/* ===== Mano de cartas en batalla: cartas de verdad ===== */
#screen-battle .weapon-bar { align-items: flex-end; flex-wrap: nowrap; gap: 10px; padding: 8px 14px 8px 8px; background: linear-gradient(to top, rgba(0,0,0,.7), rgba(0,0,0,.35)); border-radius: 16px 16px 12px 12px; }
#screen-battle .hud-ability { bottom: 156px; }
.weapon-bar .basics { display: flex; flex-direction: column; gap: 4px; }
.weapon-bar .wbtn.basic { width: 40px; height: 32px; font-size: 1.05em; flex-direction: row; gap: 2px; }
.weapon-bar .wbtn.basic small { font-size: .55em; margin: 0; }
.weapon-bar .wbtn.basic .k { top: 1px; left: 3px; }
.hand-info { align-self: center; gap: 2px; }
.deck-stack { position: relative; width: 34px; height: 46px; border-radius: 5px; border: 2px solid #e8c27a; display: flex; align-items: center; justify-content: center;
  background: repeating-linear-gradient(45deg, #5a3b1c 0 5px, #6e4a24 5px 10px); box-shadow: 2px 2px 0 #3a2510, 4px 4px 0 #2a1a0b; color: #fff; font-size: 1.05em; }
.deck-stack b { background: rgba(0,0,0,.55); border-radius: 50%; min-width: 22px; line-height: 22px; text-align: center; }
.hand { display: flex; align-items: flex-end; padding: 0 6px; }
.hcard { position: relative; width: 70px; height: 100px; margin: 0 -5px; padding: 0; border-radius: 9px; cursor: pointer; color: #2a1c0e;
  border: 3px solid var(--tc); transform-origin: 50% 120%; transition: transform .15s, box-shadow .15s, filter .15s;
  background: linear-gradient(170deg, #fff6df 0%, #f0dcb0 55%, #e0c38c 100%);
  box-shadow: 0 4px 10px rgba(0,0,0,.55), inset 0 0 0 2px rgba(255,255,255,.55);
  display: flex; flex-direction: column; align-items: center; font-family: inherit; }
.hcard.tool { background: linear-gradient(170deg, #eaf6ff 0%, #c9e4fb 55%, #9fc9ef 100%); }
.hcard:hover:not(:disabled) { transform: translateY(-22px) scale(1.12) !important; z-index: 30 !important; box-shadow: 0 10px 22px rgba(0,0,0,.6), 0 0 0 2px var(--tc); }
.hcard.sel { box-shadow: 0 0 0 3px #fff, 0 0 18px 4px var(--tc), 0 8px 18px rgba(0,0,0,.6); }
.hcard:disabled { filter: brightness(.6) saturate(.7); cursor: default; }
.hc-top { width: 100%; display: flex; justify-content: space-between; align-items: center; padding: 2px 3px 0; }
.hc-key { font-size: 10px; font-weight: 800; color: rgba(0,0,0,.45); min-width: 10px; }
.hc-tier { font-size: 9px; font-weight: 800; color: #15100a; background: var(--tc); border-radius: 3px; padding: 0 3px; line-height: 13px; }
.hc-art { width: 54px; height: 38px; margin-top: 2px; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 26px;
  background: radial-gradient(circle at 50% 40%, rgba(255,255,255,.9), color-mix(in srgb, var(--tc) 45%, #fff) 70%); border: 1px solid rgba(0,0,0,.18); }
.hc-name { font-size: 9.5px; font-weight: 800; line-height: 1.05; margin-top: 3px; padding: 0 3px; text-align: center; height: 20px; overflow: hidden; display: flex; align-items: center; }
.hc-stat { font-size: 8.5px; font-weight: 700; color: #6a4a22; margin-top: auto; margin-bottom: 4px; white-space: nowrap; max-width: 64px; overflow: hidden; text-overflow: ellipsis; }
.hcard .wdis { top: -7px; right: -7px; bottom: auto; }
.hcard.empty { border: 2px dashed rgba(255,255,255,.25); background: rgba(255,255,255,.04); box-shadow: none; justify-content: center; cursor: default; color: rgba(255,255,255,.25); font-size: 20px; margin: 0 2px; }
@media (max-width: 760px) {
  #screen-battle .weapon-bar { gap: 4px; padding: 4px; max-width: 99vw; }
  #screen-battle .hud-ability { bottom: 118px; }
  .hcard { width: 48px; height: 70px; margin: 0 -4px; border-width: 2px; }
  .hc-art { width: 38px; height: 26px; font-size: 18px; }
  .hc-name { font-size: 7.5px; height: 16px; }
  .hc-stat { display: none; }
  .deck-stack { width: 26px; height: 36px; }
  .hand-info small { display: none; }
  .weapon-bar .wbtn.basic { width: 34px; height: 26px; }
}

/* carta recién robada en la mano */
.hcard.fresh { animation: freshcard 1.4s ease-out; }
@keyframes freshcard { 0% { box-shadow: 0 0 22px 6px #ffe08a; filter: brightness(1.5); } 100% { box-shadow: none; filter: none; } }

/* carta de habilidad del bicho */
.wbtn.ability { border-width: 2px; background: linear-gradient(160deg, color-mix(in srgb, var(--tc) 30%, rgba(0,0,0,.4)), rgba(0,0,0,.5)); }
.wbtn.ability.passive { opacity: .8; }
.wbtn.ability .k { font-size: .32em; }

/* Dibujos de las cartas (hoja de sprites) */
.wart { display: inline-block; width: 1.25em; height: 1.25em; vertical-align: middle; font-style: normal;
  background: url(../assets/sprites/cartas.webp?v=28) no-repeat; background-size: 600% 500%; filter: drop-shadow(0 1px 1px rgba(0,0,0,.35)); }
.hcard .hc-art { height: 44px; }
.hc-art .wart { width: 42px; height: 42px; }
.card-art .wart { width: 1.5em; height: 1.5em; }
.mc-art .wart { width: 1.3em; height: 1.3em; }
.craft-art .wart { width: 2.2em; height: 2.2em; }
.lines .wart, .qrow .wart { width: 1.6em; height: 1.6em; }
.wbtn.basic .wart { width: 24px; height: 24px; }
@media (max-width: 760px) { .hcard .hc-art { height: 28px; } .hc-art .wart { width: 26px; height: 26px; } .wbtn.basic .wart { width: 20px; height: 20px; } }

/* las básicas y la habilidad también son cartas (a la izquierda de la mano) */
.weapon-bar .basics { flex-direction: row; align-items: flex-end; gap: 0; margin: 0; font-size: 1em; padding: 0 8px 0 4px; border-right: 1px solid rgba(255,255,255,.15); }
.hcard.basic { background: linear-gradient(170deg, #fff6dc 0%, #f1dca4 55%, #d9b56a 100%); }
.hcard.ability { background: linear-gradient(170deg, #f4ecff 0%, color-mix(in srgb, var(--tc) 35%, #fff) 60%, color-mix(in srgb, var(--tc) 60%, #555) 100%); }
.hcard.ability.passive { filter: saturate(.75); }
.hcard .ab-art { font-size: 30px; display: flex; align-items: center; justify-content: center; }
@media (max-width: 760px) { .hcard .ab-art { font-size: 20px; } }

/* panel derecho: solo la habitación que estás trabajando */
.side.empty { display: flex; flex-direction: column; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.panel-head h3 { margin: 0; }
.panel-head .btn { width: auto; margin: 0; }

/* panel de bichos (cartas por clase y tier) */
.bgroups { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-bottom: 10px; }
.bgroup, .bugcard { position: relative; border: 2px solid var(--tc); border-radius: 12px; padding: 8px 8px 10px; display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center;
  background: linear-gradient(165deg, color-mix(in srgb, var(--tc) 26%, #1d1610), #110c07 75%); }
.bgroup .tier-badge, .bugcard .tier-badge { position: absolute; top: 6px; left: 6px; background: var(--tc); color: #15100a; font-weight: 800; font-size: .72em; padding: 0 6px; border-radius: 999px; }
.bg-art .bug-svg { width: 74px; height: 52px; overflow: visible; }
.bg-n { position: absolute; top: 4px; right: 8px; font-weight: 800; color: var(--tc); font-size: 1.1em; }
.bgroup small, .bugcard small { font-size: .74em; }
.bgroup .merge { width: 100%; margin-top: 4px; }
.bgroup .merge:not(:disabled) { background: var(--tc); color: #15100a; border-color: var(--tc); font-weight: 800; }
.bugcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; margin-bottom: 10px; }
.bugcard.squad { box-shadow: 0 0 0 2px #ffd45c, 0 0 14px rgba(255,212,92,.35); }
.bugcard .star { position: absolute; top: 2px; right: 2px; }
.bc-art .bug-svg { width: 58px; height: 40px; overflow: visible; }
.race-mini { margin: 6px 0 10px; font-size: .88em; }
.race-mini summary { cursor: pointer; color: var(--accent-2); }

/* ---- viajes por los túneles: recolectar afuera y mudarse de sala ---- */
.colony { position: relative; }
.colony-fx { position: absolute; inset: 0; pointer-events: none; z-index: 6; }
.traveler { position: absolute; left: 0; top: 0; width: 40px; height: 28px; will-change: transform; }
.traveler .tv-bug { width: 100%; height: 100%; }
.traveler .bug-svg { width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 2px 1px rgba(0,0,0,.5)); }
.traveler.busy .bug-svg { animation: forage .25s ease-in-out infinite alternate; }
@keyframes forage { to { transform: translateY(-3px) rotate(-10deg); } }
.traveler .carry { position: absolute; left: 50%; top: -12px; transform: translateX(-50%); font-size: 17px; line-height: 1; filter: drop-shadow(0 1px 1px rgba(0,0,0,.6)); }
.fx-pop { position: absolute; transform: translateX(-50%); font-weight: 800; font-size: .9em; color: #c8ff9e; text-shadow: 0 1px 2px #000, 0 0 6px rgba(0,0,0,.6); white-space: nowrap; animation: fxpop 1.5s ease-out forwards; }
@keyframes fxpop { 0% { opacity: 0; margin-top: 6px; } 15% { opacity: 1; } 100% { opacity: 0; margin-top: -34px; } }
.res-node { position: absolute; bottom: 18px; transform: translateX(-50%); z-index: 3; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.res-node .pile { font-size: 28px; letter-spacing: -6px; line-height: 1; filter: drop-shadow(0 2px 1px rgba(0,0,0,.35)); }
.res-node small { font-size: 10px; font-weight: 700; color: #fff; background: rgba(0,0,0,.45); padding: 0 6px; border-radius: 999px; white-space: nowrap; }

/* Online */
.net-wait { position: absolute; top: 96px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.7); color: #fff; padding: 6px 16px; border-radius: 999px; font-size: .9em; pointer-events: none; }
.online-box { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.online-box .btn { width: auto; margin: 0; }
.join-code { display: inline-flex; gap: 4px; }
.join-code input { width: 92px; text-transform: uppercase; letter-spacing: 2px; font-weight: 700; text-align: center; padding: 6px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: inherit; }
.room-code { font-size: 2.2em; font-weight: 800; letter-spacing: 8px; text-align: center; padding: 8px; border: 2px dashed var(--accent); border-radius: 12px; margin: 6px 0 12px; user-select: all; }
.online-players { list-style: none; padding: 0; margin: 8px 0 14px; display: flex; flex-direction: column; gap: 6px; }
.online-players li { background: rgba(0,0,0,.2); border-radius: 8px; padding: 6px 10px; }
.ow-side { display: inline-block; min-width: 72px; font-size: .75em; color: var(--muted); }
.ol-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; width: 100%; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.ol-h { flex-basis: 100%; font-size: .9em; }
.online-box > small { flex-basis: 100%; }
.online-players li.me { outline: 2px solid var(--accent, #ffcf4a); }
.ow-teams { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ow-teams .online-players { margin: 8px 0 6px; }
.ow-sit { width: auto; margin: 0 0 0 6px; padding: 2px 8px; font-size: .8em; }
@media (max-width: 560px) { .ow-teams { grid-template-columns: 1fr; } }

/* =====================================================================
   UI de la base (v43) y celular
   ===================================================================== */
/* --- base: barra superior y botones con ícono + texto --- */
.top-actions .btn { display: inline-flex; align-items: center; gap: 6px; }
.top-actions .lbl.opt { display: none; }
.res b { font-variant-numeric: tabular-nums; }

/* --- salas: aviso de sala vacía --- */
.cell.room.needs::after {
  content: '!'; position: absolute; top: 8px; right: 10px; z-index: 2; width: 20px; height: 20px; border-radius: 50%;
  background: #ff9f2e; color: #2a1404; font-weight: 900; font-size: 13px; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 2px rgba(0,0,0,.35), 0 0 12px rgba(255,160,50,.8); animation: needpulse 1.6s ease-in-out infinite;
}
.cell.room.needs .lv { margin-right: 22px; }
@keyframes needpulse { 50% { transform: scale(1.18); } }

/* --- panel lateral: resumen de la colonia y panel de sala --- */
.colony-sum h3 { margin-bottom: 10px; }
.cstats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cstat { background: rgba(0,0,0,.22); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.cstat .cs-ico { font-size: 1.2em; line-height: 1; }
.cstat .cs-lbl { font-size: .75em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cstat b { font-size: 1.15em; font-variant-numeric: tabular-nums; }
.cstat b small { color: var(--muted); font-weight: 500; }
.panel.alert { border-color: #a8662a; background: linear-gradient(rgba(255,150,50,.1), rgba(255,150,50,.03)), var(--panel-2); }
.panel.alert h4 { margin-top: 0; }
.go-list { display: flex; flex-direction: column; gap: 6px; }
.go-room { text-align: left; background: rgba(0,0,0,.25); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; cursor: pointer; }
.go-room:hover { border-color: var(--accent); }
.go-room small { color: var(--muted); float: right; }
.room-panel { position: relative; }
.room-panel .panel-head { justify-content: flex-start; gap: 10px; margin-bottom: 4px; }
.room-panel .panel-head h3 { flex: 1; display: flex; flex-direction: column; line-height: 1.15; font-size: 1.1em; }
.ph-ico { width: 46px; height: 46px; flex-shrink: 0; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 26px;
  background: linear-gradient(var(--w1, #6a4a30), var(--w2, #3d2a1a)); border: 2px solid rgba(0,0,0,.4); box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
.ph-lv { color: #ffd45c; letter-spacing: -1px; font-size: .75em; }
.ph-lv .off { color: rgba(255,255,255,.2); }
.sheet-grip { display: none; }

/* --- controles táctiles: escondidos salvo en pantallas táctiles --- */
.touch-pad, .rotate-hint { display: none; }

/* =====================================================================
   Celular (pantallas angostas)
   ===================================================================== */
@media (max-width: 700px) {
  body { -webkit-tap-highlight-color: transparent; }
  .btn { touch-action: manipulation; }

  /* barra de arriba compacta, recursos en una fila que se desliza */
  .topbar { gap: 6px 10px; padding: 8px 10px 6px; padding-top: calc(8px + env(safe-area-inset-top)); flex-wrap: wrap; }
  .brand { font-size: 1.05em; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .resources { order: 3; flex: 1 0 100%; flex-wrap: nowrap; overflow-x: auto; gap: 6px; scrollbar-width: none; padding-bottom: 2px; }
  .resources::-webkit-scrollbar { display: none; }
  .res { padding: 4px 10px; font-size: .85em; flex-shrink: 0; }

  /* botones como barra de navegación fija abajo */
  .top-actions {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: var(--panel); border-top: 2px solid var(--line);
    box-shadow: 0 -6px 18px rgba(0,0,0,.35);
  }
  .top-actions .btn { flex-direction: column; gap: 1px; padding: 5px 2px; border-radius: 12px; min-height: 52px; justify-content: center; }
  .top-actions .ico { font-size: 1.35em; line-height: 1.1; }
  .top-actions .lbl, .top-actions .lbl.opt { display: block; font-size: .7em; }
  #screen-base .base-layout { padding-bottom: calc(66px + env(safe-area-inset-bottom)); }

  /* colonia más compacta */
  .colony-wrap { padding: 0 6px 16px; }
  .surface { height: 112px; margin: 0 -6px 10px; }
  .entrance { transform: scale(.75); transform-origin: left bottom; }
  .flora { left: 96px; font-size: 1.1em; }
  .colony-row { grid-template-columns: 18px repeat(3, 1fr); gap: 5px; margin-bottom: 6px; }
  .colony-row:has(.cell.room)::before { left: 9px; height: 26px; }
  .cell { min-height: 100px; border-radius: 14px; }
  .cell.room { padding: 6px 6px 0; gap: 3px; border-width: 2px; }
  .cell.room:hover { transform: none; }
  .room-decor { display: none; }
  .room-lamp { width: 16px; height: 4px; }
  .room-head { gap: 3px; flex-wrap: wrap; }
  .ri { font-size: 1em; }
  .rn { font-size: .68em; flex: 1 1 60%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .lv { font-size: .6em; }
  .room-status { flex-wrap: wrap; gap: 3px; }
  .room-info { font-size: .64em; padding: 0 6px; max-width: 100%; }
  .pips i { width: 6px; height: 6px; }
  .room-floor { height: 30px; margin: auto -6px 0; }
  .walker { width: 28px; height: 20px; bottom: 6px; }
  .cell.empty { font-size: .8em; }
  .cell.room.needs::after { width: 16px; height: 16px; font-size: 11px; top: 5px; right: 5px; }
  .cell.room.needs .lv { margin-right: 16px; }

  /* panel de la sala: hoja que sube desde abajo; sin sala elegida no ocupa lugar */
  .side, .side.empty { display: none; }
  body.sheet-open #screen-base .side {
    display: block; position: fixed; left: 0; right: 0; bottom: calc(66px + env(safe-area-inset-bottom)); z-index: 35;
    max-height: 62vh; max-height: 62dvh; padding: 0 10px 10px; border: 0; border-top: 2px solid var(--accent);
    border-radius: 20px 20px 0 0; box-shadow: 0 -12px 30px rgba(0,0,0,.6); animation: sheetup .22s ease-out;
  }
  body.sheet-open #screen-base .side .panel { border: 0; background: transparent; padding: 4px 4px 8px; margin: 0; }
  .sheet-grip { display: block; width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 8px auto 6px; }
  .room-panel .panel-head { position: sticky; top: 0; background: var(--panel); z-index: 2; padding: 4px 0 8px; }
  .wrow { padding: 6px 8px; }
  .craft { padding: 10px; }

  /* ventanas: ocupan el ancho y salen desde abajo */
  .modal { padding: 0; align-items: flex-end; }
  .modal-box, .modal-box.wide, .modal-box:has(.controls) {
    width: 100%; max-height: 92vh; max-height: 92dvh; border-radius: 20px 20px 0 0; border-width: 2px 0 0;
    padding: 14px 12px calc(14px + env(safe-area-inset-bottom)); animation: sheetup .22s ease-out;
  }
  .cards { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
  .bgroups { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .bugcards { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
  .roster { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
  .deck-slots, .mini-cards { grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); }
  .controls td:first-child { white-space: normal; width: 34%; }

  #toast { bottom: calc(80px + env(safe-area-inset-bottom)); width: 92vw; align-items: center; }
  .toast-item { white-space: normal; text-align: center; font-size: .9em; }

  /* elegir raza / ingresar */
  #screen-race { padding: 18px 12px; }
  .race-cards { gap: 12px; }
  .race-card { width: 100%; max-width: 420px; padding: 16px; }
  .race-emoji { font-size: 3.4rem; }
  .subtitle { margin-bottom: 18px; }

  /* lobby: acciones fijas abajo */
  .lobby { padding: 14px 10px 110px; }
  .lobby h1 { font-size: 1.5em; }
  .choice { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
  .choice button { padding: 10px; font-size: .95em; }
  .styles { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .lobby-actions {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; margin: 0; padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    background: var(--panel); border-top: 2px solid var(--line); flex-wrap: nowrap;
  }
  .lobby-actions .btn { flex: 1; padding: 10px 6px; font-size: .9em; }
  .lobby-actions .btn.big { flex: 1.6; font-size: 1.05em; }
  .lobby-actions .btn-controls { display: none; }
  .room-code { font-size: 1.7em; letter-spacing: 5px; }
}
@keyframes sheetup { from { transform: translateY(40px); opacity: 0; } }

/* =====================================================================
   Batalla en pantallas táctiles
   ===================================================================== */
body.touch #battle-canvas { touch-action: none; cursor: default; }
body.touch .hud-help { display: none; }
body.touch .touch-pad { display: block; position: absolute; inset: 0; pointer-events: none; z-index: 5; }
body.touch { --tp: clamp(42px, 11vmin, 60px); }
body.touch .touch-pad button {
  pointer-events: auto; touch-action: none; user-select: none; -webkit-user-select: none;
  width: var(--tp); height: var(--tp); border-radius: 50%; border: 2px solid rgba(255,255,255,.35);
  background: rgba(20,14,8,.55); color: #fff; font-size: calc(var(--tp) * .42); line-height: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0;
  box-shadow: 0 3px 10px rgba(0,0,0,.4);
}
body.touch .touch-pad button.hidden { display: none !important; }
body.touch .touch-pad button small { font-size: 9px; opacity: .8; margin-top: 1px; }
body.touch .touch-pad button.on { background: rgba(255,180,80,.55); border-color: #ffd28a; transform: scale(.94); }
.tp-dpad {
  position: absolute; left: calc(10px + env(safe-area-inset-left)); bottom: calc(10px + env(safe-area-inset-bottom));
  display: grid; grid-template-columns: repeat(3, var(--tp)); grid-template-rows: repeat(3, var(--tp)); gap: 2px;
}
.tp-dpad .tp-up { grid-area: 1 / 2; } .tp-dpad .tp-left { grid-area: 2 / 1; }
.tp-dpad .tp-right { grid-area: 2 / 3; } .tp-dpad .tp-down { grid-area: 3 / 2; }
.tp-acts {
  position: absolute; right: calc(10px + env(safe-area-inset-right)); bottom: calc(10px + env(safe-area-inset-bottom));
  display: grid; grid-template-columns: repeat(2, var(--tp)) calc(var(--tp) * 1.45); grid-template-rows: var(--tp) var(--tp); gap: 6px; align-items: end;
}
.tp-acts .tp-back { grid-area: 2 / 1; } .tp-acts .tp-jump { grid-area: 2 / 2; } .tp-acts .tp-high { grid-area: 1 / 2; }
.tp-acts .tp-rot { grid-area: 1 / 1; }
body.touch .tp-acts .tp-fire {
  grid-area: 1 / 3 / 3 / 4; width: calc(var(--tp) * 1.45); height: calc(var(--tp) * 1.45); align-self: center;
  background: radial-gradient(circle at 40% 35%, rgba(255,140,60,.85), rgba(170,40,10,.8)); border-color: #ffb36a; font-size: calc(var(--tp) * .6);
}
/* HUD de la batalla ajustado al celular */
body.touch #screen-battle .weapon-bar {
  left: 50%; bottom: calc(6px + env(safe-area-inset-bottom)); max-width: calc(100vw - var(--tp) * 7.6 - 40px);
  min-width: 0; overflow-x: auto; flex-wrap: nowrap; justify-content: flex-start; scrollbar-width: none; padding: 4px;
}
body.touch .weapon-bar::-webkit-scrollbar { display: none; }
body.touch .hcard:hover:not(:disabled) { transform: none !important; }
body.touch .hud-ability { bottom: auto; top: 86px; font-size: .72em; max-width: 70vw; }
body.touch .hud-teams { font-size: .66em; min-width: 0; padding: 5px; top: calc(6px + env(safe-area-inset-top)); left: calc(6px + env(safe-area-inset-left)); }
body.touch .tm { grid-template-columns: 1fr 50px 26px; }
body.touch .hud-top { top: calc(6px + env(safe-area-inset-top)); gap: 3px; }
body.touch .hud-turn { padding: 4px 12px; font-size: .8em; }
body.touch .hud-wind { padding: 2px 10px; font-size: .72em; }
body.touch .wind { width: 90px; }
body.touch .hud-mode { display: none; }
body.touch .hud-right { top: calc(6px + env(safe-area-inset-top)); right: calc(6px + env(safe-area-inset-right)); }
body.touch .hud-right .btn { padding: 4px 8px; font-size: .75em; }
body.touch .over-box { padding: 18px; min-width: 0; width: min(92vw, 420px); }
@media (orientation: portrait) {
  body.touch .rotate-hint {
    display: block; position: absolute; left: 50%; top: 40%; transform: translateX(-50%); z-index: 6; pointer-events: none;
    background: rgba(0,0,0,.72); color: #fff; padding: 8px 16px; border-radius: 999px; font-size: .85em; white-space: nowrap;
    animation: tin .3s, fadeout 1s 5s forwards;
  }
  body.touch #screen-battle .weapon-bar { bottom: calc(var(--tp) * 3 + 24px); max-width: 96vw; }
  body.touch .hud-ability { top: 130px; }
  body.touch .hud-top { top: calc(58px + env(safe-area-inset-top)); }
  body.touch .hud-right .btn-controls { display: none; }
}
@keyframes fadeout { to { opacity: 0; } }

/* ===== Cría: reina, huevos, larvas y sala de descanso ===== */
.t-descanso   { --w1: #4d5c7a; --w2: #262d40; }
.queen { position: absolute; bottom: 2px; left: 8%; width: 104px; height: 74px; transform-origin: bottom center; z-index: 2;
  filter: drop-shadow(0 0 6px rgba(255, 210, 90, .55)) drop-shadow(0 2px 2px rgba(0,0,0,.5)); }
.queen svg { width: 100%; height: 100%; }
.queen .bug-svg * { animation: none !important; } /* la reina no camina: patas y antenas quietas */
.queen.laying { animation: queen-lay 1.8s ease-in-out; }
@keyframes queen-lay { 0%, 100% { transform: none; } 20% { transform: translateY(2px) scale(1.03, .93); } 45% { transform: translateY(-1px) scale(.98, 1.04); }
  65% { transform: translateY(2px) scale(1.04, .92); } 85% { transform: translateY(0) scale(1, 1); } }
.egg.new-egg { position: absolute; bottom: 30px; z-index: 3; animation: egg-drop 1.8s ease-in forwards; }
@keyframes egg-drop { 0%, 55% { opacity: 0; transform: translateY(0) scale(.4); } 62% { opacity: 1; transform: translateY(0) scale(.8); }
  88% { transform: translateY(22px) scale(1); } 94% { transform: translateY(19px) scale(1.05, .9); } 100% { opacity: 1; transform: translateY(22px) scale(1); } }
@keyframes queen-breathe { 50% { transform: scale(1.04, .97); } }
.egg-pile, .brood { position: absolute; bottom: 8px; display: flex; gap: 3px; align-items: flex-end; }
.egg-pile { left: 46%; flex-wrap: wrap; width: 46%; }
.brood { left: 50%; transform: translateX(-50%); gap: 7px; }
.egg { display: inline-block; width: 10px; height: 13px; border-radius: 50% 50% 46% 46% / 58% 58% 42% 42%; background: radial-gradient(circle at 35% 30%, #fffef6, #f1e6c6 60%, #cdbb8e); box-shadow: 0 1px 2px rgba(0,0,0,.35); }
.larva { position: relative; display: inline-block; width: 22px; height: 12px; border-radius: 10px 12px 6px 8px; transform: scale(var(--g, .7)); transform-origin: bottom center;
  background: repeating-linear-gradient(90deg, #f6ecd2 0 4px, #e7d6ae 4px 6px); box-shadow: 0 1px 2px rgba(0,0,0,.35); animation: wiggle 1.4s ease-in-out infinite; }
.larva.hungry { animation-duration: .5s; }
.larva b { position: absolute; top: -20px; left: 8px; font-size: 13px; font-weight: 400; animation: queen-breathe 1s ease-in-out infinite; }
@keyframes wiggle { 50% { transform: scale(var(--g, .7)) skewX(-8deg); } }
.walker.sleeper { animation: none; bottom: 6px; filter: saturate(.6) brightness(.85); }
.walker.sleeper svg { transform: rotate(8deg); }
.walker .zz { position: absolute; top: -10px; right: -2px; font-size: 11px; font-weight: 800; color: #cfe0ff; opacity: 0; animation: zz 3s ease-in-out var(--zz, 0s) infinite; }
@keyframes zz { 0% { opacity: 0; transform: translate(0, 4px) scale(.7); } 30% { opacity: 1; } 100% { opacity: 0; transform: translate(8px, -12px) scale(1.3); } }
@media (max-width: 700px) {
  .queen { width: 62px; height: 44px; bottom: 1px; }
  .egg.new-egg { bottom: 18px; }
  .egg { width: 7px; height: 9px; }
  .larva { width: 15px; height: 8px; }
  .larva b { font-size: 10px; top: -14px; }
  .egg-pile, .brood { bottom: 4px; }
}

/* ===== Recolección: pila en la sala, paquetes y almacén ===== */
.res-stack { position: absolute; right: 6%; bottom: 8px; display: flex; align-items: flex-end; gap: 1px; flex-wrap: wrap-reverse; justify-content: flex-end; max-width: 46%; pointer-events: none; }
.res-stack .raw { font-style: normal; font-size: 13px; line-height: 1; margin-left: -5px; transform: rotate(calc(var(--i) * 37deg - 40deg)); filter: drop-shadow(0 1px 1px rgba(0,0,0,.5)); }
.pkg { display: inline-flex; align-items: center; justify-content: center; width: 17px; height: 15px; margin: 0 1px; font-style: normal; font-size: 10px; line-height: 1;
  background: linear-gradient(#c79a5c, #9a6e36); border: 1px solid #5e3f1a; border-radius: 3px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.18), 0 1px 2px rgba(0,0,0,.5); }
.store-stack { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); display: flex; gap: 12px; pointer-events: none; }
.store-stack .col { display: flex; flex-direction: column-reverse; gap: 1px; }
.traveler .carry .egg { display: block; width: 10px; height: 13px; }
.traveler .carry .pkg { width: 15px; height: 13px; font-size: 9px; }
@media (max-width: 700px) {
  .res-stack .raw { font-size: 10px; }
  .pkg { width: 13px; height: 11px; font-size: 8px; }
  .store-stack { gap: 6px; }
}

/* especialidad de cada clase en la colonia */
.work-tip { font-size: .85em; background: rgba(255,200,80,.12); border: 1px solid rgba(255,200,80,.35); border-radius: 8px; padding: 5px 8px; margin: 6px 0; }
.work-on { color: #ffd166; font-weight: 700; }
.work-txt { color: #ffd166; }

/* lobby casual: todo disponible */
.casual-note { background: rgba(120,200,120,.12); border: 1px solid rgba(120,200,120,.4); border-radius: 10px; padding: 8px 12px; margin: 8px 0; }

/* dibujos de recursos y cría (recursos.png, cria.png) */
.rart { display: inline-block; width: 1.25em; height: 1.25em; vertical-align: middle; font-style: normal; background-repeat: no-repeat; }
.res .rart { width: 22px; height: 22px; }
.res-stack .raw .rart { width: 16px; height: 16px; }
.pkg .rart { width: 13px; height: 13px; }
.traveler .carry .rart { width: 18px; height: 18px; }
.egg.art { width: 15px; height: 15px; border-radius: 0; background-color: transparent; box-shadow: none; background-repeat: no-repeat; filter: drop-shadow(0 1px 1px rgba(0,0,0,.4)); }
.larva.art { width: 24px; height: 24px; border-radius: 0; box-shadow: none; background-repeat: no-repeat; filter: drop-shadow(0 1px 1px rgba(0,0,0,.4)); }
.traveler .carry .egg.art { width: 15px; height: 15px; }
@media (max-width: 700px) {
  .egg.art { width: 11px; height: 11px; }
  .larva.art { width: 17px; height: 17px; }
  .res .rart { width: 18px; height: 18px; }
  .res-stack .raw .rart { width: 12px; height: 12px; }
}

/* menú de batalla: pausa y chat */
.pause-banner { position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%); background: rgba(0,0,0,.75); color: #fff; font-size: 1.8em; font-weight: 800;
  padding: 14px 32px; border-radius: 16px; text-align: center; cursor: pointer; z-index: 20; }
.pause-banner small { display: block; font-size: .45em; font-weight: 400; opacity: .7; margin-top: 4px; }
.pause-ask { position: absolute; top: 96px; left: 50%; transform: translateX(-50%); background: rgba(20,14,8,.92); border: 1px solid var(--line); color: #fff;
  padding: 8px 12px; border-radius: 12px; display: flex; gap: 8px; align-items: center; z-index: 21; }
.chat { position: absolute; left: 10px; bottom: 120px; z-index: 15; display: flex; flex-direction: column-reverse; align-items: flex-start; gap: 6px; max-width: min(340px, 80vw); }
.chat-toggle { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: rgba(20,14,8,.85); font-size: 18px; cursor: pointer; position: relative; }
.chat.new .chat-toggle::after { content: ''; position: absolute; top: 2px; right: 2px; width: 10px; height: 10px; border-radius: 50%; background: #ff5a3c; }
.chat-body { display: none; background: rgba(20,14,8,.88); border: 1px solid var(--line); border-radius: 12px; padding: 8px; width: min(340px, 80vw); }
.chat.open .chat-body { display: block; }
.chat-log { max-height: 160px; overflow-y: auto; font-size: .85em; display: flex; flex-direction: column; gap: 3px; margin-bottom: 6px; }
.chat-log .cm.team { background: rgba(120,200,255,.08); border-radius: 4px; padding: 0 3px; }
.chat-form { display: flex; gap: 4px; }
.chat-form .chat-in { flex: 1; min-width: 0; background: rgba(0,0,0,.35); border: 1px solid var(--line); color: #fff; border-radius: 8px; padding: 5px 8px; }
.chat-form .chat-to { background: rgba(0,0,0,.35); color: #fff; border: 1px solid var(--line); border-radius: 8px; }
.chat-form .btn { width: auto; margin: 0; }

/* fin de la batalla: elegir entre otra casual o la colonia */
.over-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.over-actions .btn { width: auto; }

/* íconos de las salas (salas.png) */
.ri .rart, .ri .roomart { width: 1.35em; height: 1.35em; }
.room-decor .rart { width: 64px; height: 64px; }
.ph-ico .rart { width: 34px; height: 34px; }
.go-room .rart { width: 20px; height: 20px; }
@media (max-width: 700px) { .room-decor .rart { width: 42px; height: 42px; } }

/* ===== Ranqueada con cuenta y ranking ===== */
.choice button.locked { opacity: .55; }
.choice button.locked small::after { content: ' · 🔐 con cuenta'; }
.ranking { width: 100%; border-collapse: collapse; margin: 8px 0 14px; font-size: .95em; }
.ranking td { padding: 6px 8px; border-bottom: 1px solid rgba(255,255,255,.08); }
.ranking td:first-child { width: 2.5em; text-align: right; opacity: .7; }
.ranking tr.me td { background: rgba(255,200,80,.14); font-weight: bold; }

/* ===== Borrar cuenta ===== */
.link-btn.danger-link { color: #ff7a6b; margin-top: 6px; }
#del-form label { display: block; margin: 10px 0 4px; }
#del-form input { width: 100%; }

/* Crear partida: opciones contra la IA */
.match-opts { display: flex; flex-direction: column; gap: 8px; margin-bottom: 6px; }
.mo-row { display: flex; flex-direction: column; gap: 4px; }
.mo-title { font-weight: 700; font-size: .9em; }
.mo-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 6px; }
.mo-btn { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 7px 10px; border-radius: 10px; text-align: left; cursor: pointer;
  background: rgba(0,0,0,.25); color: inherit; font: inherit; font-weight: 700; border: 2px solid rgba(255,255,255,.08); }
.mo-btn small { font-weight: 400; font-size: .75em; opacity: .75; }
.mo-btn.sel { border-color: var(--accent, #ffb02e); background: rgba(255,176,46,.14); }
.mo-btn:disabled { opacity: .45; cursor: default; }

/* ===== 📖 Enciclopedia ===== */
.modal-box.enc-box, .modal-box.enc-box:has(.controls) { max-width: 1100px; width: 96vw; max-height: 92vh; display: flex; flex-direction: column; padding-bottom: 8px; overflow: hidden; }
.enc-head .btn { width: auto; margin-top: 0; }
.enc-head, .enc-tabs, .enc-tiers { flex-shrink: 0; }
.enc { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.enc-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.enc-head h3 { margin: 0; flex: 0 0 auto; }
.enc-q { flex: 1 1 200px; min-width: 0; padding: 7px 10px; border-radius: 8px; border: 1px solid rgba(255,255,255,.2); background: rgba(0,0,0,.25); color: inherit; font: inherit; }
.enc-tabs { display: flex; gap: 4px; overflow-x: auto; margin: 10px 0 6px; padding-bottom: 2px; }
.enc-tabs button { flex: 0 0 auto; padding: 6px 11px; border-radius: 8px; border: 1px solid rgba(255,255,255,.15); background: rgba(255,255,255,.05); color: inherit; font: inherit; cursor: pointer; white-space: nowrap; }
.enc-tabs button.sel { background: rgba(255,200,80,.22); border-color: rgba(255,200,80,.6); font-weight: bold; }
.enc-tiers { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: .9em; min-height: 4px; margin-bottom: 6px; }
.enc-tiers button { padding: 3px 9px; border-radius: 6px; border: 1px solid var(--tc); background: transparent; color: var(--tc); font: inherit; cursor: pointer; }
.enc-tiers button.sel { background: var(--tc); color: #111; font-weight: bold; }
.enc-body { overflow-y: auto; flex: 1; min-height: 0; padding-right: 4px; }
.enc-intro { margin: 2px 0 10px; opacity: .9; }
.enc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; }
.enc-grid.one { grid-template-columns: 1fr; }
.enc-card { display: flex; gap: 10px; padding: 10px; border-radius: 10px; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.1); align-items: flex-start; }
.enc-card.mine { border-color: rgba(255,200,80,.6); }
.enc-card[hidden] { display: none; }
.enc-art { flex: 0 0 64px; height: 64px; display: flex; align-items: center; justify-content: center; font-size: 40px; }
.enc-art .wart { width: 64px; height: 64px; }
.enc-art.bug svg { width: 64px; height: auto; }
.enc-info { flex: 1; min-width: 0; }
.enc-info h4 { margin: 0 0 4px; }
.enc-info p { margin: 4px 0; font-size: .92em; }
.enc-info ul { margin: 4px 0; padding-left: 18px; font-size: .92em; }
.enc-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; }
.enc-tag { font-size: .75em; padding: 1px 7px; border-radius: 10px; background: rgba(255,255,255,.1); white-space: nowrap; }
.enc-tag.race { background: rgba(255,170,60,.2); }
.enc-tag.ok { background: rgba(120,220,120,.18); }
.enc-tag.tool { background: rgba(90,180,255,.2); }
.enc-tag.inf { background: rgba(200,140,255,.2); }
.enc-tag.warn { background: rgba(255,110,90,.22); }
.enc-stats { border-collapse: collapse; font-size: .88em; margin: 4px 0; }
.enc-stats td { padding: 2px 10px 2px 0; vertical-align: top; }
.enc-stats td:first-child { opacity: .75; }
.enc-meta { font-size: .82em !important; opacity: .8; }
.enc-controls { display: block; }
@media (max-width: 700px) {
  .modal-box.enc-box, .modal-box.enc-box:has(.controls) { width: 100%; max-width: none; }
  .enc-grid { grid-template-columns: 1fr; }
  .enc-art { flex-basis: 48px; height: 48px; font-size: 30px; }
  .enc-art .wart, .enc-art.bug svg { width: 48px; height: 48px; }
}

/* ===== Arañas: tela en la superficie ===== */
.s-aranas::after { background: linear-gradient(#7aa64a, #3f6a26); }
.e-aranas { /* embudo de seda con la tela alrededor */
  width: 120px; height: 66px; border-radius: 60px 60px 6px 6px;
  background: repeating-radial-gradient(circle at 50% 100%, rgba(255,255,255,.75) 0 1px, transparent 1.5px 9px),
              repeating-conic-gradient(from 0deg at 50% 100%, rgba(255,255,255,.6) 0 .6deg, transparent .6deg 15deg),
              radial-gradient(ellipse at 50% 100%, rgba(235,230,250,.55), rgba(200,190,230,.25) 70%, transparent 72%);
}
.e-aranas .door { left: 50%; bottom: 0; width: 30px; height: 22px; transform: translateX(-50%); border-radius: 15px 15px 0 0; background: radial-gradient(ellipse at 50% 100%, #1a1026, #3a2a4a); }
.t-acecho { --w1: #6a4a8a; --w2: #2e1f40; }

/* =====================================================================
   Juego de batallas (v86): inicio, puntos, rotación semanal y tienda
   ===================================================================== */
#screen-lobby { display: flex; flex-direction: column; }
.home-bar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px 16px; flex-wrap: wrap;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top)); background: var(--panel); border-bottom: 2px solid var(--line);
}
.home-bar .brand { font-size: 1.25em; font-weight: 800; }
.wallet { display: flex; gap: 8px; flex: 1; flex-wrap: wrap; align-items: center; }
.coin { background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.coin small { color: var(--muted); }
.home-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.home-actions .btn { display: inline-flex; align-items: center; gap: 6px; }
#screen-lobby .lobby { width: 100%; }

.weekly { background: linear-gradient(90deg, rgba(255,190,80,.16), rgba(255,190,80,.04)); border: 1px solid rgba(255,190,80,.45);
  border-radius: 14px; padding: 10px 14px; margin: 14px 0 4px; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
.wk-items { display: flex; flex-wrap: wrap; gap: 6px; }
.wk { display: inline-flex; align-items: center; gap: 4px; background: rgba(0,0,0,.25); border-radius: 999px; padding: 2px 10px 2px 4px; font-size: .9em; }
.wk .wart { width: 22px; height: 22px; }
.wk.bug { padding-left: 10px; }

.race-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.race-chip { background: var(--panel); border: 2px solid var(--line); border-radius: 14px; padding: 8px 6px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; }
.race-chip .rc-emoji { font-size: 1.8em; line-height: 1.1; }
.race-chip b { font-size: .85em; line-height: 1.15; }
.race-chip small { color: var(--muted); font-size: .72em; }
.race-chip.sel { border-color: var(--accent); background: var(--panel-2); box-shadow: 0 0 0 3px rgba(232,137,60,.25); }
.race-chip.locked { opacity: .6; filter: grayscale(.6); }
.race-chip.locked:hover { opacity: .85; }

.bcard.locked, .mcard.locked { opacity: .55; filter: grayscale(.5); }
.mcard.full { opacity: .5; }
.mc-free { position: absolute; top: 2px; left: 4px; font-size: 12px; }
.weapon-bar .hand.classic { display: flex; gap: 2px; }

/* tienda */
.sh-tabs { display: flex; gap: 6px; margin: 8px 0 12px; flex-wrap: wrap; }
.sh-tabs .btn { width: auto; margin: 0; }
.shop { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.sh-group { grid-column: 1 / -1; margin: 10px 0 0; }
.sh-item { background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; padding: 10px; display: flex; flex-direction: column; gap: 4px; align-items: center; text-align: center; }
.sh-item.own { opacity: .7; }
.sh-item b { line-height: 1.2; }
.sh-item small { font-size: .78em; line-height: 1.3; }
.sh-art { height: 56px; display: flex; align-items: center; justify-content: center; }
.sh-art .wart { width: 52px; height: 52px; }
.sh-art .bug-svg { width: 70px; height: 46px; }
.sh-emoji { font-size: 40px; }
.sh-item .btn { width: auto; margin: auto 0 0; }
.sh-own { margin-top: auto; color: var(--good); font-weight: 700; font-size: .85em; }
.sh-free { background: rgba(255,190,80,.2); color: #ffd28a; border-radius: 999px; padding: 1px 8px; font-size: .75em; font-weight: 700; }
.modal-box h3 .coin { font-size: .75em; margin-left: 8px; font-weight: 600; }

@media (max-width: 700px) {
  .home-bar { padding: 8px 10px; padding-top: calc(8px + env(safe-area-inset-top)); gap: 6px; }
  .home-bar .brand { font-size: 1.05em; }
  .home-actions { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: var(--panel); border-top: 2px solid var(--line); }
  .home-actions .btn { flex-direction: column; gap: 1px; padding: 5px 2px; border-radius: 12px; min-height: 52px; justify-content: center; }
  .home-actions .ico { font-size: 1.35em; line-height: 1.1; }
  .home-actions .lbl { font-size: .68em; }
  #screen-lobby .lobby { padding-bottom: 170px; }
  #screen-lobby .lobby-actions { bottom: calc(66px + env(safe-area-inset-bottom)); }
  .race-pick { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  .shop { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

/* ===== Personajes (v88): nombre arriba, tipo abajo, retrato de la hoja retratos_<raza> ===== */
.ch-type { display: block; font-size: .72em; font-weight: 500; color: var(--muted); line-height: 1.2; }
.sq .ch-type, .bcard .ch-type { font-size: .62em; }
.portrait { display: block; width: 100%; height: 100%; min-height: 56px; background-size: 300% 200%; background-repeat: no-repeat; border-radius: 10px; }
.bcard-art .portrait { width: 64px; height: 64px; margin: 0 auto; }
.sh-art .portrait { width: 64px; height: 64px; }
.enc-art .portrait { width: 96px; height: 96px; }
.enc-quote { font-style: italic; color: #ffe2b0; margin: 4px 0; }

/* ===== Menú de armas del modo clásico (v90): estilo Worms, a la derecha, una fila por tipo ===== */
.wmenu {
  position: absolute; right: 10px; top: 56px; z-index: 25; width: max-content; max-width: calc(100vw - 20px);
  max-height: calc(100% - 200px); overflow-y: auto; display: flex; flex-direction: column; gap: 3px; padding: 8px;
  background: rgba(14, 9, 4, .9); border: 2px solid var(--ink, #120a04); border-radius: 14px;
  box-shadow: inset 0 2px 0 rgba(255,255,255,.08), 0 0 0 2px color-mix(in srgb, var(--accent) 45%, transparent), 0 10px 26px rgba(0,0,0,.5);
  animation: wm-in .14s ease-out; scrollbar-width: thin;
}
@keyframes wm-in { from { opacity: 0; transform: translateX(16px); } }
.wm-head { display: flex; align-items: center; gap: 8px; padding: 0 2px 4px; }
.wm-head b { font-family: var(--font-title, inherit); font-weight: 400; font-size: 1.1em; color: var(--accent-2); flex: 1; }
.wm-x { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: .9em; padding: 2px 6px; border-radius: 6px; }
.wm-x:hover { background: rgba(255,255,255,.1); color: #fff; }
.wm-row { display: flex; align-items: stretch; gap: 3px; }
.wm-cat {
  width: 34px; flex: 0 0 34px; display: grid; place-items: center; font-size: 1.15em; border-radius: 8px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 35%, #000), color-mix(in srgb, var(--accent) 15%, #000));
  border: 2px solid var(--ink, #120a04);
}
.wm-cells { display: flex; flex-wrap: wrap; gap: 3px; max-width: calc(6 * 47px); }
.wm-cell {
  position: relative; width: 44px; height: 44px; padding: 0; cursor: pointer; display: grid; place-items: center;
  background: linear-gradient(180deg, #3a2a1a, #22170d); border: 2px solid var(--ink, #120a04); border-radius: 8px;
  box-shadow: inset 0 2px 0 rgba(255,255,255,.08); transition: transform .08s, filter .1s;
}
.wm-cell .wart { width: 34px; height: 34px; }
.wm-cell.tool { background: linear-gradient(180deg, #23384a, #142230); }
.wm-cell:hover:not(:disabled) { filter: brightness(1.3); transform: scale(1.08); z-index: 1; }
.wm-cell.sel { box-shadow: 0 0 0 2px var(--accent-2), 0 0 12px color-mix(in srgb, var(--accent) 60%, transparent); }
.wm-cell:disabled { cursor: default; }
.wm-cell.empty { filter: grayscale(1) brightness(.45); }
.wm-n { position: absolute; right: 1px; bottom: 0; font-style: normal; font-size: 10px; font-weight: 900; color: #fff; text-shadow: 0 0 2px #000, 0 1px 0 #000; }
.wm-n.inf { font-size: 15px; line-height: 1; bottom: -1px; }
.wm-k { position: absolute; left: 3px; top: 0; font-size: 9px; font-weight: 900; color: #ffd27a; text-shadow: 0 1px 0 #000; }
.wm-foot { margin-top: 4px; padding: 5px 8px; border-radius: 8px; background: rgba(0,0,0,.4); font-weight: 800; font-size: .85em; text-align: center; min-height: 1.6em; }
.hcard.wm-open .hc-stat { color: #ffd27a; }
@media (max-width: 700px) {
  .wmenu { top: 46px; right: 6px; max-height: calc(100% - 160px); padding: 6px; }
  .wm-cell { width: 38px; height: 38px; } .wm-cell .wart { width: 28px; height: 28px; }
  .wm-cells { max-width: calc(5 * 41px); }
  .wm-cat { width: 28px; flex-basis: 28px; font-size: 1em; }
}

/* ===== Tutorial (v91): cartel de pasos arriba al centro ===== */
.tut-panel {
  position: absolute; top: 72px; left: 10px; z-index: 26; width: min(380px, calc(100vw - 20px)); /* a la izquierda: el centro queda libre para ver la isla y los muñecos */
  background: rgba(14, 9, 4, .92); border: 2px solid var(--ink, #120a04); border-radius: 14px; padding: 8px 12px 10px;
  box-shadow: inset 0 2px 0 rgba(255,255,255,.08), 0 0 0 2px color-mix(in srgb, var(--accent) 55%, transparent), 0 10px 24px rgba(0,0,0,.45);
  animation: tut-in .25s ease-out;
}
.tut-panel.ok { box-shadow: inset 0 2px 0 rgba(255,255,255,.08), 0 0 0 2px #7cd44a, 0 0 22px rgba(124,212,74,.45); }
@keyframes tut-in { from { opacity: 0; transform: translateX(-10px); } }
.tut-top { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.tut-badge { font-family: var(--font-title, inherit); color: var(--accent-2); font-size: 1.05em; }
.tut-dots { display: flex; gap: 5px; flex: 1; }
.tut-dots i { width: 10px; height: 10px; border-radius: 50%; background: rgba(255,255,255,.18); border: 1px solid rgba(0,0,0,.6); }
.tut-dots i.cur { background: var(--accent-2); box-shadow: 0 0 6px var(--accent); }
.tut-dots i.done { background: #7cd44a; }
.tut-skip { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.18); color: #f0e2cc; border-radius: 8px; padding: 3px 10px;
  font: inherit; font-size: .8em; font-weight: 800; cursor: pointer; white-space: nowrap; }
.tut-skip:hover { background: rgba(255,255,255,.18); }
.tut-body { display: flex; gap: 10px; align-items: flex-start; }
.tut-ico { font-size: 2em; line-height: 1; filter: drop-shadow(0 2px 0 rgba(0,0,0,.4)); }
.tut-body b { font-size: 1.05em; }
.tut-body p { margin: 2px 0 0; font-size: .9em; line-height: 1.4; color: #f3e6d0; }
.tut-body kbd { font-size: .85em; padding: 0 5px; }
@media (max-width: 700px) {
  .tut-panel { top: 64px; left: 6px; width: min(300px, calc(100vw - 12px)); padding: 6px 8px 8px; }
  .tut-body p { font-size: .8em; }
  .tut-ico { font-size: 1.5em; }
}

/* ===== Editor de mapas (v92) ===== */
#screen-editor { display: flex; flex-direction: column; background: var(--bg); }
.ed-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px 12px; padding-top: calc(8px + env(safe-area-inset-top)); background: var(--panel); border-bottom: 2px solid var(--line); }
.ed-bar .btn { width: auto; margin: 0; }
#ed-name { flex: 1; min-width: 140px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; color: var(--text); padding: 8px 10px; font: inherit; }
.ed-tools { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 8px 12px; background: var(--panel-2); border-bottom: 1px solid var(--line); }
.ed-group { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.ed-group .btn { width: auto; margin: 0; }
.ed-lbl { font-weight: 700; font-size: .8em; color: var(--muted); margin-right: 4px; }
.ed-brush { min-width: 38px; display: inline-flex; align-items: center; justify-content: center; }
.ed-brush i { display: block; border-radius: 50%; background: currentColor; }
.ed-wrap { flex: 1; min-height: 0; padding: 8px; display: flex; align-items: flex-start; justify-content: center; overflow: auto; }
#ed-canvas { border-radius: 10px; box-shadow: 0 4px 18px rgba(0,0,0,.5); touch-action: none; cursor: crosshair; max-width: 100%; }
.ed-help { text-align: center; margin: 0 0 10px; font-size: .85em; padding: 0 12px; }
.ed-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.ed-item { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center; background: rgba(0,0,0,.2); border-radius: 10px; padding: 8px 10px; }
.ed-item small { grid-column: 1; }
.ed-item span { grid-row: 1 / 3; grid-column: 2; display: flex; gap: 4px; }
.ed-item .btn { width: auto; margin: 0; }
#btn-editor { margin-top: 8px; width: auto; }
.ed-local { background: rgba(255,190,80,.08); border: 1px solid rgba(255,190,80,.35); border-radius: 10px; padding: 8px; margin: 8px 0; display: flex; flex-direction: column; gap: 6px; }
.ed-import { display: flex; gap: 6px; margin-bottom: 8px; }
.ed-import input { width: 110px; text-transform: uppercase; letter-spacing: 2px; font-weight: 700; text-align: center; padding: 6px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: inherit; }
.ed-import .btn { width: auto; margin: 0; }
.ed-link { width: 100%; padding: 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: inherit; font: inherit; font-size: .85em; }

/* ===== v101: menú de armas fijo a la derecha (se puede ocultar) y botón de habilidad en el celular ===== */
.tp-acts .tp-ab { grid-area: 1 / 1; }
#screen-battle .weapon-bar:empty { display: none; }
.wmenu.collapsed { padding: 0; background: none; border: 0; box-shadow: none; animation: none; overflow: visible; }
.wm-tab {
  display: flex; flex-direction: column; align-items: center; gap: 0; width: 44px; padding: 6px 0 4px; cursor: pointer;
  background: rgba(14, 9, 4, .9); color: #fff; font-size: 1.4em; line-height: 1; border: 2px solid var(--ink, #120a04); border-radius: 12px;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 45%, transparent), 0 6px 16px rgba(0,0,0,.45);
}
.wm-tab small { font-size: 10px; font-weight: 900; color: #ffd27a; margin-top: 2px; }
.wm-tab:hover { filter: brightness(1.25); }

/* ===== Razas y bichos (v104): cartel al pasar el mouse por un bicho + ventana de razas ===== */
.bugtip {
  position: fixed; z-index: 90; width: 300px; pointer-events: none; padding: 10px 12px 9px;
  background: rgba(16, 10, 5, .97); color: var(--text); border: 2px solid var(--ink, #120a04); border-radius: 14px;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 55%, transparent), 0 12px 28px rgba(0,0,0,.55);
  font-size: .86rem; line-height: 1.3; animation: bt-in .12s ease-out;
}
@keyframes bt-in { from { opacity: 0; transform: translateY(4px); } }
.bugtip::after { /* flechita que apunta al bicho */
  content: ''; position: absolute; left: calc(var(--ax, 50%) - 8px); bottom: -9px; width: 14px; height: 14px; transform: rotate(45deg);
  background: rgba(16, 10, 5, .97); border-right: 2px solid var(--ink, #120a04); border-bottom: 2px solid var(--ink, #120a04);
}
.bugtip.below::after { bottom: auto; top: -9px; transform: rotate(225deg); }
.bt-head { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.bt-art { flex: 0 0 58px; width: 58px; height: 46px; display: grid; place-items: center; border-radius: 12px;
  background: radial-gradient(circle at 50% 60%, color-mix(in srgb, var(--accent) 30%, transparent), transparent 70%); }
.bt-art .bug-svg { width: 58px; height: 40px; overflow: visible; }
.bt-art .portrait { width: 46px; height: 46px; min-height: 0; }
.bt-names { display: flex; flex-direction: column; min-width: 0; }
.bt-names b { font-family: var(--font-title, inherit); font-weight: 400; font-size: 1.2em; color: #fff; line-height: 1.05; }
.bt-names small { color: var(--accent-2); font-weight: 800; }
.bt-names i { color: #ffe2b0; font-size: .86em; }
.bt-bio { margin: 0 0 6px; font-size: .85em; color: var(--muted); }
.bt-perks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.bt-perks li { display: flex; gap: 7px; align-items: flex-start; font-size: .88em; }
.bt-perks li b { color: #fff; }
.bt-ico { flex: 0 0 18px; text-align: center; }
.bt-st { display: block; margin-top: 2px; font-size: .9em; color: var(--accent-2); }
.bt-race { margin-top: 7px; padding-top: 6px; border-top: 1px dashed rgba(255,255,255,.15); font-size: .8em; color: var(--muted); }
.bt-con { color: #ffb0a0; }
.bt-status { display: inline-block; margin-top: 7px; padding: 2px 9px; border-radius: 999px; font-weight: 900; font-size: .78em; border: 1px solid rgba(0,0,0,.5); }
.bt-status.own { background: rgba(124, 212, 74, .18); color: #a8f07a; }
.bt-status.free { background: rgba(255, 210, 63, .2); color: var(--gold, #ffd23f); }
.bt-status.lock { background: rgba(255,255,255,.08); color: var(--muted); }
[data-bug] { cursor: help; }
button[data-bug] { cursor: pointer; }

.modal-box.rz-box { width: min(1120px, 100%); }
.rz-tabs { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 12px; }
.rz-tab { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 7px 4px; cursor: pointer; font: inherit; color: inherit;
  border: 2px solid var(--ink, #120a04); border-radius: 12px; background: linear-gradient(180deg, color-mix(in srgb, var(--panel-2) 85%, #fff 8%), var(--panel));
  box-shadow: 0 3px 0 var(--ink, #120a04); }
.rz-tab span { font-size: 1.6em; line-height: 1.1; }
.rz-tab b { font-size: .74em; line-height: 1.1; text-align: center; }
.rz-tab small { font-size: .7em; color: var(--muted); }
.rz-tab.sel { background: linear-gradient(180deg, var(--accent-2), var(--accent)); color: #2a1404; box-shadow: 0 3px 0 var(--ink, #120a04), 0 0 14px var(--glow); }
.rz-tab.sel small { color: #4a2a0a; }
.rz-tab.locked span { filter: grayscale(.8); }
.rz-race { background: rgba(0,0,0,.22); border: 2px solid var(--ink, #120a04); border-radius: 14px; padding: 10px 14px; margin-bottom: 12px; }
.rz-hero { display: flex; gap: 12px; align-items: center; }
.rz-emoji { font-size: 3em; filter: drop-shadow(0 3px 0 rgba(0,0,0,.4)); }
.rz-name { margin: 0; font-size: 1.3em; text-transform: none; letter-spacing: 0; color: #fff; font-family: var(--font-title, inherit); font-weight: 400; }
.rz-name small { font-family: var(--font-ui, inherit); color: var(--muted); font-size: .6em; }
.rz-hero p { margin: 2px 0 0; color: var(--muted); font-size: .9em; }
.rz-mods { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 8px; }
.rz-pro, .rz-con { padding: 3px 10px; border-radius: 999px; font-size: .82em; font-weight: 800; border: 1px solid rgba(0,0,0,.5); }
.rz-pro { background: rgba(124, 212, 74, .14); color: #c8f5a8; }
.rz-con { background: rgba(255, 110, 90, .14); color: #ffc0b0; }
.rz-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rz-actions .btn { width: auto; margin: 0; }
.rz-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.rz-bug { background: linear-gradient(180deg, color-mix(in srgb, var(--panel-2) 85%, #fff 6%), var(--panel)); border: 2px solid var(--ink, #120a04);
  border-radius: 14px; padding: 10px 12px; box-shadow: 0 4px 0 rgba(0,0,0,.4); font-size: .9rem; }
.rz-bug.lock .bt-art { filter: grayscale(.7) brightness(.8); }
.rz-bug .bt-art { flex-basis: 70px; width: 70px; height: 54px; }
.rz-bug .bt-art .bug-svg { width: 70px; height: 48px; }
#stage-race + .stage-count { white-space: nowrap; }
@media (max-width: 700px) {
  .rz-tabs { grid-template-columns: repeat(4, 1fr); }
  .rz-grid { grid-template-columns: 1fr; }
  .rz-emoji { font-size: 2.2em; }
}
/* barra de arriba: el aviso para invitados no empuja los botones (se corta con …) */
.wallet > .muted { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
/* escenario: el título ocupa su lugar y los botones bajan si no entran */
.stage-head .stage-title { flex: 1 1 230px; }
.stage-head .btn { white-space: nowrap; }

/* ===== Aventura (v105): niveles para un solo bicho ===== */
.adv-panel-lobby { padding: 10px 12px; }
.adv-btn { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 10px 10px; font-size: 1.15em;
  font-family: var(--font-title, inherit); font-weight: 400; letter-spacing: .03em;
  background: linear-gradient(180deg, #7ad0ff, #2e8fd8) !important; color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.45); }
.adv-btn small { font-family: var(--font-ui, inherit); font-weight: 800; font-size: .58em; letter-spacing: 0; color: #e8f6ff; }
.modal-box.av-box { width: min(900px, 100%); }
.av-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 4px; }
.av-level { display: flex; gap: 14px; align-items: center; padding: 12px 14px; border-radius: 14px; border: 2px solid var(--ink, #120a04);
  background: linear-gradient(180deg, color-mix(in srgb, var(--panel-2) 85%, #fff 6%), var(--panel)); box-shadow: 0 4px 0 rgba(0,0,0,.4); }
.av-ico { font-size: 2.6em; filter: drop-shadow(0 3px 0 rgba(0,0,0,.4)); }
.av-info { flex: 1; min-width: 0; }
.av-info b { font-family: var(--font-title, inherit); font-weight: 400; font-size: 1.2em; color: #fff; }
.av-info p { margin: 3px 0; color: #f0e2cc; font-size: .92em; }
.av-play { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.av-play .btn { width: auto; margin: 0; white-space: nowrap; }
.av-stars { font-size: 1.4em; letter-spacing: 2px; color: #ffd23f; text-shadow: 0 2px 0 rgba(0,0,0,.4); }
.av-soon { padding: 18px; text-align: center; border: 2px dashed rgba(255,255,255,.15); border-radius: 14px; }
.adv-now { flex: 1; color: #ffd23f; letter-spacing: 1px; }
.adv-over .adv-stars { display: flex; justify-content: center; gap: 10px; font-size: 3em; margin: 6px 0 8px; }
.adv-over .adv-stars span { filter: grayscale(1) brightness(.4); transform: scale(.6); animation: star-pop .45s cubic-bezier(.2,1.6,.4,1) forwards; animation-delay: var(--d); }
.adv-over .adv-stars span:not(.on) { animation-name: star-dim; }
@keyframes star-pop { to { filter: none; transform: scale(1); } }
@keyframes star-dim { to { transform: scale(.85); } }
@media (max-width: 700px) {
  .av-level { flex-wrap: wrap; }
  .av-play { flex-direction: row; width: 100%; justify-content: space-between; }
}

/* ===== v106: Bichos y Tienda como páginas de pantalla completa ===== */
#modal.page-mode { padding: 0; background: var(--bg, #1a120a); align-items: stretch; justify-content: stretch; }
#modal.page-mode .modal-box.page {
  width: 100vw; max-width: none; height: 100vh; height: 100dvh; max-height: none; margin: 0;
  border: 0; border-radius: 0; padding: 0 max(18px, env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  overflow-y: auto; display: block; animation: page-in .18s ease-out;
}
@keyframes page-in { from { opacity: 0; transform: translateY(10px); } }
.modal-box.page > h3 {
  position: sticky; top: 0; z-index: 6; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin: 0 calc(-1 * max(18px, env(safe-area-inset-left))) 14px; padding: calc(12px + env(safe-area-inset-top)) max(18px, env(safe-area-inset-left)) 12px;
  background: var(--panel); border-bottom: 2px solid var(--line); box-shadow: 0 6px 16px rgba(0,0,0,.35); font-size: 1.35em;
}
.modal-box.page .page-back { width: auto; margin: 0; flex: none; }
.modal-box.page > #m-close { display: none; } /* ya está ← Volver arriba */
.modal-box.page > *:not(h3) { max-width: 1500px; margin-left: auto; margin-right: auto; }
.modal-box.page .shop { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
@media (max-width: 700px) {
  .modal-box.page > h3 { font-size: 1.1em; gap: 8px; }
  .modal-box.page .shop { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

/* ===== v112: fila de la raza y el bicho en el menú de armas (habilidad + ataques de la raza) ===== */
.wm-row.wm-race { padding-bottom: 4px; margin-bottom: 2px; border-bottom: 1px dashed color-mix(in srgb, var(--accent) 45%, transparent); }
.wm-row.wm-race .wm-cat { background: linear-gradient(180deg, #4a2f6a, #2a1840); }
.wm-cell.ability { background: linear-gradient(180deg, #5a3a86, #2c1a48); }
.wm-cell.ability .wart, .wm-cell.ability { font-size: 1.5em; }
.wm-cell.ability.on { box-shadow: 0 0 0 2px #ffe08a, 0 0 10px #ffe08a; }

/* volumen de los efectos de sonido */
.snd-row { display: flex; align-items: center; gap: 10px; margin: 10px 0; font-weight: 700; }
.snd-row input[type=range] { flex: 1; accent-color: var(--accent, #ffb02e); }
.snd-row b { min-width: 42px; text-align: right; font-size: .9em; }
.snd-voices { flex: 1; margin: 0; display: grid !important; grid-template-columns: repeat(3, 1fr) !important; gap: 4px; }
.snd-voices button { padding: 6px 4px; min-width: 0; }

/* ---- Campo de práctica ---- */
.pr-tabs { margin: 10px 0 4px; }
.pr-race { margin: 4px 0 10px; }
.pr-bugs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.pr-bug { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; border-radius: 12px; border: 2px solid var(--line); background: var(--panel-2); color: inherit; cursor: pointer; font: inherit; }
.pr-bug:hover { border-color: var(--accent, #ffb02e); }
.pr-bug.sel { border-color: var(--accent, #ffb02e); box-shadow: 0 0 0 3px rgba(255,176,46,.25); background: rgba(255,176,46,.12); }
.pr-bug .pr-art { width: 64px; height: 64px; display: grid; place-items: center; overflow: hidden; border-radius: 10px; }
.pr-bug .pr-art > * { max-width: 100%; max-height: 100%; }
.pr-bug b { font-size: .85em; line-height: 1.1; text-align: center; }
.pr-bug small { font-size: .72em; color: var(--muted); text-align: center; }
.pr-tiers button { border-bottom: 3px solid var(--tc); }
.pr-tiers button small, .pr-maps button small { display: block; font-size: .7em; opacity: .8; }
.pr-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.pr-actions .btn { width: auto; flex: 1; }
@media (max-width: 560px) { .pr-bugs { grid-template-columns: repeat(2, 1fr); } }
/* panel del campo de práctica en la batalla */
.pr-panel .pr-stats { display: flex; gap: 10px; flex-wrap: wrap; font-size: .85em; margin: 4px 0; }
.pr-panel .pr-stats b { color: var(--accent, #ffb02e); }
.pr-panel .pr-btns { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.pr-panel .pr-btns button { flex: 1 1 auto; min-width: 0; width: auto; margin: 0; padding: 5px 8px !important; font-size: .75em !important; white-space: nowrap; }
.adv-btn.pr-btn { margin-top: 8px; background: linear-gradient(180deg, #8ee07a, #3f9a36) !important; }
.adv-btn.pr-btn small { color: #f0ffe8; }

/* ===== v132: resumen de la partida en el cartel final (como en Worms) ===== */
.recount { text-align: left; margin: 10px auto 12px; padding: 10px 14px; max-width: 460px; background: rgba(0,0,0,.25); border-radius: 12px; border: 1px solid rgba(255,255,255,.08); }
.recount h4 { margin: 0 0 6px; text-align: center; font-size: 1em; color: var(--accent-2, #ffd27a); }
.rc-row { display: flex; gap: 8px; align-items: baseline; padding: 3px 0; font-size: .92em; }
.rc-row > span { flex: none; width: 1.4em; text-align: center; }
.rc-row.bad { color: #ffb4a8; }

/* ===== v133: logros y misiones semanales ===== */
.lg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.lg-item { display: flex; gap: 12px; align-items: center; background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.lg-item.got { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 25%, transparent); }
.lg-ico { font-size: 2em; flex: none; width: 1.4em; text-align: center; }
.lg-info { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.lg-tier { display: inline-block; padding: 0 6px; border-radius: 6px; background: var(--accent); color: #1a1006; font-size: .8em; margin-left: 4px; }
.lg-bar { height: 8px; border-radius: 6px; background: rgba(0,0,0,.35); overflow: hidden; }
.lg-bar i { display: block; height: 100%; background: linear-gradient(90deg, #ffb02e, #ffd23f); border-radius: 6px; }
.lg-item.mission.got .lg-bar i { background: linear-gradient(90deg, #5ec46a, #a6f05a); }
.lg-pips { color: #ffd23f; letter-spacing: 1px; margin-left: 4px; }
.lg-ok { color: #a6f05a; }
