/* ==========================================================================
   Sistema de Dado — No More Pigs  ·  DESIGN SYSTEM
   Tema JoJo: dark editorial-menacing. Tipografia carrega a personalidade;
   a ousadia é gasta no momento de power-up. Motion orquestrado e discreto.
   ========================================================================== */

/* ---- Tokens ------------------------------------------------------------- */
:root {
  --bg:        #0d0a15;
  --bg-2:      #120e1c;
  --panel:     #1a1426;
  --panel-2:   #221933;
  --panel-3:   #2b2040;
  --line:      rgba(160, 107, 255, 0.16);
  --line-2:    rgba(160, 107, 255, 0.30);

  --text:      #efe9f7;
  --muted:     #a89dc2;
  --faint:     #8f85ac;          /* subido de #6f6690 p/ passar contraste AA */

  --purple:    #a06bff;
  --purple-d:  #7c3aed;
  --magenta:   #ff5da2;
  --gold:      #ffcf4d;
  --cyan:      #4dd6ff;
  --green:     #57e6a1;
  --orange:    #ff8c42;
  --red:       #ff5470;

  --vit:       #ff5470;   /* vitalidade (corpo) */
  --res:       #a06bff;   /* resolução (espírito) */
  --stamina:   #ffcf4d;   /* estamina (hamon) */

  /* cor semântica — SEPARADA do accent (bom / aviso / crítico) */
  --sev-ok:    #57e6a1;
  --sev-warn:  #ffcf4d;
  --sev-crit:  #ff5470;

  --r-lg: 18px;
  --r:    13px;
  --r-sm: 9px;
  --pill: 999px;

  /* escala de elevação */
  --ink: #07050d;
  --e1: 0 1px 0 rgba(255,255,255,.03), 0 3px 10px -6px var(--ink);
  --e2: 0 12px 30px -16px var(--ink);
  --e3: 0 26px 64px -28px var(--ink), 0 0 0 1px var(--line-2);
  --glow: 0 0 0 1px var(--line-2), 0 12px 34px -14px rgba(160,107,255,0.5);

  /* motion */
  --ease-standard: cubic-bezier(.2,.8,.2,1);
  --ease-out:      cubic-bezier(.22,.61,.36,1);
  --ease-spring:   cubic-bezier(.34,1.56,.64,1);
  --ease-emph:     cubic-bezier(.7,0,.2,1);
  --dur-1: 120ms; --dur-2: 200ms; --dur-3: 320ms; --dur-4: 560ms;
  --stagger: 45ms;

  /* tipografia (system-ui) */
  --sans:    system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: var(--sans);
  --num:     var(--sans);
  --mono:    "SFMono-Regular", ui-monospace, "JetBrains Mono", "Fira Code", Consolas, monospace;

  --header-h: 62px;
  --maxw: 1180px;
}

/* ---- Reset -------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body::before {
  /* aura de fundo */
  content: "";
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(900px 500px at 12% -8%, rgba(124,58,237,0.22), transparent 60%),
    radial-gradient(800px 500px at 100% 0%, rgba(255,93,162,0.13), transparent 55%),
    radial-gradient(700px 600px at 50% 120%, rgba(77,214,255,0.07), transparent 60%),
    var(--bg);
}
body::after {
  /* halftone de mangá, sutil */
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: 0.55;
  background-image: radial-gradient(rgba(160,107,255,0.09) 1.1px, transparent 1.4px);
  background-size: 20px 20px;
  -webkit-mask-image: radial-gradient(circle at 50% 0%, #000 0%, transparent 75%);
  mask-image: radial-gradient(circle at 50% 0%, #000 0%, transparent 75%);
}

img { max-width: 100%; display: block; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--panel-3); border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--purple-d); background-clip: content-box; }

/* ---- Tipografia --------------------------------------------------------- */
h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.15; font-weight: 800; text-wrap: balance; }
h1 { font-size: clamp(1.5rem, 3.5vw, 2.1rem); letter-spacing: .5px; }
h2 { font-size: 1.3rem; letter-spacing: .3px; }
h3 { font-size: 1.05rem; }
.section-title {
  text-transform: uppercase; letter-spacing: 2px; font-size: .8rem;
  color: var(--muted); font-weight: 800; margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px;
}
/* numéricos alinhados → tabular */
.m-num, .stepper .val, .table td.num, .table th.num, .badge, .tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono { font-family: var(--mono); }
.gradient-text {
  background: linear-gradient(100deg, var(--purple) 0%, var(--magenta) 55%, var(--gold) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ---- Boot / loading ----------------------------------------------------- */
.boot { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 14px; }
.boot-mark { font-size: 1.6rem; }
.boot-text { color: var(--muted); letter-spacing: 3px; text-transform: uppercase; font-size: .74rem; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--line-2); border-top-color: var(--purple); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg) } }

