/* Table · estilo según el mockup: pergamino, botones pizarra, HP verde, mano de cartas arriba */
:root {
  --bg: #1b1820;
  --bg2: #2c2636;
  --tan: #ecdcc2;
  --tan2: #dccab0;
  --tan3: #cdb892;
  --slate: #c6cedb;
  --slate2: #a9b3c4;
  --ink: #2b2218;
  --ink2: #5a4b3a;
  --accent: #d98b2b;
  --ok: #1f8a4c;
  --danger: #b3261e;
  --hp-good: #00c060;
  --hp-mid: #e6b422;
  --hp-low: #e2452f;
  --hp-back: #6e6e76;
  --radius: 22px;
  font-family: ui-rounded, "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  background: radial-gradient(1200px 700px at 30% -10%, var(--bg2), var(--bg));
  background-attachment: fixed;
  color: #f1ece4;
  line-height: 1.35;
}
button { font: inherit; cursor: pointer; color: inherit; }
button:disabled { cursor: not-allowed; opacity: .55; }
h1, h2, h3, h4, p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
:focus-visible { outline: 3px solid #ffd166; outline-offset: 2px; }

/* ───────────── utilidades ───────────── */
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.row.grow, .grow { flex: 1; min-width: 0; }
.stack { display: grid; gap: 10px; }
.muted { opacity: .7; font-size: .92rem; }
.form-msg { color: var(--danger); font-weight: 700; min-height: 1.2em; }
.ok-msg { color: var(--ok); font-weight: 700; }
.mini-list { display: grid; gap: 6px; font-size: .9rem; }

/* ───────────── controles ───────────── */
.card, .toolbar, .mini, .panel, .dialog, .flyout { color-scheme: light; }
input[type="text"], input[type="password"], input[type="number"], select, textarea {
  font: inherit; color: var(--ink);
  width: 100%; padding: 10px 12px;
  background: #fff9ee; border: 2px solid var(--tan3); border-radius: 12px;
}
select { width: auto; max-width: 100%; }
.row > input[type="text"], .row > input[type="password"] { flex: 1 1 180px; width: auto; min-width: 0; }
input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); }

