/* Blackspire Realms: painted high-fantasy look. All art in assets/ is original, AI-generated (see ART_CREDITS.md). Fonts: Cinzel + Cinzel Decorative (SIL OFL 1.1, bundled in assets/fonts). */
@font-face { font-family:"Cinzel"; font-weight:600; font-style:normal; font-display:swap; src:url(assets/fonts/cinzel-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family:"Cinzel"; font-weight:800; font-style:normal; font-display:swap; src:url(assets/fonts/cinzel-latin-800-normal.woff2) format("woff2"); }
@font-face { font-family:"Cinzel Decorative"; font-weight:900; font-style:normal; font-display:swap; src:url(assets/fonts/cinzel-decorative-latin-900-normal.woff2) format("woff2"); }
:root {
  --ink:#2e1d10; --ink2:#5a4026; --paper:#f6e9c8; --paper2:#ead7a6; --leather:#2a1a10; --leather2:#3d2716;
  --gold:#d9a21b; --gold2:#f3d36b; --goldDark:#7a5412; --pop:#e9b53a; --good:#2f8f4e; --bad:#b8372c; --royal:#2b3f86; --wine:#6d1f2f;
  --serif:"Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;
  --display:"Cinzel", "Palatino Linotype", Palatino, Georgia, serif;
  --title:"Cinzel Decorative", "Cinzel", Georgia, serif;
  --parch:url(assets/parchment.webp);
}
* { box-sizing: border-box; }
html, body { margin:0; height:100%; overflow-x:hidden; -webkit-text-size-adjust:100%; text-size-adjust:100%; background:var(--leather); color:var(--ink); font-family:var(--serif); }
#app { height:100%; position:relative; }
.screen { position:absolute; inset:0; display:flex; flex-direction:column; }
#overlay { align-items:center; justify-content:center; background:rgba(22,12,6,.82); overflow:auto; z-index:9; padding:12px; }
/* parchment panel with an illuminated gold rim */
.card { position:relative; background:var(--parch) center/cover, var(--paper); border-radius:14px; padding:20px 24px; max-width:560px; width:100%; border:3px solid var(--gold); box-shadow:inset 0 0 0 2px var(--goldDark), inset 0 0 0 5px #f8edcf, inset 0 0 28px #b8892f66, 0 12px 28px #000a; }
h1 { margin:0 0 4px; font-size:34px; font-family:var(--title); color:var(--wine); }
h2 { margin:0 0 8px; font-family:var(--display); font-weight:800; color:var(--wine); letter-spacing:.5px; }
.sub { margin:0 0 12px; } .fine { font-size:13px; opacity:.85; }
.row { display:flex; align-items:center; gap:10px; margin:8px 0; }
.btns { display:flex; gap:10px; flex-wrap:wrap; margin:14px 0 6px; }
button { font:inherit; font-family:var(--display); font-weight:800; letter-spacing:.3px; touch-action:manipulation; -webkit-tap-highlight-color:transparent; border:2px solid var(--goldDark); border-radius:10px; padding:8px 14px; background:linear-gradient(180deg,#f7dc82,#d9a21b); color:var(--ink); cursor:pointer; box-shadow:inset 0 1px 0 #fff9, 0 3px 0 #5a3d0c, 0 5px 8px #0004; }
button:active { transform:translateY(2px); box-shadow:inset 0 1px 0 #fff9, 0 1px 0 #5a3d0c; }
button.alt { background:linear-gradient(180deg,#f3e6c2,#d9c28a); border-color:#8a6a2c; box-shadow:inset 0 1px 0 #fff9, 0 3px 0 #6b5220, 0 5px 8px #0003; }
button.big { font-size:17px; padding:10px 20px; } button.small { padding:4px 10px; font-size:12px; }
button:disabled { opacity:.5; cursor:not-allowed; filter:saturate(.6); }
button.on { background:linear-gradient(180deg,#8a2c3f,#5d1a2a); color:#ffeab0; border-color:#e5b94a; }
.dot { width:18px; height:18px; border-radius:50%; border:2px solid #fff; box-shadow:0 0 0 1px #0006; flex:none; }
select, input { font:inherit; font-size:16px; padding:5px 8px; border-radius:8px; border:2px solid #b8924a; background:#fffaf0; color:var(--ink); }
#top { display:flex; align-items:center; gap:10px 14px; padding:8px 12px; background:linear-gradient(180deg,#43291a,#2a1a10); color:#f6e9c8; flex:none; flex-wrap:wrap; border-bottom:3px solid var(--gold); box-shadow:0 3px 0 var(--goldDark), 0 4px 10px #0007; position:relative; z-index:2; }
#top .spacer { flex:1; }
#turnInfo { font-family:var(--display); font-weight:800; display:flex; align-items:center; gap:6px; } #resInfo { display:flex; gap:8px; flex-wrap:wrap; }
.crestmini { width:30px; height:30px; border-radius:50%; border:2px solid var(--gold2); object-fit:cover; flex:none; box-shadow:0 0 0 1px #000a; }
.pill { background:#0005; border:1px solid #d9a21b88; border-radius:999px; padding:3px 10px; font-size:14px; }
.endturn { background:linear-gradient(180deg,#58b46f,#2b7d47); color:#fff; border-color:#124d27; font-size:15px; padding:8px 16px; text-shadow:0 1px 0 #0006; box-shadow:inset 0 1px 0 #fff6, 0 3px 0 #124d27, 0 5px 8px #0004; }
kbd { background:#0004; border-radius:4px; padding:0 5px; font-size:12px; font-family:var(--serif); }
main { flex:1; display:flex; min-height:0; }
#mapWrap { flex:1; min-width:0; display:flex; align-items:center; justify-content:center; background:radial-gradient(circle at 50% 40%, #4a3320, #1c110a); padding:6px; }
canvas { max-width:100%; max-height:100%; border-radius:6px; border:3px solid var(--gold); box-shadow:0 0 0 2px var(--goldDark), 0 6px 16px #000a; image-rendering:auto; touch-action:manipulation; }
#side { width:330px; background:var(--parch) center/cover, var(--paper); border-left:3px solid var(--gold); display:flex; flex-direction:column; min-height:0; flex:none; }
.tabs { display:flex; gap:4px; padding:6px; } .tabs button { flex:1; padding:6px 4px; font-size:13px; }
.tabs button:not(.on) { background:linear-gradient(180deg,#f3e6c2,#d9c28a); border-color:#8a6a2c; }
#panel { padding:6px 12px 12px; overflow:auto; flex:1; font-size:14px; }
#panel h3 { margin:6px 0 4px; font-family:var(--display); font-weight:800; color:var(--wine); } #panel .muted { opacity:.75; font-size:13px; }
.grid { display:grid; gap:6px; } .g2 { grid-template-columns:1fr 1fr; } .g3 { grid-template-columns:1fr 1fr 1fr; }
.opt { text-align:left; padding:6px 8px; font-size:12.5px; line-height:1.2; font-family:var(--serif); font-weight:700; }
.opt small { display:block; font-weight:400; opacity:.85; }
.opt .uicon { width:22px; height:22px; margin:-2px 4px -5px 0; }
.bar { height:10px; background:#3d271655; border:1px solid #7a5412aa; border-radius:6px; overflow:hidden; margin:3px 0; } .bar i { display:block; height:100%; background:linear-gradient(180deg,#6fd08b,#2f8f4e); }
.uicard { display:flex; gap:10px; align-items:center; margin:2px 0 6px; } .uicard h3 { margin:0 0 2px; }
.uportrait { width:64px; height:64px; border-radius:10px; border:3px solid var(--gold); box-shadow:0 0 0 1px var(--goldDark), 0 3px 6px #0005; object-fit:cover; flex:none; background:#e9d08a; }
.uicon { width:18px; height:18px; border-radius:50%; object-fit:cover; vertical-align:middle; flex:none; }
.leaderrow { display:flex; gap:10px; align-items:center; margin:6px 0; } .leaderrow .uportrait { width:72px; height:72px; border-radius:50%; }
footer { background:linear-gradient(180deg,#2a1a10,#1b110a); color:#f0e2bd; padding:6px 12px; flex:none; font-size:13px; border-top:3px solid var(--gold); }
#hint { color:#ffd77a; font-weight:700; margin-bottom:3px; min-height:18px; }
#log { height:58px; overflow:auto; opacity:.92; }
#log div { padding:1px 0; } .tag { display:inline-block; width:10px; height:10px; border-radius:50%; margin-right:5px; }
.techcol { display:flex; flex-direction:column; gap:6px; }
.tech { text-align:left; font-size:12px; padding:6px; line-height:1.2; font-family:var(--serif); font-weight:700; } .tech.done { background:linear-gradient(180deg,#c9ecb4,#8fcb7a); border-color:#2f6d2b; } .tech small { display:block; font-weight:400; }
table.r { width:100%; border-collapse:collapse; } table.r td, table.r th { padding:3px 4px; text-align:left; border-bottom:1px solid #7a54124a; font-size:13px; vertical-align:middle; }
.winart { display:block; width:96px; height:96px; margin:0 auto 6px; border-radius:50%; border:4px solid var(--gold); box-shadow:0 0 0 2px var(--goldDark), 0 0 22px #ffd54a; object-fit:cover; }
@media (max-width: 760px) { main { flex-direction:column; } #side { width:100%; height:36%; border-left:0; border-top:3px solid var(--gold); } }

/* ================= Start page: painted key art, parchment card, gold trim ================= */
#setup { background:#1c110a; z-index:5; overflow-x:hidden; overflow-y:auto; -webkit-overflow-scrolling:touch; padding:max(12px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
.sky { position:fixed; inset:0; z-index:0; pointer-events:none; background:linear-gradient(180deg, #1c110a99, #1c110acc), url(assets/title.webp) center top/cover no-repeat; }
.setupcard { position:relative; z-index:1; margin:auto; max-width:520px; min-width:0; padding:0 14px 18px; }
.masthead { margin:0 -14px; height:min(72vw, 300px); background:linear-gradient(180deg, #0000 30%, #20120aee 100%), url(assets/title.webp) center 30%/cover no-repeat; border-bottom:3px solid var(--gold); position:relative; border-radius:11px 11px 0 0; }
.masthead .ornament { position:absolute; inset:6px; border:2px solid #f3d36bcc; border-radius:8px; box-shadow:inset 0 0 0 1px #7a5412; pointer-events:none; }
.setupcard h1 { position:relative; text-align:center; margin:-96px -14px 10px; min-height:96px; display:flex; flex-direction:column; justify-content:flex-end; padding:0 8px 6px; font-size:clamp(26px, 8.6vw, 40px); line-height:1.08; letter-spacing:.5px; color:#ffeaa0; font-weight:900; text-shadow:0 2px 0 #5a3d0c, 0 0 14px #000, 0 3px 10px #000; background:none; }
.setupcard h1 span { display:inline-block; white-space:nowrap; margin:0 .06em; }
.setupcard h1 .t2 { color:#fff4c8; }
.setupcard .sub { text-align:center; margin:12px 0 12px; font-size:16px; line-height:1.35; font-style:italic; }
.block { display:flex; align-items:center; flex-wrap:wrap; gap:8px 10px; margin:10px 0; min-width:0; }
.lbl { font-family:var(--display); font-weight:800; color:var(--wine); }
#countBtns { display:flex; flex-wrap:wrap; gap:8px; }
#countBtns button { width:48px; height:48px; padding:0; border-radius:50%; font-size:20px; }
#countBtns button.on { transform:scale(1.08); box-shadow:0 0 0 2px #f3d36b, 0 3px 0 #3d0f1a; }
#countBtns button:disabled { font-size:13px; }
#seats { display:grid; gap:10px; margin:10px 0; }
.seat { --c:#e8453c; --tint:#e8453c29; --edge:#e8453c88; position:relative; display:grid; grid-template-columns:1fr 1fr; gap:8px; align-items:end; padding:10px 12px 12px; min-width:0; border-radius:12px; border:3px solid var(--c); background:linear-gradient(135deg, #fff9e8 0%, #fbefcf 45%, var(--tint) 100%); box-shadow:inset 0 0 0 2px #fff6, 0 4px 0 var(--edge); }
.seat.enter { animation:pop .45s cubic-bezier(.3,1.6,.5,1) both; animation-delay:calc(var(--n) * .06s); }
.seat .head { grid-column:1 / -1; display:flex; align-items:center; gap:10px; font-family:var(--display); font-size:17px; font-weight:800; color:var(--c); min-width:0; }
.seat .head .dot { width:22px; height:22px; background:var(--c); border-width:3px; box-shadow:0 2px 0 #0003; }
.seat .head .who { display:flex; flex-direction:column; min-width:0; line-height:1.15; } .seat .head .who small { font-family:var(--serif); font-weight:400; font-style:italic; font-size:12.5px; color:var(--ink2); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.seat .head .face { margin-left:auto; width:52px; height:52px; border-radius:50%; border:3px solid var(--gold); box-shadow:0 0 0 2px var(--goldDark), 0 3px 6px #0005; object-fit:cover; background:radial-gradient(circle,#f8e7ab,#d9a21b); flex:none; display:flex; align-items:center; justify-content:center; font-family:var(--title); font-size:24px; color:var(--wine); }
.seat label { display:flex; flex-direction:column; gap:3px; font-size:13px; font-weight:700; min-width:0; color:var(--ink); }
.seat label.wide { grid-column:1 / -1; }
.seat label[hidden] { display:none; }
.seat select { width:100%; min-width:0; max-width:100%; min-height:48px; font-size:16px; font-weight:700; border:2px solid var(--edge); border-radius:10px; padding:6px 8px; background-color:#fffaf0; }
.seedrow input { flex:1 1 130px; min-width:0; min-height:48px; font-size:18px; font-weight:700; border-radius:10px; border-color:#b8924a; }
.check { min-height:48px; padding:6px 12px; border-radius:10px; background:#f3e3b8; border:1px solid #b8924a; font-size:15px; cursor:pointer; }
.check input { width:26px; height:26px; flex:none; accent-color:var(--wine); margin:0; }
.setupcard .btns { display:grid; grid-template-columns:1fr; gap:10px; margin:14px -6px 8px; padding:10px 6px 6px; position:static; }
.setupcard .btns button { width:100%; min-height:56px; font-size:18px; border-radius:12px; }
button.go { background:linear-gradient(180deg,#ffe88e,#e0a416 60%,#c68a0c); box-shadow:inset 0 1px 0 #fffb, 0 5px 0 #6b470a, 0 8px 14px #0005; font-size:21px; letter-spacing:1px; }
button.go:active { transform:translateY(3px); box-shadow:inset 0 1px 0 #fffb, 0 2px 0 #6b470a; }
.setupcard .btns button.alt { min-height:50px; font-size:16px; }
.setupcard .fine { font-size:13px; line-height:1.4; margin:8px 2px 0; }
.setuperr { margin:10px 0 0; padding:10px 12px; border-radius:10px; background:#ffe3df; border:2px solid #b8372c; color:#7a1c14; font-weight:700; }
@media (max-width:350px) { .seat { grid-template-columns:1fr; } .seat .head { font-size:15px; } .seat .head .face { width:44px; height:44px; } }
@media (min-width:520px) { .setupcard { padding:0 24px 24px; } .masthead { margin:0 -24px; } .setupcard h1 { margin-left:-24px; margin-right:-24px; } .setupcard .btns { grid-template-columns:1fr 1fr; } .setupcard .btns .go { grid-column:1 / -1; } .seat { grid-template-columns:1fr 1fr; } }
@keyframes pop { from { transform:scale(.88); opacity:0; } to { transform:scale(1); opacity:1; } }
@media (prefers-reduced-motion: reduce) { button.go, .seat { animation:none !important; } }

/* ================= Main game screen: bright, sunny, vibrant palette (scoped to #game so the Start page is untouched) ================= */
#game { --gink:#3a2614; --gink2:#6b4f2f; --sky1:#f6e9c8; --sky2:#e2c88f; --sun1:#fffbe6; --sun2:#ffefb8; --berry:#d6336c; background:#e9d6a8; color:var(--gink); }
#game #top { background:linear-gradient(180deg,#f8edcf 0%,#e0c68c 100%); color:var(--gink); border-bottom:3px solid var(--gold); box-shadow:0 3px 0 var(--goldDark), 0 4px 10px #7a541244; }
#game .crestmini { border-color:var(--gold); box-shadow:0 0 0 1px var(--goldDark), 0 2px 4px #0003; }
#game .pill { background:#ffffffcc; color:var(--gink); border:1.5px solid var(--gold); font-weight:700; box-shadow:0 1px 0 #fff, 0 2px 4px #7a541233; }
#game kbd { background:#0000001f; color:inherit; }
#game .endturn { background:linear-gradient(180deg,#5cf08a,#16b04f); color:#fff; border-color:#0a6b30; text-shadow:0 1px 1px #0a4d22; box-shadow:inset 0 1px 0 #fff8, 0 3px 0 #0a6b30, 0 5px 8px #0a6b3055; }
#game #mapWrap { background:radial-gradient(circle at 50% 35%, #faf0d3 0%, #ead7a6 55%, #d9bf86 100%); }
#game canvas { box-shadow:0 0 0 2px var(--goldDark), 0 6px 16px #7a541266; }
#game #side { background:linear-gradient(180deg,var(--sun1) 0%,var(--sun2) 100%); border-left:3px solid var(--gold); color:var(--gink); }
#game .tabs { background:linear-gradient(180deg,#fff,#fff6d6); border-bottom:2px solid #f3d36b; }
#game .tabs button:not(.on) { background:linear-gradient(180deg,#fcf3da,#ead6a4); border-color:#b8924a; color:var(--gink); box-shadow:inset 0 1px 0 #fff, 0 3px 0 #8a6a2c, 0 5px 8px #7a541233; }
#game .tabs button.on { background:linear-gradient(180deg,#ff7fb0,#d6336c); color:#fff; border-color:var(--gold2); text-shadow:0 1px 1px #7a1038; box-shadow:inset 0 1px 0 #fff8, 0 3px 0 #8f1f4a, 0 5px 8px #8f1f4a44; }
#game #panel h3, #game #panel h2 { color:#b8234f; }
#game #panel .muted { opacity:.85; color:var(--gink2); }
#game button.alt { background:linear-gradient(180deg,#fcf3da,#ead6a4); border-color:#b8924a; color:var(--gink); box-shadow:inset 0 1px 0 #fff, 0 3px 0 #8a6a2c, 0 5px 8px #7a541233; }
#game #panel button:not(.alt):not(.on) { background:linear-gradient(180deg,#fff3b0,#ffc83a); border-color:var(--goldDark); color:var(--gink); }
#game .opt small { color:var(--gink2); opacity:1; }
#game .bar { background:#3a261422; border-color:#b8924aaa; }
#game .bar i { background:linear-gradient(180deg,#7bf5a0,#16b04f); }
#game .tech.done { background:linear-gradient(180deg,#c9ffd9,#7be8a0); border-color:#16a04a; }
#game table.r td, #game table.r th { border-bottom:1px solid #b8924a66; }
#game .uportrait { background:#fff3c4; }
#game footer { background:linear-gradient(180deg,#f8edcf,#e0c68c); color:var(--gink); border-top:3px solid var(--gold); box-shadow:0 -2px 0 var(--goldDark), 0 -3px 10px #7a541233; }
#game #hint { color:#a63a00; }
#game #log { opacity:1; color:var(--gink); }
@media (max-width: 760px) { #game #side { border-left:0; border-top:3px solid var(--gold); } }

/* ================= Game screen layout: full-bleed pannable map, non-overlapping panel + tip (scoped to #game) ================= */
#game main { overflow:hidden; }
#game #mapWrap { position:relative; padding:0; overflow:hidden; display:block; min-height:120px; }
#game canvas { position:absolute; left:0; top:0; max-width:none; max-height:none; border:0; border-radius:0; box-shadow:none; touch-action:none; -webkit-user-select:none; user-select:none; -webkit-touch-callout:none; }
#mapCtl { position:absolute; right:8px; bottom:8px; display:flex; flex-direction:column; gap:8px; z-index:2; }
.mapbtn { width:44px; height:44px; padding:0; border-radius:12px; font-size:24px; line-height:1; display:flex; align-items:center; justify-content:center; opacity:.92; }
#game #side { overflow:hidden; min-width:0; }
#game #panel { min-height:0; overflow-x:hidden; overflow-y:auto; -webkit-overflow-scrolling:touch; overflow-wrap:anywhere; }
#game footer { min-width:0; }
#game #hint { overflow-wrap:anywhere; word-break:normal; line-height:1.3; margin:0 0 3px; min-height:0; }
#game #hint:empty { display:none; }
#game #log { overflow-wrap:anywhere; }
@media (max-width: 760px) {
  #game #top { padding:6px 10px; gap:6px 8px; padding-left:max(10px, env(safe-area-inset-left)); padding-right:max(10px, env(safe-area-inset-right)); padding-top:max(6px, env(safe-area-inset-top)); }
  #game #turnInfo { order:1; flex:1 1 0; min-width:0; font-size:14px; line-height:1.15; }
  #game #turnInfo span { min-width:0; overflow-wrap:anywhere; }
  #game #top .spacer { display:none; }
  #game #menuBtn { order:2; min-height:36px; padding:4px 12px; font-size:13px; }
  #game #endBtn { order:3; min-height:36px; padding:4px 14px; font-size:14px; }
  #game #resInfo { order:4; flex:1 1 100%; flex-wrap:wrap; gap:6px; }
  #game .pill { font-size:13px; padding:2px 8px; }
  #game kbd { display:none; }
  #game main { flex-direction:column; }
  #game #side { flex:none; width:100%; height:clamp(150px, 28vh, 250px); height:clamp(150px, 28dvh, 250px); border-left:0; }
  #game .tabs { padding:5px 6px; flex:none; } #game .tabs button { min-height:40px; }
  #game #panel { padding:4px 10px 8px; }
  #game footer { padding:5px 10px max(6px, env(safe-area-inset-bottom)); padding-left:max(10px, env(safe-area-inset-left)); padding-right:max(10px, env(safe-area-inset-right)); font-size:13px; }
  #game #log { height:36px; }
}
@media (max-width: 760px) and (max-height: 740px) { #game #log { display:none; } #game #side { height:clamp(140px, 27vh, 200px); height:clamp(140px, 27dvh, 200px); } }
@media (min-width: 761px) { #mapCtl { right:12px; bottom:12px; } }
@media (max-width: 350px) {
  #game #turnInfo { font-size:13px; gap:5px; } #game .crestmini { width:26px; height:26px; }
  #game #menuBtn { padding:4px 8px; font-size:12px; } #game #endBtn { padding:4px 10px; font-size:13px; }
  #game .pill { font-size:12px; padding:2px 7px; }
}

/* ================= How to play book (src/howto.js): paged, parchment, phone-first ================= */
#howto { z-index:20; background:rgba(22,12,6,.86); align-items:center; justify-content:center; padding:max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
.hw-card-main { position:relative; width:100%; max-width:640px; height:100%; max-height:920px; display:flex; flex-direction:column; background:var(--parch) center/cover, var(--paper); border:3px solid var(--gold); border-radius:14px; box-shadow:inset 0 0 0 2px var(--goldDark), inset 0 0 0 5px #f8edcf, inset 0 0 28px #b8892f66, 0 12px 28px #000a; overflow:hidden; color:var(--ink); }
.hw-head { display:flex; align-items:center; gap:8px; padding:12px 12px 8px 14px; border-bottom:2px solid #b8924a88; flex:none; }
.hw-titlebox { display:flex; align-items:center; gap:8px; flex:1; min-width:0; }
.hw-ico-big { font-size:26px; line-height:1; }
.hw-head h2 { margin:0; font-size:clamp(18px, 5.4vw, 26px); line-height:1.1; }
.hw-count { font-family:var(--display); font-weight:800; font-size:13px; color:var(--ink2); white-space:nowrap; }
.hw-x { order:3; width:40px; height:40px; padding:0; border-radius:50%; font-size:18px; flex:none; }
.hw-body { flex:1; overflow-y:auto; overflow-x:hidden; -webkit-overflow-scrolling:touch; padding:10px 16px 16px; font-size:16px; line-height:1.42; outline:none; }
.hw-body h3 { font-family:var(--display); font-weight:800; color:var(--wine); font-size:17px; margin:14px 0 6px; }
.hw-body h4 { font-family:var(--display); font-weight:800; margin:0 0 6px; color:var(--royal); }
.hw-body p { margin:6px 0; } .hw-body ul, .hw-body ol { margin:6px 0; padding-left:22px; } .hw-body li { margin:3px 0; }
.hw-small { font-size:13.5px; opacity:.85; }
.hw-tip { background:#fff3c4; border:2px dashed var(--gold); border-radius:10px; padding:8px 10px; margin:10px 0; }
.hw-hero { display:block; width:100%; height:150px; object-fit:cover; object-position:center 30%; border-radius:10px; border:3px solid var(--gold); box-shadow:0 0 0 1px var(--goldDark), 0 4px 10px #0004; margin-bottom:8px; }
.hw-wins { display:grid; grid-template-columns:repeat(3,1fr); gap:8px; margin:8px 0; }
.hw-win { background:#fff8de; border:2px solid var(--gold); border-radius:12px; padding:8px 6px; text-align:center; box-shadow:0 2px 0 var(--goldDark); }
.hw-win span { font-size:30px; display:block; } .hw-win b { font-family:var(--display); color:var(--wine); display:block; } .hw-win small { display:block; font-size:12.5px; line-height:1.25; margin-top:2px; }
.hw-toc { display:flex; flex-wrap:wrap; gap:6px; } .hw-toc button { font-size:13px; padding:5px 9px; min-height:36px; }
.hw-cards { display:grid; grid-template-columns:1fr 1fr; gap:6px; }
.hw-card { display:flex; align-items:center; gap:8px; background:#fff8de; border:1.5px solid #b8924a; border-radius:10px; padding:5px 7px; }
.hw-card small { display:block; font-size:12.5px; opacity:.85; line-height:1.2; }
.hw-badge { width:44px; height:44px; border-radius:8px; overflow:hidden; border:2px solid var(--gold); flex:none; } .hw-tile, .hw-badge img { width:100%; height:100%; object-fit:cover; display:block; }
.hw-mini { width:24px; height:24px; border-radius:5px; object-fit:cover; vertical-align:middle; border:1.5px solid var(--gold); margin-right:3px; }
.hw-map { display:grid; grid-template-columns:repeat(7,1fr); gap:2px; max-width:420px; margin:8px auto; }
.hw-cell { position:relative; aspect-ratio:1; border-radius:5px; overflow:hidden; border:1.5px solid #8a6a2c88; background:#d4c093; }
.hw-cell.fog { background:#d4c093 radial-gradient(circle,#fff6dc99 0 12%,transparent 13%); }
.hw-cell.dim::after { content:""; position:absolute; inset:0; background:rgba(120,88,48,.45); }
.hw-cellimg { width:100%; height:100%; object-fit:cover; display:block; } .hw-cellunit { position:absolute; inset:12%; width:76%; height:76%; border-radius:50%; border:2px solid var(--gold); object-fit:cover; background:#f1dfa6; }
.hw-t { width:100%; border-collapse:collapse; margin:6px 0; font-size:14.5px; } .hw-t th { text-align:left; font-family:var(--display); color:var(--wine); } .hw-t td, .hw-t th { padding:5px 6px; border-bottom:1px solid #7a54124a; vertical-align:top; }
.hw-wide { font-size:13.5px; }
.hw-formula { display:grid; grid-template-columns:repeat(3,1fr); gap:6px; margin:8px 0; } .hw-formula.one { grid-template-columns:1fr; }
.hw-formula div { background:#fff8de; border:2px solid var(--gold); border-radius:12px; padding:8px; text-align:center; } .hw-formula b { display:block; font-family:var(--display); color:var(--wine); font-size:17px; } .hw-formula small { display:block; font-size:12.5px; line-height:1.25; }
.hw-formula.big b { font-size:21px; }
.hw-row { display:flex; align-items:center; gap:10px; margin-bottom:6px; } .hw-ico { width:46px; height:46px; border-radius:10px; border:2px solid var(--gold); object-fit:cover; vertical-align:middle; margin-right:4px; background:#e9d08a; }
.hw-portrait { width:64px; height:64px; border-radius:12px; border:3px solid var(--gold); box-shadow:0 0 0 1px var(--goldDark), 0 3px 6px #0005; object-fit:cover; background:#e9d08a; flex:none; }
.hw-units { display:grid; gap:8px; } .hw-unit { display:flex; gap:10px; align-items:flex-start; background:#fff8de; border:1.5px solid #b8924a; border-radius:12px; padding:8px; } .hw-unit.big .hw-portrait { width:84px; height:84px; }
.hw-unit small { font-size:13.5px; } .hw-stats { font-size:14px; margin:2px 0; letter-spacing:.2px; }
.hw-cost { font-family:var(--display); font-weight:800; font-size:13px; background:#0000000f; border-radius:999px; padding:1px 8px; }
.hw-need { font-size:12px; background:#f7dc82; border-radius:6px; padding:1px 6px; } .hw-need.ok { background:#c9ecb4; }
.hw-tree { display:grid; grid-template-columns:1fr; gap:8px; } .hw-branch { background:#fff8de; border:2px solid var(--gold); border-radius:12px; padding:8px 10px; }
.hw-tech { padding:4px 0; border-top:1px solid #7a54122a; } .hw-tech:first-of-type { border-top:0; } .hw-tech small { display:block; font-size:13px; } .hw-tech em { font-size:12px; color:var(--ink2); }
.hw-calc { background:#fff8de; border:2px solid var(--gold); border-radius:12px; padding:8px 10px; margin:8px 0; } .hw-calcrow { display:flex; align-items:center; gap:6px; flex-wrap:wrap; font-size:13.5px; } .hw-calcrow .hw-ico { width:34px; height:34px; margin:0; } .hw-calcline { margin:2px 0 8px 2px; font-size:15px; }
.hw-realms { display:grid; gap:6px; } .hw-realm { display:flex; gap:10px; align-items:center; background:#fff8de; border:1.5px solid #b8924a; border-radius:12px; padding:6px 8px; } .hw-realm img { width:52px; height:52px; border-radius:50%; border:3px solid var(--gold); object-fit:cover; flex:none; } .hw-realm span { font-size:13.5px; } .hw-realm small { opacity:.75; font-style:italic; }
.hw-tips li { margin:6px 0; } .hw-end { text-align:center; font-family:var(--display); font-weight:800; color:var(--wine); font-size:18px; margin-top:14px; }
.hw-video { width:100%; max-height:60vh; border-radius:10px; border:3px solid var(--gold); background:#000; margin-top:8px; } .hw-video-btn { width:100%; }
.hw-foot { display:flex; align-items:center; gap:8px; padding:8px 10px calc(8px + env(safe-area-inset-bottom)); border-top:2px solid #b8924a88; flex:none; background:linear-gradient(180deg,#f6e9c800,#ead7a6aa); }
.hw-foot button { min-height:48px; min-width:84px; font-size:15px; }
.hw-dots { flex:1; display:flex; justify-content:center; flex-wrap:wrap; gap:0; max-width:330px; margin:0 auto; }
.hw-dot { width:22px; height:30px; padding:0; border:0; background:none; box-shadow:none; position:relative; }
.hw-dot::after { content:""; position:absolute; left:50%; top:50%; width:9px; height:9px; margin:-4.5px; border-radius:50%; background:#8a6a2c66; border:1px solid #7a5412; }
.hw-dot.on::after { background:var(--wine); transform:scale(1.35); }
@media (max-width:400px) { .hw-wins { grid-template-columns:1fr; } .hw-win { display:grid; grid-template-columns:44px 1fr; text-align:left; align-items:center; column-gap:8px; } .hw-win span { grid-row:span 2; text-align:center; } .hw-cards { grid-template-columns:1fr; } .hw-formula { grid-template-columns:1fr; } .hw-dots { display:none; } .hw-foot button { flex:1; } .hw-hero { height:120px; } .hw-body { padding:8px 12px 14px; font-size:15.5px; } }
@media (min-width:700px) { .hw-tree { grid-template-columns:1fr 1fr 1fr; } .hw-units { grid-template-columns:1fr 1fr; } .hw-cards { grid-template-columns:1fr 1fr 1fr; } }

.hw-bigicon { width:56px; height:56px; border-radius:12px; border:3px solid var(--gold); background:#e9d08a; font-size:30px; display:flex; align-items:center; justify-content:center; flex:none; }

/* ---- audio controls (start screen + in-game Menu) ---- */
.audiobox { display:block; }
.audiopanel { display:grid; gap:8px; width:100%; }
.audrow { display:flex; align-items:center; gap:10px; min-width:0; }
.audrow .audtog { flex:0 0 48px; width:48px; height:48px; min-height:48px; padding:0; border-radius:12px; font-size:22px; line-height:1; display:grid; place-items:center; }
.audrow .audtog.off { opacity:.65; filter:grayscale(.6); }
.audrow .audlbl { flex:0 0 auto; min-width:58px; font-weight:800; font-size:15px; }
.audrow input[type=range] { flex:1 1 auto; min-width:0; width:100%; height:32px; margin:0; accent-color:#b8792a; }
.audrow.off .audlbl { opacity:.6; }
#menuAudio { margin:6px 0 4px; }
#menuAudio .audtog { background:#f7e7b4; border:2px solid #b8924a; color:#3b2410; }

/* ---- trophy shelf ---- */
.shelfbox { display:block; }
.shelfbox .lbl { display:block; margin-bottom:6px; }
.shelf { display:grid; grid-template-columns:repeat(3, minmax(0, 1fr)); gap:8px; align-items:stretch; padding:10px 6px 8px; border-radius:12px; background:linear-gradient(180deg, #5a3a1c18, #5a3a1c33); border-bottom:6px solid #8a5a24; box-shadow:inset 0 -3px 0 #5a3512; }
.shelf .slot { display:flex; flex-direction:column; align-items:center; text-align:center; gap:2px; min-width:0; }
.shelf .slot img { width:64px; height:64px; object-fit:contain; filter:grayscale(1) brightness(.55) contrast(.9); opacity:.55; }
.shelf .slot.won img { filter:drop-shadow(0 2px 5px #8a5a24aa); opacity:1; }
.shelf .slot b { font-size:12px; line-height:1.15; font-family:var(--display); }
.shelf .slot .cnt { font-weight:900; font-size:15px; color:#8a1f16; }
.shelf .slot small { font-size:11px; line-height:1.2; opacity:.85; }
.shelf .slot:not(.won) b, .shelf .slot:not(.won) small { opacity:.65; }

/* ---- win screen prize ---- */
.prize { text-align:center; margin:6px 0 10px; }
.prize img { display:block; margin:0 auto; width:150px; height:150px; object-fit:contain; filter:drop-shadow(0 4px 10px #b8860bcc); animation:trophyPop .7s cubic-bezier(.2,1.4,.4,1) both; }
.prize .prizename { font-family:var(--display); font-weight:900; font-size:20px; color:var(--wine); margin-top:2px; }
.prize small { display:block; opacity:.85; }
@keyframes trophyPop { from { transform:scale(.3) rotate(-12deg); opacity:0; } to { transform:scale(1) rotate(0); opacity:1; } }
@media (prefers-reduced-motion: reduce) { .prize img { animation:none; } }
@media (max-height:700px) { .prize img { width:112px; height:112px; } }

/* ================= Story tutorial: Lumi the Lantern Owl ================= */
#guide { display:none; }
#game.tut #guide { display:block; }
#game.tut #hint, #game.tut #log { display:none !important; }
#game.tut footer { padding-top:6px; }
#game canvas.lumi { position:relative; left:auto; top:auto; border:3px solid var(--gold); border-radius:50%; touch-action:manipulation; }
.lumi { display:block; border-radius:50%; flex:none; box-shadow:0 0 0 2px var(--goldDark), 0 3px 8px #0004; background:#f6e3a0; }
#guide .gbody { display:flex; gap:10px; align-items:stretch; height:142px; }
#guide .gface { width:60px; height:60px; margin-top:4px; cursor:pointer; }
#guide .gbubble { position:relative; flex:1; min-width:0; display:flex; flex-direction:column; gap:2px; padding:5px 8px 6px; border-radius:12px; background:#fffaf0; border:2px solid var(--gold); box-shadow:0 2px 0 var(--goldDark), 0 4px 8px #7a541233; color:var(--ink); }
#guide .gbubble::before { content:""; position:absolute; left:-10px; top:20px; border:8px solid transparent; border-right:9px solid var(--gold); border-left:0; }
#guide .gbubble::after { content:""; position:absolute; left:-6px; top:21px; border:7px solid transparent; border-right:8px solid #fffaf0; border-left:0; }
#guide .grow { display:flex; align-items:center; gap:6px; min-width:0; }
#guide .ggoal { flex:1; min-width:0; font:800 11.5px/1.2 var(--display); color:var(--wine); max-height:28px; overflow:hidden; }
#guide .gico { flex:none; width:36px; height:30px; padding:0; font-size:16px; line-height:1; border-radius:8px; }
#guide .gico.off { opacity:.6; }
#guide .gsay { flex:1; min-height:0; overflow:auto; font-size:14.5px; line-height:1.28; }
#guide .gactrow { min-height:38px; }
#guide .gdo { flex:1; min-width:0; font-weight:800; font-size:13.5px; line-height:1.2; color:#1d6b3a; }
#guide .goodbtn { margin-left:auto; min-height:38px; padding:6px 16px; font-size:15px; background:linear-gradient(180deg,#58b46f,#2b7d47); color:#fff; border-color:#124d27; text-shadow:0 1px 0 #0006; }
#guide.nudge .gbubble { animation:tutshake .45s; border-color:#c62828; }
#tutRing { position:absolute; z-index:2; pointer-events:none; border:4px solid #ffd34d; border-radius:10px; box-shadow:0 0 0 2px #fff, 0 0 14px 4px rgba(255,200,40,.9), inset 0 0 10px rgba(255,220,100,.7); animation:tutpulse 1.1s ease-in-out infinite; }
#tutRing::after { content:""; position:absolute; left:50%; top:-24px; margin-left:-10px; border:10px solid transparent; border-top:14px solid #ffd34d; border-bottom:0; filter:drop-shadow(0 1px 0 #7a5412); animation:tutbob .9s ease-in-out infinite; }
#tutRing.below::after { top:auto; bottom:-24px; border-top:0; border-bottom:14px solid #ffd34d; border-left:10px solid transparent; border-right:10px solid transparent; }
#tutRing.shake { animation:tutshake .45s, tutpulse 1.1s ease-in-out infinite; }
.tutglow { box-shadow:0 0 0 3px #ffd34d, 0 0 14px 5px rgba(255,190,40,.95) !important; animation:tutglow 1s ease-in-out infinite; position:relative; z-index:1; }
@keyframes tutpulse { 0%,100% { transform:scale(1); } 50% { transform:scale(1.07); } }
@keyframes tutbob { 0%,100% { transform:translateY(0); } 50% { transform:translateY(5px); } }
@keyframes tutglow { 0%,100% { filter:brightness(1); } 50% { filter:brightness(1.18); } }
@keyframes tutshake { 0%,100% { transform:translateX(0); } 20% { transform:translateX(-5px); } 40% { transform:translateX(5px); } 60% { transform:translateX(-3px); } 80% { transform:translateX(3px); } }
.tuthead { display:flex; gap:12px; align-items:center; margin-bottom:6px; } .tuthead h2 { margin:0 0 2px; } .tuthead p { margin:0; }
.lumisays { font-style:italic; font-size:17px; line-height:1.35; margin:6px 2px 4px; } .tutdone { margin:6px 2px; }
.lvls { display:grid; gap:8px; margin:8px 0; }
button.lvl { display:flex; align-items:center; gap:10px; width:100%; text-align:left; padding:8px 10px; min-height:54px; background:linear-gradient(180deg,#f3e6c2,#d9c28a); border-color:#8a6a2c; font-family:var(--serif); }
button.lvl.next { background:linear-gradient(180deg,#ffe9a0,#f0c04a); border-color:var(--goldDark); }
button.lvl .lnum { flex:none; width:32px; height:32px; border-radius:50%; background:var(--wine); color:#ffeab0; display:flex; align-items:center; justify-content:center; font:800 16px var(--display); }
button.lvl.done .lnum { background:var(--good); } button.lvl.locked .lnum { background:#8a7a5a; }
button.lvl .ltxt { flex:1; min-width:0; } button.lvl .ltxt b { display:block; font:800 15px var(--display); } button.lvl .ltxt small { display:block; font-weight:400; font-size:12.5px; opacity:.85; }
button.lvl .lgo { flex:none; font:800 13px var(--display); color:var(--wine); }
@media (min-width:761px) { #guide .gbody { height:112px; } #guide .gface { width:76px; height:76px; } #guide .gsay { font-size:15.5px; } }
@media (max-width:760px) and (max-height:700px) { #guide .gbody { height:130px; } #guide .gsay { font-size:14px; } }

/* ================= Blackspire event banner ================= */
#evBanner { position:absolute; z-index:3; left:8px; top:8px; display:flex; align-items:center; gap:8px; max-width:calc(100% - 16px); pointer-events:none; background:linear-gradient(180deg,#fff7de,#f1dca0); border:2px solid var(--gold); border-radius:12px; box-shadow:0 3px 10px #0005, inset 0 0 0 1px #fff9; color:var(--ink); }
#evBanner.full { right:8px; padding:8px 12px; animation:evin .4s ease-out; }
#evBanner.chip { padding:3px 10px 3px 8px; font-size:13px; }
#evBanner .evico { font-size:30px; line-height:1; flex:none; } #evBanner.chip .evico { font-size:16px; }
#evBanner .evtxt b { display:block; font:800 15px/1.2 var(--display); color:var(--wine); } #evBanner.chip .evtxt b { display:inline; font-size:13px; }
#evBanner .evtxt small { display:block; font-size:12.5px; line-height:1.25; }
@keyframes evin { from { transform:translateY(-14px); opacity:0; } to { transform:none; opacity:1; } }
@media (max-width:760px) { #evBanner.full { max-width:none; } }
@media (prefers-reduced-motion: reduce) { #tutRing, #tutRing::after, .tutglow, #evBanner.full, #guide.nudge .gbubble { animation:none !important; } }
.tuthead .hear { flex:none; width:44px; height:44px; margin-left:auto; padding:0; font-size:20px; line-height:1; border-radius:50%; }

/* ---- Full Unlock box (start screen), Game Center row ---- */
.unlockbox { display:block; background:#fff8de; border:2px solid var(--gold); border-radius:12px; padding:10px 12px; box-shadow:0 2px 0 var(--goldDark); }
.unlockbox .ub-line { margin:0 0 8px; font-weight:700; }
.unlockbox .ub-btns { display:flex; flex-wrap:wrap; gap:8px; }
.unlockbox .ub-btns button { min-height:44px; }
.unlockbox .ub-msg { margin:8px 0 0; min-height:1.2em; font-size:14px; color:var(--ink2); }
.gcrow { display:flex; flex-wrap:wrap; align-items:center; gap:6px 10px; margin-top:10px; font-size:14px; }
.gcrow .gc-txt { flex:1 1 180px; min-width:0; }
.gcrow button { min-height:40px; }

/* ---- Paywall ---- */
.pw { position:fixed; inset:0; z-index:60; display:flex; align-items:center; justify-content:center; background:rgba(22,12,6,.82); padding:max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); overflow-y:auto; -webkit-overflow-scrolling:touch; }
.pw-card { width:100%; max-width:440px; max-height:100%; overflow-y:auto; background:var(--parch) center/cover, var(--paper); border:3px solid var(--gold); border-radius:16px; box-shadow:0 0 0 2px var(--goldDark), 0 10px 30px #000a; padding:0 16px 16px; text-align:center; color:var(--ink); }
.pw-art { display:block; width:calc(100% + 32px); margin:0 -16px 8px; height:130px; object-fit:cover; object-position:center 25%; border-bottom:3px solid var(--gold); border-radius:13px 13px 0 0; }
.pw-card h2 { font-family:var(--display); font-weight:800; color:var(--wine); margin:6px 0 6px; font-size:clamp(22px, 6.5vw, 28px); }
.pw-lead { margin:6px 0 10px; font-size:17px; line-height:1.4; }
.pw-list { list-style:none; margin:8px 0; padding:0; text-align:left; display:grid; gap:6px; }
.pw-list li { background:#fff8de; border:1.5px solid #b8924a; border-radius:10px; padding:8px 10px; font-size:16px; font-weight:700; }
.pw-fine { font-size:13px; opacity:.85; margin:8px 0; line-height:1.35; }
.pw-dev { font-style:italic; }
.pw-btns { display:flex; flex-wrap:wrap; gap:8px; justify-content:center; margin:10px 0 4px; }
.pw-btns button { min-height:48px; }
.pw-btns.small button { min-height:44px; }
.pw-q { font-family:var(--display); font-weight:800; font-size:30px; margin:10px 0; color:var(--royal); }
.pw-input { width:140px; font:inherit; font-size:28px; text-align:center; padding:8px; border:3px solid var(--goldDark); border-radius:10px; background:#fffdf3; color:var(--ink); }
.pw-status { min-height:1.3em; margin:8px 0 0; font-size:15px; font-weight:700; color:var(--ink2); }
.pw-status.bad { color:var(--bad); }

/* ---- iOS app (Capacitor adds html.native): no text selection or callouts on game chrome, no rubber-band bounce, no tap flash ---- */
html.native, html.native body { overscroll-behavior:none; -webkit-touch-callout:none; -webkit-tap-highlight-color:transparent; touch-action:manipulation; }
html.native body { -webkit-user-select:none; user-select:none; position:fixed; inset:0; width:100%; }
html.native input { -webkit-user-select:text; user-select:text; }
html.native .proto { display:none; }
/* wide screens in the app (iPad portrait): the 760px rules above do not apply, so keep the header clear of the status bar and the footer clear of the home indicator */
html.native #game #top { padding-top:max(8px, env(safe-area-inset-top)); padding-left:max(12px, env(safe-area-inset-left)); padding-right:max(12px, env(safe-area-inset-right)); }
html.native #game footer { padding-bottom:max(6px, env(safe-area-inset-bottom)); }

/* ---- seasonal themes (src/seasons.js): edges and panel borders only, never over map squares ---- */
html[data-season] #game #top, html[data-season] #side { border-color: var(--season-a); }
html[data-season] #game #top { background: linear-gradient(180deg, var(--season-b) 0%, #e8d3a0 100%); }
html[data-season] #endBtn { box-shadow: 0 0 0 2px var(--season-a); }
.season-strip { position:absolute; left:0; right:0; height:22px; display:flex; justify-content:space-around; align-items:center; pointer-events:none; z-index:3; overflow:hidden; }
.season-strip svg { width:20px; height:20px; flex:none; filter: drop-shadow(0 1px 1px #0003); }
.season-strip-bottom { bottom:-13px; }
#side { position:relative; }
.season-strip-top { top:-11px; }
#setup { position:relative; }
.season-strip-setup { top:0; opacity:.9; }
.season-badge { background:var(--season-a); color:#fff; font:700 12px/1 system-ui, sans-serif; padding:4px 8px; border-radius:10px; white-space:nowrap; pointer-events:none; box-shadow:0 1px 3px #0003; }
.season-garland { position:absolute; left:0; right:0; bottom:-4px; height:8px; pointer-events:none; z-index:3; background: radial-gradient(circle,#ffd54a 2.5px,transparent 3.5px) 0 0/20px 8px, radial-gradient(circle,#7fd0ff 2.5px,transparent 3.5px) 10px 0/20px 8px; }
.season-corner { position:fixed; bottom:max(2px, env(safe-area-inset-bottom)); z-index:4; pointer-events:none; opacity:.95; }
.season-corner-l { left:2px; } .season-corner-r { right:2px; }
.season-fx { position:absolute; inset:0; width:100%; height:100%; pointer-events:none; z-index:1; }
.seasonctl { display:flex; align-items:center; gap:8px; margin-top:8px; font-size:14px; }
.seasonctl select { min-height:36px; font-size:15px; }
@media (max-width: 600px) { .season-badge { font-size:14px; padding:3px 5px; } .season-badge .sb-txt { display:none; } }
.season-badge { flex:none; }
