/* Roses & Thorns — RWBY-inspired theme: ink black, rose crimson, aura teal. */
:root {
  --bg: #0d0b10;
  --bg-2: #16131c;
  --panel: #1c1826;
  --panel-2: #241f30;
  --line: #342d42;
  --line-soft: #2a2436;
  --text: #ece7f2;
  --text-dim: #a99fbb;
  --text-faint: #746a86;
  --rose: #e0284b;
  --rose-bright: #ff3b5c;
  --rose-soft: #7d1a2e;
  --thorn: #4a2b3a;
  --aura: #2fd6c6;
  --aura-dim: #1c8a80;
  --gold: #ffcf5c;
  --hp: #e0284b;
  --hp-track: #3a1a24;
  --aura-track: #143a37;
  --ok: #4ad07f;
  --warn: #ffb84d;
  --danger: #ff5c5c;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 30px rgba(0,0,0,.45);
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --serif: 'Georgia', 'Times New Roman', serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: radial-gradient(1200px 600px at 80% -10%, #241226 0%, transparent 60%),
              radial-gradient(900px 500px at -10% 20%, #10202a 0%, transparent 55%),
              var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  min-height: 100%;
}
.hidden { display: none !important; }
a { color: var(--rose-bright); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Top bar ---------- */
#topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 0 20px; height: 60px;
  background: rgba(18,15,24,.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
}
.brand { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 700; }
.brand-rose { font-size: 22px; filter: drop-shadow(0 0 6px rgba(224,40,75,.6)); }
.brand-text { font-family: var(--serif); font-size: 20px; letter-spacing: .5px; }
.brand .amp { color: var(--rose); }
#nav { display: flex; gap: 4px; margin-left: 10px; flex: 1; }
#nav a {
  color: var(--text-dim); padding: 8px 14px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; text-decoration: none;
}
#nav a:hover { background: var(--panel); color: var(--text); }
#nav a.active { background: var(--rose-soft); color: #fff; }
#user-menu { display: flex; align-items: center; gap: 10px; }
.pill-owner { background: linear-gradient(135deg, var(--gold), #d99b1e); color: #2a1a00; font-size: 10px; font-weight: 800; padding: 3px 8px; border-radius: 20px; text-transform: uppercase; letter-spacing: .5px; }

/* ---------- Layout ---------- */
#app { max-width: 1200px; margin: 0 auto; padding: 28px 20px 80px; }
.loading-screen { text-align: center; padding: 120px 0; color: var(--text-dim); }
.petal-spinner { font-size: 42px; animation: spin 2s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

h1 { font-family: var(--serif); font-size: 30px; margin-bottom: 4px; }
h2 { font-family: var(--serif); font-size: 22px; margin: 8px 0; }
h3 { font-size: 16px; margin: 4px 0; }
.subtitle { color: var(--text-dim); margin-bottom: 22px; }
.section-title { font-family: var(--serif); font-size: 20px; margin: 26px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; justify-content: space-between; }

/* ---------- Cards ---------- */
.card {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }

.campaign-card { cursor: pointer; transition: transform .12s, border-color .12s; position: relative; overflow: hidden; }
.campaign-card:hover { transform: translateY(-3px); border-color: var(--rose); }
.campaign-card .badge-row { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  padding: 9px 16px; border-radius: var(--radius-sm); cursor: pointer;
  font-size: 14px; font-weight: 600; font-family: inherit; transition: .12s;
}
.btn:hover { border-color: var(--rose); background: var(--panel); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--rose), var(--rose-soft)); border-color: var(--rose); color: #fff; }
.btn-primary:hover { background: linear-gradient(135deg, var(--rose-bright), var(--rose)); }
.btn-ghost { background: transparent; }
.btn-danger { border-color: var(--rose-soft); color: var(--danger); }
.btn-danger:hover { background: rgba(255,92,92,.12); border-color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; }
.btn-aura { background: linear-gradient(135deg, var(--aura), var(--aura-dim)); border-color: var(--aura); color: #04201d; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Forms ---------- */
label { display: block; font-size: 13px; color: var(--text-dim); margin: 12px 0 5px; font-weight: 600; }
input, select, textarea {
  width: 100%; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 12px; font-size: 14px; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--rose); box-shadow: 0 0 0 2px rgba(224,40,75,.2); }
textarea { resize: vertical; min-height: 70px; }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field-row > div { flex: 1; min-width: 140px; }
.check { display: flex; align-items: center; gap: 8px; margin: 10px 0; }
.check input { width: auto; }
.hint { font-size: 12px; color: var(--text-faint); margin-top: 4px; }
.num-inline { width: 80px; display: inline-block; }

/* ---------- Auth ---------- */
.auth-wrap { max-width: 420px; margin: 60px auto; text-align: center; }
.auth-logo { font-size: 56px; filter: drop-shadow(0 0 20px rgba(224,40,75,.5)); }
.auth-tabs { display: flex; gap: 6px; margin: 22px 0 16px; background: var(--bg); padding: 5px; border-radius: var(--radius-sm); }
.auth-tabs button { flex: 1; background: transparent; border: none; color: var(--text-dim); padding: 9px; border-radius: 6px; cursor: pointer; font-weight: 700; font-family: inherit; }
.auth-tabs button.active { background: var(--rose-soft); color: #fff; }

/* ---------- Badges / chips ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px; background: var(--panel-2); border: 1px solid var(--line); color: var(--text-dim); text-transform: uppercase; letter-spacing: .4px; }
.badge.public { color: var(--aura); border-color: var(--aura-dim); }
.badge.private { color: var(--text-faint); }
.badge.dm { color: var(--gold); border-color: #7a5a12; }
.badge.grimm { color: #c471ff; border-color: #5a2a7a; }
.badge.soul { color: var(--aura); }
.badge.robotic { color: #78b6ff; border-color: #2a4a7a; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 20px; background: var(--panel-2); border: 1px solid var(--line); font-size: 13px; cursor: pointer; user-select: none; }
.chip.selected { background: var(--rose-soft); border-color: var(--rose); color: #fff; }
.chip.ultimate { box-shadow: 0 0 0 2px var(--gold) inset; }
.chip.nefarious { box-shadow: 0 0 0 2px var(--danger) inset; }
.chip.disabled { opacity: .4; cursor: not-allowed; }
.tag-ultimate { color: var(--gold); font-weight: 800; }
.tag-nefarious { color: var(--danger); font-weight: 800; }

/* ---------- Bars (HP / Aura) ---------- */
.bar { height: 16px; border-radius: 20px; background: var(--hp-track); overflow: hidden; position: relative; border: 1px solid var(--line); }
.bar > span { display: block; height: 100%; transition: width .3s; }
.bar.hp > span { background: linear-gradient(90deg, var(--rose-soft), var(--rose)); }
.bar.aura { background: var(--aura-track); }
.bar.aura > span { background: linear-gradient(90deg, var(--aura-dim), var(--aura)); }
.bar-label { display: flex; justify-content: space-between; font-size: 12px; margin: 8px 0 3px; color: var(--text-dim); font-weight: 600; }
.bar-label .v { color: var(--text); }

/* ---------- Character sheet ---------- */
.sheet-header { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.portrait { width: 92px; height: 92px; border-radius: var(--radius); object-fit: cover; border: 2px solid var(--line); background: var(--bg); display: flex; align-items: center; justify-content: center; font-size: 40px; flex-shrink: 0; }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 10px; }
.stat-tile { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px; text-align: center; }
.stat-tile .n { font-size: 24px; font-weight: 800; font-family: var(--serif); }
.stat-tile .l { font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .5px; }
.skill-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 6px; }
.skill-row { display: flex; align-items: center; justify-content: space-between; padding: 7px 11px; background: var(--bg); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); cursor: pointer; }
.skill-row:hover { border-color: var(--rose); }
.skill-row .sk-name { font-size: 13px; }
.skill-row .sk-mod { font-weight: 800; font-family: var(--serif); font-size: 15px; min-width: 34px; text-align: right; }
.skill-row .sk-mod.pos { color: var(--aura); }
.skill-row .sk-mod.neg { color: var(--danger); }
.mini { font-size: 11px; color: var(--text-faint); }
.cat-head { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--rose-bright); margin: 16px 0 8px; font-weight: 800; }

/* ---------- Campaign layout ---------- */
.campaign-layout { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }
@media (max-width: 900px) { .campaign-layout { grid-template-columns: 1fr; } }
.side-panel { position: sticky; top: 80px; }
.log-feed { max-height: 460px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding-right: 4px; }
.log-item { font-size: 13px; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--bg); border-left: 3px solid var(--line); }
.log-item.roll { border-left-color: var(--rose); }
.log-item.system { border-left-color: var(--aura-dim); color: var(--text-dim); font-style: italic; }
.log-item .who { font-weight: 700; color: var(--rose-bright); }
.log-item .roll-total { font-family: var(--serif); font-weight: 800; font-size: 16px; }
.log-item .success { color: var(--ok); font-weight: 700; }
.log-item .failure { color: var(--danger); font-weight: 700; }
.log-time { font-size: 10px; color: var(--text-faint); }
.chat-input-row { display: flex; gap: 8px; margin-top: 10px; }

/* ---------- Combat tracker ---------- */
.combatant { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg); margin-bottom: 8px; }
.combatant.active { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 0 18px rgba(255,207,92,.25); }
.combatant.party { border-left: 3px solid var(--aura); }
.combatant.enemy { border-left: 3px solid var(--rose); }
.combatant.down { opacity: .5; }
.init-badge { font-family: var(--serif); font-weight: 800; font-size: 18px; width: 34px; text-align: center; color: var(--gold); }
.combatant .cbars { flex: 1; }
.combatant .cbars .bar { height: 11px; }
.combatant-name { font-weight: 700; font-size: 14px; }

