@font-face { font-family: 'Overpass'; src: url('assets/font/Overpass.ttf') format('truetype'); font-weight: 100 900; }
@font-face { font-family: 'Molot'; src: url('assets/font/Molot.ttf') format('truetype'); }

:root {
  --teal: #00ddd9; --green: #279b39; --green2: #2bc04a; --blue: #1f8ef1; --blue-d: #1670c4; --red: #ef3b2f; --orange: #fb7000;
  --ink: #1d2733; --ink2: #2b3a4c; --gold: #e9b949; --gold-d: #b8860b; --paper: #ffffff; --line: #e6e9ee; --muted: #8a94a3; --bg: #eef1f5;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #10161f; font-family: 'Overpass', 'Avenir Next', 'Segoe UI', system-ui, sans-serif; color: var(--ink); }
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; padding: 0; }
img { -webkit-user-drag: none; user-select: none; }

#app { position: relative; max-width: 480px; height: 100vh; height: 100dvh; margin: 0 auto; background: var(--paper); display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 0 60px rgba(0,0,0,.5); }

/* ---------- top bar ---------- */
#topbar { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top));
  background: linear-gradient(180deg, #24364a, #17222f); color: #fff; border-bottom: 3px solid var(--gold); }
#topbar .brand { font-family: 'Molot', 'Overpass', sans-serif; font-size: 22px; letter-spacing: .5px; color: var(--gold); text-shadow: 0 2px 0 #000; display: flex; align-items: center; gap: 8px; }
#topbar .cn { font-family: 'STKaiti', 'KaiTi', 'Noto Serif SC', serif; font-size: 20px; background: #b3261e; color: #fff3d6; padding: 2px 6px; border-radius: 4px; text-shadow: none; }
#menuBtn { font-size: 24px; width: 36px; height: 36px; color: #fff; }
#helpBtn img { width: 30px; height: 30px; filter: invert(1) brightness(1.2); opacity: .9; }

/* ---------- character bar ---------- */
#charbar { flex: none; display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: #fff; border-bottom: 1px solid var(--line); cursor: pointer; position: relative; }
#charbar.prison { background: url(assets/img/heroBarPrison.png) center/120px repeat; }
#charbar.prison::after { content: ''; position: absolute; inset: 0; background: url(assets/img/heroBarPrisonBars.png) center/auto 100% repeat-x; opacity: .85; pointer-events: none; }
#charbar.demonic { background: #2a0e14 url(assets/img/heroBarVampire.png) center/110px repeat; color: #ffd5d5; }
#charbar.demonic #csub { color: #ff9a9a; }
#cname { font-weight: 800; font-size: 19px; position: relative; z-index: 1; }
#csub { font-size: 13px; color: var(--muted); font-weight: 600; position: relative; z-index: 1; }
.money { text-align: right; font-weight: 800; font-size: 15px; position: relative; z-index: 1; }
#cstones { color: #138a8a; } #csilver { color: #8a6d12; font-size: 13px; }
#charbar.demonic #cstones { color: #7ff; } #charbar.demonic #csilver { color: #fd6; }

#cultbar { flex: none; padding: 6px 14px 8px; background: linear-gradient(180deg, #fff9e9, #fff3d1); border-bottom: 1px solid #f0dfae; cursor: pointer; }
.cb-top { display: flex; justify-content: space-between; font-size: 13px; color: #6b5310; }
.cb-top b { color: #3e2f05; }
.bn { background: var(--red); color: #fff; font-size: 10px; font-weight: 800; padding: 1px 5px; border-radius: 3px; vertical-align: 1px; animation: pulse 1.2s infinite; }
.cb-bar { position: relative; height: 12px; margin-top: 4px; background: #eadbb2; border-radius: 7px; overflow: hidden; }
.cb-bar i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #f7c948, #e09a00); border-radius: 7px; transition: width .5s; }
.cb-bar span { position: absolute; right: 6px; top: -1px; font-size: 10px; font-weight: 800; color: #5a4300; }

/* ---------- log ---------- */
#log { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 16px 20px; background: #fff; -webkit-overflow-scrolling: touch; }
.yr { padding: 8px 0 6px; border-bottom: 1px solid #f1f3f6; }
.yr .age { font-weight: 800; color: var(--blue); font-size: 15px; margin-bottom: 2px; }
.yr p { margin: 3px 0; font-size: 14.5px; line-height: 1.38; color: #2a3340; }
.yr p.good { color: #1b8a32; } .yr p.bad { color: #c62a20; } .yr p.gold { color: #a87400; font-weight: 700; }

/* ---------- toolbar ---------- */
#toolbar { flex: none; display: flex; align-items: flex-end; justify-content: space-around; padding: 6px 4px 4px; background: #fff; border-top: 1px solid var(--line); position: relative; }
.tb { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 70px; }
.tb-ico { width: 46px; height: 46px; display: flex; align-items: center; justify-content: center; }
.tb-ico img { width: 46px; height: 46px; }
.tb-circle { width: 46px; height: 46px; border-radius: 50%; background: var(--teal); display: flex; align-items: center; justify-content: center; font-size: 24px; box-shadow: inset 0 -3px 0 rgba(0,0,0,.12); }
.tb-circle.orange { background: var(--orange); border: 3px solid #fff; box-shadow: 0 0 0 2px var(--orange); width: 44px; height: 44px; }
.tb-lbl { font-size: 11px; font-weight: 700; color: #4a5562; }
.tb:active .tb-ico { transform: scale(.92); }
.tb.age { width: 92px; margin-top: -30px; }
.tb.age img { width: 92px; height: 92px; filter: drop-shadow(0 3px 4px rgba(0,0,0,.25)); }
.tb.age img.bump { animation: agepop .35s; }
@keyframes agepop { 40% { transform: scale(.86); } 100% { transform: scale(1); } }
body.dead .tb:not(.age) { opacity: .35; }

/* ---------- stats ---------- */
#stats { flex: none; padding: 6px 14px; padding-bottom: max(8px, env(safe-area-inset-bottom)); background: #f7f8fa; border-top: 1px solid var(--line); }
.stat { display: grid; grid-template-columns: 104px 22px 1fr 40px; align-items: center; gap: 6px; height: 23px; font-size: 13px; }
.st-n { font-weight: 700; color: #3a4552; text-align: right; }
.st-e { font-size: 15px; text-align: center; }
.st-bar { height: 13px; background: #dfe3e8; border-radius: 7px; overflow: hidden; }
.st-bar i { display: block; height: 100%; border-radius: 7px; transition: width .4s, background .4s; }
.st-v { font-weight: 800; color: #3a4552; font-size: 12px; }

/* ---------- sheets ---------- */
#sheets { position: absolute; inset: 0; z-index: 20; pointer-events: none; }
#sheets.open { pointer-events: auto; }
.sheet { position: absolute; inset: 0; background: var(--bg); display: flex; flex-direction: column; animation: slidein .2s ease-out; }
@keyframes slidein { from { transform: translateX(30px); opacity: .4; } }
.sheet-head { flex: none; display: flex; align-items: center; padding: 10px 10px; padding-top: max(10px, env(safe-area-inset-top)); background: linear-gradient(180deg, #24364a, #17222f); color: #fff; border-bottom: 3px solid var(--gold); }
.sheet-head .back { display: flex; align-items: center; gap: 4px; height: 34px; padding: 0 12px 0 6px; border-radius: 17px; background: var(--teal); color: #fff; font-weight: 800; font-size: 15px; box-shadow: inset 0 -3px 0 rgba(0,0,0,.15); }
.sheet-head .back img { height: 20px; display: block; }
.sheet-title { flex: 1; text-align: center; font-weight: 800; font-size: 18px; }
.sheet-sp { width: 76px; }
.sheet-banner { flex: none; padding: 10px 14px; background: #fff8e1; border-bottom: 1px solid #f0dfae; font-weight: 700; font-size: 14px; color: #5c4600; }
.sheet-banner small { font-weight: 600; color: #8a7230; }
.sheet-banner.prisonban { background: #3a3f46; color: #fff; }
.sheet-body { flex: 1; overflow-y: auto; padding-bottom: 30px; }
.sec-h { padding: 14px 16px 6px; font-size: 12px; font-weight: 800; letter-spacing: .8px; text-transform: uppercase; color: var(--blue); }
.sec-note { padding: 8px 16px; font-size: 13px; color: var(--muted); }
.row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 11px 14px; background: #fff; border-bottom: 1px solid var(--line); min-height: 56px; }
.row:active { background: #eef6ff; }
.row.dis { opacity: .45; }
.row.hot { background: linear-gradient(90deg, #fff4e0, #fff); }
.row-e { font-size: 26px; width: 34px; text-align: center; flex: none; }
.row-img { width: 58px; height: auto; flex: none; border-radius: 4px; }
.row-mid { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.row-t { font-weight: 700; font-size: 15px; }
.row-t small { color: var(--muted); font-weight: 600; }
.row-sub { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.row-r { font-weight: 800; font-size: 13px; color: #138a8a; white-space: nowrap; }
.chev { color: #c3c9d1; font-size: 26px; line-height: 1; }
.mini-bar { display: block; height: 7px; background: #e3e7ec; border-radius: 4px; margin-top: 5px; overflow: hidden; max-width: 180px; }
.mini-bar i { display: block; height: 100%; border-radius: 4px; }

/* ---------- popups ---------- */
#popups { position: absolute; inset: 0; z-index: 50; pointer-events: none; }
#popups:not(:empty) { pointer-events: auto; }
.pop-back { position: absolute; inset: 0; background: rgba(10,15,22,.55); animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.pop { position: absolute; left: 16px; right: 16px; top: 50%; transform: translateY(-50%); max-height: calc(100% - 40px); display: flex; flex-direction: column; background: #fff; border-radius: 14px; overflow: hidden; box-shadow: 0 12px 40px rgba(0,0,0,.4); animation: popin .22s cubic-bezier(.2,1.4,.5,1); }
@keyframes popin { from { transform: translateY(-50%) scale(.85); opacity: 0; } }
.pop-head { padding: 12px 44px; text-align: center; font-weight: 800; font-size: 17px; color: #fff; background: var(--blue); min-height: 44px; }
.tone-red .pop-head { background: var(--red); } .tone-green .pop-head { background: var(--green2); }
.tone-gold .pop-head { background: linear-gradient(90deg, #c98a00, #f2c230, #c98a00); color: #3a2a00; }
.pop-x { position: absolute; right: 6px; top: 4px; } .pop-x img { width: 36px; }
.pop-body { padding: 16px 18px 6px; text-align: center; overflow-y: auto; }
.pop-emoji { font-size: 54px; line-height: 1.1; margin-bottom: 6px; }
.pop-img { max-width: 140px; max-height: 90px; margin-bottom: 8px; }
.pop-text { font-size: 15.5px; line-height: 1.45; color: #2a3340; text-align: center; }
.pop-choices { padding: 10px 14px 14px; display: flex; flex-direction: column; gap: 8px; }
.choice { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 11px 12px; border-radius: 10px; background: var(--blue); color: #fff; font-weight: 800; font-size: 15px; box-shadow: inset 0 -3px 0 var(--blue-d); }
.choice small { font-weight: 600; font-size: 12px; opacity: .85; }
.choice .cimg { height: 28px; }
.choice:active { transform: translateY(1px); box-shadow: inset 0 -1px 0 var(--blue-d); }
.choice:disabled { background: #c7ced8; box-shadow: none; opacity: .8; }
.choice.gray { background: #8f9aa8; box-shadow: inset 0 -3px 0 #6f7a88; }
.choice.ok { background: var(--green2); box-shadow: inset 0 -3px 0 #1d8a37; }
.choice.win { background: var(--green2); } .choice.lose { background: var(--red); box-shadow: inset 0 -3px 0 #a3241b; }

/* fight */
.fighters { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 4px; }
.fighter { width: 40%; text-align: center; }
.f-emoji { font-size: 46px; }
.f-emoji.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px) rotate(-6deg); } 40%, 80% { transform: translateX(6px) rotate(6deg); } }
.f-name { font-weight: 800; font-size: 13px; }
.f-title { font-size: 11px; color: var(--muted); }
.f-pow { font-size: 11px; color: var(--muted); font-weight: 700; }
.vs { font-family: 'Molot', sans-serif; font-size: 26px; color: var(--red); }
.hp { height: 10px; background: #f3d0cd; border-radius: 5px; overflow: hidden; margin: 4px 0; }
.hp i { display: block; height: 100%; background: linear-gradient(90deg, #2bc04a, #8ee04a); transition: width .4s; }
.fight-log { margin: 6px 14px 0; height: 130px; overflow-y: auto; background: #f6f7f9; border-radius: 8px; padding: 6px 10px; }
.fl { font-size: 13px; padding: 3px 0; animation: fade .3s; }
.fl.me { color: #1b8a32; } .fl.foe { color: #c62a20; text-align: right; }

/* clock */
.clock { width: 120px; height: 120px; margin: 4px auto 10px; background: url(assets/img/clock_sheet.png) 0 0 / 960px 120px; animation: clock 1s steps(8) infinite; }
@keyframes clock { to { background-position: -960px 0; } }

/* ---------- fx ---------- */
#fx { position: absolute; inset: 0; z-index: 80; pointer-events: none; overflow: hidden; }
.toast { position: absolute; left: 50%; top: 120px; transform: translateX(-50%); background: rgba(20,28,38,.92); color: #fff; padding: 9px 16px; border-radius: 20px; font-weight: 700; font-size: 14px; white-space: nowrap; animation: toast 2.6s forwards; }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, -10px); } 10%, 85% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }
.confetti { position: absolute; top: -20px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }
.thumb { position: absolute; left: 50%; top: 40%; width: 128px; height: 128px; margin-left: -64px; animation: thumb 1.05s steps(12) forwards; }
.thumb.like { background: url(assets/img/like_sheet.png) 0 0 / 1536px 128px; }
.thumb.dislike { background: url(assets/img/dislike_sheet.png) 0 0 / 1536px 128px; }
@keyframes thumb { to { background-position: -1536px 0; } }
.tut-hand { position: absolute; z-index: 90; width: 60px; left: 50%; bottom: 120px; margin-left: 10px; pointer-events: none; animation: tap 1s infinite; }
@keyframes tap { 50% { transform: translateY(14px) scale(.95); } }
@keyframes pulse { 50% { opacity: .6; } }

/* ---------- overlay screens ---------- */
#overlay { position: absolute; inset: 0; z-index: 40; display: none; }
#overlay.open { display: block; }
.start { position: absolute; inset: 0; overflow-y: auto; padding: 40px 22px 30px; display: flex; flex-direction: column; gap: 12px;
  background: radial-gradient(circle at 50% 18%, #2e4a66 0, #17222f 60%, #0d131b 100%); color: #fff; }
.start.graves { padding: 0; gap: 0; background: var(--bg); color: var(--ink); }
.logo { text-align: center; margin: 10px 0 24px; }
.logo-cn { display: inline-block; font-family: 'STKaiti', 'KaiTi', 'Noto Serif SC', serif; font-size: 54px; background: #b3261e; color: #fff3d6; padding: 4px 16px; border-radius: 8px; box-shadow: 0 6px 0 #6e140f; }
.logo-en { font-family: 'Molot', sans-serif; font-size: 38px; color: var(--gold); margin-top: 18px; text-shadow: 0 3px 0 #000; }
.logo-sub { color: #9fb2c6; font-size: 14px; }
.big-btn { padding: 15px; border-radius: 12px; font-weight: 800; font-size: 17px; color: #fff; }
.big-btn.blue { background: var(--blue); box-shadow: inset 0 -4px 0 var(--blue-d); }
.big-btn.green { background: var(--green2); box-shadow: inset 0 -4px 0 #1d8a37; }
.custom { background: rgba(255,255,255,.07); border-radius: 12px; padding: 12px 14px; }
.custom summary { font-weight: 800; cursor: pointer; font-size: 16px; }
.custom label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 700; color: #9fb2c6; margin: 10px 0; text-transform: uppercase; letter-spacing: .5px; }
.custom input, .custom select { font: inherit; font-size: 15px; padding: 10px; border-radius: 8px; border: 0; background: #fff; color: var(--ink); text-transform: none; letter-spacing: 0; }
.custom .big-btn { width: 100%; margin-top: 6px; }
.link { color: #9fb2c6; font-weight: 700; padding: 10px; }

.death { position: absolute; inset: 0; overflow-y: auto; background: linear-gradient(180deg, #e9ecef, #cfd5dc); padding: 30px 18px 30px; text-align: center; }
.death.asc { background: linear-gradient(180deg, #fff6d6, #ffe08a 60%, #f7c948); }
.d-top { font-family: 'Molot', sans-serif; font-size: 26px; letter-spacing: 3px; color: #5d6670; }
.death.asc .d-top { color: #8a5d00; }
.d-stone { font-size: 76px; }
.d-name { font-size: 26px; font-weight: 800; }
.d-age { color: #5d6670; font-weight: 600; margin-bottom: 14px; }
.d-title { display: flex; align-items: center; gap: 12px; text-align: left; background: #fff; border-radius: 12px; padding: 10px 14px; box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.d-title img { width: 54px; } .d-title b { display: block; font-size: 18px; color: #a87400; } .d-title small { color: #5d6670; font-size: 13px; }
.d-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.d-grid div { background: #fff; border-radius: 10px; padding: 8px 10px; text-align: left; }
.d-grid span { display: block; font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; }
.d-grid b { font-size: 13.5px; }
.d-hist { text-align: left; background: rgba(255,255,255,.6); border-radius: 10px; padding: 10px 12px; font-size: 13px; color: #3a4552; margin-bottom: 10px; }
.d-cont { text-align: left; border-radius: 12px; overflow: hidden; margin-bottom: 10px; }
.d-cont .sec-h { background: #fff; }
.newlife img { width: 120px; filter: drop-shadow(0 4px 6px rgba(0,0,0,.3)); }
.newlife:active img { transform: scale(.94); }

@media (min-width: 481px) { #app { border-left: 1px solid #000; border-right: 1px solid #000; } }
@media (max-height: 640px) { .stat { height: 19px; } .tb-ico, .tb-ico img, .tb-circle { width: 40px; height: 40px; } .tb.age img { width: 80px; height: 80px; } }

/* ---------- v2 additions ---------- */
.brand .ver { font-size: 11px; background: #f5c400; color: #3a2a00; border-radius: 8px; padding: 1px 6px; margin-left: 4px; vertical-align: middle; }
.row.warn { background: linear-gradient(90deg, #ffe9e6, #fff); }
.row-html { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.codex { background: #fff; padding: 4px 16px 14px; font-size: 13.5px; line-height: 1.45; color: #222; }
.codex p { margin: 6px 0; }
.codex h4 { margin: 12px 0 4px; font-size: 14px; color: #1b6fd1; }
.codex table { width: 100%; border-collapse: collapse; margin: 6px 0 10px; font-size: 12.5px; }
.codex th, .codex td { border-bottom: 1px solid #e6e6e6; padding: 4px 6px; text-align: left; vertical-align: top; }
.codex th { background: #f3f6fb; font-weight: 700; }
.codex code { background: #f3f3f3; padding: 0 4px; border-radius: 4px; font-size: 12px; }