/* skeleton shimmer */
.skeleton { position: relative; overflow: hidden; background: var(--panel-2); border-radius: var(--r); border: 1px solid var(--line); }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(160,107,255,.10), transparent);
  animation: shimmer 1.25s var(--ease-standard) infinite; }
@keyframes shimmer { to { transform: translateX(100%) } }
.sk-line { height: 12px; border-radius: 99px; }
.sk-circle { border-radius: 50%; }

/* ---- App shell ---------------------------------------------------------- */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.app-header {
  position: sticky; top: 0; z-index: 40; height: var(--header-h);
  display: flex; align-items: center; gap: 18px;
  padding: 0 clamp(14px, 3vw, 28px);
  background: rgba(13,10,21,0.80); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  transition: border-color var(--dur-2) var(--ease-out), box-shadow var(--dur-2) var(--ease-out);
}
.app-header.scrolled { border-bottom-color: var(--line-2); box-shadow: 0 10px 28px -18px var(--ink); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 900; letter-spacing: .5px; white-space: nowrap; }
.brand .brand-name { font-size: 1.05rem; }
.brand .brand-sub { font-size: .58rem; letter-spacing: 2.5px; text-transform: uppercase; color: var(--faint); display: block; margin-top: -2px; }

.app-nav { display: flex; align-items: center; gap: 4px; margin-left: 6px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.app-nav::-webkit-scrollbar { display: none; }
.nav-link {
  color: var(--muted); padding: 8px 13px; border-radius: var(--pill); font-weight: 700; font-size: .9rem;
  white-space: nowrap; border: 1px solid transparent; text-decoration: none; display: inline-flex; gap: 6px; align-items: center; position: relative;
  transition: color var(--dur-1), background-color var(--dur-2) var(--ease-out), border-color var(--dur-2), transform var(--dur-1);
}
.nav-link:hover { color: var(--text); background: var(--panel); text-decoration: none; }
.nav-link:active { transform: scale(.96); }
.nav-link.active { color: var(--text); background: var(--panel); border-color: var(--line-2); }
.nav-link.active::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: 4px; height: 2px; background: var(--gold); transform: skewX(-16deg); }