/* ---------- Roller ---------- */
.roller-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px,1fr)); gap: 6px; }
.die-btn { font-family: var(--serif); font-weight: 700; }

/* ---------- Table ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line-soft); font-size: 14px; }
th { color: var(--text-faint); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
tr:hover td { background: var(--bg); }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(5,3,8,.72); backdrop-filter: blur(3px); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 100; overflow-y: auto; }
.modal { background: linear-gradient(180deg, var(--panel), var(--bg-2)); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); width: 100%; max-width: 560px; padding: 24px; animation: pop .15s ease; }
.modal.wide { max-width: 820px; }
@keyframes pop { from { transform: scale(.96); opacity: 0; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-close { background: none; border: none; color: var(--text-dim); font-size: 22px; cursor: pointer; line-height: 1; }

/* ---------- Toast ---------- */
#toast-root { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast { background: var(--panel-2); border: 1px solid var(--line); border-left: 4px solid var(--rose); padding: 12px 18px; border-radius: var(--radius-sm); box-shadow: var(--shadow); font-size: 14px; animation: slidein .2s ease; max-width: 340px; }
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--danger); }
@keyframes slidein { from { transform: translateX(40px); opacity: 0; } }

/* ---------- Misc ---------- */
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.center { text-align: center; }
.mt { margin-top: 16px; } .mt-sm { margin-top: 8px; } .mb { margin-bottom: 16px; }
.empty { text-align: center; color: var(--text-faint); padding: 40px 20px; }
.empty .big { font-size: 40px; margin-bottom: 8px; }
.divider { border-top: 1px solid var(--line-soft); margin: 16px 0; }
.flex { display: flex; gap: 10px; align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.pointer { cursor: pointer; }
.scroll-x { overflow-x: auto; }
code.exp { background: var(--bg); padding: 2px 6px; border-radius: 4px; font-size: 12px; color: var(--gold); }
.quote { font-style: italic; color: var(--text-dim); border-left: 3px solid var(--rose-soft); padding-left: 12px; margin: 8px 0; font-family: var(--serif); }
