:root {
  --bg: #17110c;
  --panel: rgba(28, 20, 13, 0.93);
  --panel2: #251a10;
  --line: #5a4424;
  --gold: #c9a24a;
  --gold2: #f0d488;
  --text: #ecdfc4;
  --muted: #a8977a;
  --red: #c0533f;
  --green: #7ea35a;
  --purple: #b48ad0;
  --blue: #7fb0d8;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font: 15px/1.4 'EB Garamond', Georgia, serif; }
button { font: inherit; color: inherit; cursor: pointer; }
h2, h3, .logo, #top nav button, .season { font-family: Cinzel, serif; letter-spacing: .04em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pos { color: var(--green); } .neg { color: var(--red); }
.purple-t { color: var(--purple); }
[hidden] { display: none !important; }
.ic { width: 16px; height: 16px; vertical-align: -3px; }

#map { position: fixed; inset: 0; display: block; cursor: grab; }

/* ---------- top bar ---------- */
#top { position: fixed; top: 0; left: 0; right: 0; height: 58px; display: flex; align-items: center; gap: 22px; padding: 0 16px;
  background: linear-gradient(#2a1d12, #1a120b); border-bottom: 1px solid var(--gold); box-shadow: 0 4px 18px #0008; z-index: 5; }
#date { display: flex; flex-direction: column; min-width: 150px; }
#date .season { color: var(--gold2); font-size: 18px; display: inline; }
#date .year { font-family: Cinzel, serif; font-size: 18px; display: inline; }
#date .sub { font-size: 12px; color: var(--muted); }
#res { display: flex; gap: 18px; }
#res .r { display: grid; grid-template-columns: auto auto; column-gap: 6px; align-items: center; }
#res .r b { font-size: 18px; font-weight: 600; }
#res .r small { grid-column: 1 / 3; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
#res .r.warn b { color: #e7a54a; } #res .r.crit b { color: #ff6a50; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .5; } }
#ap { display: flex; align-items: center; gap: 5px; }
#ap .pip { width: 14px; height: 14px; transform: rotate(45deg); border: 1px solid var(--gold); background: transparent; }
#ap .pip.on { background: var(--gold); box-shadow: 0 0 8px var(--gold); }
#ap small { margin-left: 6px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
#top nav { margin-left: auto; display: flex; gap: 8px; }
#top nav button { background: #2d2013; border: 1px solid var(--line); padding: 7px 12px; border-radius: 3px; font-size: 13px; }
#top nav button:hover { border-color: var(--gold); }
#endTurn { background: linear-gradient(#8e1f1f, #5e1212) !important; border-color: var(--gold) !important; color: var(--gold2); font-weight: 600; }
#endTurn:disabled { opacity: .4; cursor: default; }

/* ---------- side panels ---------- */
.panel { position: fixed; top: 66px; bottom: 12px; width: 310px; overflow-y: auto; background: var(--panel); border: 1px solid var(--line);
  border-radius: 4px; padding: 14px; z-index: 4; box-shadow: 0 6px 24px #0009; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
#left { left: 12px; }
#right { right: 12px; width: 340px; }
.panel h2 { margin: 0; font-size: 19px; color: var(--gold2); }
.panel h3 { font-size: 13px; color: var(--gold); text-transform: uppercase; margin: 16px 0 8px; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.card.me { display: flex; gap: 12px; align-items: center; }
.card.me h2 { font-size: 16px; line-height: 1.2; }
.traits { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px; }
.trait { font-size: 12px; border: 1px solid var(--line); padding: 0 6px; border-radius: 10px; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 12px 0 8px; }
.stat { background: var(--panel2); border: 1px solid var(--line); text-align: center; padding: 4px 0; border-radius: 3px; }
.stat small { display: block; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.stat b { font-size: 18px; color: var(--gold2); }
.hp small { font-size: 12px; color: var(--muted); }
.bar { height: 6px; background: #0006; border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--gold); }
.bar.green i { background: var(--green); } .bar.red i { background: var(--red); }
.status { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 3px; background: #ffffff10; border: 1px solid var(--line); }
.tag.gold { border-color: var(--gold); color: var(--gold2); } .tag.red { border-color: var(--red); color: #f0a090; } .tag.purple { border-color: var(--purple); color: var(--purple); }
.fam { display: flex; gap: 8px; align-items: center; padding: 4px; border-radius: 3px; cursor: pointer; font-size: 14px; line-height: 1.2; }
.fam:hover { background: #ffffff0c; }
.fam small { color: var(--muted); }
.emp { display: flex; gap: 8px; align-items: center; font-size: 14px; line-height: 1.25; margin-bottom: 8px; }
.emp small { color: var(--muted); }
.path { border: 1px solid var(--line); border-radius: 3px; padding: 6px 8px; margin-bottom: 6px; background: #00000025; }
.path.ready { border-color: var(--purple); box-shadow: 0 0 10px #b48ad044; }
.path .ph { display: flex; justify-content: space-between; font-size: 14px; }
.path .ph span { color: var(--muted); font-size: 12px; }
.path ul { list-style: none; margin: 3px 0; padding: 0; font-size: 13px; color: var(--muted); }
.path li.ok { color: var(--green); }
.path small { font-size: 11px; font-style: italic; }

.back { background: none; border: none; color: var(--gold); padding: 0; margin-bottom: 6px; font-size: 13px; }
.subt { color: var(--gold); font-size: 13px; font-style: italic; }
.flav { color: var(--muted); font-style: italic; font-size: 14px; margin: 8px 0 12px; }
.loclist { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.loc { text-align: left; background: var(--panel2); border: 1px solid var(--line); padding: 7px 10px; border-radius: 3px; }
.loc:hover { border-color: var(--gold); }
.loc small { display: block; color: var(--muted); font-size: 12px; }
.acts { display: flex; flex-direction: column; gap: 7px; }
.act { text-align: left; background: linear-gradient(#2c2014, #21170e); border: 1px solid var(--line); padding: 8px 10px; border-radius: 3px; transition: border-color .15s, transform .1s; }
.act:hover:not(:disabled) { border-color: var(--gold); transform: translateX(-2px); }
.act:disabled { opacity: .5; cursor: default; }
.act .ah { display: flex; justify-content: space-between; align-items: baseline; }
.act .ah b { color: var(--gold2); font-weight: 600; }
.act > small { display: block; color: var(--muted); font-size: 13px; line-height: 1.25; margin: 2px 0; }
.act .af { display: flex; justify-content: space-between; font-size: 13px; gap: 8px; }
.act .why { color: #e09080; font-size: 12px; font-style: italic; text-align: right; }
.chance { font-size: 12px; color: var(--blue); border: 1px solid #7fb0d866; padding: 0 5px; border-radius: 8px; }

/* ---------- log ---------- */
#log { position: fixed; left: 334px; right: 364px; bottom: 12px; max-height: 170px; background: var(--panel); border: 1px solid var(--line); border-radius: 4px; z-index: 4; display: flex; flex-direction: column; }
#log.collapsed #logBody { display: none; }
#logToggle { background: none; border: none; border-bottom: 1px solid var(--line); text-align: left; padding: 4px 10px; font-family: Cinzel, serif; font-size: 12px; color: var(--gold); }
#logBody { overflow-y: auto; padding: 4px 10px 6px; font-size: 14px; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.le { padding: 2px 0; border-bottom: 1px solid #ffffff08; }
.le .lt { color: var(--muted); font-size: 12px; margin-right: 8px; font-family: Cinzel, serif; }
.le.good { color: #cfe0b0; } .le.bad { color: #f0a898; } .le.major { color: var(--gold2); font-weight: 600; } .le.hint { color: var(--blue); font-style: italic; }

/* ---------- modal ---------- */
#modal { position: fixed; inset: 0; background: #0009; display: flex; align-items: center; justify-content: center; z-index: 20; backdrop-filter: blur(2px); }
.box { width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 60px); overflow-y: auto; background: linear-gradient(#2a1e12, #1c140c); border: 1px solid var(--gold);
  border-radius: 4px; padding: 20px 24px; box-shadow: 0 10px 60px #000; animation: rise .25s ease-out; }
.box.wide { width: min(760px, calc(100vw - 32px)); }
.box.danger { border-color: var(--red); box-shadow: 0 0 40px #c0533f55, 0 10px 60px #000; }
.box.major, .box.succession { border-color: var(--purple); box-shadow: 0 0 40px #b48ad044, 0 10px 60px #000; }
@keyframes rise { from { transform: translateY(12px); opacity: 0; } }
.box h2 { margin: 0 0 10px; color: var(--gold2); font-size: 22px; text-align: center; }
.box h3 { color: var(--gold); font-size: 14px; border-bottom: 1px solid var(--line); padding-bottom: 3px; }
.mbody p { margin: 8px 0; }
.choices { display: flex; flex-direction: column; gap: 7px; margin-top: 14px; }
.choice { background: linear-gradient(#3a2a18, #2a1d10); border: 1px solid var(--line); padding: 9px 14px; border-radius: 3px; text-align: left; }
.choice:hover:not(:disabled) { border-color: var(--gold); color: var(--gold2); }
.choice:disabled { opacity: .45; cursor: default; }
.choice small { display: block; font-size: 13px; color: var(--muted); }
.clist { display: flex; flex-direction: column; gap: 4px; }
.crow { display: flex; align-items: center; gap: 10px; padding: 6px; border: 1px solid #ffffff0a; border-radius: 3px; background: #00000022; }
.crow .cinfo { flex: 1; font-size: 14px; line-height: 1.25; }
.crow .cinfo small { color: var(--muted); }
.crow .op { font-family: Cinzel, serif; font-size: 16px; min-width: 40px; text-align: right; color: var(--muted); }
.crow .op.pos { color: var(--green); } .crow .op.neg { color: var(--red); }
.crow .ph { width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--gold); display: flex; align-items: center; justify-content: center; background: #2c3a48; font-size: 20px; flex: none; }
.sec { font-size: 12px; color: var(--muted); }
.sec.known { color: #e8c06a; } .sec.bm { color: var(--purple); }
.fac { font-size: 11px; padding: 0 5px; border-radius: 3px; }
.fac.opt { background: #3a4a6a; } .fac.pop { background: #6a3a2a; }
.pick { background: linear-gradient(#5e1a1a, #3e1010); border: 1px solid var(--gold); padding: 5px 10px; border-radius: 3px; min-width: 90px; color: var(--gold2); }
.pick small { display: block; font-size: 11px; color: var(--text); }
.pick:disabled { opacity: .45; cursor: default; filter: grayscale(.6); }
.pt { flex: none; }

/* ---------- toasts ---------- */
#toasts { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); z-index: 30; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.toast { background: #1d140ce8; border: 1px solid var(--gold); padding: 8px 16px; border-radius: 3px; max-width: 520px; font-size: 15px; box-shadow: 0 4px 20px #000a; animation: rise .2s; transition: opacity .5s; }
.toast.bad { border-color: var(--red); } .toast.out { opacity: 0; }
#flash { position: fixed; top: 38%; left: 0; right: 0; text-align: center; font-family: Cinzel, serif; font-size: 44px; color: var(--gold2); text-shadow: 0 2px 20px #000; pointer-events: none; opacity: 0; z-index: 6; }
#flash.show { animation: flash 1.6s ease-out; }
@keyframes flash { 15% { opacity: 1; letter-spacing: .12em; } 70% { opacity: 1; } 100% { opacity: 0; letter-spacing: .2em; } }

/* ---------- title & end ---------- */
#title, #end { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; overflow-y: auto; padding: 20px;
  background: radial-gradient(ellipse at center, #1a120bcc 0%, #0b0806f2 70%); }
.tbox { width: min(720px, 100%); text-align: center; margin: auto; }
.logo { font-size: clamp(26px, 8.4vw, 60px); color: var(--gold2); text-shadow: 0 0 30px #c9a24a55, 0 3px 0 #5a3a10; line-height: 1; margin-bottom: 10px; }
.logo em { font-style: normal; color: #8e1f1f; margin: 0 .2em; font-size: .7em; }
.logo span:last-child { color: var(--purple); }
.logo.small { font-size: clamp(26px, 8vw, 44px); }
.tag-line { color: var(--muted); font-style: italic; font-size: 18px; }
.form { text-align: left; margin-top: 20px; background: var(--panel); border: 1px solid var(--line); padding: 18px; border-radius: 4px; }
.form label { display: block; font-family: Cinzel, serif; font-size: 13px; color: var(--gold); margin: 10px 0 6px; }
.form .row { display: flex; gap: 8px; margin-top: 6px; }
.form select { flex: 1; background: var(--panel2); color: var(--text); border: 1px solid var(--line); padding: 6px; font: 16px 'EB Garamond', serif; border-radius: 3px; }
.colors .sw { width: 34px; height: 26px; border: 2px solid transparent; border-radius: 3px; }
.colors .sw.on { border-color: var(--gold2); box-shadow: 0 0 8px var(--gold); }
.ups { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.up { text-align: left; background: var(--panel2); border: 1px solid var(--line); padding: 10px; border-radius: 3px; }
.up.on { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); }
.up b { color: var(--gold2); display: block; } .up small { color: var(--muted); display: block; } .up em { font-size: 13px; color: var(--blue); }
.big { display: block; width: 100%; margin-top: 16px; padding: 12px; font-family: Cinzel, serif; font-size: 18px; letter-spacing: .1em; color: var(--gold2);
  background: linear-gradient(#8e1f1f, #5e1212); border: 1px solid var(--gold); border-radius: 3px; }
.big:hover { filter: brightness(1.15); }
#end.win .logo span { color: var(--purple); }
.end-text { font-size: 19px; line-height: 1.5; }
ol.lineage { text-align: left; list-style: none; padding: 0; margin: 14px 0; }
ol.lineage li { padding: 6px 10px; border-left: 2px solid var(--gold); margin-bottom: 6px; background: #00000030; }
ol.lineage li.cur { border-color: var(--purple); }

@media (max-width: 1100px) {
  #left { width: 260px; } #right { width: 290px; }
  #log { left: 282px; right: 312px; }
  #res { gap: 10px; } #res .r small { display: none; }
}
#mtabs { display: none; }
#map { touch-action: none; }

/* ---- phones (portrait, or landscape with little height): map on top, one panel at a time in a bottom sheet ---- */
@media (max-width: 800px), (max-height: 520px) {
  html, body { font-size: 15px; }
  #top { flex-wrap: wrap; height: auto; padding: max(6px, env(safe-area-inset-top)) 10px 6px; gap: 4px 12px; }
  #date { min-width: 0; flex-direction: row; align-items: baseline; gap: 6px; }
  #date .sub { display: none; }
  #date .season, #date .year { font-size: 15px; }
  #res { gap: 10px; } #res .r { column-gap: 3px; } #res .r b { font-size: 15px; } #res .r small { display: none; }
  #ap small { display: none; } #ap .pip { width: 11px; height: 11px; }
  #top nav { width: 100%; margin-left: 0; gap: 6px; }
  #top nav button { flex: 1; padding: 9px 4px; font-size: 12px; min-height: 38px; }
  #endTurn { flex: 1.5 !important; }
  .panel, #log { display: none; position: fixed; left: 0; right: 0; top: auto; width: auto; bottom: calc(50px + env(safe-area-inset-bottom));
    height: 52vh; height: 52dvh; max-height: none; border-radius: 10px 10px 0 0; z-index: 6; padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); }
  #left, #right { width: auto; }
  .stat small { font-size: 10px; }
  body[data-mtab="left"] #left, body[data-mtab="right"] #right { display: block; }
  body[data-mtab="log"] #log { display: flex; }
  #logToggle { display: none; } #log.collapsed #logBody { display: block; } #logBody { flex: 1; }
  #mtabs { display: flex; position: fixed; left: 0; right: 0; bottom: 0; height: calc(50px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--panel); border-top: 1px solid var(--line); z-index: 7; }
  #mtabs button { flex: 1; background: none; border: none; border-top: 2px solid transparent; color: var(--muted); font-family: Cinzel, serif; font-size: 13px; letter-spacing: .04em; }
  #mtabs button.on { color: var(--gold2); border-top-color: var(--gold); background: #ffffff08; }
  #modal { align-items: flex-end; }
  .box, .box.wide { width: 100vw; max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); border-radius: 10px 10px 0 0; padding: 16px 14px calc(16px + env(safe-area-inset-bottom)); }
  .box h2 { font-size: 19px; }
  .choice, .pick, .act { min-height: 44px; }
  .crow { flex-wrap: wrap; } .crow .pick { margin-left: auto; }
  table.houses { font-size: 13px; } table.houses th, table.houses td { padding: 3px 4px; }
  #toasts { top: auto; bottom: calc(64px + env(safe-area-inset-bottom)); width: 92vw; }
  body[data-mtab] #toasts { bottom: calc(52vh + 58px); }
  #title, #end { padding: 12px; align-items: flex-start; }
  .ups { grid-template-columns: 1fr; }
}

/* ---- NPC politics ---- */
.le.news { color: #b9c4cf; }
.npcl { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 2px; }
.npcl .amb { color: #d8b878; }
.npcl .pact { color: var(--green); }
.npcl .foe { color: #e09080; }
.npcl .cand { color: var(--gold2); }
.clist.click .crow { cursor: pointer; }
.clist.click .crow:hover { border-color: var(--gold); }
.mem { list-style: none; padding: 0; margin: 6px 0 0; font-size: 14px; }
.mem li { padding: 3px 0; border-bottom: 1px solid #ffffff0a; }
.mem .pos { color: var(--green); } .mem .neg { color: var(--red); }
.race { font-size: 13px; margin-top: 6px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 3px; background: #00000022; }
.race .rr { display: flex; justify-content: space-between; gap: 8px; }
.race .rr.me { color: var(--gold2); }
.race .rr.rv { cursor: pointer; } .race .rr.rv:hover { color: var(--gold2); }

/* ---- historical events ---- */
.le.history { color: #e6cf98; font-style: italic; }
.box.history { border-color: #c9a45a; box-shadow: 0 0 40px #c9a45a33, 0 10px 60px #000; }
.hdate { display: block; font-family: Cinzel, serif; font-size: 13px; letter-spacing: 1px; color: var(--gold); margin-bottom: 6px; }

/* ---- dynasties ---- */
.npcl .great { color: #e8b84a; }
.heirmark { color: var(--gold2); font-size: 12px; }
.mood.m0 { color: var(--red); } .mood.m1 { color: #e09080; } .mood.m2 { color: var(--muted); } .mood.m3, .mood.m4 { color: var(--green); }
.goals { list-style: none; padding: 0; margin: 4px 0 8px; font-size: 13px; color: var(--muted); }
.goals li { padding: 2px 0; } .goals li.ok { color: var(--green); text-decoration: line-through; }
.warnline { color: #f0a090; font-size: 13px; margin: 4px 0; }
.temper { color: #d8b878; display: block; line-height: 1.3; margin-top: 2px; }
table.houses { width: 100%; border-collapse: collapse; font-size: 14px; }
table.houses th { text-align: left; font-family: Cinzel, serif; font-size: 11px; color: var(--muted); font-weight: 500; padding: 3px 6px; border-bottom: 1px solid var(--line); }
table.houses td { padding: 4px 6px; border-bottom: 1px solid #ffffff0a; }
table.houses tr.great td:first-child { color: #e8b84a; }
table.houses .pos { color: var(--green); } table.houses .neg { color: var(--red); }
.box.report .deltas { display: flex; flex-wrap: wrap; gap: 6px 14px; font-family: Cinzel, serif; font-size: 14px; }
.dl.pos { color: var(--green); } .dl.neg { color: var(--red); }
ul.rep { list-style: none; padding: 0; margin: 4px 0; font-size: 14px; max-height: 240px; overflow-y: auto; }
ul.rep li { padding: 3px 0; border-bottom: 1px solid #ffffff08; }
ul.rep .pos { color: var(--green); } ul.rep .neg { color: #f0a090; }
.reptoggle { display: block; margin-top: 10px; font-size: 13px; color: var(--muted); cursor: pointer; }
.tabs { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.tab { background: #00000033; border: 1px solid var(--line); color: var(--muted); padding: 5px 12px; border-radius: 3px; font-family: Cinzel, serif; font-size: 13px; cursor: pointer; }
.tab.on { color: var(--gold2); border-color: var(--gold); }
ul.tree, ul.tree ul { list-style: none; margin: 0; padding-left: 18px; border-left: 1px solid var(--line); }
ul.tree { padding-left: 4px; border-left: none; }
ul.tree li { margin: 3px 0; }
.tn { font-size: 14px; } .tn small { color: var(--muted); }
.tn.head { color: var(--gold2); font-weight: 600; } .tn.emp { color: var(--purple); }
.tn.dead { opacity: 0.6; } .tn.gone { text-decoration: line-through; }
.chronicle h4 { font-family: Cinzel, serif; color: var(--gold); margin: 12px 0 4px; font-size: 14px; }
.chr { margin: 3px 0; font-size: 14px; } .chr .lt { color: var(--muted); font-family: Cinzel, serif; font-size: 12px; margin-right: 6px; }
details.endx { text-align: left; margin: 10px 0; max-height: 50vh; overflow-y: auto; background: #00000033; border: 1px solid var(--line); border-radius: 4px; padding: 6px 12px; }
details.endx summary { cursor: pointer; font-family: Cinzel, serif; color: var(--gold2); }

/* ---- phones held sideways: one-row header, panel slides in from the right ---- */
@media (max-height: 520px) and (min-width: 560px) {
  #top { flex-wrap: nowrap; padding-top: 4px; padding-bottom: 4px; padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
  #top nav { width: auto; margin-left: auto; }
  #top nav button { flex: none; min-height: 34px; padding: 6px 10px; }
  #endTurn { flex: none !important; }
  .panel, #log { top: 50px; left: auto; right: 0; width: min(46vw, 400px) !important; height: auto; bottom: calc(42px + env(safe-area-inset-bottom)); border-radius: 10px 0 0 0; }
  #mtabs { height: calc(42px + env(safe-area-inset-bottom)); left: auto; width: min(46vw, 400px); border-left: 1px solid var(--line); }
  body[data-mtab] #toasts { bottom: 54px; left: 28%; }
}

/* ---- guide ---- */
#guide { position: fixed; bottom: 196px; left: 50%; transform: translateX(-50%); width: min(430px, calc(100vw - 700px)); min-width: 300px; z-index: 8;
  background: linear-gradient(#22303c, #18222b); border: 1px solid #7fb0d8; border-radius: 6px; padding: 10px 14px 12px; box-shadow: 0 6px 30px #000a; font-size: 14.5px; animation: rise .25s ease-out; }
#guide .gh { display: flex; justify-content: space-between; align-items: center; font-family: Cinzel, serif; font-size: 11px; letter-spacing: .1em; color: #8fc4ef; text-transform: uppercase; }
#guide .gx { background: none; border: none; color: #8fc4ef; font-size: 15px; padding: 2px 4px; cursor: pointer; }
#guide .gt { display: block; font-family: Cinzel, serif; color: #dceefc; font-size: 16px; margin: 4px 0 2px; }
#guide p { margin: 4px 0 8px; line-height: 1.35; }
#guide .gb { display: flex; justify-content: flex-end; }
#guide .gn { background: #2f4b62; border: 1px solid #7fb0d8; color: #e6f3fd; padding: 6px 14px; border-radius: 3px; font-family: Cinzel, serif; font-size: 12px; cursor: pointer; min-height: 32px; }
#guide .gn.ghost { background: none; border-color: #4d6b82; color: #8fa9bd; }
.guide-hl { outline: 2px solid #8fc4ef !important; outline-offset: 2px; animation: guidepulse 1.2s ease-in-out infinite; }
@keyframes guidepulse { 50% { outline-color: transparent; } }
.guidechk { display: flex !important; align-items: center; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 14px 0 4px; color: #b9d6ee; cursor: pointer; text-transform: none !important; letter-spacing: 0 !important; font-family: 'EB Garamond', serif !important; font-size: 16px !important; }
.guidechk small { color: var(--muted); }
.guidechk input { width: 18px; height: 18px; accent-color: #7fb0d8; }
@media (max-width: 1100px) { #guide { width: min(400px, calc(100vw - 600px)); min-width: 280px; } }
@media (max-width: 800px), (max-height: 520px) {
  #guide { top: auto; bottom: calc(58px + env(safe-area-inset-bottom)); left: 8px; right: 8px; width: auto; min-width: 0; transform: none; font-size: 14px; max-height: 40vh; overflow-y: auto; }
  body[data-mtab] #guide { bottom: auto; top: 100px; max-height: 30vh; }
}
@media (max-height: 520px) and (min-width: 560px) {
  #guide { left: 8px; right: auto; width: min(48vw, 380px); }
  body[data-mtab] #guide { top: 52px; }
}
@media (max-width: 800px), (max-height: 520px) {
  body:has(#guide:not([hidden])):not([data-mtab]) #toasts { top: 100px; bottom: auto; }
}

/* ---- action effects ---- */
.act .gain { display: flex; flex-direction: column; gap: 1px; margin-top: 4px; font-size: 13px; line-height: 1.3; text-align: left; }
.act .gain .gup { color: #9fd07a; }
.act .gain .dn { color: #f0a090; }
.act .gain .rk { color: #e7b45a; }
.act:disabled .gain { opacity: .8; }
.sec.known.sev3 b { color: #f08a6a; }
.secnote { display: inline; font-size: 13px; color: #c9b88a; font-style: italic; }

/* ---- difficulty picker ---- */
.ups.diffs { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 800px) { .ups.diffs { grid-template-columns: 1fr; } }

/* ---- clickable character names ---- */
a.cl { color: inherit; text-decoration: underline dotted rgba(232, 192, 106, .55); text-underline-offset: 2px; cursor: pointer; }
a.cl:hover { color: #f0d080; text-decoration-color: #f0d080; }
button a.cl { text-decoration: none; pointer-events: none; }

/* ---- dealing with people (character page) ---- */
.pas { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px; margin: 6px 0 10px; }
.pas .pa { text-align: left; background: var(--panel2); border: 1px solid var(--line); color: var(--ink, #eadfc8); padding: 7px 9px; border-radius: 3px; cursor: pointer; font: inherit; font-size: 14px; line-height: 1.25; }
.pas .pa:hover:not(:disabled) { border-color: var(--gold); }
.pas .pa:disabled { opacity: .55; cursor: default; }
.pas .pa em { display: block; font-size: 12px; color: var(--muted); font-style: normal; }
.pas .pa small { display: block; font-size: 12px; color: #d9a08a; }
.pas .pa .chance { float: right; font-size: 12px; color: var(--gold2); }
.intel { color: var(--gold2); letter-spacing: 2px; }
.unk { color: var(--muted); font-style: italic; }

/* ---- save export / import ---- */
#saveCode, #impCode { width: 100%; box-sizing: border-box; background: #120d09; color: var(--muted); border: 1px solid var(--line); border-radius: 3px; font: 12px/1.3 ui-monospace, Menlo, monospace; padding: 6px; resize: vertical; }
#impFile { color: var(--muted); max-width: 100%; }
.linkbtn { background: none; border: none; color: #b9d6ee; text-decoration: underline dotted; cursor: pointer; font: inherit; margin: 6px auto 0; display: block; }

/* ---- tap tooltips ---- */
#tipBox { position: fixed; z-index: 60; background: #241a10; border: 1px solid var(--gold); border-radius: 4px; padding: 8px 10px; font-size: 14px; line-height: 1.35; box-shadow: 0 6px 20px rgba(0,0,0,.6); pointer-events: none; }
#res .r, #ap, #date { cursor: help; }
.act .af .per { color: var(--muted); font-style: italic; margin-left: auto; }
.act .af .per + .why { margin-left: 8px; }
.natkids { margin: 4px 0; }

/* ---- provinces ---- */
.pwrap { border: 1px solid var(--line); border-radius: 4px; overflow: hidden; background: #2a2116; }
.provmap { display: block; width: 100%; height: auto; }
.provmap .land { fill: #3a2f20; }
.provmap .isle { stroke: #4a3c28; stroke-width: 1; }
.provmap .sea { fill: #1d2c33; stroke: #4a3c28; stroke-width: 1.5; }
.provmap .road { stroke: rgba(240,212,136,.13); stroke-width: 1.5; stroke-dasharray: 4 5; }
.provmap .ring { fill: none; stroke: rgba(0,0,0,.45); stroke-width: 5; }
.provmap .prog { fill: none; stroke: var(--gold2); stroke-width: 5; stroke-linecap: round; }
.provmap .disc { stroke: #120d09; stroke-width: 2; }
.provmap .pnode { cursor: pointer; }
.provmap .pnode.on .disc { stroke: var(--gold2); stroke-width: 3; }
.provmap .pnode:hover .disc { filter: brightness(1.25); }
.provmap .pl { fill: var(--text); font: 600 17px Cinzel, serif; text-anchor: middle; paint-order: stroke; stroke: #120d09; stroke-width: 4px; }
.provmap .leg { fill: #fff; font-size: 19px; text-anchor: middle; pointer-events: none; }
.provmap .rome { fill: var(--purple); stroke: #120d09; stroke-width: 2; }
.plegend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 6px 0 10px; }
.plegend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; }
.dot.you { background: var(--gold); } .dot.riv { background: #a0463c; } .dot.none { background: #6d6253; }
.pdet h3 { margin: 4px 0; }
.pbars { display: grid; gap: 4px; margin: 6px 0 8px; }
.pbars div { display: grid; grid-template-columns: 170px 1fr 34px; align-items: center; gap: 8px; font-size: 13px; }
.pbars div::before { content: none; }
.pbars i { display: block; height: 8px; border-radius: 4px; background: var(--gold); max-width: 100%; }
.pbars i.riv { background: #a0463c; }
.pbars div > span { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pdet .acts { display: grid; gap: 6px; }
.plist { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px; margin-top: 12px; }
.pli { text-align: left; background: #21170e; border: 1px solid var(--line); border-radius: 3px; padding: 6px 8px; }
.pli small { display: block; color: var(--muted); }
.pli.on { border-color: var(--gold); }
@media (max-width: 800px) { .pbars div { grid-template-columns: 110px 1fr 30px; } .provmap .pl { font-size: 22px; } }
@media (max-width: 800px) {
  #top nav { gap: 5px; }
  #top nav button { letter-spacing: 0; padding: 8px 2px; font-size: 11px; }
  #top nav #btnHelp { flex: 0 0 34px; }
  #top nav #endTurn { flex: 1.25; }
}
.pguide { background: #13202b; border: 1px solid #4f7fa3; border-radius: 4px; padding: 8px 12px; margin-bottom: 10px; }
.pguide .gh { font-family: Cinzel, serif; font-size: 11px; letter-spacing: .1em; color: #8fc4ef; text-transform: uppercase; }
.pguide ol { margin: 6px 0 8px; padding-left: 20px; } .pguide li { margin: 3px 0; }
.pguide .gotit { margin-top: 2px; }
.gbox { background: #13202b; border: 1px solid #4f7fa3; border-radius: 4px; padding: 8px 12px; margin-bottom: 10px; }
.gbox .gh { font-family: Cinzel, serif; font-size: 11px; letter-spacing: .1em; color: #8fc4ef; text-transform: uppercase; }
.gbox ol { margin: 6px 0 8px; padding-left: 20px; } .gbox li { margin: 3px 0; }

/* ---------------- online play (js/net.js) ---------------- */
#netbar { position: fixed; top: 58px; left: 0; right: 0; height: 30px; z-index: 5; display: flex; align-items: center; gap: 14px; padding: 0 14px;
  background: #120c08ee; border-bottom: 1px solid var(--line); font-size: 14px; }
body.online .panel { top: 96px; }
body.online #toasts { top: 100px; }
#netbar .seats { display: flex; gap: 10px; overflow-x: auto; scrollbar-width: none; min-width: 0; }
#netbar .seat { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; color: var(--muted); }
#netbar .seat i, .seatt .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; border: 1px solid #0008; margin-right: 4px; }
#netbar .seat b { font-weight: 600; color: var(--muted); }
#netbar .seat .pn { font-size: .85em; opacity: .8; }
#netbar .seat .pn::before { content: '· '; }
.who-pl { color: var(--gold2); font-size: .9em; font-weight: normal; }
.who-pl.ai { color: var(--muted); }
#netbar .seat.done b { color: var(--green); }
#netbar .seat.me { color: var(--gold2); }
#netbar .seat.out { opacity: .5; text-decoration: line-through; }
#netbar .clock { margin-left: auto; white-space: nowrap; color: var(--text); font-variant-numeric: tabular-nums; }
#netbar .clock.late { color: var(--red); }
#netbar .netst { white-space: nowrap; }
#netbar .chatbtn { background: var(--panel2); border: 1px solid var(--line); border-radius: 3px; padding: 2px 10px; font-family: Cinzel, serif; font-size: 12px; color: var(--gold2); }
.badge { background: var(--red); color: #fff; border-radius: 9px; padding: 0 6px; font-size: 11px; margin-left: 4px; }
#endTurn.waiting { background: #2f4b2a; }
#chatPanel, #housesPanel { position: fixed; top: 96px; right: 12px; width: min(380px, calc(100vw - 24px)); max-height: calc(100vh - 120px); z-index: 35; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--gold); border-radius: 4px; box-shadow: 0 8px 30px #000a; }
#title #chatPanel, body:not(.online) #chatPanel { top: 20px; }
#chatPanel .ch-head, #housesPanel .ch-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); font-family: Cinzel, serif; }
#chatPanel .ch-head .x { margin-left: auto; background: none; border: none; color: var(--muted); font-size: 16px; }
#chatPanel .ch-tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
#chatPanel .ch-tabs button { background: var(--panel2); border: 1px solid var(--line); border-radius: 3px; padding: 3px 8px; font-size: 13px; }
#chatPanel .ch-tabs button.on { border-color: var(--gold); color: var(--gold2); }
#chatPanel .ch-body { padding: 8px 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
#chatPanel .msgs { max-height: 50vh; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
#chatPanel .msg { background: #00000030; border-left: 2px solid var(--line); padding: 4px 8px; word-wrap: break-word; }
#chatPanel .msg.mine { border-left-color: var(--gold); }
#chatPanel .who { color: var(--gold2); font-weight: 600; } #chatPanel .at { color: var(--muted); font-size: 12px; }
#chatPanel .rep { float: right; background: none; border: none; color: var(--muted); font-size: 12px; opacity: .6; }
#chatPanel form.say { display: flex; gap: 6px; }
#chatPanel input, .tbox.mp input, .tbox.mp select { background: var(--panel2); color: var(--text); border: 1px solid var(--line); padding: 6px; font: 16px 'EB Garamond', serif; border-radius: 3px; }
#chatPanel form.say input { flex: 1; min-width: 0; }
#chatPanel button, .tbox.mp .row button, .tbox.mp .mine button, .seatt button, .invite button, .hostp button { background: var(--panel2); border: 1px solid var(--line); border-radius: 3px; padding: 4px 10px; color: var(--gold2); }
#chatPanel .mute, .hostp label { font-size: 13px; color: var(--muted); }
#chatPanel .key { width: 100%; font-family: monospace; font-size: 12px; }
.tbox.mp { text-align: left; width: min(900px, 100%); }
.tbox.mp .logo, .tbox.mp .tag-line { text-align: center; }
.tbox.mp h3 { font-family: Cinzel, serif; color: var(--gold); margin: 14px 0 6px; }
.tbox.mp label { display: block; font-family: Cinzel, serif; font-size: 12px; color: var(--gold); margin: 8px 0 3px; }
.tbox.mp label input, .tbox.mp label select { display: block; width: 100%; box-sizing: border-box; margin-top: 3px; font-family: 'EB Garamond', serif; }
.tbox.mp .row { display: flex; gap: 6px; } .tbox.mp .row select, .tbox.mp .row input { flex: 1; min-width: 0; }
.mpcols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.mpcols .col { background: var(--panel); border: 1px solid var(--line); padding: 14px; border-radius: 4px; }
.tbox.mp details { margin: 8px 0; color: var(--muted); } .tbox.mp summary { cursor: pointer; }
.tbox.mp .mine .g { display: flex; align-items: center; gap: 8px; padding: 6px 8px; background: var(--panel); border: 1px solid var(--line); margin-bottom: 4px; border-radius: 3px; }
.tbox.mp .mine .g .open { margin-left: auto; }
.invite { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 14px 0; }
.invite b { font-family: Cinzel, serif; font-size: 28px; color: var(--gold2); letter-spacing: .08em; }
.seatt { width: 100%; border-collapse: collapse; margin: 8px 0; } .seatt td { padding: 5px 6px; border-bottom: 1px solid #5a442455; }
.big.alt { background: linear-gradient(#2f4b62, #1d3243); border-color: #7fb0d8; color: #e6f3fd; }
@media (max-width: 800px), (max-height: 520px) {
  .mpcols { grid-template-columns: 1fr; }
  #netbar { top: auto; bottom: calc(50px + env(safe-area-inset-bottom)); height: 32px; gap: 10px; padding: 0 10px; font-size: 13px; border-top: 1px solid var(--line); border-bottom: none; }
  #netbar .netst:empty { display: none; }
  body.online .panel, body.online #log { top: auto; bottom: calc(82px + env(safe-area-inset-bottom)); }
  body.online #toasts { top: auto; bottom: calc(96px + env(safe-area-inset-bottom)); }
  #chatPanel { top: 10px; right: 6px; max-height: 70vh; }
}

/* houses against houses */
#housesPanel { left: 12px; right: auto; width: min(440px, calc(100vw - 24px)); }
#housesPanel .ch-head .x { margin-left: auto; background: none; border: none; color: var(--muted); font-size: 16px; }
#housesPanel .ch-tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
#housesPanel .ch-tabs button, #housesPanel form button { background: var(--panel2); border: 1px solid var(--line); border-radius: 3px; padding: 3px 8px; font-size: 13px; color: var(--gold2); }
#housesPanel .ch-tabs button.on { border-color: var(--gold); }
#housesPanel .ch-tabs button.out { opacity: .5; text-decoration: line-through; }
#housesPanel .ch-body { padding: 8px 10px; overflow-y: auto; min-height: 0; }
#housesPanel .ch-body p { margin: 0 0 8px; }
#housesPanel form.offer { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--line); padding-top: 8px; }
#housesPanel form.offer label { display: flex; flex-direction: column; font-size: 13px; color: var(--muted); }
#housesPanel .ofArg { display: flex; gap: 6px; flex-wrap: wrap; } #housesPanel .ofArg[hidden] { display: none; } #housesPanel .ofArg label { flex: 1; min-width: 120px; }
#housesPanel input, #housesPanel select { background: var(--panel2); color: var(--text); border: 1px solid var(--line); padding: 6px; font: 16px 'EB Garamond', serif; border-radius: 3px; width: 100%; box-sizing: border-box; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; border: 1px solid #0008; margin-right: 4px; vertical-align: middle; }
#netbar .reign { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; color: var(--purple, #b48ad8); font-family: Cinzel, serif; font-size: 12px; }
#netbar .reign i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; border: 1px solid #0008; }
#netbar .reign.muted { color: var(--muted); }
table.scores { margin: 10px auto; border-collapse: collapse; font-size: 15px; }
table.scores th, table.scores td { padding: 4px 10px; border-bottom: 1px solid var(--line); text-align: center; }
table.scores td:first-child, table.scores th:first-child { text-align: left; }
table.scores tr.win td { color: var(--gold2); }
@media (max-width: 700px) { #netbar .reign { display: none; } }

/* reminders and moderation */
#chatPanel .notify label { display: block; margin: 6px 0; }
#chatPanel .notify input[type=email], #chatPanel .notify #nHook { width: 100%; box-sizing: border-box; margin-top: 3px; }
#chatPanel .notify .row label { display: inline-block; margin-right: 10px; }
#chatPanel .notify hr { border: none; border-top: 1px solid var(--line); margin: 10px 0; }
#chatPanel .msg .hid { color: var(--muted); font-style: italic; }
#chatPanel button.mod { float: right; font-size: 12px; padding: 1px 8px; }

/* the installable app */
.tbox.mp .install { margin: 6px 0 0; }
.tbox.mp .install button, #chatPanel #nDevice button { background: var(--panel2); border: 1px solid var(--gold); border-radius: 3px; padding: 4px 12px; color: var(--gold2); }
#chatPanel #nDevice label { display: block; margin: 4px 0; }