.header-right { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.session-badge {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: var(--pill);
  background: var(--panel); border: 1px solid var(--line); font-size: .8rem; font-weight: 700; white-space: nowrap;
}
.session-badge b { color: var(--gold); font-family: var(--num); }
.user-menu { position: relative; }
.user-chip { display: flex; align-items: center; gap: 9px; cursor: pointer; padding: 5px 6px 5px 5px; border-radius: var(--pill); border: 1px solid var(--line); background: var(--panel);
  transition: border-color var(--dur-2), transform var(--dur-1); }
.user-chip:hover { border-color: var(--line-2); }
.user-chip:active { transform: scale(.97); }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-content: center; font-weight: 800; font-size: .85rem; color: #17101f; flex: none; font-family: var(--sans); }
.user-chip .u-name { font-size: .85rem; font-weight: 700; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dropdown {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 190px;
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: var(--r); box-shadow: var(--e3);
  padding: 6px; z-index: 50; animation: pop var(--dur-2) var(--ease-spring);
  transform-origin: top right;
}
.dropdown button { display: flex; width: 100%; text-align: left; gap: 8px; align-items: center; padding: 9px 11px; background: none; border: none; border-radius: var(--r-sm); cursor: pointer; color: var(--text); font-weight: 600; transition: background-color var(--dur-1); }
.dropdown button:hover { background: var(--panel-3); }
.dropdown .dd-sep { height: 1px; background: var(--line); margin: 5px 2px; }

.app-main { flex: 1; width: 100%; max-width: var(--maxw); margin: 0 auto; padding: clamp(16px, 3vw, 30px); }

/* entrada de view: no CONTAINER (persiste entre re-renders internos da ficha,
   então não replaya a cada allocate). Stagger fica só em grids opt-in .stagger. */
.view { animation: viewIn var(--dur-3) var(--ease-out) both; }
@keyframes viewIn { from { opacity: 0 } to { opacity: 1 } }
.stagger > * { animation: cardIn var(--dur-3) var(--ease-out) both; animation-delay: min(calc(var(--i,0) * var(--stagger)), 400ms); }
@keyframes cardIn { from { opacity: 0; transform: translateY(14px) scale(.98) } to { opacity: 1; transform: none } }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head .ph-title { display: flex; flex-direction: column; gap: 2px; }

/* ---- Cards / panels ----------------------------------------------------- */
.card {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 18px; box-shadow: var(--e2); position: relative;
  transition: transform var(--dur-2) var(--ease-standard), border-color var(--dur-2);
}
.card.pad-lg { padding: 24px; }
.card.glow { box-shadow: var(--glow); border-color: var(--line-2); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-h h3 { margin: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; box-shadow: var(--e1); }
.panel-2 { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; position: relative; }

.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.cols-auto { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.nowrap { flex-wrap: nowrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.between { justify-content: space-between; }
.right { margin-left: auto; }
.center { text-align: center; }
.gap-sm { gap: 8px; }
.wrap { flex-wrap: wrap; }
.hidden { display: none !important; }
.grow { flex: 1; min-width: 0; }

/* ---- Buttons ------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: var(--pill); border: 1px solid var(--line-2);
  background: var(--panel-2); color: var(--text); font-weight: 700; cursor: pointer;
  white-space: nowrap; user-select: none; font-size: .92rem; position: relative; overflow: hidden;
  transition: transform var(--dur-1) var(--ease-out), border-color var(--dur-1), box-shadow var(--dur-2), background-color var(--dur-2);
}
.btn:hover { border-color: var(--purple); transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.97); transition-duration: 60ms; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { background: linear-gradient(120deg, var(--purple-d), var(--purple)); border-color: transparent; color: #fff; box-shadow: 0 8px 20px -8px rgba(124,58,237,.8); }
.btn-primary:hover { border-color: transparent; box-shadow: 0 12px 28px -8px rgba(124,58,237,1); }
/* sheen diagonal SÓ no CTA herói */
.btn-primary::after { content: ""; position: absolute; inset: 0; transform: translateX(-130%) skewX(-20deg);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.22), transparent); pointer-events: none; }
.btn-primary:hover::after { transform: translateX(130%) skewX(-20deg); transition: transform .55s var(--ease-out); }
.btn-gold { background: linear-gradient(120deg, #e0a92e, var(--gold)); border-color: transparent; color: #2a1c00; }
.btn-magenta { background: linear-gradient(120deg, #d63c85, var(--magenta)); border-color: transparent; color: #fff; }
.btn-danger { background: linear-gradient(120deg, #b83252, var(--red)); border-color: transparent; color: #fff; }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost:hover { background: var(--panel); }
.btn-sm { padding: 6px 12px; font-size: .82rem; }
.btn-xs { padding: 4px 9px; font-size: .76rem; }
.btn-icon { padding: 8px; width: 38px; height: 38px; border-radius: 50%; }
.btn-block { width: 100%; }
.btn-group { display: inline-flex; gap: 0; border-radius: var(--pill); overflow: hidden; border: 1px solid var(--line-2); }
.btn-group .btn { border-radius: 0; border: none; border-right: 1px solid var(--line); }
.btn-group .btn:last-child { border-right: none; }

/* ripple */
.ripple { position: absolute; border-radius: 50%; transform: scale(0); background: rgba(255,255,255,.28); pointer-events: none; animation: ripple .55s var(--ease-out) forwards; }
@keyframes ripple { to { transform: scale(1); opacity: 0 } }

/* Stepper +/- para pontos */
.stepper { display: inline-flex; align-items: center; gap: 0; border: 1px solid var(--line-2); border-radius: var(--pill); overflow: hidden; }
.stepper button { width: 34px; height: 34px; border: none; background: var(--panel-2); color: var(--text); font-size: 1.15rem; font-weight: 800; cursor: pointer; display: grid; place-content: center; transition: background-color var(--dur-1), transform 80ms; }
.stepper button:hover:not(:disabled) { background: var(--purple-d); }
.stepper button:active:not(:disabled) { transform: scale(.86); background: var(--purple-d); }
.stepper button:disabled { opacity: .3; cursor: not-allowed; }
.stepper .val { min-width: 40px; text-align: center; font-weight: 700; }

@keyframes valuePop { 0% { transform: scale(1) } 35% { transform: scale(1.24); color: var(--gold) } 100% { transform: scale(1) } }
.pop { animation: valuePop var(--dur-2) var(--ease-spring); }

/* ---- Forms -------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: .78rem; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 700; }
.input, .textarea, .select {
  width: 100%; padding: 11px 13px; border-radius: var(--r-sm);
  background: var(--bg-2); border: 1px solid var(--line-2); color: var(--text); outline: none;
  transition: border-color var(--dur-2), box-shadow var(--dur-2);
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(160,107,255,.18); }
.textarea { resize: vertical; min-height: 90px; font-family: inherit; line-height: 1.5; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23a89dc2' d='M6 8 0 0h12z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 34px; cursor: pointer; }
.input-inline { width: auto; padding: 6px 10px; }

/* ---- Badges / chips ----------------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: var(--pill); font-size: .74rem; font-weight: 800; letter-spacing: .3px; background: var(--panel-3); border: 1px solid var(--line); text-transform: uppercase; }
.badge.role-master { background: linear-gradient(120deg, rgba(255,207,77,.22), rgba(255,140,66,.16)); border-color: rgba(255,207,77,.4); color: var(--gold); }
.badge.role-player { background: var(--panel-3); border-color: var(--line-2); color: var(--purple); }
/* severidade semântica (separada do accent) */
.badge.sev-ok,  .badge.b-green { color: var(--sev-ok);   border-color: rgba(87,230,161,.35);  background: rgba(87,230,161,.12); }
.badge.sev-warn,.badge.b-gold  { color: var(--sev-warn); border-color: rgba(255,207,77,.35);  background: rgba(255,207,77,.12); }
.badge.sev-crit,.badge.b-red   { color: var(--sev-crit); border-color: rgba(255,84,112,.35);  background: rgba(255,84,112,.12); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: var(--pill); background: var(--panel-2); border: 1px solid var(--line); font-size: .82rem; font-weight: 600; }
.chip .x { cursor: pointer; opacity: .6; font-weight: 900; position: relative; }
.chip .x::after { content: ""; position: absolute; inset: -10px; }
.chip .x:hover { opacity: 1; color: var(--red); }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }

/* ---- Stat tiles (atributos) -------------------------------------------- */
.stat-tile {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r);
  padding: 12px; display: flex; flex-direction: column; gap: 6px; position: relative; overflow: hidden;
  transition: border-color var(--dur-2), transform var(--dur-2) var(--ease-standard);
}
.stat-tile .st-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stat-tile .st-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); font-weight: 800; font-family: var(--sans); display: inline-flex; align-items: center; }
.stat-tile .st-value { font-size: 1.9rem; font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; }
.stat-tile .st-tier { font-size: .68rem; color: var(--faint); font-weight: 700; }
.stat-bar { height: 6px; border-radius: 99px; background: var(--bg-2); overflow: hidden; }
.stat-bar > i { display: block; height: 100%; border-radius: 99px; background: var(--purple); transition: width var(--dur-4) var(--ease-standard); }
.stat-tile.derived .st-value { color: var(--cyan); }

/* ---- Meters (VIT/RES/Estamina) ------------------------------------------ */
.meter { display: flex; flex-direction: column; gap: 5px; }
.meter-head { display: flex; align-items: center; justify-content: space-between; font-size: .82rem; font-weight: 700; }
.meter-head .m-num { font-weight: 700; }
.meter-track { height: 14px; border-radius: 99px; background: var(--bg-2); border: 1px solid var(--line); overflow: hidden; position: relative; }
.meter-fill { height: 100%; border-radius: 99px; transition: width var(--dur-4) var(--ease-standard); }
.meter-fill.vit { background: linear-gradient(90deg, #b83252, var(--vit)); }
.meter-fill.res { background: linear-gradient(90deg, var(--purple-d), var(--res)); }
.meter-fill.stamina { background: linear-gradient(90deg, #e0a92e, var(--stamina)); }
/* severidade codificada na FORMA (borda), não só no número */
.meter-track[data-sev="warn"] { box-shadow: inset 0 0 0 1px rgba(255,207,77,.35); }
.meter-track[data-sev="crit"] { box-shadow: inset 0 0 0 1px rgba(255,84,112,.5); }
.meter-track[data-sev="crit"]::after { content: ""; position: absolute; inset: -1px; border-radius: inherit;
  box-shadow: inset 0 0 0 2px var(--sev-crit); opacity: .35; animation: sevBlink 1.4s ease-in-out infinite; pointer-events: none; }
@keyframes sevBlink { 50% { opacity: 1 } }
.meter-track.hit  { animation: hitFlash .45s var(--ease-out); }
.meter-track.heal { animation: healFlash .45s var(--ease-out); }
@keyframes hitFlash  { 0% { box-shadow: inset 0 0 0 2px rgba(255,84,112,.9) } 100% { box-shadow: inset 0 0 0 2px transparent } }
@keyframes healFlash { 0% { box-shadow: inset 0 0 0 2px rgba(87,230,161,.9) } 100% { box-shadow: inset 0 0 0 2px transparent } }

/* ---- Tables ------------------------------------------------------------- */
.table-wrap { overflow-x: auto; border-radius: var(--r); border: 1px solid var(--line); }
table.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { padding: 10px 13px; text-align: left; border-bottom: 1px solid var(--line); }
.table th { background: var(--panel-2); font-size: .74rem; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 800; position: sticky; top: 0; font-family: var(--sans); }
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background-color var(--dur-1); }
.table tbody tr:hover { background: rgba(160,107,255,.06); }
.table td.num, .table th.num { text-align: right; }

/* ---- Modal -------------------------------------------------------------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(6,4,12,.72); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); z-index: 100; display: grid; place-items: center; padding: 18px; animation: fade var(--dur-2) var(--ease-out); }
.modal {
  width: min(560px, 100%); max-height: 88vh; overflow: auto;
  background: linear-gradient(180deg, var(--panel-2), var(--panel)); border: 1px solid var(--line-2);
  border-radius: var(--r-lg); box-shadow: var(--e3); animation: modalPop var(--dur-3) var(--ease-spring);
}
.modal.wide { width: min(880px, 100%); }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes modalPop { 0% { transform: scale(.94) translateY(10px); opacity: 0 } 60% { transform: scale(1.008); opacity: 1 } 100% { transform: scale(1) } }
@keyframes pop { from { transform: scale(.96) translateY(8px); opacity: 0 } to { transform: none; opacity: 1 } }
.modal-backdrop.closing { animation: fadeOut var(--dur-1) var(--ease-out) forwards; }
.modal-backdrop.closing .modal { animation: popOut var(--dur-1) var(--ease-out) forwards; }
@keyframes fadeOut { to { opacity: 0 } }
@keyframes popOut { to { transform: scale(.96) translateY(6px); opacity: 0 } }
.modal-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel-2); z-index: 1; }
.modal-h h3 { margin: 0; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.modal-close { background: none; border: none; color: var(--muted); font-size: 1.5rem; cursor: pointer; line-height: 1; padding: 2px 6px; border-radius: 8px; position: relative; transition: color var(--dur-1), background-color var(--dur-1); }
.modal-close::after { content: ""; position: absolute; inset: -10px; }
.modal-close:hover { color: var(--text); background: var(--panel-3); }

/* ---- Toasts ------------------------------------------------------------- */
.toast-wrap { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 10px; align-items: center; pointer-events: none; width: min(420px, calc(100% - 24px)); }
.toast {
  pointer-events: auto; width: 100%; padding: 12px 16px; border-radius: var(--r); background: var(--panel-2);
  border: 1px solid var(--line-2); box-shadow: var(--e3); display: flex; gap: 10px; align-items: center;
  font-weight: 600; animation: toastIn var(--dur-3) var(--ease-spring); border-left: 4px solid var(--purple); position: relative; overflow: hidden;
}
.toast.info { border-left-color: var(--cyan); }
.toast.success { border-left-color: var(--sev-ok); }
.toast.error { border-left-color: var(--sev-crit); }
.toast.warn { border-left-color: var(--sev-warn); }
.toast::after { content: ""; position: absolute; left: 0; bottom: 0; height: 2px; width: 100%; background: currentColor; opacity: .35; transform-origin: left; animation: toastTimer linear forwards; animation-duration: var(--tms, 3200ms); }
@keyframes toastTimer { to { transform: scaleX(0) } }
@keyframes toastIn { from { transform: translateY(16px); opacity: 0 } to { transform: none; opacity: 1 } }
.toast.out { animation: toastOut var(--dur-2) var(--ease-out) forwards; }
@keyframes toastOut { to { transform: translateY(16px); opacity: 0 } }

/* ---- Tabs --------------------------------------------------------------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { padding: 10px 15px; background: none; border: none; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 700; cursor: pointer; white-space: nowrap; position: relative; transition: color var(--dur-1); }
.tab:hover { color: var(--text); }
.tab::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, var(--purple), var(--magenta)); transform: scaleX(0); transform-origin: center;
  transition: transform var(--dur-3) var(--ease-standard), opacity var(--dur-2); opacity: 0; }
.tab:hover::after { transform: scaleX(.4); opacity: .5; }
.tab.active { color: var(--text); }
.tab.active::after { transform: scaleX(1); opacity: 1; }

/* ---- Empty state -------------------------------------------------------- */
.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty .e-mark { color: var(--faint); margin-bottom: 12px; opacity: .8; display: inline-flex; }

/* ---- Login -------------------------------------------------------------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: min(420px, 100%); animation: modalPop var(--dur-4) var(--ease-spring); }
.auth-logo { text-align: center; margin-bottom: 24px; }

/* ---- Character card (dashboard) ---------------------------------------- */
.char-card { cursor: pointer; overflow: hidden; position: relative; isolation: isolate;
  transition: transform var(--dur-2) var(--ease-standard), border-color var(--dur-2), box-shadow var(--dur-2); }
.char-card::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; z-index: 2;
  background: radial-gradient(220px circle at var(--mx,50%) var(--my,0%), rgba(160,107,255,.14), transparent 60%);
  transition: opacity var(--dur-2); }
.char-card:hover { transform: translateY(-4px); border-color: var(--line-2); }
.char-card:hover::after { opacity: 1; }
.char-card:active { transform: translateY(-1px) scale(.995); }
/* canto dobrado de mangá (atrás do conteúdo) */
.char-card .cc-band { position: absolute; top: 0; right: 0; width: 42px; height: 42px; margin: 0; z-index: 0;
  clip-path: polygon(100% 0, 0 0, 100% 100%); background: var(--cc, var(--purple)); opacity: .9; box-shadow: -1px 1px 0 rgba(0,0,0,.35); }
.char-card > *:not(.cc-band) { position: relative; z-index: 1; }
.char-card .cc-name { font-size: 1.15rem; font-weight: 900; }
.char-card .cc-stand { color: var(--magenta); font-weight: 700; font-size: .88rem; }

/* ---- O momento: power-up ------------------------------------------------ */
.power-ring { position: absolute; inset: -2px; border-radius: inherit; border: 2px solid var(--gold); pointer-events: none; opacity: 0; transform: scale(.9); animation: ringBurst var(--dur-4) var(--ease-spring) forwards; }
@keyframes ringBurst { 0% { opacity: 0; transform: scale(.9) } 25% { opacity: 1 } 100% { opacity: 0; transform: scale(1.06) } }
.power-vignette { position: fixed; inset: 0; z-index: 150; pointer-events: none; background: radial-gradient(120% 80% at 50% 50%, transparent 55%, rgba(255,207,77,.18) 100%); opacity: 0; animation: vignetteFlash var(--dur-4) var(--ease-out) forwards; }
@keyframes vignetteFlash { 0%,100% { opacity: 0 } 30% { opacity: 1 } }

/* menacing ゴゴゴ — pontual (vida crítica) */
.menacing { font-family: var(--display); color: var(--gold); letter-spacing: 2px; opacity: .85; font-weight: 600; user-select: none; }

/* ---- Dado (dormente; ativa quando houver rolador) ----------------------- */
.d20-result { font-family: var(--display); font-size: 2.6rem; font-weight: 600; animation: diceSlam var(--dur-4) var(--ease-spring) both; }
@keyframes diceSlam { 0% { transform: scale(.4) rotate(-8deg); opacity: 0 } 55% { transform: scale(1.16) rotate(2deg); opacity: 1 } 100% { transform: none } }
.crit-hit { color: var(--gold); text-shadow: 0 0 18px rgba(255,207,77,.6); position: relative; }
.crit-hit::after { content: ""; position: absolute; inset: -8px; border-radius: 50%; box-shadow: 0 0 40px 8px rgba(255,207,77,.55); opacity: 0; animation: critGlow 1.1s ease forwards; pointer-events: none; }
@keyframes critGlow { 20% { opacity: 1 } 100% { opacity: 0 } }
.crit-miss { color: var(--red); text-shadow: 0 0 18px rgba(255,84,112,.5); }

/* ---- Fotos (personagem / Stand) ---------------------------------------- */
.avatar-img { overflow: hidden; }
.avatar-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-slot { position: relative; padding: 0; border: none; background: none; cursor: pointer; border-radius: 50%; line-height: 0; }
.photo-cam { position: absolute; bottom: -2px; right: -2px; width: 22px; height: 22px; border-radius: 50%; background: var(--purple-d); color: #fff; display: grid; place-content: center; border: 2px solid var(--panel); box-shadow: var(--e1); transition: transform var(--dur-1); }
.photo-slot:hover .photo-cam { transform: scale(1.12); }
.photo-cam .ico svg { width: 12px; height: 12px; }
.stand-photo { display: block; width: 100%; max-height: 340px; object-fit: contain; border-radius: var(--r); border: 1px solid var(--line-2); background: var(--bg-2); }

/* ---- Ícones (SVG inline) ------------------------------------------------ */
.ico { display: inline-flex; align-items: center; justify-content: center; vertical-align: -0.14em; flex: none; line-height: 0; }
.ico svg { display: block; }
.ico + * { margin-left: .05em; }
.section-title .ico { font-size: 1.05em; color: var(--purple); }

/* botão de ajuda "?" ao lado de atributos */
.attr-help { display: inline-flex; align-items: center; justify-content: center; width: 17px; height: 17px; padding: 0; margin-left: 5px; border: none; background: none; color: var(--faint); cursor: pointer; border-radius: 50%; vertical-align: -0.18em; position: relative; transition: color var(--dur-1), background-color var(--dur-1); }
.attr-help::after { content: ""; position: absolute; inset: -12px; }
.attr-help:hover { color: var(--purple); background: rgba(160,107,255,.15); }
.attr-help .ico svg { width: 14px; height: 14px; }

/* ---- Foco acessível ----------------------------------------------------- */
:where(a, button, .btn, .nav-link, .tab, .chip, .stepper button, .stat-tile, .char-card, .modal-close, .attr-help, [tabindex]):focus-visible {
  outline: 2px solid #cbb2ff; outline-offset: 2px;
}
:focus:not(:focus-visible) { outline: none; }
.input:focus-visible, .textarea:focus-visible, .select:focus-visible { box-shadow: 0 0 0 3px rgba(160,107,255,.22); }

/* ---- utils -------------------------------------------------------------- */
.divider { height: 1px; background: var(--line); margin: 16px 0; border: none; }
.tabular { font-variant-numeric: tabular-nums; }
.text-sm { font-size: .85rem; }
.text-xs { font-size: .76rem; }
.b { font-weight: 800; }
.pointer { cursor: pointer; }
.scroll-x { overflow-x: auto; }
.mt-0 { margin-top: 0 } .mt-1 { margin-top: 8px } .mt-2 { margin-top: 16px } .mt-3 { margin-top: 24px }
.mb-0 { margin-bottom: 0 } .mb-1 { margin-bottom: 8px } .mb-2 { margin-bottom: 16px }
.w-full { width: 100%; }
.nowrap-text { white-space: nowrap; }

/* ---- Responsivo --------------------------------------------------------- */
@media (max-width: 860px) {
  .cols-4 { grid-template-columns: repeat(2, 1fr); }
  .cols-3 { grid-template-columns: repeat(2, 1fr); }
  .brand .brand-sub { display: none; }
}
@media (max-width: 620px) {
  :root { --header-h: 56px; }
  .cols-2 { grid-template-columns: 1fr; }
  .app-header { gap: 10px; }
  .brand .brand-name { font-size: 1.02rem; }
  .session-badge { display: none; }
  .user-chip .u-name { display: none; }
  .page-head { align-items: flex-start; }
}
@media (max-width: 420px) {
  .cols-4, .cols-3 { grid-template-columns: 1fr 1fr; }
}
/* alvos de toque maiores em touch */
@media (pointer: coarse) {
  .stepper button { width: 40px; height: 40px; }
  .btn-icon { width: 44px; height: 44px; }
  .btn-xs, .btn-sm { min-height: 40px; }
}

/* ---- Reduced motion (kill-switch global; fica por último) ---------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}
