:root {
  --bg: #14110f;
  --bg2: #1d1915;
  --card: #241f1a;
  --card2: #2d2620;
  --line: #3b3229;
  --ink: #f1e7d8;
  --ink2: #c9b9a2;
  --muted: #8f8070;
  --amber: #e2a85a;
  --amber2: #f3c77f;
  --red: #d9634f;
  --green: #7fbf7a;
  --teal: #5fa8a0;
  --serif: "Shippori Mincho", "Yu Mincho", "Hiragino Mincho ProN", serif;
  --sans: "Zen Kaku Gothic New", "Hiragino Sans", "Yu Gothic", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; min-height: 100dvh; background: radial-gradient(ellipse at top, #2a2018 0%, var(--bg) 60%) fixed; }
#app { max-width: 720px; margin: 0 auto; padding: 0 16px calc(90px + env(safe-area-inset-bottom)); }
[hidden] { display: none !important; }
button { font-family: inherit; }
.btn { appearance: none; border: 1px solid var(--line); background: var(--card2); color: var(--ink); border-radius: 12px; padding: 12px 16px; font-size: 16px; font-weight: 700; cursor: pointer; touch-action: manipulation; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: linear-gradient(180deg, var(--amber2), var(--amber)); color: #2a1c0c; border-color: #b9863f; }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 12px; font-size: 14px; border-radius: 10px; }
.btn.wide { width: 100%; }
.btn.armed { background: var(--red); color: #fff; border-color: var(--red); }
.btn.danger { border-color: #7a3b31; color: #f0b3a8; }
input[type=text], input:not([type]) { width: 100%; font: inherit; font-size: 18px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: #100d0b; color: var(--ink); }
input:focus { outline: 2px solid var(--amber); outline-offset: 1px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > .grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
h1, h2, h3 { font-family: var(--serif); margin: 0; }

/* ── トップ ── */
.hero { margin: 0 -16px; position: relative; aspect-ratio: 3 / 2; max-height: 52vh; overflow: hidden; background: #0c0a08; }
.hero img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 40%, var(--bg) 100%); }
.title-block { text-align: center; margin: -56px 0 18px; position: relative; z-index: 1; }
.title-block .sub { color: var(--amber2); font-size: 13px; letter-spacing: .3em; }
.title-block h1 { font-size: clamp(28px, 8vw, 40px); line-height: 1.25; margin-top: 6px; text-shadow: 0 2px 12px #000; }
.title-block p { color: var(--ink2); font-size: 14px; margin: 8px 0 0; }
.box { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin: 14px 0; }
.box h3 { font-size: 17px; margin-bottom: 10px; }
.stack > * + * { margin-top: 10px; }
.invite { background: #3a2a14; border: 1px solid #6b4b1f; color: var(--amber2); border-radius: 12px; padding: 10px 12px; font-size: 14px; }

/* ── ロビー ── */
.code-big { font-family: var(--serif); font-size: 44px; letter-spacing: .15em; color: var(--amber2); text-align: center; }
.players { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--card2); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 14px; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.chip.off { opacity: .5; }
.chip.off .dot { background: var(--muted); }
.chip.me { border-color: var(--amber); }
.roles { display: grid; grid-template-columns: 1fr; gap: 8px; }
.role-card { display: flex; gap: 12px; align-items: center; text-align: left; background: var(--card2); border: 1px solid var(--line); border-radius: 14px; padding: 12px; color: var(--ink); cursor: pointer; width: 100%; }
.role-card .ic { font-size: 28px; width: 40px; text-align: center; }
.role-card b { font-family: var(--serif); font-size: 18px; }
.role-card .who { margin-left: auto; font-size: 13px; color: var(--amber2); white-space: nowrap; }
.role-card.mine { border-color: var(--amber); background: #3a2c1a; }
.role-card.taken { opacity: .55; }
.toggle { display: flex; align-items: center; gap: 10px; }
.toggle input { width: 22px; height: 22px; accent-color: var(--amber); }

/* ── 上の帯 ── */
.hdr { position: sticky; top: 0; z-index: 20; margin: 0 -16px 12px; padding: calc(8px + env(safe-area-inset-top)) 16px 8px; background: rgba(20, 17, 15, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.hdr .top { display: flex; align-items: center; gap: 8px; }
.hdr .ch { font-family: var(--serif); font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.hdr .ch small { color: var(--amber2); margin-right: 6px; font-size: 13px; }
.hdr .clock { font-variant-numeric: tabular-nums; color: var(--ink2); font-size: 14px; }
.icon-btn { appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 10px; width: 36px; height: 36px; font-size: 17px; cursor: pointer; padding: 0; }
.icon-btn.off { opacity: .4; }
.hdr .mem { display: flex; gap: 6px; margin-top: 6px; overflow-x: auto; scrollbar-width: none; }
.hdr .mem .chip { padding: 3px 9px; font-size: 12px; flex: none; }
.progress { height: 3px; background: var(--line); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--amber); transition: width .5s; }

/* ── 読み物 ── */
.scene { display: flex; flex-direction: column; gap: 12px; }
.pic { position: relative; margin: 0 -16px; aspect-ratio: 3 / 2; max-height: 46vh; overflow: hidden; background: radial-gradient(circle at 50% 40%, #3a2c1e, #0c0a08 70%); }
.pic img { width: 100%; height: 100%; object-fit: cover; display: block; animation: kb 18s ease-out both; }
.pic .ph { position: absolute; inset: 0; display: grid; place-items: center; font-size: 72px; opacity: .55; }
@keyframes kb { from { transform: scale(1.0); } to { transform: scale(1.08); } }
.pic .big { position: absolute; inset: auto 0 0 0; padding: 40px 16px 18px; text-align: center; font-family: var(--serif); font-weight: 800; font-size: clamp(26px, 7vw, 40px); color: #fff; text-shadow: 0 2px 16px #000, 0 0 30px rgba(0,0,0,.8); background: linear-gradient(180deg, transparent, rgba(0,0,0,.7)); animation: rise .9s ease-out both; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.say { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px 18px; min-height: 120px; cursor: pointer; animation: rise .35s ease-out both; }
.say .who { display: inline-block; font-size: 13px; font-weight: 700; color: #2a1c0c; background: var(--amber); border-radius: 6px; padding: 2px 8px; margin-bottom: 8px; }
.say .who.kuro { background: #9b3d33; color: #fff; }
.say .who.door { background: #5b6b78; color: #fff; }
.say .who.youth { background: #4c6fa8; color: #fff; }
.say .who.k { background: #222; color: #e9e9e9; border: 1px solid #555; }
.say p { margin: 0; font-family: var(--serif); font-size: 19px; line-height: 1.85; font-weight: 500; }
.kmsg { background: #0e1013; border: 1px solid #2f3540; border-radius: 16px; padding: 18px; animation: rise .35s ease-out both; }
.kmsg .from { display: flex; align-items: center; gap: 10px; color: #9aa7b8; font-size: 13px; margin-bottom: 10px; }
.kmsg .av { width: 34px; height: 34px; border-radius: 50%; background: #222; border: 1px solid #555; display: grid; place-items: center; font-weight: 800; color: #eee; font-family: var(--serif); }
.kmsg p { margin: 0; background: #1f2630; border-radius: 4px 14px 14px 14px; padding: 12px 14px; font-size: 17px; line-height: 1.7; }
.nav { display: flex; gap: 10px; align-items: center; }
.nav .count { color: var(--muted); font-size: 13px; min-width: 52px; text-align: center; }
.waitline { font-size: 13px; color: var(--ink2); text-align: center; }
.paper { background: #efe3cc; color: #2b2116; border-radius: 6px; padding: 22px 20px; font-family: var(--serif); box-shadow: 0 10px 30px rgba(0,0,0,.5); line-height: 1.95; font-size: 18px; animation: rise .5s ease-out both; }
.paper .to { font-weight: 800; margin-bottom: 8px; }
.paper .sign { text-align: right; margin-top: 12px; font-weight: 700; }
.role-reveal { text-align: center; background: linear-gradient(180deg, #33261a, var(--card)); border: 1px solid #6b4b1f; border-radius: 18px; padding: 22px 18px; animation: rise .5s ease-out both; }
.role-reveal .ic { font-size: 56px; }
.role-reveal h2 { font-size: 30px; margin-top: 4px; }
.role-reveal .ttl { color: var(--amber2); font-size: 14px; letter-spacing: .1em; }
.role-reveal .skill { color: var(--ink2); font-size: 14px; margin: 8px 0 12px; }
.role-reveal .story { text-align: left; font-family: var(--serif); font-size: 16px; line-height: 1.9; border-top: 1px solid var(--line); padding-top: 12px; }
.role-reveal .story p { margin: 0 0 6px; }
.secret { background: #2b0f0c; border: 2px solid #a33a2c; border-radius: 16px; padding: 18px; position: relative; animation: rise .5s ease-out both; }
.secret::before { content: "極秘"; position: absolute; top: -12px; right: 14px; background: #a33a2c; color: #fff; font-weight: 800; padding: 2px 10px; border-radius: 4px; transform: rotate(4deg); }
.secret p { margin: 0 0 8px; line-height: 1.75; }
.rules { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.rules h2 { font-size: 22px; margin-bottom: 8px; }
.rules ol { margin: 0; padding-left: 1.3em; line-height: 1.8; }
.kname { text-align: center; padding: 28px 12px; }
.kname .n { font-family: var(--serif); font-size: clamp(36px, 11vw, 60px); font-weight: 800; color: var(--amber2); animation: rise .8s ease-out both; }
.vtable { width: 100%; border-collapse: collapse; font-size: 15px; }
.vtable td { padding: 8px 6px; border-bottom: 1px solid var(--line); }
.vtable .hit { color: var(--green); font-weight: 700; }
.verdict { font-family: var(--serif); font-size: 20px; font-weight: 800; text-align: center; margin-top: 12px; color: var(--amber2); }

/* ── 謎 ── */
.qbanner { position: relative; margin: 0 -16px; height: 150px; overflow: hidden; background: #0c0a08; }
.qbanner img { width: 100%; height: 100%; object-fit: cover; opacity: .55; }
.qbanner .cap { position: absolute; left: 16px; right: 16px; bottom: 12px; }
.qbanner .cap small { color: var(--amber2); font-size: 13px; letter-spacing: .15em; }
.qbanner .cap h2 { font-size: 26px; text-shadow: 0 2px 10px #000; }
.question { font-family: var(--serif); font-size: 20px; font-weight: 700; line-height: 1.6; margin: 14px 0 4px; }
.lead { color: var(--ink2); font-size: 14px; margin: 0 0 10px; }
.sec-title { font-size: 13px; color: var(--amber2); letter-spacing: .15em; margin: 18px 0 8px; font-weight: 700; }
.clue { background: #f2e8d5; color: #2b2116; border-radius: 10px; padding: 14px 14px 12px; margin-bottom: 10px; box-shadow: 0 6px 18px rgba(0,0,0,.35); }
.clue .ct { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-weight: 800; font-family: var(--serif); font-size: 17px; border-bottom: 1px dashed #b9a684; padding-bottom: 6px; margin-bottom: 8px; }
.clue .ct small { font-family: var(--sans); font-weight: 700; font-size: 12px; color: #7a5a2e; white-space: nowrap; }
.clue p { margin: 6px 0; line-height: 1.75; font-size: 16px; }
.clue .quote { margin: 8px 0; padding: 8px 12px; border-left: 4px solid #c99b52; background: #e9dcc2; font-family: var(--serif); line-height: 1.8; }
.clue ul { margin: 6px 0; padding-left: 1.3em; line-height: 1.8; }
.clue img { width: 100%; border-radius: 6px; display: block; margin: 4px 0; filter: sepia(.35); }
.grid { border-collapse: collapse; margin: 8px auto; font-family: var(--serif); }
.grid th { font-family: var(--sans); font-size: 12px; color: #7a5a2e; font-weight: 700; padding: 2px 6px; }
.grid td { width: 44px; height: 44px; text-align: center; font-size: 22px; font-weight: 700; border: 1px solid #b9a684; background: #fbf4e6; }
.grid.marks td { color: #8a2f22; font-size: 24px; }
.bottle { display: flex; gap: 10px; align-items: center; background: #e9dcc2; border-radius: 8px; padding: 8px 10px; margin: 6px 0; }
.bottle .b { font-size: 26px; }
.bottle .nm { font-weight: 700; }
.bottle .tag { margin-left: auto; text-align: center; font-family: var(--serif); }
.bottle .tag b { display: block; font-size: 24px; background: #fff8ea; border: 1px solid #b9a684; border-radius: 4px; width: 40px; line-height: 40px; }
.bottle .mk { font-size: 12px; font-weight: 700; }
.bottle .mk.y { color: #2f6f2a; }
.bottle .mk.n { color: #8b7b63; }
.memword { text-align: center; font-family: var(--serif); font-size: 40px; font-weight: 800; letter-spacing: .2em; margin: 6px 0 4px; }
.common { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.common b { font-family: var(--serif); }
.common ol, .common ul { margin: 6px 0 0; padding-left: 1.2em; line-height: 1.85; }
.answer { position: sticky; bottom: 0; z-index: 10; margin: 14px -16px 0; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: rgba(20, 17, 15, .96); border-top: 1px solid var(--line); }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.options .btn { font-size: 15px; padding: 12px 8px; }
.feed { display: flex; flex-direction: column; gap: 6px; }
.feed .it { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 14px; animation: rise .3s ease-out both; }
.feed .it .ans { font-weight: 700; }
.feed .it.ng .mark { color: var(--red); font-weight: 800; }
.feed .it.ok .mark { color: var(--green); font-weight: 800; }
.feed .it .msg { margin-top: 4px; color: var(--ink2); font-family: var(--serif); }
.feed .it.hint { color: var(--amber2); }
.hints .h { background: #2a2214; border: 1px solid #6b4b1f; border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; line-height: 1.7; }
.hints .h b { color: var(--amber2); margin-right: 6px; }
.kpanel { background: #2b0f0c; border: 2px dashed #a33a2c; border-radius: 14px; padding: 14px; margin-top: 16px; }
.kpanel b { color: #ff9c8a; }
.kpanel p { margin: 6px 0 10px; line-height: 1.7; }
.kpanel + .kpanel { margin-top: 10px; }
.kword { font-family: var(--serif); font-size: 30px; font-weight: 800; color: #ffd2c8; margin-top: 6px; }
.memo-box { margin-top: 6px; }
textarea.memo { width: 100%; font: inherit; font-size: 16px; line-height: 1.6; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: #100d0b; color: var(--ink); resize: vertical; }
.kwords { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-family: var(--serif); font-size: 20px; font-weight: 700; color: var(--amber2); }
.vtable .kw { font-family: var(--serif); font-weight: 700; font-size: 18px; }
.solved { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(0,0,0,.72); animation: fade .3s both; padding: 16px; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.solved .in { text-align: center; animation: pop .5s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
.solved .big { font-family: var(--serif); font-size: clamp(48px, 16vw, 84px); font-weight: 800; color: var(--amber2); text-shadow: 0 0 30px rgba(226,168,90,.6); }
.solved .ans { font-family: var(--serif); font-size: 28px; margin-top: 6px; }
.solved .by { color: var(--ink2); margin-top: 8px; }

/* ── 投票・おしまい ── */
.cands { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cands .btn.sel { border-color: var(--amber); background: #3a2c1a; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; text-align: center; }
.stat b { display: block; font-family: var(--serif); font-size: 26px; color: var(--amber2); }
.stat span { font-size: 12px; color: var(--muted); }
.credits { color: var(--muted); font-size: 12px; line-height: 1.8; text-align: center; }

/* ── 下の固定バー（記録） ── */
.dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; display: flex; justify-content: center; pointer-events: none; padding-bottom: env(safe-area-inset-bottom); }
.dock .btn { pointer-events: auto; margin-bottom: 10px; box-shadow: 0 4px 16px rgba(0,0,0,.5); }

/* ── 重ねる画面 ── */
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.75); display: grid; place-items: center; padding: 16px; }
.overlay .panel { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 20px; max-width: 420px; width: 100%; display: grid; gap: 10px; }
.sheet { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: flex; flex-direction: column; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: calc(12px + env(safe-area-inset-top)) 16px 12px; border-bottom: 1px solid var(--line); }
.sheet-body { overflow-y: auto; padding: 12px 16px 40px; max-width: 720px; width: 100%; margin: 0 auto; }
.sheet-body h3 { color: var(--amber2); font-size: 16px; margin: 18px 0 8px; }
.sheet-body .ln { font-family: var(--serif); line-height: 1.8; margin: 4px 0; }
.sheet-body .ln b { font-family: var(--sans); font-size: 12px; color: var(--amber2); margin-right: 6px; }
.netbar, .toast { position: fixed; left: 50%; transform: translateX(-50%); z-index: 80; width: max-content; max-width: calc(100vw - 24px); padding: 10px 16px; border-radius: 999px; font-size: 14px; font-weight: 700; box-shadow: 0 6px 20px rgba(0,0,0,.5); }
.netbar { top: calc(10px + env(safe-area-inset-top)); background: #FFE08A; color: #2a1c0c; }
.toast { bottom: calc(80px + env(safe-area-inset-bottom)); background: var(--ink); color: var(--bg); }
@media (min-width: 640px) {
  .roles { grid-template-columns: 1fr 1fr; }
  .pic, .hero, .qbanner { margin: 0; border-radius: 0 0 16px 16px; }
}
