/* ============================================================
   Roll & Initiative — Tema "Mesa de RPG" (v4, UI compacta)
   ============================================================ */
:root {
  --wood-dark: #2b1a10;
  --wood: #3e2717;
  --wood-light: #55351f;
  --gold: #c9a24a;
  --gold-bright: #e8c76e;
  --wine: #6e1f2a;
  --wine-bright: #9c2f3e;
  --parchment: #e8d9b0;
  --parchment-dark: #d4c193;
  --ink: #2a1c10;
  --green-felt: #1e3a2a;
  --font-title: 'Cinzel', serif;
  --font-body: 'IM Fell English', Georgia, serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: var(--font-body);
  color: var(--parchment);
  background-color: var(--wood-dark);
  background-image:
    radial-gradient(ellipse at 50% 30%, rgba(232,199,110,.10), transparent 55%),
    radial-gradient(ellipse at 50% 100%, rgba(0,0,0,.55), transparent 60%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='160'%3E%3Crect width='220' height='160' fill='%233e2717'/%3E%3Cg stroke='%232b1a10' stroke-width='2'%3E%3Cline x1='0' y1='40' x2='220' y2='40'/%3E%3Cline x1='0' y1='80' x2='220' y2='80'/%3E%3Cline x1='0' y1='120' x2='220' y2='120'/%3E%3C/g%3E%3Cg stroke-width='1' opacity='.35' stroke-linecap='round'%3E%3Cpath d='M10 12 Q 70 18 130 10 T 215 14' fill='none' stroke='%2355351f'/%3E%3Cpath d='M5 55 Q 60 48 120 56 T 210 52' fill='none' stroke='%2355351f'/%3E%3Cpath d='M15 95 Q 80 102 140 94 T 218 98' fill='none' stroke='%2355351f'/%3E%3Cpath d='M8 135 Q 66 128 128 136 T 212 132' fill='none' stroke='%2355351f'/%3E%3C/g%3E%3Cg fill='%232b1a10' opacity='.8'%3E%3Cellipse cx='40' cy='60' rx='4' ry='7'/%3E%3Cellipse cx='170' cy='25' rx='3' ry='6'/%3E%3Cellipse cx='110' cy='140' rx='4' ry='6'/%3E%3C/g%3E%3C/svg%3E");
  min-height: 100vh;
}

/* ---------------- Telas ---------------- */
.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; flex-direction: column; }
#screen-home { align-items: center; justify-content: center; position: relative; overflow: hidden; }
#screen-table.active { height: 100vh; min-height: 0; overflow: hidden; }

/* ---------------- Scrollbars temáticas ---------------- */
.panel, .feed, .modal-body, .init-list {
  scrollbar-width: thin;
  scrollbar-color: var(--gold) rgba(0,0,0,.35);
}
.panel::-webkit-scrollbar, .feed::-webkit-scrollbar,
.modal-body::-webkit-scrollbar { width: 9px; }
.panel::-webkit-scrollbar-track, .feed::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track { background: rgba(0,0,0,.35); border-radius: 5px; }
.panel::-webkit-scrollbar-thumb, .feed::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold) 50%, #8a6b2c);
  border-radius: 5px;
  border: 2px solid rgba(0,0,0,.45);
}

/* ---------------- Pergaminho (home) ---------------- */
.parchment {
  background:
    radial-gradient(ellipse at 30% 20%, rgba(255,255,255,.25), transparent 60%),
    linear-gradient(160deg, var(--parchment), var(--parchment-dark));
  color: var(--ink);
  border-radius: 6px;
  box-shadow: 0 0 0 2px rgba(201,162,74,.6), 0 18px 60px rgba(0,0,0,.7), inset 0 0 40px rgba(120,90,40,.25);
  position: relative;
}