.btn {
  background: var(--slate); color: var(--ink);
  border: 2px solid var(--slate2); border-radius: 14px;
  padding: 10px 16px; font-weight: 800;
  transition: transform .08s, filter .15s;
}
.btn:hover:not(:disabled) { filter: brightness(1.06); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn.primary { background: var(--accent); border-color: #a86614; color: #fff; text-shadow: 0 1px 0 #0003; }
.btn.danger { background: var(--danger); border-color: #7d1511; color: #fff; }
.btn.ghost { background: transparent; border-color: currentColor; color: inherit; }
.btn.small { padding: 6px 12px; font-size: .88rem; border-radius: 11px; }
.link { background: none; border: 0; padding: 4px 0; text-decoration: underline; color: inherit; opacity: .85; }
.link.left { text-align: left; }
a.link { cursor: pointer; font-size: .9rem; }

.badge { font-size: .75rem; font-weight: 800; padding: 3px 9px; border-radius: 999px; }
.badge.ok { background: #cdeed9; color: #14532d; }
.badge.off { background: #e5e0d8; color: #5b5348; }
.code {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-weight: 800; letter-spacing: .18em; font-size: 1.15rem;
  background: #fff9ee; border: 2px dashed var(--tan3); border-radius: 10px; padding: 2px 10px;
  color: var(--ink);
}
.code-input { text-align: center; letter-spacing: .3em; font-weight: 800; font-size: 1.3rem; text-transform: uppercase; }
.tag { font-size: .7rem; font-weight: 800; padding: 2px 7px; border-radius: 999px; background: #ffffff22; margin-left: 6px; }
.tag.crit { background: #ffd166; color: #4a3200; }
.tag.fumble { background: #ff8a80; color: #5a0f0a; }

/* ───────────── tarjetas / pantalla de acceso ───────────── */
.card {
  background: var(--tan); color: var(--ink);
  border-radius: var(--radius); padding: 20px;
  display: grid; gap: 12px;
  box-shadow: 0 10px 30px #0006, inset 0 0 0 2px var(--tan2);
}
.card h2 { font-size: 1.2rem; }
.card h3 { font-size: 1rem; margin-top: 6px; }
.card summary { cursor: pointer; font-weight: 800; }

.home { max-width: 560px; margin: 0 auto; padding: 36px 16px 56px; display: grid; gap: 18px; }
.home-title { text-align: center; }
.home-title h1 { font-size: 3.2rem; letter-spacing: .04em; color: var(--tan); text-shadow: 0 3px 0 #0007; }
.home-title p { opacity: .75; }
.home-foot { text-align: center; opacity: .55; font-size: .85rem; }

.campaign-list { display: grid; gap: 10px; }
.campaign {
  display: grid; grid-template-columns: 1fr auto auto; gap: 10px 14px; align-items: center;
  background: var(--tan2); border-radius: 16px; padding: 10px 14px;
}
.campaign-info { display: grid; gap: 4px; justify-items: start; }
.campaign-code { display: flex; align-items: center; gap: 6px; }
@media (max-width: 520px) {
  .campaign { grid-template-columns: 1fr; }
}

.avatar-pick { padding: 0; border: 0; background: none; }
.avatar-preview {
  width: 64px; height: 64px; border-radius: 50%; overflow: hidden;
  display: grid; place-items: center;
  background: var(--tan3); font-weight: 800; font-size: 1.4rem; color: var(--ink2);
  border: 3px solid var(--slate2);
}
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; }

/* ───────────── barra superior ───────────── */
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; background: #0004; backdrop-filter: blur(6px);
}
.topbar-title { font-size: 1.05rem; }
.topbar { color: #f1ece4; position: relative; z-index: 50; } /* por encima de .stage para que sus menús reciban clics */
.camp-name { opacity: .8; }

/* ───────────── avisos y diálogos ───────────── */
.toast-host { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 3000; display: grid; gap: 8px; width: min(440px, 92vw); pointer-events: none; }
.toast { background: #2b2630; color: #fff; padding: 11px 16px; border-radius: 14px; box-shadow: 0 6px 20px #0008; border: 2px solid #ffffff22; transition: opacity .3s; }
.toast.error { background: #6b1a16; border-color: #ff8a80; }
.toast.out { opacity: 0; }
.overlay { position: fixed; inset: 0; background: #000a; display: grid; place-items: center; z-index: 2500; padding: 16px; }
.dialog { background: var(--tan); color: var(--ink); border-radius: var(--radius); padding: 22px; width: min(420px, 100%); display: grid; gap: 18px; box-shadow: 0 20px 50px #000a; }

/* ───────────── LED de estados ───────────── */
.led {
  position: relative; flex: none; display: inline-block;
  width: 16px; height: 16px; border-radius: 50%;
  background: #17151a; border: 2px solid #55505e;
}
.led.on { background: var(--led); border-color: #fffa; box-shadow: 0 0 9px 1px var(--led); }
.led.dim { border-color: var(--led); }
.led.big { width: 30px; height: 30px; border-width: 3px; }

/* ───────────── mini tarjeta (mano del jugador y panel del DM) ───────────── */
.mini {
  position: relative; width: 176px; min-height: 150px;
  background: var(--tan); color: var(--ink);
  border-radius: 30px 30px 18px 18px; padding: 10px 14px 12px;
  box-shadow: 0 6px 16px #0007, inset 0 0 0 2px var(--tan2);
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; align-content: start;
  transition: transform .18s ease;
}
.mini-head { position: relative; display: flex; align-items: center; gap: 8px; min-height: 24px; }
.mini-name { flex: 1; min-width: 0; text-align: right; font-weight: 800; font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-check { flex: none; }
.led-tip {
  display: none; position: absolute; left: 0; top: 28px; z-index: 20;
  background: #25202b; color: #fff; font-size: .75rem; padding: 4px 9px; border-radius: 8px; white-space: nowrap;
}
.led:hover + .led-tip, .led:focus + .led-tip { display: block; }

.mini-hp {
  position: relative; height: 16px; border-radius: 8px; overflow: hidden;
  background: var(--hp-back);
}
.mini-hp-fill { position: absolute; inset: 0 auto 0 0; background: var(--hp-good); transition: width .35s ease; }
.mini-hp-text { position: relative; display: block; text-align: center; font-size: .72rem; line-height: 16px; font-weight: 800; color: #fff; text-shadow: 0 1px 2px #000a; }

.mini-body { position: relative; height: 88px; }
.mini-avatar {
  position: absolute; right: 0; bottom: 0; width: 84px; height: 84px; border-radius: 50%; overflow: hidden;
  background: #c7d3e6; border: 3px solid var(--slate2);
  display: grid; place-items: center;
}
.mini-avatar img, .avatar-big img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mini-initials { font-weight: 800; font-size: 1.6rem; color: #4a4a60; }

.roll-badge { position: absolute; left: 0; top: 8px; width: 52px; height: 52px; }
.d20 { display: block; width: 100%; text-align: center; font-size: 54px; line-height: 52px; color: #f08a24; filter: drop-shadow(0 2px 0 #7a3b0a); opacity: .55; transition: opacity .2s; }
.roll-value { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 900; color: #fff; font-size: 1.05rem; text-shadow: 0 1px 3px #000c; opacity: 0; transition: opacity .2s; }
.roll-label { position: absolute; left: 0; top: 58px; z-index: 20; display: none; background: #25202b; color: #fff; font-size: .72rem; padding: 3px 8px; border-radius: 8px; white-space: nowrap; }
.roll-badge.fresh .d20, .mini:hover .d20, .mini:focus-within .d20 { opacity: 1; }
.roll-badge.fresh .roll-value, .mini:hover .roll-value, .mini:focus-within .roll-value { opacity: 1; }
.mini:hover .roll-label, .mini:focus-within .roll-label { display: block; }
.roll-badge.fresh { animation: pop .4s ease-out; }
.roll-badge.crit .d20 { color: #ffd166; filter: drop-shadow(0 0 8px #ffd166); animation: glow 1s ease-in-out infinite alternate; }
.roll-badge.fumble .d20 { color: #d9534f; }

.mini-actions { display: flex; gap: 6px; justify-content: flex-end; }
.mini-btn { background: var(--slate); border: 2px solid var(--slate2); border-radius: 10px; padding: 3px 10px; font-size: .78rem; font-weight: 800; color: var(--ink); }
.mini-btn.danger { background: #f1c9c5; border-color: #d98f89; color: #7d1511; }
.mini.down { filter: grayscale(.75); }
.mini:has(.mini-check:checked) { outline: 3px solid #ffd166; outline-offset: 2px; }
.mini.flash .mini-avatar { animation: ring 1s ease-out; }

@keyframes pop { 0% { transform: scale(.4); } 70% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes glow { to { filter: drop-shadow(0 0 14px #ffd166); } }
@keyframes ring { 0% { box-shadow: 0 0 0 0 var(--flash), 0 0 0 0 var(--flash); } 100% { box-shadow: 0 0 0 16px #0000, 0 0 30px 12px #0000; } }

/* ───────────── vista del DM ───────────── */
.dm-screen { min-height: 100dvh; }
.dm-main { max-width: 1100px; margin: 0 auto; padding: 18px 16px 60px; display: grid; gap: 18px; }
.dm-title { font-size: 1.3rem; }
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px;
  background: var(--tan); color: var(--ink); border-radius: var(--radius); padding: 12px 18px;
  box-shadow: inset 0 0 0 2px var(--tan2);
}
.toolbar .row { gap: 6px; }
.tool-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-left: 20px; border-left: 2px solid var(--tan3); }
.tool-title { font-weight: 800; text-transform: uppercase; font-size: .75rem; letter-spacing: .08em; color: var(--ink2); }
.sel-count { font-size: .88rem; color: var(--ink2); }
.mini-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 18px; justify-items: center; }
.mini-grid .mini { width: 100%; max-width: 250px; }
.empty { text-align: center; padding: 20px; }

.req-list { display: grid; gap: 10px; }
.req { background: var(--tan2); border-radius: 14px; padding: 10px 14px; display: grid; gap: 6px; }
.req.closed { opacity: .65; }
.req-results { display: grid; gap: 3px; }
.req-results li { display: flex; justify-content: space-between; gap: 12px; }
.req .tag { background: #0002; }

/* ───────────── vista del jugador ───────────── */
.player-screen { min-height: 100dvh; display: flex; flex-direction: column; }
.stage { position: relative; flex: 1; min-height: 120px; }
.result-host { position: absolute; left: 50%; top: 14%; transform: translateX(-50%); width: min(540px, 94%); z-index: 40; }
.result-card {
  background: #25202bee; border: 2px solid #f0b34a; border-radius: 20px; padding: 14px 18px;
  display: grid; gap: 8px; animation: pop .28s ease-out; cursor: pointer; box-shadow: 0 14px 40px #000a;
}
.result-card h3 { color: #f0b34a; }
.result-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.result-kind { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; opacity: .7; min-width: 64px; }
.dice { display: inline-flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.die-group { display: inline-flex; gap: 4px; align-items: center; }
.die { display: inline-grid; place-items: center; min-width: 32px; height: 32px; padding: 0 4px; border-radius: 9px; background: #fff; color: #222; font-weight: 900; opacity: .6; }
.die.chosen { opacity: 1; outline: 3px solid var(--hp-good); }
.die.nat20 { background: #ffd166; }
.die.nat1 { background: #ff8a80; }
.result-sum strong { font-size: 1.5rem; color: #fff; }
.flat { font-weight: 800; }

.dock { position: relative; width: min(1200px, 100%); margin: 0 auto; padding: 0 14px 14px; }
.hand { position: relative; z-index: 1; display: flex; justify-content: center; gap: 0; margin-bottom: -58px; min-height: 40px; padding-top: 10px; }
.hand.empty { margin-bottom: 0; min-height: 0; }
.hand .mini { margin: 0 -8px; transform-origin: 50% 100%; }
.hand .mini:nth-child(1) { transform: rotate(-6deg); }
.hand .mini:nth-child(2) { transform: rotate(-2deg); }
.hand .mini:nth-child(3) { transform: rotate(2deg); }
.hand .mini:nth-child(4) { transform: rotate(6deg); }
.hand .mini:nth-child(n+5) { transform: rotate(8deg); }
.hand .mini:hover, .hand .mini:focus-within { transform: translateY(-62px) rotate(0); z-index: 6; }

.panel {
  position: relative; z-index: 2;
  display: grid; grid-template-columns: 250px 1fr; gap: 22px; align-items: start;
  background: var(--tan); color: var(--ink); border-radius: 44px; padding: 18px 26px 20px 18px;
  box-shadow: 0 14px 36px #000a, inset 0 0 0 3px var(--tan2);
}
.panel-left { position: relative; }
.avatar-wrap { position: relative; width: 214px; height: 214px; margin: 6px auto 0; }
.avatar-big { width: 100%; height: 100%; border-radius: 50%; overflow: hidden; background: #c7d3e6; border: 6px solid var(--slate2); display: grid; place-items: center; }
.avatar-big .mini-initials { font-size: 3.4rem; }
.avatar-wrap .led { position: absolute; left: -2px; top: 6px; }
.stats-toggle {
  position: absolute; left: -26px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 56px; border: 0; background: var(--tan3); color: var(--ink2);
  border-radius: 14px 0 0 14px; font-size: 1.1rem; font-weight: 900;
}
.save-d20 {
  position: absolute; left: -10px; bottom: -10px; z-index: 3;
  display: flex; align-items: center; gap: 6px;
  background: #1fb5a8; color: #fff; border: 3px solid #0e6f67; border-radius: 18px; padding: 6px 12px 6px 8px;
  font-weight: 800; box-shadow: 0 6px 16px #0007; max-width: 230px;
  animation: beacon 1.6s ease-in-out infinite;
}
.save-d20.requested { background: #d94f3d; border-color: #7d2418; }
.save-icon { font-size: 1.7rem; line-height: 1; }
.save-text { font-size: .85rem; text-align: left; line-height: 1.1; }
.save-count { background: #fff; color: #222; border-radius: 999px; padding: 0 7px; font-size: .75rem; }
@keyframes beacon { 0%, 100% { box-shadow: 0 6px 16px #0007, 0 0 0 0 #ffffff00; } 50% { box-shadow: 0 6px 16px #0007, 0 0 0 9px #ffffff55; } }

.panel-main { display: grid; gap: 10px; min-width: 0; }
.panel-head { display: flex; align-items: center; gap: 12px 22px; flex-wrap: wrap; }
.who { display: grid; }
.char-name { font-size: 1.7rem; line-height: 1.05; }
.hit-die { font-weight: 800; }
.coins { display: flex; gap: 6px 18px; flex-wrap: wrap; flex: 1; justify-content: center; font-size: 1.35rem; font-weight: 700; }
.coin b { font-weight: 900; margin-right: 2px; }
.notes-toggle { margin-left: auto; font-size: 1.9rem; background: none; border: 0; }

.hp-row { position: relative; display: flex; align-items: center; gap: 12px; }
.hp-bar { position: relative; flex: 1; height: 40px; border-radius: 10px; overflow: hidden; background: var(--hp-back); display: flex; align-items: center; justify-content: space-between; }
.hp-fill { position: absolute; inset: 0 auto 0 0; background: var(--hp-good); transition: width .35s ease; }
.hp-fill.good { background: var(--hp-good); }
.hp-fill.mid { background: var(--hp-mid); }
.hp-fill.low { background: var(--hp-low); }
.hp-text { position: relative; z-index: 1; margin: 0 auto; font-weight: 900; font-size: 1.15rem; color: #fff; text-shadow: 0 1px 3px #0009; pointer-events: none; }
.hp-btn { position: relative; z-index: 2; width: 44px; height: 100%; border: 0; background: none; color: #fff; font-size: 1.7rem; font-weight: 900; text-shadow: 0 1px 3px #0009; }
.hp-btn:hover { background: #ffffff25; }
.hp-bar .hp-text { position: absolute; left: 50%; transform: translateX(-50%); margin: 0; }
.hp-label { font-weight: 900; font-size: 1.4rem; }
.ac {
  width: 46px; height: 54px; display: grid; place-items: center; font-weight: 900; font-size: 1.3rem;
  background: var(--slate); border: 2px solid var(--slate2); border-radius: 8px 8px 22px 22px;
}
.hp-pop {
  position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%); z-index: 15;
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 16px;
  background: #fff9ee; border: 3px solid var(--tan3); box-shadow: 0 10px 24px #0007; color: var(--ink);
}
.hp-pop.dmg { border-color: var(--hp-low); }
.hp-pop.heal { border-color: var(--hp-good); }
.hp-sign { font-size: 1.8rem; font-weight: 900; width: 26px; text-align: center; }
.hp-input { width: 110px; font-size: 1.1rem; font-weight: 800; text-align: center; }

.rollmode { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rollmode > button { background: var(--tan2); border: 2px solid var(--tan3); border-radius: 999px; padding: 3px 14px; font-weight: 800; font-size: .85rem; color: var(--ink2); }
.rollmode > button.active { background: var(--ink); border-color: var(--ink); color: var(--tan); }
.count-box { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; font-size: .85rem; margin-left: 6px; }
.count-box button { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--tan3); background: var(--tan2); font-weight: 900; line-height: 1; }

.actions-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px;
  max-height: 252px; overflow-y: auto; padding: 8px; background: var(--tan2); border-radius: 18px;
  scrollbar-width: thin;
}
.act {
  position: relative; min-height: 88px; padding: 8px 12px 8px 46px; text-align: right;
  display: flex; flex-direction: column; justify-content: center; gap: 1px;
  background: var(--slate); border: 2px solid var(--slate2); border-radius: 16px; color: var(--ink);
  user-select: none; -webkit-touch-callout: none; touch-action: manipulation;
  box-shadow: 0 3px 0 var(--slate2); transition: transform .08s;
}
.act:hover { filter: brightness(1.05); }
.act:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--slate2); }
.act-icons { position: absolute; left: 8px; top: 8px; width: 30px; font-size: 1.25rem; line-height: 1.15; text-align: center; white-space: normal; word-break: break-all; }
.act-level { position: absolute; left: 8px; bottom: 6px; font-size: .68rem; font-weight: 800; opacity: .7; }
.act-name { font-weight: 900; font-size: 1.02rem; line-height: 1.05; }
.act-label { font-size: .72rem; opacity: .75; }
.act-roll { font-weight: 900; font-size: 1.05rem; }
.act-atk { font-size: .7rem; opacity: .7; font-weight: 700; }
.act.timing-bonus { border-color: #8fa0bb; }
.act.timing-reaction { border-color: #c7a54a; }

.action-tooltip {
  position: fixed; z-index: 2000; max-width: min(340px, calc(100vw - 16px)); max-height: min(240px, 50vh);
  overflow-y: auto; overscroll-behavior: contain; padding: 10px 12px;
  background: #25202b; color: #f4efe8; border: 2px solid #f0b34a; border-radius: 12px;
  font-size: .85rem; line-height: 1.35; white-space: pre-wrap; overflow-wrap: anywhere;
  box-shadow: 0 10px 28px #000a;
}

/* desplegables (estadísticas y notas) */
.flyout {
  position: absolute; bottom: calc(100% + 10px); z-index: 30;
  background: var(--tan); color: var(--ink); border-radius: 24px; padding: 14px;
  box-shadow: 0 16px 40px #000b, inset 0 0 0 3px var(--tan2);
  max-height: max(260px, calc(100dvh - 500px)); overflow: auto;
}
.stats-flyout { left: 0; width: min(380px, 100%); }
.notes-flyout { right: 0; width: min(340px, 100%); display: grid; gap: 8px; }
.notes-area { min-height: 220px; resize: vertical; background: repeating-linear-gradient(#fffdf7, #fffdf7 27px, #cfdcf0 28px); line-height: 28px; padding: 0 10px; }
.stats-top { display: grid; grid-template-columns: 72px 1fr; gap: 10px; }
.ability-col { display: grid; gap: 6px; }
.ability {
  display: grid; justify-items: center; padding: 3px 0 7px; background: var(--slate); border: 2px solid var(--slate2);
  border-radius: 8px 8px 20px 20px; color: var(--ink); line-height: 1.05;
}
.ab-short { font-size: .65rem; font-weight: 800; }
.ab-score { font-size: 1.35rem; font-weight: 900; }
.ab-mod { font-size: .7rem; font-weight: 800; opacity: .75; }
.info-col { display: grid; gap: 8px; align-content: start; }
.info-boxes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.info-box { display: grid; justify-items: center; align-content: center; gap: 2px; padding: 6px 4px; text-align: center; background: var(--slate); border: 2px solid var(--slate2); border-radius: 10px; color: var(--ink); }
.info-box small { font-size: .55rem; font-weight: 800; line-height: 1.05; }
.info-box b { font-size: 1.15rem; }
.pill { display: flex; align-items: center; gap: 6px; background: var(--slate); border-radius: 999px; padding: 4px 10px; font-size: .62rem; font-weight: 800; }
.pill b { font-size: .8rem; }
.stat-list { display: grid; gap: 2px; margin-top: 4px; }
.stat-list h4 { margin: 8px 0 2px; font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink2); }
.stat-row { display: flex; align-items: center; gap: 12px; padding: 4px 8px; border: 0; background: none; border-radius: 8px; text-align: left; font-size: .85rem; color: var(--ink); }
.stat-row:hover { background: var(--tan2); }
.stat-row.prof .stat-label { font-weight: 900; }
.stat-mod { width: 28px; text-align: right; font-weight: 900; }

/* ───────────── móvil ───────────── */
@media (max-width: 760px) {
  .panel { grid-template-columns: 1fr; border-radius: 32px; padding: 16px; }
  .avatar-wrap { width: 150px; height: 150px; }
  .stats-toggle { left: -10px; width: 28px; height: 46px; border-radius: 12px; }
  .save-d20 { left: 50%; bottom: -14px; transform: translateX(-50%); animation: none; }
  .coins { font-size: 1.05rem; justify-content: flex-start; }
  .hand { margin-bottom: -48px; overflow-x: auto; justify-content: flex-start; padding-left: 8px; }
  .hand .mini { flex: none; transform: none !important; margin: 0 4px; width: 150px; }
  .flyout { position: fixed; inset: auto 8px 8px 8px; width: auto; max-height: 70dvh; }
  .stats-flyout, .notes-flyout { left: 8px; right: 8px; width: auto; }
  .tool-group { padding-left: 0; border-left: 0; }
  .home-title h1 { font-size: 2.4rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}


/* ───────────── cambios de vida visibles en las tarjetas ───────────── */
.mini-hp { overflow: visible; }
.mini-hp-fill { border-radius: 8px; }
.hp-float {
  position: absolute; right: -8px; top: -16px; z-index: 12; font-weight: 900; font-size: 1.15rem; opacity: 0;
  pointer-events: none; background: #fffdf6; padding: 0 8px; border-radius: 999px; border: 2px solid currentColor;
  box-shadow: 0 2px 6px #0006;
}
.hp-float.dmg { color: #c0261d; }
.hp-float.heal { color: #15803d; }
.hp-float.show { animation: hpfloat 3s ease-out forwards; }
@keyframes hpfloat { 0% { opacity: 0; transform: translateY(6px) scale(.6); } 12% { opacity: 1; transform: translateY(-10px) scale(1.25); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-26px) scale(1); } }
.mini.hp-hit { animation: hit .5s ease-in-out; box-shadow: 0 6px 16px #0007, 0 0 0 3px #dc2626, 0 0 18px 4px #dc262699; }
.mini.hp-heal { box-shadow: 0 6px 16px #0007, 0 0 0 3px #16a34a, 0 0 18px 4px #16a34a88; }
@keyframes hit { 0%, 100% { translate: 0 0; } 25% { translate: -4px 0; } 75% { translate: 4px 0; } }
.roll-dmg {
  position: absolute; left: 54px; top: 14px; z-index: 5; background: #7d1511; color: #fff; font-weight: 900;
  font-size: .8rem; padding: 2px 7px; border-radius: 10px; white-space: nowrap; opacity: 0; transition: opacity .2s;
}
.roll-badge.fresh .roll-dmg, .mini:hover .roll-dmg, .mini:focus-within .roll-dmg { opacity: 1; }
.roll-label { width: max-content; white-space: normal; max-width: 200px; z-index: 30; }

/* ───────────── ficha de un jugador vista por el DM ───────────── */
.dialog.statsdlg { width: min(560px, 100%); max-height: calc(100dvh - 32px); overflow: auto; gap: 12px; }
.statsdlg h3 { font-size: 1.3rem; }
.statsdlg .sub { color: var(--ink2); font-weight: 700; margin-top: -8px; }
.sd-facts { display: flex; flex-wrap: wrap; gap: 6px 14px; font-weight: 800; }
.sd-abilities { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.sd-ab { background: var(--slate); border: 2px solid var(--slate2); border-radius: 10px; text-align: center; padding: 4px 2px; display: grid; }
.sd-ab small { font-weight: 800; font-size: .7rem; }
.sd-ab b { font-size: 1.15rem; }
.sd-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.sd-list { display: grid; gap: 2px; align-content: start; }
.sd-list h4 { margin: 6px 0 2px; font-size: .9rem; }
.sd-row { display: flex; gap: 8px; font-size: .9rem; }
.sd-row .m { width: 2.2em; font-weight: 900; text-align: right; }
.sd-row.prof { font-weight: 800; }
.sd-row.prof .l::after { content: " ●"; font-size: .6rem; vertical-align: middle; }
.sd-row.prof2 .l::after { content: " ●●"; }
@media (max-width: 760px) { .sd-abilities { grid-template-columns: repeat(3, 1fr); } .sd-cols { grid-template-columns: 1fr; } }


/* ───────────── historial de tiradas (DM) ───────────── */
.hist-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: 340px; overflow: auto; }
.hist-item { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 5px 8px; border-radius: 8px; background: #0000000d; font-size: .9rem; }
.hist-item time { color: var(--ink2); font-size: .78rem; font-variant-numeric: tabular-nums; }
.hist-who { font-weight: 900; }
.hist-what { flex: 1; min-width: 120px; }
.hist-val { font-weight: 900; padding: 1px 8px; border-radius: 999px; background: var(--slate); border: 2px solid var(--slate2); white-space: nowrap; }
.hist-val.dmg { background: #f1c9c5; border-color: #d98f89; color: #7d1511; }
.hist-val small { font-weight: 700; }
.hist-item.crit { box-shadow: inset 3px 0 0 #ffd166; }
.hist-item.fumble { box-shadow: inset 3px 0 0 #d9534f; }


/* ───────────── mantener pulsado = ver estados ───────────── */
.holdable { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; touch-action: manipulation; }
.led-tip.show { display: block; }
.led-tip.own { left: -2px; top: 42px; z-index: 40; }
.led { cursor: help; }

/* ───────────── monedas editables ───────────── */
.coins-edit { font-size: 1.5rem; background: none; border: 0; line-height: 1; padding: 2px 4px; }
.coins-edit:hover { transform: scale(1.15); }
.coin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px 12px; }
.coin-field { display: grid; gap: 2px; font-weight: 800; font-size: .8rem; }
.coin-field input { font-weight: 800; font-size: 1.05rem; }
.dialog h3 { font-size: 1.2rem; }

/* ───────────── hoja de estadísticas: lista compacta (info-col dentro de ability-col) ───────────── */
.stats-top { display: block; }
.ability-col { display: grid; grid-template-columns: 72px 1fr; gap: 6px 10px; align-items: start; }
.ability { grid-column: 1; max-height: 100px; align-self: start; }
.info-col { grid-column: 2; grid-row: 1 / span 6; align-self: start; }


/* ───────────── tiro personalizado y descanso corto ───────────── */
.who { gap: 4px; }
.custom-roll { display: grid; gap: 2px; margin-top: 4px; }
.custom-roll label { font-size: 1.05rem; font-weight: 700; }
.custom-row { display: flex; gap: 8px; align-items: stretch; }
.custom-roll .custom-input {
  flex: 1; min-width: 150px; max-width: 320px; background: #fff !important; color: #1b1510; border: 3px solid #c4c4c4;
  border-radius: 6px; padding: 6px 10px; font-size: 1.05rem; font-weight: 700;
}
.custom-btn {
  background: #ffc80f; color: #1b1510; border: 3px solid #e0ac00; border-radius: 14px; padding: 4px 18px;
  font-weight: 900; font-size: 1rem; letter-spacing: .02em;
}
.custom-btn:hover { background: #ffd23a; }
.custom-btn:active { transform: translateY(1px); }
.act-rest { background: #dfe7d4; border-color: #aab99a; }
.act-rest .act-roll { font-size: 1.1rem; }

/* ───────────── tiros del DM ───────────── */
.dm-roll-row { display: flex; flex-wrap: wrap; gap: 14px 18px; align-items: flex-end; margin-top: 8px; }
.dm-roll-row .custom-roll { margin: 0; min-width: 260px; }
.d20-quick {
  display: grid; justify-items: center; align-content: center; width: 76px; height: 76px; border-radius: 18px;
  background: #f08a24; color: #fff; border: 3px solid #a85a10; box-shadow: 0 4px 0 #7a3b0a; font-weight: 900;
}
.d20-quick span { font-size: 2rem; line-height: 1; }
.d20-quick b { font-size: .95rem; }
.d20-quick:active { transform: translateY(3px); box-shadow: 0 1px 0 #7a3b0a; }
.dm-result { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; min-width: 160px; flex: 1; font-weight: 700; }
.dm-total { font-size: 2rem; line-height: 1; }
.dm-parts { display: inline-flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.dm-result .die { background: var(--slate); border: 2px solid var(--slate2); color: var(--ink); }

/* pantalla completa / muescas: respeta las áreas seguras del dispositivo */
body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
.topbar { padding-top: max(10px, env(safe-area-inset-top)); }


/* ───────────── zona de peligro (eliminar campaña) ───────────── */
.danger-zone { margin-top: 14px; padding: 12px 14px; border: 2px dashed #d98f89; border-radius: 12px; background: #f1c9c522; display: grid; gap: 8px; justify-items: start; }
.danger-zone h3 { color: #7d1511; }
.btn.danger { background: #b3261e; color: #fff; border-color: #7d1511; }
.btn.danger:disabled { opacity: .45; cursor: not-allowed; }

/* ───────────── modo overlay (pywebview) ───────────── */
body.overlay-mode { overflow: hidden; }
.overlay-mode .dock { width: min(760px, 100%); margin: 0 auto; }
.overlay-mode .topbar { background: none; border: 0; box-shadow: none; justify-content: flex-start; width: max-content; padding: 6px 8px; }
.overlay-mode .overlay { background: transparent; pointer-events: none; }
.overlay-mode .overlay > * { pointer-events: auto; }
.overlay-mode .toast-host { bottom: auto; top: 18px; }
.ov-pill { position: fixed; right: 14px; bottom: 14px; z-index: 5000; display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: #25202bee; border: 2px solid #f0b34a; }
.ov-pill button { border: 0; background: none; width: 30px; height: 30px; border-radius: 50%; font-size: 1rem; }
.ov-pill button:hover { background: #ffffff22; }
body:not(.overlay-mode) .ov-pill { display: none; }
.ov-folded .panel, .ov-folded .hand, .ov-folded .flyout { display: none !important; }
.overlay-mode .player-screen { height: 100dvh; min-height: 0; }
.overlay-mode .actions-grid { max-height: max(120px, 24dvh); overflow-y: auto; }   /* el panel nunca desborda la pantalla */

/* ───────────── control de sonido ───────────── */
.snd { position: relative; }
.snd summary { list-style: none; cursor: pointer; padding: 5px 10px; border-radius: 999px; border: 2px solid #ffffff55; background: #0003; }
.snd summary::-webkit-details-marker { display: none; }
.snd-pop { position: fixed; right: 8px; top: 56px; z-index: 3500; width: min(230px, calc(100vw - 16px)); padding: 12px; display: grid; gap: 10px; border-radius: 14px; background: #fff9ee; color: var(--ink); border: 2px solid var(--tan3); box-shadow: 0 8px 24px #0006; }
.snd-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.snd-row input[type=range] { width: 110px; }
