:root { --ink: #1d1a24; --paper: #fffdf6; --bg: #efe6d4; --a: #ffcf3a; --b: #5ab0ff; --warm: #ff8a5a; --spooky: #5a4ab0; --action: #e83a3a; --adventure: #2a9a6a; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); font-family: "Huninn", "Comic Neue", "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", sans-serif; }
body { background-image: radial-gradient(rgba(29,26,36,.08) 1.2px, transparent 1.4px); background-size: 9px 9px; }
button { font: inherit; cursor: pointer; color: inherit; }
.btn { border: 3px solid var(--ink); border-radius: 12px; background: #fff; padding: 9px 16px; font-weight: 700; font-size: 16px; box-shadow: 4px 4px 0 var(--ink); transition: transform .06s; }
.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.btn.a { background: var(--a); } .btn.b { background: var(--b); } .btn.big { font-size: 20px; padding: 12px 22px; }
.btn.ghost { background: rgba(255,255,255,.6); box-shadow: none; border-width: 2px; }
.btn.sm { padding: 4px 12px; font-size: 18px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; align-items: center; }
.fine { font-size: 12px; opacity: .65; text-align: center; margin: 14px 8px; }

/* ---------- title ---------- */
.title { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 16px; }
.tart { width: min(860px, 100%); border: 5px solid var(--ink); box-shadow: 8px 8px 0 var(--ink); background: #fff; line-height: 0; transform: rotate(-1deg); }
.tart svg { width: 100%; height: auto; aspect-ratio: 400 / 230; display: block; }
.title h1 { margin: -46px 0 0; text-align: center; position: relative; transform: rotate(-2deg); }
.title h1 span { display: inline-block; font-family: Bangers, "Huninn", sans-serif; font-size: clamp(44px, 9vw, 92px); letter-spacing: .04em; color: var(--a); -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 6px 6px 0 var(--ink); }
.title h1 small { display: block; font-size: clamp(16px, 3vw, 24px); background: var(--ink); color: #fff; padding: 4px 14px; margin: 4px auto 0; width: fit-content; transform: rotate(1deg); }

/* ---------- chapter list ---------- */
.list { max-width: 1100px; margin: 0 auto; padding: 14px; }
.listtop { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; } .listtop h2 { flex: 1; margin: 0; font-size: 24px; }
.chgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; margin-top: 14px; }
.chcard { background: var(--paper); border: 4px solid var(--ink); box-shadow: 6px 6px 0 var(--ink); cursor: pointer; display: flex; flex-direction: column; padding-bottom: 12px; transition: transform .12s; }
.chcard:hover { transform: translate(-2px, -2px) rotate(-.5deg); }
.cover { position: relative; border-bottom: 4px solid var(--ink); line-height: 0; }
.cover svg { width: 100%; aspect-ratio: 400 / 240; display: block; }
.cover .tone { position: absolute; left: 8px; top: 8px; line-height: 1; padding: 4px 10px; font-weight: 700; color: #fff; border: 2px solid var(--ink); background: var(--tc); font-size: 13px; transform: rotate(-3deg); }
.cover .stamp { position: absolute; right: 8px; bottom: 10px; line-height: 1; padding: 6px 10px; font-weight: 700; color: #c8283a; border: 3px solid #c8283a; background: rgba(255,255,255,.85); transform: rotate(8deg); }
.tone-warm { --tc: var(--warm); } .tone-spooky { --tc: var(--spooky); } .tone-action { --tc: var(--action); } .tone-adventure { --tc: var(--adventure); }
.chinfo { padding: 10px 14px 4px; } .chinfo h3 { margin: 2px 0 4px; font-size: 22px; } .chinfo p { margin: 0 0 6px; font-size: 14px; line-height: 1.5; }
.chinfo small { opacity: .7; font-weight: 700; } .chcard .row { padding: 0 12px; justify-content: flex-start; }

/* ---------- reader ---------- */
.reader { min-height: 100vh; }
.rbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 6px; padding: 6px 10px; background: var(--ink); color: #fff; }
.rbar .btn { color: #fff; background: transparent; border-color: rgba(255,255,255,.4); }
.rtitle { flex: 1; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet { max-width: 980px; margin: 0 auto; padding: 14px 12px 60px; }
.page { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; background: var(--paper); padding: 12px; border: 3px solid var(--ink); box-shadow: 6px 6px 0 rgba(29,26,36,.35); }
.panel { position: relative; aspect-ratio: 4 / 3; border: 4px solid var(--ink); background: #fff; overflow: hidden; transition: opacity .35s, transform .35s; }
.panel.wide { grid-column: 1 / -1; aspect-ratio: 2.25 / 1; }
.panel svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.panel.pending { opacity: 0; transform: scale(.97); }
.panel.shown { opacity: 1; transform: none; }
.panel.f-sepia svg { filter: sepia(.8) saturate(.9); }
.panel.f-dark svg { filter: brightness(.55); }
.panel.shake.shown { animation: shake .45s; }
@keyframes shake { 20% { transform: translate(-6px, 2px); } 40% { transform: translate(5px, -3px); } 60% { transform: translate(-4px, 1px); } 80% { transform: translate(3px, 0); } }
.cap { position: absolute; left: 0; top: 0; max-width: 72%; background: #fff3a8; border: 0 solid var(--ink); border-width: 0 3px 3px 0; padding: 6px 10px; font-size: clamp(11px, 1.55vw, 15px); line-height: 1.45; font-weight: 700; z-index: 2; }
.bub { position: absolute; z-index: 3; max-width: 46%; background: #fff; border: 3px solid var(--ink); border-radius: 18px; padding: 6px 11px; font-size: clamp(11px, 1.6vw, 16px); line-height: 1.4; font-weight: 700; --tx: 50%; }
.panel.wide .bub { max-width: 34%; }
.bub::after { content: ''; position: absolute; left: calc(var(--tx) - 8px); bottom: -14px; border: 8px solid transparent; border-top: 12px solid var(--ink); border-bottom: 0; }
.bub::before { content: ''; position: absolute; left: calc(var(--tx) - 5px); bottom: -8px; border: 5px solid transparent; border-top: 8px solid #fff; border-bottom: 0; z-index: 1; }
.bub.notail::before, .bub.notail::after { display: none; }
.bub.k-shout { background: #fff6a8; border-width: 4px; border-radius: 6px; font-size: clamp(12px, 1.9vw, 19px); transform: rotate(-2deg); text-transform: uppercase; }
.bub.k-shout::before { border-top-color: #fff6a8; }
.bub.k-think { border-style: dashed; border-radius: 26px; font-style: italic; }
.bub.k-think::after { width: 10px; height: 10px; border: 3px solid var(--ink); border-radius: 50%; background: #fff; bottom: -16px; } .bub.k-think::before { display: none; }
.bub.k-whisper { border-style: dashed; font-size: clamp(10px, 1.4vw, 14px); color: #4a4a5a; }
.bub.k-scared { border-color: #3a3a8a; background: #eef0ff; border-radius: 10px 22px 12px 20px; }
.bub.k-scared::before { border-top-color: #eef0ff; } .bub.k-scared::after { border-top-color: #3a3a8a; }
.bub.k-off { background: #e8f4ff; border-radius: 6px; }
.sfx { position: absolute; z-index: 2; font-family: Bangers, "Huninn", sans-serif; font-size: clamp(22px, 4.6vw, 46px); color: var(--c); -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; text-shadow: 3px 3px 0 var(--ink); transform: rotate(var(--r)); letter-spacing: .04em; white-space: nowrap; pointer-events: none; }
.panel.shown .sfx { animation: boom .4s ease-out; }
@keyframes boom { from { transform: rotate(var(--r)) scale(2.2); opacity: 0; } }
.after { margin-top: 16px; display: flex; justify-content: center; }
.tap { font-weight: 700; padding: 8px 16px; background: var(--ink); color: #fff; border-radius: 20px; animation: nudge 1.2s ease-in-out infinite; cursor: pointer; }
@keyframes nudge { 50% { transform: translateX(6px); } }
.choice { width: min(640px, 100%); background: var(--paper); border: 4px solid var(--ink); box-shadow: 6px 6px 0 var(--ink); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.choice .q { font-weight: 700; font-size: 18px; text-align: center; }
.btn.opt { text-align: left; background: #fff; font-size: 16px; } .btn.opt:hover { background: #fff3a8; }
.endcard { width: min(620px, 100%); background: var(--ink); color: #fff; border: 4px solid var(--ink); box-shadow: 6px 6px 0 var(--tc, #888); padding: 18px; text-align: center; }
.endcard .theend { font-family: Bangers, "Huninn", sans-serif; font-size: 34px; color: var(--a); letter-spacing: .05em; }
.endcard h3 { margin: 6px 0; font-size: 22px; } .endcard p { line-height: 1.6; } .endcard small { opacity: .7; display: block; margin-bottom: 12px; }
.endcard .btn { color: var(--ink); } .endcard .btn.ghost { color: #fff; }

/* ---------- interactive scenes ---------- */
.mini { background: var(--paper); border: 3px solid var(--ink); padding: 12px; box-shadow: 6px 6px 0 rgba(29,26,36,.35); display: flex; flex-direction: column; gap: 10px; }
.minicap { background: #fff3a8; border: 3px solid var(--ink); padding: 8px 12px; font-weight: 700; line-height: 1.5; }
.minicap small { display: block; font-weight: 400; opacity: .8; }
.stage { position: relative; aspect-ratio: 400 / 260; border: 4px solid var(--ink); overflow: hidden; touch-action: none; }
.stage svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.spot { position: absolute; border: 0; background: transparent; border-radius: 50%; padding: 0; cursor: pointer; }
.spot:hover { box-shadow: 0 0 0 3px rgba(255,207,58,.8) inset; }
.hinting .spot.win { animation: hint 1s ease-in-out infinite; } @keyframes hint { 50% { box-shadow: 0 0 0 5px #ffcf3a inset, 0 0 24px #ffcf3a; } }
.spot.found { box-shadow: 0 0 0 4px #4ad86a inset; }
.pop { position: absolute; z-index: 4; max-width: 36%; background: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 5px 10px; font-weight: 700; font-size: clamp(11px, 1.6vw, 15px); animation: popin .2s; pointer-events: none; }
.pop.good { background: #c8f8c8; } @keyframes popin { from { transform: scale(.6); } }
.minifoot { display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap; min-height: 44px; }
.count { font-weight: 700; }
.flashlight { cursor: none; }
.darkness { position: absolute; inset: 0; background: #05060c; pointer-events: none; z-index: 2;
  -webkit-mask-image: radial-gradient(circle at var(--mx) var(--my), transparent 0, transparent 9%, #000 17%);
  mask-image: radial-gradient(circle at var(--mx) var(--my), transparent 0, transparent 9%, #000 17%); }
.flashlight .pop { z-index: 5; }
.clue { background: #eaf4ff; border: 2px dashed var(--ink); padding: 8px 12px; font-family: "Comic Neue", "Huninn", sans-serif; font-weight: 700; line-height: 1.5; }
.board { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; background: #2a5a3a; border: 4px solid var(--ink); padding: 14px; border-radius: 10px; }
.board.zap { animation: shake .4s; }
.board .col { display: flex; flex-direction: column; gap: 8px; }
.chip { background: #1d1a24; color: #ffd030; border: 3px solid #888; border-radius: 6px; padding: 14px 8px; text-align: center; font-size: 28px; } .chip small { display: block; font-size: 10px; color: #ccc; }
.wire, .port { border: 3px solid var(--ink); border-radius: 10px; background: #fff; padding: 8px; font-weight: 700; display: flex; align-items: center; gap: 8px; text-align: left; }
.wire i { width: 30px; height: 10px; border-radius: 5px; border: 2px solid var(--ink); flex: none; }
.wire.sel { background: #fff3a8; transform: translateX(6px); } .wire.ok, .port.ok { opacity: .8; background: #d8ffd8; }
.port b { width: 26px; height: 26px; border-radius: 50%; background: var(--c, #ccc); border: 2px solid var(--ink); display: grid; place-items: center; flex: none; }
.wmsg { text-align: center; font-weight: 700; min-height: 22px; color: #c8283a; }
.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.item { border: 3px solid var(--ink); border-radius: 12px; background: #fff; padding: 10px; font-weight: 700; display: flex; flex-direction: column; align-items: center; gap: 4px; box-shadow: 3px 3px 0 var(--ink); }
.item span { font-size: 34px; } .item.on { background: var(--a); transform: translate(-2px, -2px) rotate(-1deg); }

@media (max-width: 640px) {
  .page { grid-template-columns: 1fr; padding: 8px; gap: 10px; }
  .panel, .panel.wide { aspect-ratio: 4 / 3; }
  .bub, .panel.wide .bub { max-width: 58%; font-size: 13px; }
  .cap { font-size: 12px; }
  .board { grid-template-columns: 1fr 1fr; } .chip { display: none; }
}

/* ---------- Dog Man style: hand-lettered text, wobbly hand-drawn borders, slightly crooked panels ---------- */
html, body { font-family: "Patrick Hand", "LXGW WenKai TC", "Huninn", "Microsoft JhengHei", sans-serif; }
body { background-color: #fbf6ea; background-image: radial-gradient(rgba(20,18,24,.06) 1px, transparent 1.3px); }
.btn { font-family: "Patrick Hand", "LXGW WenKai TC", sans-serif; font-size: 18px; border-radius: 14px 6px 12px 5px / 6px 12px 5px 14px; }
.page { border-radius: 4px 10px 6px 12px / 12px 4px 10px 6px; background: #fffef9; }
.panel { border-width: 4px; border-radius: 6px 14px 5px 12px / 14px 5px 12px 6px; }
.page > .panel:nth-child(odd) { transform: rotate(-.35deg); } .page > .panel:nth-child(even) { transform: rotate(.4deg); }
.page > .panel.pending { transform: scale(.97); }
.bub { font-family: "Patrick Hand", "LXGW WenKai TC", sans-serif; font-weight: 700; font-size: clamp(12px, 1.75vw, 18px); line-height: 1.3; border-width: 3px; border-radius: 255px 18px 225px 18px / 18px 225px 18px 255px; padding: 7px 13px; }
.bub.k-shout { border-radius: 8px 22px 6px 18px / 18px 6px 22px 8px; }
.bub.k-think { border-radius: 40px; }
.cap { font-family: "Patrick Hand", "LXGW WenKai TC", sans-serif; font-size: clamp(12px, 1.6vw, 16px); border-radius: 0 0 14px 0 / 0 0 6px 0; background: #fff1a0; }
.sfx { font-family: "Permanent Marker", "LXGW WenKai TC", sans-serif; font-weight: 700; -webkit-text-stroke: 2.5px #141218; }
.title h1 span, .endcard .theend { font-family: "Permanent Marker", "LXGW WenKai TC", sans-serif; font-weight: 700; }
.chcard, .tart, .choice, .mini, .endcard { border-radius: 6px 16px 5px 14px / 14px 5px 16px 6px; }
.btn.opt { font-size: 18px; }
