/* Lasers & Feelings toolset */
:root {
  --bg: #0a0e1a;
  --bg2: #111731;
  --panel: #171e3d;
  --panel2: #1e2750;
  --line: #2b356b;
  --text: #e8ecff;
  --muted: #8f9ace;
  --lasers: #4dc3ff;
  --lasers-dim: #1a5f8a;
  --feelings: #ff5c8a;
  --feelings-dim: #8a2447;
  --ok: #57e389;
  --warn: #ffca4d;
  --danger: #ff6b5c;
  --radius: 12px;
  --shadow: 0 4px 18px rgba(0,0,0,.45);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(ellipse at 20% -10%, #1a2452 0%, var(--bg) 55%) fixed, var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}
a { color: var(--lasers); }
h1,h2,h3,h4 { line-height: 1.2; margin: 0 0 .5em; }
p { margin: .4em 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }

/* --- logo / landing --- */
.logo { font-weight: 800; letter-spacing: .12em; font-size: 1.05rem; white-space: nowrap; }
.logo .lz { color: var(--lasers); }
.logo .fl { color: var(--feelings); }
.logo .amp { color: var(--muted); }
body.landing { display: flex; align-items: center; justify-content: center; }
.landing-box { text-align: center; padding: 2rem; }
.landing-box .logo { font-size: 1.6rem; margin-bottom: 1rem; }

/* --- app shell --- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: .8rem;
  padding: .55rem .9rem;
  background: rgba(10,14,26,.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar .who { margin-left: auto; text-align: right; font-size: .8rem; color: var(--muted); }
.wrap { max-width: 1100px; margin: 0 auto; padding: 1rem .9rem 5.5rem; }
@media (min-width: 900px) { .wrap { padding-bottom: 2rem; } }

/* --- tabs --- */
nav.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  display: flex; justify-content: space-around;
  background: rgba(13,18,36,.97);
  border-top: 1px solid var(--line);
  padding: .3rem 0 calc(.3rem + env(safe-area-inset-bottom));
}
nav.tabs button {
  background: none; border: 0; color: var(--muted);
  font-size: .72rem; font-weight: 600; letter-spacing: .02em;
  padding: .35rem .6rem; cursor: pointer; border-radius: 8px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
nav.tabs button svg { width: 20px; height: 20px; }
nav.tabs button.active { color: var(--lasers); }
@media (min-width: 900px) {
  nav.tabs {
    position: sticky; top: 47px; bottom: auto;
    justify-content: flex-start; gap: .3rem;
    border-top: 0; border-bottom: 1px solid var(--line);
    padding: .35rem .9rem;
  }
  nav.tabs button { flex-direction: row; gap: 6px; font-size: .85rem; padding: .4rem .8rem; }
  nav.tabs button.active { background: var(--panel2); }
}
.tabpane { display: none; }
.tabpane.active { display: block; }

/* --- cards & grids --- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.card h3 { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; font-size: 1.02rem; }
.card h3 .spacer { margin-left: auto; }
.grid2 { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 900px) { .grid2 { grid-template-columns: 1fr 1fr; } .grid2 .card { margin-bottom: 0; } }
.row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.grow { flex: 1 1 auto; }

/* --- forms --- */
input[type=text], input[type=number], textarea, select {
  width: 100%;
  background: var(--bg2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .55rem .7rem;
  font: inherit;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--lasers-dim); border-color: var(--lasers); }
textarea { min-height: 90px; resize: vertical; }
label.f { display: block; margin: .6rem 0 .2rem; font-size: .82rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.field-error { color: var(--danger); font-size: .85rem; margin-top: .3rem; }

button.btn {
  font: inherit; font-weight: 700;
  border: 1px solid var(--line);
  background: var(--panel2); color: var(--text);
  border-radius: 9px; padding: .5rem .95rem;
  cursor: pointer;
  transition: filter .12s;
}
button.btn:hover { filter: brightness(1.18); }
button.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: linear-gradient(135deg, #1d6fa8, #164a86); border-color: #2b86c9; }
.btn.pink { background: linear-gradient(135deg, #a83a5e, #7c2447); border-color: #c94d77; }
.btn.danger { background: #58231f; border-color: #8a3b34; }
.btn.ghost { background: transparent; }
.btn.sm { padding: .25rem .6rem; font-size: .8rem; border-radius: 7px; }

.pill {
  display: inline-block; padding: .1rem .55rem;
  border-radius: 99px; font-size: .72rem; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase;
  border: 1px solid var(--line); color: var(--muted); background: var(--bg2);
}
.pill.lasers { color: var(--lasers); border-color: var(--lasers-dim); }
.pill.feelings { color: var(--feelings); border-color: var(--feelings-dim); }
.pill.ok { color: var(--ok); border-color: #2c6e46; }
.pill.warn { color: var(--warn); border-color: #7a5f1e; }

/* choice chips (style/role/goal pickers) */
.chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.chips .chip {
  font: inherit; font-size: .9rem;
  background: var(--bg2); color: var(--text);
  border: 1px solid var(--line); border-radius: 99px;
  padding: .35rem .85rem; cursor: pointer;
}
.chips .chip.sel { border-color: var(--lasers); background: var(--lasers-dim); font-weight: 700; }
.chips.pinksel .chip.sel { border-color: var(--feelings); background: var(--feelings-dim); }

/* --- number slider --- */
.numpick { display: flex; gap: .45rem; }
.numpick button {
  flex: 1; font: inherit; font-size: 1.2rem; font-weight: 800;
  padding: .6rem 0; border-radius: 10px; cursor: pointer;
  background: var(--bg2); color: var(--text); border: 1px solid var(--line);
}
.numpick button.sel { border-color: var(--lasers); background: var(--lasers-dim); }
.numscale { display: flex; justify-content: space-between; font-size: .75rem; margin-top: .25rem; }
.numscale .l { color: var(--feelings); font-weight: 700; }
.numscale .r { color: var(--lasers); font-weight: 700; }

/* --- dice --- */
.dicebar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.die {
  width: 44px; height: 44px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.25rem; font-weight: 800;
  background: var(--bg2); border: 2px solid var(--line); color: var(--text);
}
.die.hit { border-color: var(--ok); color: var(--ok); }
.die.miss { opacity: .55; }
.die.lf { border-color: var(--warn); color: var(--warn); box-shadow: 0 0 12px rgba(255,202,77,.5); animation: lfpulse 1.2s ease-in-out infinite alternate; }
@keyframes lfpulse { from { box-shadow: 0 0 6px rgba(255,202,77,.3);} to { box-shadow: 0 0 16px rgba(255,202,77,.75);} }
.die.rolling { animation: shake .45s ease-in-out; }
@keyframes shake {
  0% { transform: rotate(0) translateY(0); }
  25% { transform: rotate(-14deg) translateY(-5px); }
  55% { transform: rotate(11deg) translateY(-2px); }
  100% { transform: rotate(0) translateY(0); }
}
.mode-toggle { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.mode-toggle button {
  font: inherit; font-weight: 800; letter-spacing: .05em;
  padding: .5rem 1rem; border: 0; cursor: pointer;
  background: var(--bg2); color: var(--muted); flex: 1;
}
.mode-toggle button.lasers.sel { background: var(--lasers-dim); color: var(--lasers); }
.mode-toggle button.feelings.sel { background: var(--feelings-dim); color: var(--feelings); }
.checkline { display: flex; align-items: center; gap: .45rem; font-size: .92rem; padding: .2rem 0; cursor: pointer; }
.checkline input { width: 18px; height: 18px; accent-color: var(--lasers); }

/* --- roll feed --- */
.feed { display: flex; flex-direction: column; gap: .55rem; max-height: 430px; overflow-y: auto; }
.rollitem {
  background: var(--bg2); border: 1px solid var(--line);
  border-radius: 10px; padding: .5rem .7rem;
}
.rollitem .top { display: flex; gap: .5rem; align-items: baseline; flex-wrap: wrap; }
.rollitem .name { font-weight: 800; }
.rollitem .time { margin-left: auto; color: var(--muted); font-size: .75rem; }
.rollitem .dice { display: flex; gap: .3rem; margin: .35rem 0 .15rem; flex-wrap: wrap; }
.rollitem .die { width: 30px; height: 30px; font-size: .95rem; border-radius: 7px; }
.rollitem .outcome { font-size: .85rem; }
.rollitem .outcome.o0 { color: var(--danger); }
.rollitem .outcome.o1 { color: var(--warn); }
.rollitem .outcome.o2 { color: var(--ok); }
.rollitem .outcome.o3 { color: var(--ok); font-weight: 800; }
.rollitem .lfnote { color: var(--warn); font-weight: 700; font-size: .85rem; }
.rollitem.flash { animation: flashin .9s ease-out; }
@keyframes flashin { from { background: #2a3a72; } to { background: var(--bg2); } }

/* --- viewscreen / art --- */
.viewscreen {
  background: #000; border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  min-height: 160px; display: flex; align-items: center; justify-content: center;
  position: relative;
}
.viewscreen img { width: 100%; height: auto; display: block; }
.viewscreen .cap {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: linear-gradient(transparent, rgba(0,0,0,.85));
  padding: 1.4rem .8rem .5rem; font-size: .9rem;
}
.viewscreen .empty { color: var(--muted); padding: 2rem; text-align: center; font-size: .9rem; }
.artgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .7rem; }
.artcard { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.artcard.live { border-color: var(--ok); box-shadow: 0 0 10px rgba(87,227,137,.35); }
.artcard img { width: 100%; height: 100px; object-fit: cover; display: block; cursor: pointer; }
.artcard .meta { padding: .4rem .5rem; font-size: .78rem; }
.artcard .meta .row { gap: .3rem; }

/* --- stubs --- */
.stub {
  background: var(--bg2); border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: 10px; padding: .6rem .75rem; margin-bottom: .55rem;
}
.stub.k-npc { border-left-color: #b085f5; }
.stub.k-location { border-left-color: #57e389; }
.stub.k-plot { border-left-color: var(--warn); }
.stub.k-enemy { border-left-color: var(--danger); }
.stub.k-item { border-left-color: var(--lasers); }
.stub.k-scene { border-left-color: var(--feelings); }
.stub .head { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; cursor: pointer; }
.stub .head .t { font-weight: 800; }
.stub .body { white-space: pre-wrap; font-size: .92rem; margin-top: .4rem; color: #cdd5f7; }
.stub.revealed-badge { }
.kindpill { font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

/* --- character sheet --- */
.sheet .bigname { font-size: 1.4rem; font-weight: 800; }
.statnum {
  display: flex; align-items: center; justify-content: center;
  width: 64px; height: 64px; border-radius: 50%;
  font-size: 1.8rem; font-weight: 800;
  border: 3px solid var(--lasers); color: var(--lasers);
  background: var(--bg2); flex: 0 0 auto;
}
.lf-scale { display: flex; align-items: center; gap: .5rem; font-size: .78rem; font-weight: 700; }
.lf-scale .bar { flex: 1; height: 6px; border-radius: 4px; background: linear-gradient(90deg, var(--feelings), var(--lasers)); position: relative; }
.lf-scale .bar .dot { position: absolute; top: -5px; width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 3px solid var(--bg); transform: translateX(-50%); }

/* --- party table (dm) --- */
.partycard { display: flex; gap: .8rem; align-items: flex-start; }
.partycard .statnum { width: 52px; height: 52px; font-size: 1.4rem; }

/* --- modal --- */
.modal-back {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(4,6,14,.75); backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 2rem .8rem; overflow-y: auto;
}
.modal {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  width: 100%; max-width: 620px; padding: 1.1rem;
}

/* --- rules page --- */
.rules { max-width: 800px; margin: 0 auto; }
.rules h2 { color: var(--lasers); margin-top: 1.6rem; letter-spacing: .04em; }
.rules h2.f { color: var(--feelings); }
.rules .outcome-table { width: 100%; border-collapse: collapse; margin: .6rem 0; }
.rules .outcome-table td { border: 1px solid var(--line); padding: .5rem .6rem; vertical-align: top; }
.rules .outcome-table td:first-child { font-weight: 800; text-align: center; width: 2.6rem; font-size: 1.1rem; }
.rules table.adv { width: 100%; border-collapse: collapse; margin: .5rem 0 1rem; }
.rules table.adv td, .rules table.adv th { border: 1px solid var(--line); padding: .35rem .55rem; font-size: .92rem; }
.rules table.adv th { background: var(--panel2); text-align: left; }
.attrib { font-size: .8rem; color: var(--muted); border-top: 1px solid var(--line); margin-top: 2rem; padding-top: .8rem; }

.toast {
  position: fixed; left: 50%; bottom: 74px; transform: translateX(-50%);
  z-index: 200; background: var(--panel2); border: 1px solid var(--line);
  color: var(--text); border-radius: 10px; padding: .6rem 1rem;
  box-shadow: var(--shadow); font-weight: 600; max-width: 90vw;
}
.toast.err { border-color: var(--danger); color: var(--danger); }
@media (min-width: 900px) { .toast { bottom: 24px; } }

.copybox { display: flex; gap: .4rem; align-items: center; }
.copybox input { font-size: .78rem; color: var(--muted); }
.linklist .plabel { font-weight: 800; }
details.helpbox { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: .6rem .8rem; margin: .6rem 0; }
details.helpbox summary { cursor: pointer; font-weight: 700; color: var(--muted); }
.emptyhint { color: var(--muted); font-size: .9rem; padding: .6rem 0; }
