/* 初星ミステリー。tools/mystery-server.js から配る。ログイン前のページも、このファイルだけを使う */
:root {
  --bg: #f5efe4; --card: #fffdf8; --ink: #2a2433; --muted: #7d7280; --line: #e6d9c4;
  --accent: #b3402e; --accent-ink: #fff; --accent-soft: #f6e0d6; --gold: #b98a22; --note: #fdf6dc; --receipt: #ffffff; --talk: #eef3fb; --item: #eff6ea;
  --shadow: 0 1px 2px rgba(60,30,10,.08), 0 8px 22px rgba(60,30,10,.1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14131c; --card: #1f1d2b; --ink: #f2ecdf; --muted: #a59eb0; --line: #38334a;
    --accent: #e8705a; --accent-ink: #1a1014; --accent-soft: #3d2530; --gold: #e5bb5c; --note: #2e2a1e; --receipt: #2a2833; --talk: #1f2a3c; --item: #20301f;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 500 15px/1.7 'Zen Maru Gothic', system-ui, sans-serif; }
h1, h2, h3 { font-family: 'Zen Old Mincho', serif; margin: 0; line-height: 1.35; }
button, select, input, textarea { font: inherit; color: inherit; }
.btn { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 9px; padding: 8px 16px; font-weight: 700; cursor: pointer; min-height: 40px; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.btn.small { padding: 3px 11px; min-height: 30px; font-size: 13px; }
input, select, textarea { width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
textarea { min-height: 88px; resize: vertical; }
.small { font-size: 13px; color: var(--muted); }
.err { color: var(--accent); font-weight: 700; }

/* ログインの画面 */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.gatecard { background: var(--card); padding: 28px; border-radius: 16px; box-shadow: var(--shadow); width: min(360px, 100%); }
.gatecard h1 { font-size: 26px; margin-bottom: 14px; text-align: center; }
.gatecard form { display: grid; gap: 12px; }
.gatecard label { display: grid; gap: 3px; font-size: 13px; color: var(--muted); }

/* 全体 */
#app { max-width: 1240px; margin: 0 auto; padding: 14px 16px 60px; }
.top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.top h1 { font-size: 22px; }
.top .sp { flex: 1; }
.chip { display: inline-block; background: var(--accent-soft); border-radius: 99px; padding: 1px 11px; font-size: 13px; font-weight: 700; }
.card { background: var(--card); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow); }
.stack { display: grid; gap: 12px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pre { white-space: pre-wrap; }

/* 棚 */
.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.sc { display: flex; flex-direction: column; gap: 6px; }
.sc h3 { font-size: 19px; }
.sc .solved { color: var(--gold); font-weight: 700; font-size: 13px; }
.faces { display: flex; gap: 4px; }
.faces img { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; }

/* 地図 */
.play { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 12px; align-items: start; }
@media (max-width: 880px) { .play { grid-template-columns: 1fr; } }
.mapcard { position: relative; border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); background: linear-gradient(#bfe0f2, #e8f3e8); }
.mapcard.b-夕 { background: linear-gradient(#f2b48a, #f6dcc0); }
.mapcard.b-夜 { background: linear-gradient(#10152f, #27305a); }
.mapcard.b-朝 { background: linear-gradient(#cfe7f6, #f6efe0); }
#mapbox { position: relative; overflow: hidden; }
#mapbox.scroll { overflow-x: auto; }
#stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
#overlay { position: relative; }
.pl { cursor: pointer; }
.pl:hover { filter: brightness(1.08); }
.pl.fog { filter: grayscale(1) opacity(.45) blur(1.2px); }
.pl.locked { filter: saturate(.45) brightness(.82); }
.plabel { position: absolute; transform: translate(-50%, 0); z-index: 4000; white-space: nowrap; font-size: 12px; font-weight: 700; background: rgba(255,253,248,.95); color: #2b2622; border-radius: 99px; padding: 1px 9px; box-shadow: 0 1px 3px rgba(0,0,0,.22); cursor: pointer; }
.plabel.here { background: #f07a2a; color: #fff; }
.plabel.sel { outline: 2px solid #d6453d; }
.plabel.fog { background: rgba(230,230,235,.9); color: #66606e; }
.plabel.locked { background: rgba(240,228,214,.95); }
.pin { position: absolute; z-index: 5000; width: 36px; display: flex; flex-direction: column; align-items: center; pointer-events: none; }
.pin img, .pin .pb { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; border: 2px solid #fffdf8; box-shadow: 0 2px 5px rgba(0,0,0,.3); background: #ddd; }
.pin .pb { display: grid; place-items: center; background: #f07a2a; color: #fff; font-weight: 700; font-size: 13px; }
.pin.other .pb { background: #3f7fd6; }
.pin span { font-size: 10px; font-weight: 700; color: #2b2622; background: rgba(255,253,248,.92); border-radius: 6px; padding: 0 4px; margin-top: -3px; white-space: nowrap; }
.mapback { position: absolute; left: 10px; top: 10px; z-index: 6000; }

/* 横の欄 */
.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tabs button { flex: 1; background: transparent; border: 0; border-bottom: 2px solid var(--line); padding: 6px; cursor: pointer; font-weight: 700; color: var(--muted); }
.tabs button.on { color: var(--accent); border-color: var(--accent); }
.acts { display: grid; gap: 6px; margin-top: 8px; }
.act { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: transparent; border: 1px solid var(--line); border-radius: 9px; padding: 7px 11px; cursor: pointer; text-align: left; min-height: 42px; width: 100%; }
.act:hover:not(:disabled) { border-color: var(--accent); }
.act:disabled { opacity: .55; cursor: default; }
.act small { color: var(--muted); font-size: 12px; }
.moves b { letter-spacing: 2px; color: var(--accent); }
.person { display: flex; gap: 8px; align-items: center; }
.person img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }

/* 手帳 */
.clue { border-radius: 9px; padding: 8px 11px; border: 1px solid var(--line); background: var(--note); }
.clue.receipt { background: var(--receipt); border-style: dashed; font-family: 'Courier New', 'Zen Maru Gothic', monospace; }
.clue.talk { background: var(--talk); }
.clue.item { background: var(--item); }
.clue h4 { margin: 0 0 2px; font-size: 14px; }
.clue .foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin-top: 3px; }
label.pick { display: flex; gap: 8px; align-items: flex-start; }
label.pick input { width: auto; margin-top: 8px; }

/* 聞きこみ */
.iv-head { display: flex; gap: 10px; align-items: flex-end; }
.iv-head .face { width: 96px; height: 112px; border-radius: 12px; overflow: hidden; background: var(--talk); flex: none; }
.iv-head .face img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 0; transform: scale(1.9); transform-origin: 50% 6%; }
.picks { display: grid; gap: 6px; }
label.pick .clue { font-size: 13.5px; padding: 6px 10px; }
.say { margin: 6px 0; }
.say .q { color: var(--muted); font-size: 14px; }
.say .a { background: var(--talk); border-radius: 10px; padding: 6px 11px; }
.got { color: var(--gold); font-size: 13px; font-weight: 700; }
.wait { color: var(--muted); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .wait { animation: none; } }

/* 大きな画面（報告会・告発など） */
.wide { max-width: 760px; margin: 0 auto; }
.lead { font-size: 16px; }
.turn { display: flex; gap: 10px; align-items: flex-start; margin: 8px 0; }
.turn img { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; }
.turn .bb { background: var(--talk); padding: 7px 12px; border-radius: 12px; flex: 1; }
.turn.me { flex-direction: row-reverse; }
.turn.me .bb { background: var(--accent-soft); }
.grade { font: 700 62px/1 'Zen Old Mincho', serif; color: var(--accent); }
ul.score { list-style: none; padding: 0; margin: 6px 0; }
ul.score li { display: flex; justify-content: space-between; padding: 2px 0; border-bottom: 1px dashed var(--line); }

/* 重ねて出す窓 */
.modal { position: fixed; inset: 0; background: rgba(15,10,20,.55); display: grid; place-items: center; padding: 16px; z-index: 9000; }
.modal > div { background: var(--card); border-radius: 14px; padding: 18px; width: min(460px, 100%); max-height: 86vh; overflow: auto; box-shadow: var(--shadow); display: grid; gap: 10px; }
#toasts { position: fixed; right: 12px; bottom: 12px; display: grid; gap: 6px; z-index: 9500; max-width: 300px; }
.toast { background: var(--ink); color: var(--bg); padding: 7px 12px; border-radius: 9px; font-size: 13.5px; box-shadow: var(--shadow); }