.home-card { width: min(430px, 92vw); padding: 42px 38px 34px; text-align: center; animation: fadeZoom .6s ease both; }
.logo { width: 92px; margin-bottom: 6px; filter: drop-shadow(0 4px 10px rgba(0,0,0,.4)); }
.logo-num { font-family: var(--font-title); font-size: 40px; font-weight: 900; fill: var(--wine); }
.logo-num.small { font-size: 46px; fill: var(--gold); }
.title { font-family: var(--font-title); font-weight: 900; font-size: 2rem; letter-spacing: .04em; color: var(--wine); text-shadow: 0 1px 0 rgba(255,255,255,.4); }
.subtitle { margin: 4px 0 26px; font-style: italic; opacity: .8; }
.home-card label { display: block; text-align: left; font-weight: bold; margin-bottom: 6px; }

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  font-family: var(--font-body);
  font-size: 1rem;
  background: rgba(255,255,255,.55);
  border: 1px solid rgba(110,31,42,.45);
  border-radius: 4px;
  color: var(--ink);
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--wine); box-shadow: 0 0 0 3px rgba(110,31,42,.18); }

.btn {
  font-family: var(--font-title);
  font-weight: 700;
  letter-spacing: .05em;
  cursor: pointer;
  padding: 10px 18px;
  border-radius: 4px;
  border: 1px solid var(--gold);
  background: linear-gradient(180deg, var(--wood-light), var(--wood-dark));
  color: var(--gold-bright);
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.5); filter: brightness(1.15); }
.btn:active { transform: translateY(0); }
.btn-gold {
  width: 100%; margin-top: 14px;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold) 55%, #a37f33);
  color: var(--wood-dark); border-color: #7d6127;
  text-shadow: 0 1px 0 rgba(255,255,255,.35);
}
.btn-small { padding: 7px 12px; font-size: .78rem; }
.btn-block { display: block; width: 100%; margin-top: 8px; }
.btn-danger { border-color: var(--wine-bright); color: #e9a0ab; }
.btn-icon {
  padding: 8px 10px; font-size: .9rem; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn-icon .ic { width: 1.15em; height: 1.15em; }
.btn-mini {
  background: none; border: none; cursor: pointer;
  color: var(--gold-bright); padding: 3px 5px; border-radius: 3px;
  transition: transform .12s ease, background .12s ease;
}
.btn-mini:hover { transform: scale(1.2); background: rgba(232,199,110,.12); }
.btn-mini .ic { width: 1em; height: 1em; }
label .btn, .btn label { cursor: pointer; }
label.btn input { display: none; }
label.btn { display: inline-flex; align-items: center; gap: 6px; }

.divider { display: flex; align-items: center; gap: 10px; margin: 22px 0 14px; opacity: .7; font-style: italic; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: rgba(42,28,16,.4); }
.join-row { display: flex; gap: 10px; }
.join-row input { text-transform: uppercase; letter-spacing: .2em; text-align: center; font-family: var(--font-title); }
.error { color: var(--wine-bright); min-height: 1.2em; margin-top: 8px; font-weight: bold; }
.error.small { font-size: .8rem; }

/* ---------------- Velas ---------------- */
.candle {
  position: absolute; bottom: 8vh; width: 26px; height: 120px;
  background: linear-gradient(180deg, #f3e6c8, #d8c39a);
  border-radius: 6px 6px 3px 3px;
  box-shadow: 0 10px 30px rgba(0,0,0,.6);
}
.candle::before {
  content: ''; position: absolute; top: -34px; left: 50%; translate: -50% 0;
  width: 16px; height: 30px;
  background: radial-gradient(ellipse at 50% 80%, #fff6c9 0%, #ffb84d 45%, #ff7b1f 75%, transparent 78%);
  border-radius: 50% 50% 45% 45% / 65% 65% 35% 35%;
  animation: flicker 1.6s ease-in-out infinite;
  filter: drop-shadow(0 0 18px rgba(255,170,60,.8));
}
.candle::after {
  content: ''; position: absolute; top: -110px; left: 50%; translate: -50% 0;
  width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,190,90,.16), transparent 65%);
  animation: flicker 2.3s ease-in-out infinite reverse;
  pointer-events: none;
}
.candle-left { left: 6vw; } .candle-right { right: 6vw; height: 90px; }

@keyframes flicker {
  0%,100% { transform: scale(1) rotate(-2deg); opacity: 1; }
  25% { transform: scale(1.08) rotate(2deg); opacity: .92; }
  50% { transform: scale(.94) rotate(-1deg); opacity: .98; }
  75% { transform: scale(1.05) rotate(1.5deg); opacity: .9; }
}

/* ---------------- Cabeçalho ---------------- */
.table-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 16px;
  background: linear-gradient(180deg, rgba(0,0,0,.45), rgba(0,0,0,.25));
  border-bottom: 2px solid var(--gold);
  box-shadow: 0 4px 20px rgba(0,0,0,.5);
  flex-shrink: 0;
}
.header-left { display: flex; align-items: center; gap: 10px; }
.header-right { display: flex; gap: 6px; }
.mini-logo { width: 38px; }
.room-label { font-family: var(--font-title); font-weight: 700; font-size: 1.02rem; color: var(--gold-bright); }
#room-id { letter-spacing: .18em; }
.identity { font-size: .82rem; opacity: .85; font-style: italic; }
.identity .role-mestre { color: var(--gold-bright); font-weight: bold; }

/* ---------------- Layout ---------------- */
.table-main {
  flex: 1;
  display: grid;
  grid-template-columns: 235px 1fr 280px;
  gap: 12px;
  padding: 12px 16px;
  min-height: 0;
  overflow: hidden;
}

.panel {
  background: linear-gradient(180deg, rgba(0,0,0,.4), rgba(0,0,0,.25));
  border: 1px solid rgba(201,162,74,.4);
  border-radius: 8px;
  padding: 12px;
  overflow-y: auto;
  box-shadow: inset 0 0 30px rgba(0,0,0,.35);
  min-height: 0;
}

.panel-title {
  font-family: var(--font-title);
  font-size: .82rem;
  color: var(--gold-bright);
  border-bottom: 1px solid rgba(201,162,74,.35);
  padding-bottom: 6px;
  margin-bottom: 8px;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.panel-title .ic { color: var(--gold-bright); margin-right: 3px; }

/* Participantes */
.participants { list-style: none; }
.participants li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 5px 8px; margin-bottom: 4px;
  background: rgba(255,255,255,.05);
  border-left: 3px solid var(--gold);
  border-radius: 3px;
  font-size: .92rem;
  animation: slideIn .3s ease both;
}
.participants .pname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.participants .badge { color: var(--gold-bright); margin-left: 3px; }
.ic-badge { width: .8em; height: .8em; }

/* Iniciativa (mestre) */
.master-tools { margin-top: 16px; }
.hidden { display: none !important; }
.init-add-row { display: flex; gap: 5px; margin-bottom: 6px; }
.init-add-row input { flex: 1; padding: 7px 9px; font-size: .88rem; background: rgba(232,217,176,.9); }
.init-list { list-style: none; margin: 6px 0 8px; max-height: 180px; overflow-y: auto; }
.init-list li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 8px; margin-bottom: 3px;
  background: rgba(110,31,42,.3); border-radius: 3px;
  font-size: .88rem;
}
.init-list button { background: none; border: none; color: var(--wine-bright); cursor: pointer; }
.init-list button .ic { width: .85em; height: .85em; }

