:root{--bg:#fff6e8;--surface:#fff;--surface2:#ffeccf;--text:#2a2140;--muted:#6a6282;--accent:#ff8a4c;--accent-ink:#2a1200;--danger:#b3261e;--ok:#12806f;--line:#ecd9bd;--you:#6f46d1;--you-ink:#fff;--gm-rule:#12806f;--shadow:0 2px 0 rgba(42,33,64,.08);
--round:ui-rounded,"Avenir Next Rounded","Nunito","Quicksand",system-ui,sans-serif;--serif:"Iowan Old Style",Georgia,serif;--sans:system-ui,-apple-system,"Segoe UI",Roboto,sans-serif}
@media (prefers-color-scheme:dark){:root{--bg:#1b1530;--surface:#271f42;--surface2:#352b5c;--text:#f4eefc;--muted:#b8aed3;--accent:#ffa05e;--accent-ink:#2a1200;--danger:#ff9a90;--ok:#55d6bb;--line:#40346b;--you:#7d57de;--gm-rule:#55d6bb;--shadow:none}}
*{box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
body{margin:0;background:var(--bg);color:var(--text);font:1rem/1.5 var(--sans);overflow-wrap:anywhere;overflow-x:hidden}
main,.bar,.inner{max-width:42rem;margin:0 auto;padding-left:16px;padding-right:16px}
main{padding-bottom:1.5rem}
h1,h2,h3,h4,.brand{font-family:var(--round);font-weight:800;line-height:1.2}
h1{font-size:1.8rem;margin:1.2rem 0 .8rem}h2{font-size:1.3rem;margin:1.4rem 0 .6rem}h3{font-size:1.1rem;margin:.6rem 0}h4{font-size:.95rem;margin:1rem 0 .3rem;color:var(--muted);text-transform:uppercase;letter-spacing:.04em}
.card h2:first-child,.dlg h2{margin-top:0}
a{color:var(--text)}
:focus-visible{outline:3px solid var(--accent);outline-offset:2px}
.muted{color:var(--muted)}.err{color:var(--danger)}.ok{color:var(--ok)}
small{font-size:.85rem}
header{background:var(--surface);border-bottom:2px solid var(--line);position:sticky;top:0;z-index:5}
.bar{display:flex;align-items:center;gap:6px;min-height:56px;padding-top:max(0px,env(safe-area-inset-top))}
.brand{flex:1;font-size:1.15rem;color:var(--text);text-decoration:none;padding:8px 4px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.icon-btn{min-width:44px;min-height:44px;display:inline-flex;align-items:center;justify-content:center;background:none;border:0;color:var(--text);font-size:1.5rem;text-decoration:none;cursor:pointer;border-radius:12px}
.chips{display:flex;gap:6px;font-size:.8rem;font-weight:700;padding-bottom:8px}.chips:empty{display:none}
.chips span{background:var(--surface2);border-radius:99px;padding:2px 10px;white-space:nowrap}
.btn,button.btn{display:inline-flex;align-items:center;justify-content:center;min-height:44px;padding:0 18px;border-radius:14px;border:2px solid var(--line);background:var(--surface);color:var(--text);font:inherit;font-weight:700;text-decoration:none;cursor:pointer;box-shadow:var(--shadow)}
.btn.primary{background:var(--accent);border-color:var(--accent);color:var(--accent-ink)}
.btn.big{min-height:56px;font-size:1.1rem}
.btn.small{min-height:44px;padding:0 14px;font-size:.9rem}
.btn.left{justify-content:flex-start;text-align:left;padding:10px 16px;min-height:48px}
.btn.story{justify-content:flex-start;text-align:left;padding:12px 16px}
.btn:disabled{opacity:.5;cursor:default}
.btn.block{display:flex;width:100%}
.link{background:none;border:0;padding:8px 0;color:var(--text);text-decoration:underline;font:inherit;cursor:pointer;min-height:44px}
input,select,textarea{width:100%;min-height:44px;padding:8px 12px;border-radius:12px;border:2px solid var(--line);background:var(--surface);color:var(--text);font:inherit}
input[type=checkbox]{width:24px;height:24px;min-height:0;accent-color:var(--you)}
label{display:block;margin:1rem 0 .3rem;color:var(--muted);font-size:.9rem}
label.check{display:flex;align-items:center;gap:10px;margin:.4rem 0;color:var(--text);font-size:1rem;min-height:44px}
.stack>*+*{margin-top:12px}
.row{display:flex;gap:10px;flex-wrap:wrap}.row>.btn{flex:1}
ul.plain{list-style:none;margin:0;padding:0}
.vh{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
[hidden]{display:none!important}
.card{background:var(--surface);border:2px solid var(--line);border-radius:18px;padding:16px;margin:14px 0;box-shadow:var(--shadow)}
.card.notice{background:var(--surface2)}

/* the feed */
#feed{padding-top:8px}
.ev{margin:12px 0}
.ev.you{display:flex;justify-content:flex-end}
.bubble{background:var(--you);color:var(--you-ink);border-radius:20px 20px 4px 20px;padding:8px 14px;max-width:85%}
.ev.gm{border-left:4px solid var(--gm-rule);padding-left:12px}
.prose p{font-family:var(--serif);font-size:1.08rem;line-height:1.65;margin:.5em 0}
.ev.roll{background:var(--surface);border:2px solid var(--line);border-radius:14px;padding:8px 12px;display:flex;flex-wrap:wrap;gap:6px 10px;align-items:center}
.ev.roll .who{flex:1 1 100%;font-size:.9rem;color:var(--muted)}
.dice{display:inline-flex;gap:2px}
.die{font-size:2rem;line-height:1}
.die.win{color:var(--ok)}.die.miss{color:var(--muted);opacity:.7}
.die.again{text-decoration:underline wavy}
.tier{font-family:var(--round)}
.tier.failure{color:var(--danger)}.tier.super,.tier.success-and{color:var(--ok)}
.ev.mech{font-size:.85rem;color:var(--muted);margin:4px 0 4px 16px}
.ev.mech::before{content:"\2022  ";font-weight:800}
.ev.scene{display:flex;align-items:center;gap:12px;color:var(--muted);font-family:var(--round);font-weight:800;margin:22px 0}
.ev.scene::before,.ev.scene::after{content:"";flex:1;border-top:2px dashed var(--line)}
.ev.system{background:var(--surface2);border-radius:12px;padding:8px 12px;font-style:italic}
.ev.error{border:2px solid var(--danger);color:var(--danger);border-radius:12px;padding:8px 12px;font-weight:600}

/* the bottom bar */
footer.act{position:sticky;bottom:0;background:var(--surface);border-top:2px solid var(--line);z-index:4;padding-bottom:env(safe-area-inset-bottom)}
footer .inner{padding-top:8px;padding-bottom:8px;position:relative}
#latest{position:absolute;right:16px;top:-48px}
#thinking,#note,#retrybar{margin:4px 0}
#prompt{max-height:min(62dvh,calc(100dvh - 250px));overflow:auto}
#screen .card,#screen .levelup{margin-top:14px}
#screen{padding-bottom:1rem}
#prompt .card{margin:4px 0 8px;box-shadow:none}
.say{display:flex;gap:8px;align-items:flex-end}
.say textarea{resize:none;max-height:7.5rem;min-height:48px}
.say .btn{min-height:48px}

/* prompts */
.toggles{display:grid;gap:8px;margin:10px 0}
.toggle{display:flex;flex-direction:column;align-items:flex-start;text-align:left;gap:2px;min-height:56px;padding:8px 14px;border-radius:14px;border:2px solid var(--line);background:var(--surface);color:var(--text);font:inherit;cursor:pointer}
.toggle[aria-pressed=true]{border-color:var(--accent);background:var(--surface2)}
.toggle[aria-pressed=true] strong::before{content:"\2713  "}
.toggle:disabled{opacity:.55}
.die-row{display:flex;gap:8px;flex-wrap:wrap;margin:10px 0}
.die-btn{border:3px solid var(--line);border-radius:14px;background:var(--surface);min-width:56px;min-height:64px;cursor:pointer;color:var(--text)}
.die-btn .die{font-size:2.6rem}
.die-btn[aria-pressed=true]{border-color:var(--accent);background:var(--surface2)}
.die-btn[aria-pressed=true]::after{content:"\21BB";display:block;font-size:.8rem;font-weight:800;line-height:1}
.brewing .paw{display:inline-block;width:12px;height:12px;border-radius:50%;background:var(--accent);animation:bob 1s ease-in-out infinite}
@keyframes bob{50%{transform:translateY(-5px)}}
@media (prefers-reduced-motion:reduce){.brewing .paw{animation:none}}

/* sheet, wrap-up, level-up */
dialog{width:min(100% - 32px,40rem);max-height:88dvh;padding:0;border:2px solid var(--line);border-radius:20px;background:var(--bg);color:var(--text)}
dialog::backdrop{background:rgba(20,10,40,.55)}
.dlg{padding:16px}
.dlg-head{display:flex;align-items:center;justify-content:space-between}
.stats{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin:8px 0}
.stats div{background:var(--surface2);border-radius:12px;padding:6px;text-align:center}
.stats dt{font-size:.75rem;text-transform:uppercase;color:var(--muted)}.stats dd{margin:0;font-family:var(--round);font-size:1.5rem;font-weight:800}
.sheet ul{margin:0;padding-left:1.2rem}
.pips{letter-spacing:2px;color:var(--accent)}
.rank{display:flex;justify-content:space-between;align-items:center;gap:12px;padding:8px 0;border-top:1px solid var(--line)}
.rank select{width:5.5rem}
.delta{font-family:var(--round);font-weight:800;font-size:1.2rem}
body.play{min-height:100dvh;display:flex;flex-direction:column}
body.play main{flex:1;width:100%}
.say textarea{flex:1;min-width:0}.say .btn{flex:none}
.btn{gap:.4em}
.brand{flex:1 1 auto;min-width:2.5rem}
.flagged{outline:3px solid var(--accent);border-radius:12px;padding:4px;margin:6px 0}
.chips{font-size:.75rem}.chips span{padding:2px 8px}
.bar .btn{white-space:nowrap;flex:none}
.toggles{grid-template-columns:1fr 1fr;margin:8px 0}
.toggle{min-height:60px;padding:6px 10px;font-size:.95rem}
.prompt h2{font-size:1.15rem;margin-bottom:.3rem}
.prompt p{margin:.3rem 0}
.prompt .big{min-height:52px}
.keep-lines{white-space:pre-wrap;overflow-wrap:anywhere}
.bug-fab{position:fixed;right:max(16px,env(safe-area-inset-right));bottom:calc(var(--fab-lift,0px) + 16px);width:64px;height:64px;border-radius:50%;border:2px solid var(--line);background:var(--surface);color:var(--text);font-size:32px;line-height:1;cursor:pointer;z-index:5;box-shadow:0 4px 14px rgba(20,10,40,.3)}
main{padding-bottom:96px}