/* ---------------- Mesa (feltro) ---------------- */
.stage-panel { padding: 0; overflow: hidden; display: flex; }
.stage {
  flex: 1; position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; padding: 20px;
  background:
    radial-gradient(ellipse at 50% 35%, rgba(255,220,140,.09), transparent 60%),
    radial-gradient(ellipse at 50% 50%, var(--green-felt), #14281d 80%);
  border-radius: 8px;
  box-shadow: inset 0 0 60px rgba(0,0,0,.7), inset 0 0 0 6px rgba(201,162,74,.25);
  min-height: 0;
  overflow: hidden;
}
.stage-hint { font-style: italic; opacity: .55; font-size: 1rem; text-align: center; }
.stage-clear {
  position: absolute; top: 12px; right: 12px; z-index: 5;
  opacity: .65;
}
.stage-clear:hover { opacity: 1; }

/* ---------------- Dados 3D ---------------- */
.dice3d-overlay { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.dice3d-canvas { width: 100%; height: 100%; display: block; }

.die3d-label {
  position: absolute;
  transform: translate(-50%, -100%);
  text-align: center;
  pointer-events: none;
  animation: fadeZoom .35s ease both;
}
.die3d-label .num {
  display: block;
  font-family: var(--font-title);
  font-size: 2rem; font-weight: 900;
  color: #fff;
  text-shadow: 0 0 14px rgba(232,199,110,.9), 0 2px 5px rgba(0,0,0,.9);
  line-height: 1;
}
.die3d-label .owner {
  display: block;
  font-size: .82rem; font-style: italic;
  color: var(--gold-bright);
  text-shadow: 0 1px 3px rgba(0,0,0,.9);
}
.die3d-label.crit .num { color: var(--gold-bright); text-shadow: 0 0 22px rgba(232,199,110,1), 0 2px 5px rgba(0,0,0,.9); }
.die3d-label.fumble .num { color: #ff8a97; text-shadow: 0 0 22px rgba(156,47,62,1), 0 2px 5px rgba(0,0,0,.9); }

/* ---------------- Dados 2D (fallback) ---------------- */
.dice-area { display: flex; flex-wrap: wrap; gap: 20px; justify-content: center; }
.die {
  width: 110px; height: 110px;
  filter: drop-shadow(0 10px 12px rgba(0,0,0,.55));
  will-change: transform;
  animation: dieEnter .25s ease both;
}
.die .die-face { transform-box: fill-box; transform-origin: center; }
.die.settled .die-face { animation: dieSettle .35s ease both; }
.die text {
  font-family: var(--font-title); font-weight: 900;
  fill: #fff; text-anchor: middle;
  paint-order: stroke; stroke: rgba(0,0,0,.5); stroke-width: 1.5px;
}
.die .die-owner { font-family: var(--font-body); font-size: 13px; fill: var(--gold-bright); stroke: none; }
.die.crit  { filter: drop-shadow(0 0 18px rgba(232,199,110,.95)); }
.die.fumble{ filter: drop-shadow(0 0 18px rgba(156,47,62,.95)); }

@keyframes dieSettle { 0% { transform: scale(1); } 40% { transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes dieEnter { from { opacity: 0; } to { opacity: 1; } }

/* ---------------- Cartas ---------------- */
.cards-area { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; perspective: 1000px; }
.card-wrap { display: flex; flex-direction: column; align-items: center; animation: cardDeal .6s cubic-bezier(.2,.8,.3,1) both; }
.card { width: 100px; height: 140px; perspective: 1000px; }
.card-inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .65s cubic-bezier(.4,.1,.2,1.1); }
.card.flipped .card-inner { transform: rotateY(180deg); }
.card .face {
  position: absolute; inset: 0;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border-radius: 9px; box-shadow: 0 8px 20px rgba(0,0,0,.55);
}
.card .face svg { width: 100%; height: 100%; display: block; }
.card .back { transform: rotateY(0deg); }
.card .front { transform: rotateY(180deg); }

@keyframes cardDeal {
  from { opacity: 0; transform: translate(-160px, -200px) rotate(-28deg) scale(.55); }
  to   { opacity: 1; transform: translate(0,0) rotate(0) scale(1); }
}

.card-owner {
  text-align: center; margin-top: 6px; font-size: .82rem;
  color: var(--gold-bright); font-style: italic;
  width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------------- Resultado da iniciativa ---------------- */
.initiative-result {
  width: min(520px, 100%);
  max-height: 100%;
  overflow-y: auto;
  background:
    radial-gradient(ellipse at 30% 15%, rgba(255,255,255,.28), transparent 55%),
    linear-gradient(160deg, var(--parchment), var(--parchment-dark));
  color: var(--ink);
  border-radius: 6px;
  padding: 16px 20px;
  box-shadow: 0 0 0 2px rgba(201,162,74,.7), 0 16px 50px rgba(0,0,0,.7);
  animation: fadeZoom .5s ease both;
  position: relative;
  z-index: 3;
}
.initiative-result h3 {
  font-family: var(--font-title); color: var(--wine);
  border-bottom: 2px solid rgba(110,31,42,.35);
  padding-bottom: 6px; margin-bottom: 10px;
  font-size: 1rem;
}
.initiative-result ol { padding-left: 26px; }
.initiative-result li { padding: 3px 0; font-size: 1.02rem; animation: slideIn .35s ease both; }
.initiative-result li .suit-red { color: #b3232f; }
.initiative-result li .suit-black { color: #1c1c1c; }
.initiative-result li strong { font-family: var(--font-title); }
.ic-title { color: var(--wine-bright); width: 1.1em; height: 1.1em; }
.init-footnote { margin-top: 8px; font-style: italic; opacity: .7; font-size: .85rem; }

/* ---------------- Feed ---------------- */
.feed-panel { display: flex; flex-direction: column; overflow: hidden; }
.feed {
  list-style: none;
  display: flex; flex-direction: column; gap: 6px;
  overflow-y: auto; flex: 1; min-height: 0;
  padding-right: 4px;
}
.feed li {
  padding: 7px 10px;
  background: rgba(255,255,255,.05);
  border-left: 3px solid var(--wine-bright);
  border-radius: 3px;
  font-size: .88rem;
  animation: slideIn .35s ease both;
  flex-shrink: 0;
}
.feed li.dice { border-left-color: var(--gold); }
.feed li.system { opacity: .6; font-style: italic; border-left-color: rgba(255,255,255,.25); }
.feed li strong { color: var(--gold-bright); }
.feed li .result-big { font-family: var(--font-title); font-weight: 900; color: var(--gold-bright); }
.feed li time { display: block; font-size: .68rem; opacity: .5; margin-top: 1px; }
.crit-tag { color: var(--gold-bright); font-weight: bold; }
.fumble-tag { color: var(--wine-bright); font-weight: bold; }
.crit-tag .ic { color: var(--gold-bright); }
.fumble-tag .ic { color: var(--wine-bright); }

/* ---------------- Bandeja de dados ---------------- */
.dice-tray {
  display: flex; align-items: center; gap: 14px;
  padding: 8px 18px 10px;
  background:
    linear-gradient(0deg, rgba(0,0,0,.55), rgba(0,0,0,.35)),
    repeating-linear-gradient(90deg, rgba(255,255,255,.02) 0 2px, transparent 2px 8px);
  border-top: 2px solid var(--gold);
  flex-shrink: 0;
}
.tray-label {
  font-family: var(--font-title); color: var(--gold-bright);
  letter-spacing: .12em; font-size: .75rem; text-transform: uppercase;
  opacity: .8;
}
.tray-buttons { display: flex; gap: 8px; flex-wrap: wrap; }

.die-btn {
  background: none; border: none; cursor: pointer;
  padding: 4px; border-radius: 10px;
  transition: transform .16s cubic-bezier(.3,1.6,.5,1), filter .16s ease, background .16s ease;
}
.die-btn svg { width: 54px; height: 54px; display: block; filter: drop-shadow(0 5px 7px rgba(0,0,0,.55)); }
.die-btn:hover {
  transform: translateY(-6px) scale(1.12);
  filter: drop-shadow(0 0 12px rgba(232,199,110,.5));
  background: rgba(232,199,110,.07);
}
.die-btn:active { transform: translateY(-1px) scale(.95); }

/* ---------------- Ícones ---------------- */
.ic { width: 1em; height: 1em; vertical-align: -0.12em; display: inline-block; fill: none; }
.role-mestre .ic { color: var(--gold-bright); }

/* ---------------- Modal ---------------- */
.modal-root { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(10,5,2,.7); backdrop-filter: blur(3px); animation: fadeZoom .2s ease both; }
.modal {
  position: relative;
  width: min(860px, 94vw);
  max-height: 90vh;
  display: flex; flex-direction: column;
  background:
    radial-gradient(ellipse at 30% 10%, rgba(255,255,255,.22), transparent 55%),
    linear-gradient(160deg, var(--parchment), var(--parchment-dark));
  color: var(--ink);
  border-radius: 8px;
  box-shadow: 0 0 0 2px rgba(201,162,74,.8), 0 30px 80px rgba(0,0,0,.85);
  animation: fadeZoom .25s ease both;
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px 10px;
  border-bottom: 2px solid rgba(110,31,42,.3);
}
.modal-title { font-family: var(--font-title); font-size: 1.15rem; color: var(--wine); }
.modal-title .ic { color: var(--wine); }
.modal-head .btn-icon { border-color: rgba(110,31,42,.5); background: transparent; color: var(--wine); }
.modal-tabs { display: flex; gap: 4px; padding: 8px 18px 0; }
.modal-tabs .tab {
  font-family: var(--font-title); font-size: .8rem; font-weight: 700;
  padding: 7px 14px; cursor: pointer;
  border: 1px solid rgba(110,31,42,.35); border-bottom: none;
  border-radius: 6px 6px 0 0;
  background: rgba(110,31,42,.08); color: var(--ink);
  opacity: .65;
}
.modal-tabs .tab.on { background: rgba(255,255,255,.45); opacity: 1; border-color: var(--wine); }
.modal-body { padding: 14px 18px 18px; overflow-y: auto; min-height: 200px; }
.modal-empty { font-style: italic; opacity: .7; padding: 30px 0; text-align: center; }

/* PDF */
.pdf-actions { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.pdf-status { font-style: italic; font-size: .85rem; }
.pdf-frame { width: 100%; height: 58vh; border: 1px solid rgba(110,31,42,.4); border-radius: 4px; background: #fff; }

/* ---------------- Ficha interativa ---------------- */
.sheet-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px; gap: 10px;
}
.save-status { font-style: italic; font-size: .82rem; opacity: .7; }

.sheet-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.sh-box {
  border: 1px solid rgba(110,31,42,.35);
  border-radius: 6px;
  padding: 10px 12px 12px;
  background: rgba(255,255,255,.25);
}
.sh-box legend {
  font-family: var(--font-title); font-size: .78rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--wine); padding: 0 6px;
}
.sh-header, .sh-wide { grid-column: 1 / -1; }
.sh-box label { display: block; font-size: .8rem; font-weight: bold; margin-bottom: 6px; }
.sh-inp { margin-top: 2px; padding: 6px 8px; font-size: .92rem; background: rgba(255,255,255,.6); }
.sh-inp:disabled { background: rgba(255,255,255,.35); color: #444; border-style: dashed; }
.sh-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sh-attrs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.sh-attr { text-align: center; font-size: .75rem !important; }
.sh-die { text-align: center; font-family: var(--font-title); font-weight: 700; }
.sh-derived { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.sh-derived label { font-size: .72rem; text-align: center; }
.sh-num { text-align: center; }
.sh-listrow { display: flex; gap: 6px; align-items: center; margin-bottom: 5px; }
.sh-listrow .sh-mid { max-width: 90px; }
.sh-listrow .btn-mini { color: var(--wine); flex-shrink: 0; }
.sheet-grid .btn { border-color: rgba(110,31,42,.5); color: var(--wine); background: rgba(255,255,255,.3); }
.sheet-grid .btn:hover { filter: none; background: rgba(255,255,255,.55); }
.sheet-toolbar .btn { border-color: rgba(110,31,42,.5); color: var(--wine); background: rgba(255,255,255,.3); }

/* ---------------- Guia ---------------- */
.guide section { margin-bottom: 16px; }
.guide h3 {
  font-family: var(--font-title); color: var(--wine);
  font-size: .95rem; margin-bottom: 4px;
  border-bottom: 1px solid rgba(110,31,42,.25); padding-bottom: 3px;
}
.guide h3 .ic { color: var(--wine); }
.guide p { font-size: .92rem; line-height: 1.45; margin-bottom: 6px; }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; translate: -50% 20px;
  background: var(--gold); color: var(--wood-dark);
  font-family: var(--font-title); font-weight: 700;
  padding: 10px 22px; border-radius: 30px;
  box-shadow: 0 10px 30px rgba(0,0,0,.6);
  opacity: 0; pointer-events: none;
  transition: opacity .3s ease, translate .3s ease;
  z-index: 99;
  max-width: 90vw;
}
.toast.show { opacity: 1; translate: -50% 0; }

/* ---------------- Animações ---------------- */
@keyframes fadeZoom { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: scale(1); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(-14px); } to { opacity: 1; transform: translateX(0); } }

/* ---------------- Responsivo ---------------- */
@media (max-width: 1020px) {
  .table-main { grid-template-columns: 215px 1fr; grid-template-rows: 1fr auto; }
  .feed-panel { grid-column: 1 / -1; max-height: 190px; }
  .sheet-grid { grid-template-columns: 1fr; }
  .sh-attrs { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 680px) {
  #screen-table.active { height: auto; min-height: 100vh; overflow: auto; }
  .table-main { grid-template-columns: 1fr; grid-template-rows: none; }
  .side-panel { max-height: 340px; }
  .stage-panel { min-height: 380px; }
  .feed-panel { max-height: 240px; }
  .table-header { flex-direction: column; gap: 8px; }
  .candle { display: none; }
  .sh-derived { grid-template-columns: repeat(2, 1fr); }
}

/* ---------------- Ficha v5 (clone SW) ---------------- */
.sh-row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.toolbar-btns { display: flex; gap: 8px; }
.btn-save {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold) 55%, #a37f33) !important;
  color: var(--wood-dark) !important;
  border-color: #7d6127 !important;
}
.pdf-hint { font-size: .78rem; font-style: italic; opacity: .65; }
.sh-attrs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.sh-attr { text-align: center; }
.sh-attr-name {
  display: block; font-family: var(--font-title); font-weight: 700;
  font-size: .78rem; margin-bottom: 3px;
}
.sh-attr-mod { font-size: .68rem !important; margin-top: 4px; }
.sh-derived-sub { margin-top: 8px; padding-top: 6px; border-top: 1px dashed rgba(110,31,42,.25); }
.sh-total .sh-inp { background: rgba(201,162,74,.25); font-weight: bold; }
.sh-cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; }
.sh-tiny { max-width: 64px; }
.sh-armarow {
  display: grid;
  grid-template-columns: 1.4fr 0.9fr 0.9fr 0.55fr 0.55fr 0.55fr 1.6fr auto;
  gap: 5px; align-items: center; margin-bottom: 5px;
}
@media (max-width: 1020px) {
  .sh-cols2 { grid-template-columns: 1fr; }
  .sh-armarow { grid-template-columns: 1fr 1fr 1fr; }
}

/* ---------------- Bestiário ---------------- */
.monster-list { list-style: none; margin-top: 6px; }
.monster-list li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 8px; margin-bottom: 3px;
  background: rgba(110,31,42,.3); border-radius: 3px; font-size: .88rem;
}
.monster-list .mname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.monster-list .monster-empty { background: none; font-style: italic; opacity: .55; }
#inp-monster-name { margin-bottom: 6px; padding: 7px 9px; font-size: .88rem; background: rgba(232,217,176,.9); }

.monster-overlay {
  position: absolute; inset: 0; z-index: 6;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 45%, rgba(20,8,4,.55), rgba(5,2,1,.9));
  animation: fadeZoom .5s ease both;
}
.monster-frame {
  position: relative;
  max-width: min(560px, 86%);
  text-align: center;
  animation: monsterIn .7s cubic-bezier(.2,.9,.3,1.2) both;
}
.monster-frame img {
  max-width: 100%; max-height: 52vh;
  border: 3px solid var(--gold);
  border-radius: 6px;
  box-shadow: 0 0 60px rgba(156,47,62,.55), 0 24px 60px rgba(0,0,0,.9);
}
.monster-name {
  margin-top: 10px;
  font-family: var(--font-title); font-weight: 900; font-size: 1.5rem;
  color: var(--gold-bright);
  text-shadow: 0 0 18px rgba(156,47,62,.9), 0 2px 6px #000;
  letter-spacing: .06em;
}
.monster-hide { margin-top: 10px; }
@keyframes monsterIn {
  0% { opacity: 0; transform: scale(.6) translateY(40px); filter: blur(8px); }
  60% { filter: blur(0); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* tremor de tela na revelação da criatura */
.stage.quake { animation: quake .6s ease-out; }
@keyframes quake {
  0%   { transform: translate(0, 0); }
  12%  { transform: translate(-7px, 4px); }
  24%  { transform: translate(6px, -5px); }
  36%  { transform: translate(-5px, -3px); }
  48%  { transform: translate(4px, 4px); }
  60%  { transform: translate(-3px, 2px); }
  72%  { transform: translate(2px, -2px); }
  86%  { transform: translate(-1px, 1px); }
  100% { transform: translate(0, 0); }
}
