/* 潮帰り集会所: the HUD, the photo cards, the bag + notebook, the papers, the panels, the talk, the menus.
   Phones (375 px, touch) and PC. The mouse cursor is hidden only while the pointer is locked (body.locked). */
:root {
  --bg: #06080a;
  --ink: #ece8de;
  --dim: #a09a8e;
  --line: #3e4244;
  --panel: rgba(16, 18, 18, 0.95);
  --amber: #f0c050;
  --red: #e0503a;
  --green: #7ad890;
  --paper: #ece4cf;
  --paper-ink: #1f1d1a;
  --blue-ink: #24345a;
  --font: "Noto Sans JP", "Yu Gothic", "Hiragino Sans", sans-serif;
  --serif: "Zen Old Mincho", "Yu Mincho", serif;
  --hand: "Zen Kurenaido", "Yu Gothic", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font-family: var(--font); -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; overscroll-behavior: none; }
.hidden { display: none !important; }
#view { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; cursor: default; }
button { font: inherit; color: inherit; cursor: pointer; }
.small { font-size: 12px; color: var(--dim); line-height: 1.6; }
.touch-only { display: none; }
body.touch .touch-only { display: initial; }
body.touch .keys.touch-only { display: grid; }
body.touch .desk-only { display: none; }

/* ---- HUD ---- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; contain: layout; }
#objective { position: absolute; left: max(12px, env(safe-area-inset-left)); top: max(10px, env(safe-area-inset-top)); max-width: min(62vw, 560px); padding: 6px 12px; background: rgba(0, 0, 0, 0.58); border-left: 3px solid var(--amber); font-size: 14px; line-height: 1.5; border-radius: 0 6px 6px 0; }
#objective .obj-label { color: var(--amber); font-weight: 700; }
#objective.new { animation: objnew 1.6s ease-out; }
@keyframes objnew { 0% { background: rgba(240, 192, 80, 0.45); } 100% { background: rgba(0, 0, 0, 0.58); } }
#crosshair { position: absolute; left: 50%; top: 50%; width: 5px; height: 5px; margin: -2.5px 0 0 -2.5px; border-radius: 50%; background: rgba(255, 255, 255, 0.65); box-shadow: 0 0 2px #000; }
#crosshair.aim { width: 12px; height: 12px; margin: -6px 0 0 -6px; background: transparent; border: 2px solid var(--amber); }
#prompt { position: absolute; left: 50%; top: calc(50% + 22px); transform: translateX(-50%); font-size: 14px; background: rgba(0, 0, 0, 0.66); padding: 4px 12px; border-radius: 14px; white-space: nowrap; max-width: 92vw; overflow: hidden; text-overflow: ellipsis; }
#prompt:empty { display: none; }
#prompt .key { color: var(--amber); font-weight: 700; margin-right: 6px; }
#lockhint { position: absolute; left: 50%; top: calc(50% + 54px); transform: translateX(-50%); font-size: 13px; color: var(--dim); background: rgba(0, 0, 0, 0.55); padding: 3px 10px; border-radius: 10px; }
#hold-bar { position: absolute; left: 50%; top: calc(50% + 60px); transform: translateX(-50%); width: min(80vw, 340px); background: rgba(0, 0, 0, 0.66); padding: 8px 12px; border-radius: 8px; font-size: 13px; }
#hold-bar .hb-track { height: 8px; background: #2a2a28; border-radius: 4px; margin-top: 6px; overflow: hidden; }
#hold-bar .hb-track i { display: block; height: 100%; width: 0; background: var(--red); }
#toast { position: absolute; left: 50%; top: max(52px, calc(env(safe-area-inset-top) + 44px)); transform: translateX(-50%); width: min(92vw, 640px); text-align: center; font-size: 15px; line-height: 1.6; background: rgba(0, 0, 0, 0.74); padding: 10px 16px; border-radius: 8px; opacity: 0; transition: opacity 0.2s; pointer-events: auto; }
#toast.show { opacity: 1; }
#toast:empty { display: none; }
#subtitle { position: absolute; left: 50%; bottom: 196px; transform: translateX(-50%); width: min(90vw, 620px); text-align: center; font: 18px/1.6 var(--hand); color: #f4ecd6; text-shadow: 0 0 6px #000, 0 0 2px #000; opacity: 0; transition: opacity 0.4s; }
#subtitle .who { display: inline-block; font: 700 11px var(--font); color: var(--amber); border: 1px solid rgba(240, 192, 80, 0.6); border-radius: 3px; padding: 0 4px; margin-right: 8px; vertical-align: 3px; text-shadow: none; }
#subtitle.show { opacity: 1; }
#caption { position: absolute; left: max(12px, env(safe-area-inset-left)); bottom: 120px; max-width: 46vw; font-size: 13px; color: #d8d0c0; background: rgba(0, 0, 0, 0.55); padding: 3px 10px; border-radius: 4px; opacity: 0; transition: opacity 0.3s; }
#caption.show { opacity: 1; }
body.touch #caption { bottom: auto; top: 140px; }
#radio-line { position: absolute; left: 50%; bottom: 250px; transform: translateX(-50%); max-width: min(90vw, 620px); display: flex; gap: 8px; align-items: baseline; background: rgba(8, 18, 12, 0.78); border: 1px solid #2c4a34; border-radius: 8px; padding: 6px 12px; font-size: 14px; line-height: 1.5; opacity: 0; transition: opacity 0.3s; }
#radio-line.show { opacity: 1; }
#radio-line .rl-who { color: var(--green); font-weight: 700; white-space: nowrap; }
#radio-line.me .rl-who { color: var(--amber); }
/* photo cards */
#pickup, #closeup, #room-card, #chapter-card, #quest-note { position: absolute; opacity: 0; transition: opacity 0.35s, transform 0.35s; }
#pickup.show, #closeup.show, #room-card.show, #chapter-card.show, #quest-note.show { opacity: 1; }
#pickup { left: max(12px, env(safe-area-inset-left)); bottom: 20px; display: flex; gap: 10px; align-items: center; background: rgba(0, 0, 0, 0.78); border: 1px solid #5a4a20; border-radius: 8px; padding: 8px; width: min(80vw, 340px); transform: translateY(10px); }
#pickup.show { transform: none; }
.pk-img { width: 84px; height: 84px; flex: none; border-radius: 4px; background: #222 center/cover; box-shadow: 0 0 0 3px #e8e0cc, 0 3px 10px #000; transform: rotate(-2deg); }
.pk-txt small { display: block; color: var(--amber); font-size: 11px; }
.pk-txt b { display: block; font-size: 15px; }
.pk-txt span { display: block; font-size: 12px; color: var(--dim); margin-top: 2px; }
#closeup { right: max(12px, env(safe-area-inset-right)); bottom: 20px; width: min(86vw, 420px); background: rgba(0, 0, 0, 0.8); border-radius: 8px; padding: 10px; display: flex; gap: 12px; align-items: flex-start; transform: translateY(10px); }
#closeup.show { transform: none; }
#closeup .cu-img { width: 150px; height: 150px; flex: none; background: #222 center/cover; border: 6px solid #ebe3cd; border-bottom-width: 20px; box-shadow: 0 4px 14px #000; transform: rotate(1.5deg); }
#closeup.noimg .cu-img { display: none; }
#closeup .cu-txt { font-size: 14px; line-height: 1.7; }
#room-name { position: absolute; left: 50%; top: max(12px, env(safe-area-inset-top)); transform: translateX(-50%); font: 700 15px var(--font); letter-spacing: 3px; color: #f0e8d4; background: rgba(0, 0, 0, 0.5); border-bottom: 2px solid var(--amber); padding: 4px 14px; opacity: 0; transition: opacity 0.5s; white-space: nowrap; }
#room-name.show { opacity: 1; }
@media (max-width: 640px) { #room-name { top: 52px; font-size: 13px; } }
#room-card { right: max(12px, env(safe-area-inset-right)); top: max(10px, env(safe-area-inset-top)); width: min(44vw, 300px); background: #ebe3cd; color: var(--paper-ink); padding: 8px 8px 6px; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.7); transform: rotate(2deg) translateY(-8px); }
#room-card.show { transform: rotate(2deg); }
#room-card .rc-img { height: min(22vw, 170px); background: #222 center/cover; filter: saturate(0.85); }
#room-card .rc-txt { padding: 4px 2px 0; font: 15px var(--hand); }
#room-card small { color: #6a6458; margin-right: 6px; }
#chapter-card { left: 50%; top: 22%; transform: translate(-50%, 0) scale(0.97); width: min(70vw, 400px); background: rgba(0, 0, 0, 0.82); border: 1px solid #5a5040; padding: 10px; text-align: center; }
#chapter-card.show { transform: translate(-50%, 0); }
#chapter-card .cc-img { height: min(22vw, 130px); background: #222 center/220% no-repeat; background-position: 30% 60%; filter: grayscale(0.4) contrast(1.05); }
#chapter-card small { display: block; color: var(--amber); letter-spacing: 3px; margin-top: 8px; }
#chapter-card b { font: 700 24px var(--serif); letter-spacing: 4px; }
#quest-note { left: max(12px, env(safe-area-inset-left)); top: 64px; background: rgba(10, 14, 22, 0.82); border-left: 3px solid #7aa0e0; padding: 6px 12px; border-radius: 0 6px 6px 0; max-width: min(70vw, 360px); font-size: 13px; line-height: 1.5; }
#quest-note small { display: block; color: #9ab8f0; }
#quest-note b { display: block; font-size: 14px; }
#marker { position: absolute; left: 0; top: 0; display: flex; flex-direction: column; align-items: center; margin: -14px 0 0 -40px; width: 80px; pointer-events: none; }
#marker .mk-dia { color: var(--amber); font-size: 18px; text-shadow: 0 0 4px #000, 0 0 8px rgba(0, 0, 0, 0.8); }
#marker .mk-label { font-size: 11px; color: #f0e0b0; text-shadow: 0 0 3px #000; white-space: nowrap; }
#marker.edge .mk-label { opacity: 0.7; }
#debug { position: absolute; right: 8px; bottom: 8px; font: 11px/1.4 ui-monospace, monospace; background: rgba(0, 0, 0, 0.7); padding: 6px 8px; border-radius: 4px; white-space: pre-wrap; color: #cfe; display: none; max-width: 52vw; }
body.debug #debug { display: block; }
body.touch #toast { top: 96px; }
body.touch #subtitle { bottom: 230px; }
body.touch #radio-line { bottom: 286px; }
body.touch #pickup { bottom: auto; top: 140px; }
body.touch #closeup { bottom: auto; top: 120px; left: 50%; right: auto; transform: translateX(-50%); }
body.touch #closeup.show { transform: translateX(-50%); }

/* what you see through what you wear / hide in (in the world, not a screen effect) */
#visor { position: fixed; inset: 0; z-index: 4; pointer-events: none; }
#visor .vz-band { position: absolute; left: -5%; right: -5%; top: 0; height: 74%; background: linear-gradient(#000 0 82%, rgba(0, 0, 0, 0.85)); border-bottom-left-radius: 50% 22%; border-bottom-right-radius: 50% 22%; }
#visor .vz-note { position: absolute; left: 50%; top: 30%; transform: translateX(-50%); color: #776e5c; font-size: 13px; }
#hide-vents { position: fixed; inset: 0; z-index: 4; pointer-events: none; background: repeating-linear-gradient(#050505 0 26px, transparent 26px 34px); box-shadow: inset 0 0 120px #000; }

/* ---- touch ---- */
#touch { position: fixed; inset: 0; z-index: 6; pointer-events: none; }
#t-look { position: absolute; right: 0; top: 0; width: 60%; height: 100%; pointer-events: auto; touch-action: none; }
#t-stick { position: absolute; left: max(18px, env(safe-area-inset-left)); bottom: max(22px, env(safe-area-inset-bottom)); width: 128px; height: 128px; border-radius: 50%; background: rgba(255, 255, 255, 0.08); border: 2px solid rgba(255, 255, 255, 0.25); pointer-events: auto; touch-action: none; }
#t-knob { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%; background: rgba(255, 255, 255, 0.35); }
#t-buttons { position: absolute; right: max(10px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(3, 60px); gap: 7px; pointer-events: auto; }
#t-buttons button { height: 48px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, 0.35); background: rgba(20, 22, 22, 0.72); font-size: 14px; touch-action: none; }
#t-buttons button.big { grid-column: span 3; height: 58px; background: rgba(240, 192, 80, 0.28); border-color: var(--amber); font-size: 17px; font-weight: 700; }
#t-buttons button.on { background: rgba(240, 192, 80, 0.45); }
#t-buttons button.danger { border-color: var(--red); background: rgba(120, 30, 20, 0.6); }
#t-pause { position: absolute; right: max(12px, env(safe-area-inset-right)); top: 96px; width: 44px; height: 44px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.35); background: rgba(0, 0, 0, 0.5); pointer-events: auto; }

/* ---- overlays ---- */
.overlay { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, 0.64); padding: 12px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; width: min(560px, 100%); max-height: calc(100vh - 24px); overflow: auto; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6); }
.panel.wide { width: min(860px, 100%); }
.panel-title { font: 700 18px var(--font); display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; color: var(--amber); }
.close-btn { border: 1px solid var(--line); background: #1c2022; border-radius: 6px; padding: 6px 12px; font-size: 13px; color: var(--ink); }
.menu-buttons { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.menu-buttons button { padding: 12px; border-radius: 8px; border: 1px solid var(--line); background: #1a1e20; font-size: 15px; }
.menu-buttons button:hover:not(:disabled) { border-color: var(--amber); }
.menu-buttons button:disabled { opacity: 0.5; cursor: default; }
.row { display: flex; align-items: center; gap: 10px; justify-content: space-between; margin: 10px 0; font-size: 14px; }
.row select, .row input[type="range"] { flex: 1; max-width: 240px; }
.row select { background: #1a1e20; color: var(--ink); border: 1px solid var(--line); padding: 6px; border-radius: 6px; }
.hint { font-size: 12px; color: var(--dim); margin-top: 10px; text-align: center; }

/* paper */
#doc { flex-direction: column; }
#doc .paper { width: min(560px, 100%); max-height: calc(100vh - 70px); overflow: auto; background: var(--paper); color: var(--paper-ink); padding: 18px 22px 18px; border-radius: 2px; box-shadow: 0 8px 40px rgba(0, 0, 0, 0.7); position: relative; }
#doc-photo { height: min(42vw, 240px); margin: -4px -6px 12px; background: #333 center/cover; border: 6px solid #fff; box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4); transform: rotate(-0.8deg); }
#doc-title { font: 700 17px var(--serif); border-bottom: 1px solid rgba(0, 0, 0, 0.35); padding-bottom: 8px; margin-bottom: 12px; }
#doc-body { font: 16px/1.95 var(--serif); white-space: pre-wrap; user-select: text; }
#doc-body.hand { font: 19px/1.9 var(--hand); color: var(--blue-ink); }
#doc-attach { margin: 14px 0 4px; display: flex; gap: 10px; align-items: flex-end; }
#doc-attach .att-img { width: 46%; aspect-ratio: 3 / 2; background: #333 center/cover; border: 5px solid #fff; border-bottom-width: 18px; box-shadow: 0 3px 10px rgba(0, 0, 0, 0.45); transform: rotate(2deg); }
#doc-attach .att-cap { font: 14px var(--hand); color: #444; }
#doc-src { margin-top: 12px; font-size: 12px; color: #6a6458; border-top: 1px dashed rgba(0, 0, 0, 0.3); padding-top: 6px; }
#doc-think { margin-top: 8px; font: 16px var(--hand); color: #7a2a1a; }
#doc-think:empty { display: none; }
#doc .hint { color: #cfd4d0; }

/* the clipboard + notebook */
.book { width: min(900px, 100%); height: min(640px, calc(100vh - 24px)); display: flex; flex-direction: column; background: #6a4e30; border-radius: 12px; padding: 10px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.7), inset 0 0 0 2px #7e6040; position: relative; }
.book::before { content: ""; position: absolute; left: 50%; top: -8px; width: 120px; height: 24px; margin-left: -60px; background: linear-gradient(#c8ccd0, #7a7e82); border-radius: 6px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5); }
.bk-top { display: flex; justify-content: space-between; align-items: center; color: #f4e8d0; padding: 6px 4px 8px; }
.bk-title { font: 700 15px var(--font); }
.bk-title small { margin-left: 8px; font-weight: 400; color: #e0d0b0; font-size: 12px; }
.bk-tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.bk-tabs button { position: relative; padding: 7px 11px 9px; border: none; border-radius: 6px 6px 0 0; background: #c8b894; color: #3a3024; font-size: 13px; }
.bk-tabs button.on { background: var(--paper); color: #111; font-weight: 700; }
.bk-tabs button[data-count]:not([data-count=""])::after { content: attr(data-count); margin-left: 5px; font-size: 11px; background: #3a3024; color: #f0e8d4; border-radius: 8px; padding: 0 5px; }
.bk-sep { width: 8px; }
.bk-page { flex: 1; min-height: 0; background: var(--paper); color: var(--paper-ink); border-radius: 0 6px 6px 6px; overflow: hidden; background-image: linear-gradient(rgba(60, 90, 140, 0.12) 1px, transparent 1px), linear-gradient(90deg, rgba(60, 90, 140, 0.12) 1px, transparent 1px); background-size: 16px 16px; }
.bk-pane { height: 100%; overflow: auto; padding: 12px; }
#inv-pane { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 12px; }
#inv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; align-content: start; overflow: auto; }
#inv-grid .empty { grid-column: 1 / -1; color: #6a6458; font: 15px var(--hand); padding: 20px 4px; }
.slot { display: flex; flex-direction: column; align-items: stretch; gap: 4px; padding: 5px; background: #fffaf0; border: 1px solid #c8bca0; border-radius: 4px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15); text-align: center; position: relative; }
.slot .thumb { aspect-ratio: 1; background: #ddd center/cover; display: flex; align-items: center; justify-content: center; color: #555; font-size: 13px; }
.slot .nm { font-size: 11.5px; line-height: 1.3; min-height: 2.6em; color: #2a261f; }
.slot.sel { outline: 3px solid #b07810; }
.slot.new::after { content: "新"; position: absolute; right: -4px; top: -4px; background: var(--red); color: #fff; font-size: 11px; border-radius: 50%; width: 20px; height: 20px; line-height: 20px; }
.slot.doc .thumb, .slot.letter .thumb { filter: sepia(0.25); }
#inv-detail { display: flex; flex-direction: column; gap: 8px; overflow: auto; }
#inv-photo { aspect-ratio: 4 / 3; background: #333 center/cover; border: 7px solid #fff; border-bottom-width: 22px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35); transform: rotate(-1deg); }
#inv-photo.blank { background: repeating-linear-gradient(45deg, #ddd 0 8px, #e8e8e8 8px 16px); }
#inv-photo.pop { animation: pop 0.25s ease-out; }
@keyframes pop { 0% { transform: rotate(-1deg) scale(0.96); } 100% { transform: rotate(-1deg) scale(1); } }
#inv-name { font: 700 18px var(--serif); }
#inv-meta { font-size: 12px; color: #6a6458; }
#inv-desc { font-size: 14px; line-height: 1.75; white-space: pre-wrap; }
#inv-use { font: 15px var(--hand); color: var(--blue-ink); }
#inv-use.flash { animation: flash 1.2s ease-out; }
@keyframes flash { 0% { background: rgba(240, 192, 80, 0.6); } 100% { background: transparent; } }
#inv-actions { display: flex; flex-wrap: wrap; gap: 6px; }
#inv-actions button { padding: 8px 14px; border-radius: 6px; border: 1px solid #8a7a5a; background: #fffaf0; color: #2a261f; font-size: 14px; }
#inv-actions button.main { background: #2a3a5a; color: #fff; border-color: #2a3a5a; }
.bk-foot { color: #e8dcc0; font-size: 11px; padding: 6px 4px 0; }
/* journal pages */
#jr-pane { font-size: 14px; line-height: 1.7; }
.jr-now { background: #fffaf0; border-left: 4px solid #b07810; padding: 8px 12px; margin-bottom: 10px; }
.jr-now small { display: block; color: #8a6a20; }
.jr-now b { display: block; font: 700 17px var(--serif); }
.jr-now .where, .jr-now .hint { display: block; font-size: 13px; color: #555; }
.jr-now .hint { color: var(--blue-ink); font-family: var(--hand); font-size: 15px; }
.jr-h { margin: 14px 0 6px; font: 700 14px var(--font); color: #3a3024; border-bottom: 1px solid #c8bca0; }
.jr-steps, .jr-qsteps { margin: 0; padding-left: 0; list-style: none; }
.jr-steps li, .jr-qsteps li { padding: 2px 0; }
.jr-steps li.done, .jr-qsteps li.done { color: #6a6458; text-decoration: line-through; text-decoration-color: rgba(0, 0, 0, 0.35); }
.jr-qsteps li.now { color: var(--blue-ink); font-weight: 700; }
.jr-steps .ck { display: inline-block; width: 1.4em; color: #b07810; }
.jr-btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.jr-btns button { padding: 7px 12px; border: 1px solid #8a7a5a; background: #fffaf0; border-radius: 6px; color: #2a261f; }
.jr-q { background: #fffaf0; border: 1px solid #c8bca0; padding: 8px 10px; margin-bottom: 8px; border-radius: 4px; }
.jr-q.done { opacity: 0.8; }
.jr-qt { font-weight: 700; display: flex; gap: 6px; align-items: center; }
.jr-qs { margin-left: auto; font-size: 12px; color: #6a6458; }
.jr-qr { color: #2a7a3a; font-size: 13px; }
.jr-notes { list-style: none; padding: 0; margin: 0; }
.jr-notes li { padding: 3px 0; font-family: var(--hand); font-size: 16px; color: var(--blue-ink); }
.jr-notes li.rule { color: #7a2a1a; }
.jr-notes li.radio { font-family: var(--font); font-size: 13px; color: #2a4a34; }
.jr-notes .t { font: 11px var(--font); color: #8a8070; margin-right: 6px; }
.empty { color: #6a6458; }
.album { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.album .ph { border: none; background: #fff; padding: 5px 5px 4px; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25); text-align: center; }
.album .ph:nth-child(odd) { transform: rotate(-1.2deg); }
.album .ph:nth-child(even) { transform: rotate(1deg); }
.album .ph span { display: block; aspect-ratio: 3 / 2; background: #333 center/cover; }
.album .ph small { display: block; font: 12px var(--hand); color: #333; padding-top: 3px; }
.ph-view { position: absolute; inset: 0; background: rgba(20, 16, 10, 0.92); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px; z-index: 2; }
#jr-pane { position: relative; }
.ph-view div { width: 100%; height: 80%; background: center/contain no-repeat; }
.ph-view p { color: #f0e8d4; font: 16px var(--hand); }
.jr-map canvas { width: auto; height: auto; max-width: 100%; max-height: min(60vh, 470px); display: block; margin: 0 auto; border: 1px solid #c8bca0; }
.jr-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; margin-top: 6px; align-items: center; }
.jr-legend i { display: inline-block; width: 12px; height: 12px; margin-right: 4px; vertical-align: -2px; }
.jr-legend i.me { background: #c0302a; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.jr-legend i.goal { background: rgba(230, 170, 40, 0.6); border: 2px solid #b07810; }
.jr-legend i.open { background: #2a9a4a; }
.jr-legend i.shut { background: #c03a2a; }

/* puzzle panels */
.term-panel { background: #121614; border-color: #3a4a3e; width: min(640px, 100%); }
.term-head { display: flex; align-items: center; gap: 10px; color: var(--green); font-weight: 700; margin-bottom: 10px; }
.term-head .close-btn { margin-left: auto; }
#term-photo { width: 76px; height: 52px; background: #222 center/cover; border: 2px solid #cfc6b0; flex: none; }
#term-body { font-size: 14px; line-height: 1.6; }
#term-body button { border: 1px solid #3a5a44; background: #1a2a20; color: #e0f0e4; border-radius: 6px; padding: 8px 10px; font-size: 14px; }
#term-body button.on { background: #3a6a48; border-color: var(--green); }
#term-body button.off { opacity: 0.4; pointer-events: none; }
#term-body button.main { background: #6a5420; border-color: var(--amber); color: #fff; font-weight: 700; padding: 10px 18px; }
#term-body button.danger { background: #5a2018; border-color: var(--red); }
#term-body button.sm { padding: 6px 9px; }
#term-body button.focus { outline: 2px solid var(--amber); }
.t-lead { color: #c8d8cc; margin: 0 0 8px; }
.t-miss { color: var(--amber); margin-bottom: 8px; }
.t-done { color: var(--green); font-weight: 700; margin: 8px 0; }
.t-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.t-sel { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 8px 0; }
.t-sel small { width: 100%; color: var(--dim); font-size: 12px; }
.t-sel .num { font: 700 20px ui-monospace, monospace; letter-spacing: 3px; color: var(--amber); margin-right: 8px; }
.t-sel .cols { font-size: 12px; color: var(--dim); }
.t-sel .src { font-size: 13px; padding: 2px 8px; border: 1px solid #555; border-radius: 10px; color: var(--dim); }
.t-sel .src.ok { color: var(--green); border-color: var(--green); }
.t-hint { margin-top: 10px; padding: 8px; border-left: 3px solid var(--amber); background: rgba(240, 192, 80, 0.08); font-size: 13px; }
.t-hint.dim { color: var(--dim); border-color: #555; background: transparent; }
.t-warn { margin: 10px 0 0; padding: 8px; border: 2px solid var(--red); color: #ffd0c8; border-radius: 6px; }
.dials { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.dial { background: #0c100e; border: 1px solid #2a3a30; border-radius: 6px; padding: 6px; text-align: center; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px; }
.dial small { width: 100%; color: var(--dim); font-size: 12px; }
.dial b { flex: 1; font-size: 15px; color: #f8f0d8; min-width: 4em; }
.clues { display: grid; gap: 6px; margin: 6px 0 10px; }
.clue { display: flex; gap: 8px; align-items: center; background: #0c100e; border-radius: 6px; padding: 5px; }
.clue span { width: 46px; height: 46px; flex: none; background: #333 center/cover; border: 2px solid #ddd; }
.clue b { display: block; font-size: 13px; }
.clue small { display: block; font-size: 12px; color: #b8c8bc; line-height: 1.45; }
.recs { display: grid; gap: 8px; }
.rec { position: relative; text-align: left; }
.rec small { display: block; color: var(--dim); }
.rec i { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font: 700 22px ui-monospace, monospace; color: var(--amber); font-style: normal; }
.keys6 { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin: 8px 0; }
.keys6 button { font: 700 20px ui-monospace, monospace !important; padding: 12px 0 !important; }
.p07 .st { background: #0c100e; border-radius: 6px; padding: 8px; margin-bottom: 8px; }
.p07 .st p { margin: 0 0 6px; }
.p07 .st div { display: flex; flex-wrap: wrap; gap: 6px; }
#term-toast { min-height: 1.6em; margin-top: 10px; font-size: 14px; color: #fff3c8; line-height: 1.6; }

/* choice */
.choice-panel { text-align: center; }
#choice-photo { height: min(46vw, 230px); background: #222 center/cover; margin: -4px -6px 12px; border: 5px solid #e8e0cc; }
#choice-text { font: 16px/1.8 var(--serif); white-space: pre-wrap; }

/* controls */
.controls-panel .goal { font-size: 15px; line-height: 1.8; margin-bottom: 12px; padding: 10px; border: 1px solid var(--amber); border-radius: 6px; background: rgba(240, 192, 80, 0.08); }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; align-items: center; font-size: 14px; margin: 8px 0; }
.kc { display: inline-block; min-width: 26px; padding: 2px 6px; margin-right: 3px; border: 1px solid #667; border-radius: 4px; text-align: center; font: 12px ui-monospace, monospace; background: #222a2e; }
.kc.wide { min-width: 54px; }
.go { text-align: center; color: var(--amber); margin-top: 12px; font-weight: 700; animation: blink 1.6s infinite; }
@keyframes blink { 50% { opacity: 0.4; } }

/* intro */
#intro { position: fixed; inset: 0; z-index: 22; background: #000; }
#intro-bg, #intro-bg2 { position: absolute; inset: 0; background: center/cover no-repeat; opacity: 0; transition: opacity 1.6s; filter: saturate(0.7) brightness(0.7); }
#intro-bg.on, #intro-bg2.on { opacity: 1; }
.intro-box { position: absolute; left: 50%; bottom: 10%; transform: translateX(-50%); width: min(90vw, 680px); background: rgba(0, 0, 0, 0.62); padding: 16px 20px 10px; border-radius: 6px; }
#intro-text { font: 19px/1.9 var(--serif); color: #f4ecdc; min-height: 3.8em; }
#intro-text.in { animation: fadein 0.6s; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.intro-foot { display: flex; justify-content: space-between; font-size: 12px; color: var(--dim); margin-top: 6px; }
#intro-skip { position: absolute; right: 14px; top: 14px; padding: 6px 14px; border: 1px solid #555; background: rgba(0, 0, 0, 0.5); border-radius: 6px; }

/* title */
#title { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; overflow: auto; padding: 16px; background: #050607; }
#title-bg { position: absolute; inset: 0; background: center/cover no-repeat; opacity: 0.45; filter: saturate(0.6); }
#title .title-inner { position: relative; width: min(460px, 100%); text-align: center; }
#title .series { font-size: 13px; color: #c8c0b0; letter-spacing: 4px; }
#title h1 { font: 700 46px/1.15 var(--serif); margin: 10px 0 6px; letter-spacing: 6px; text-shadow: 0 0 18px rgba(240, 192, 80, 0.25); }
#title .sub { font: 15px var(--serif); letter-spacing: 3px; color: #d8d0c0; }
#title .rule { margin: 16px auto 8px; padding: 8px 12px; border-top: 1px solid #5a4a20; border-bottom: 1px solid #5a4a20; font: 15px/1.8 var(--serif); color: #f0e0c0; }
#title .meta { font-size: 13px; color: var(--dim); }
#title .headphones { margin-top: 12px; font-size: 12px; color: var(--dim); }
.title-menu { max-width: 320px; margin: 16px auto; }
#chapter-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; max-width: 380px; margin: 0 auto 10px; }
#chapter-list button { padding: 8px; border-radius: 6px; border: 1px solid var(--line); background: #1a1e20; font-size: 12px; }

/* fade / death / ending */
#fade { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; z-index: 15; transition: opacity 0.35s; }
#fade.on { opacity: 1; }
#death { position: fixed; inset: 0; z-index: 25; background: #000; display: flex; align-items: center; justify-content: center; }
#death-text { font: 22px var(--serif); color: #d8d0c0; letter-spacing: 4px; animation: fadein 2s; }
#ending { position: fixed; inset: 0; z-index: 26; background: #000; }
#ending-img, #ending-img2 { position: absolute; inset: 0; background: center/cover no-repeat; opacity: 0; transition: opacity 2.2s; }
#ending-img.on, #ending-img2.on { opacity: 0.8; }
#ending-text { position: absolute; left: 50%; bottom: 10%; transform: translateX(-50%); width: min(88vw, 720px); text-align: center; font: 18px/1.9 var(--serif); text-shadow: 0 0 8px #000, 0 0 3px #000; color: #f4eee0; }
#ending-text .last { font-size: 21px; color: #fff; margin-top: 10px; }
#ending-text p { margin: 0 0 6px; opacity: 0; transition: opacity 1.2s; }
#ending-text p.on { opacity: 1; }
#ending-skip { position: absolute; right: 16px; bottom: 16px; padding: 8px 14px; border-radius: 6px; border: 1px solid #555; background: rgba(0, 0, 0, 0.6); }

/* result */
.result-panel { text-align: center; width: min(620px, 100%); }
#result-photo { height: min(40vw, 200px); margin: -6px -8px 10px; background: #111 center/cover; border-radius: 6px 6px 0 0; }
.result-code { font-size: 13px; color: var(--dim); letter-spacing: 2px; }
.result-title { font: 700 28px var(--serif); margin: 6px 0; color: var(--amber); }
.result-last { font: 16px var(--serif); margin-bottom: 12px; }
.result-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 10px 0; }
.result-grid div { background: #1a1e20; border-radius: 6px; padding: 8px 4px; font-size: 12px; color: var(--dim); }
.result-grid b { display: block; font-size: 17px; color: var(--ink); margin-top: 2px; }
#result-ends, #gallery-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 10px 0; }
.end-card { border: 1px solid var(--line); border-radius: 6px; padding: 6px; font-size: 12px; background: #12161a; }
.end-card.seen { border-color: #6a5a20; }
.end-card.now { border-color: var(--amber); box-shadow: 0 0 0 1px var(--amber); }
.end-card .thumb { height: 56px; background: #0a0c0e center/cover no-repeat; border-radius: 4px; margin-bottom: 4px; }
#gallery-list .end-card { cursor: pointer; padding: 8px; font-size: 13px; }
#gallery-list .end-card .thumb { height: 90px; }
.credits-body p { font-size: 14px; line-height: 1.8; }
.share-text { font-size: 13px; color: var(--dim); margin: 6px 0; }
.share-buttons { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 10px 0 6px; }
.share-buttons button { padding: 9px 6px; border-radius: 8px; border: 1px solid var(--line); background: #1a1e20; }
.share-buttons .share-x { background: #000; border-color: #444; }
.share-buttons .share-fb { background: #1b4f9a; }
.share-buttons .share-line { background: #06a04a; }
.share-note { font-size: 12px; color: var(--dim); min-height: 1.4em; }

@media (max-width: 640px) {
  #objective { font-size: 12px; max-width: 56vw; padding: 5px 8px; }
  #inv-pane { grid-template-columns: 1fr; }
  #inv-detail { order: -1; }
  #inv-photo { aspect-ratio: 16 / 9; }
  #inv-grid { grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); overflow: visible; }
  .bk-tabs button { padding: 5px 7px 7px; font-size: 12px; }
  .book { padding: 6px; }
  #title h1 { font-size: 38px; }
  #result-ends, #gallery-list { grid-template-columns: repeat(2, 1fr); }
  .result-grid { grid-template-columns: repeat(2, 1fr); }
  #closeup .cu-img { width: 104px; height: 104px; }
  #room-card { width: 46vw; }
  .dials { grid-template-columns: 1fr; }
  .keys6 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-height: 460px) {
  .panel { padding: 10px 12px; }
  #inv-pane { grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); }
  #inv-grid { grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 5px; }
  .slot .nm { font-size: 10.5px; min-height: 2.4em; }
  #inv-detail { flex-direction: row; flex-wrap: wrap; align-items: flex-start; order: 0; }
  #inv-photo { width: 44%; aspect-ratio: 4 / 3; border-width: 4px 4px 12px; }
  .inv-info { flex: 1; min-width: 0; }
  #inv-name { font-size: 15px; }
  #inv-desc { font-size: 12.5px; line-height: 1.6; }
  .bk-tabs button { padding: 4px 7px 6px; font-size: 12px; }
  .bk-top { padding: 2px 4px 4px; }
  .bk-foot { display: none; }
  .book { height: calc(100vh - 12px); }
  #doc-photo { height: 120px; }
  #room-card .rc-img { height: 90px; }
  #chapter-card { top: 8%; }
  #chapter-card .cc-img { height: 110px; }
}

/* ---- hands-on panel controls (js/mini.js) ---- */
.t-top { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 8px; }
.t-goal { flex: 1; font-size: 13px; line-height: 1.6; color: #d8e8dc; background: rgba(120, 200, 140, 0.08); border-left: 3px solid var(--green); padding: 4px 8px; }
.t-goal b { color: var(--green); margin-right: 6px; }
#term-body .t-help { flex: none; width: 34px; height: 34px; border-radius: 50%; padding: 0; font-weight: 700; }
.t-helpbox { font-size: 13px; line-height: 1.7; background: #0c100e; border: 1px dashed #3a5a44; padding: 8px; margin-bottom: 8px; }
.t-helpbox b { color: var(--amber); margin-right: 6px; }
.t-rel { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; }
.t-rel small { width: 100%; color: var(--dim); font-size: 11.5px; }
#term-body .t-relitem { display: flex; flex-direction: column; align-items: center; width: 74px; padding: 3px; background: #ece4cf; color: #222; border: none; border-radius: 3px; }
.t-relitem span { width: 66px; height: 50px; background: #333 center/cover; }
.t-relitem i { font-style: normal; font-size: 10.5px; line-height: 1.25; margin-top: 2px; }
.t-reldetail { position: absolute; inset: 0; background: rgba(10, 10, 8, 0.96); display: flex; gap: 14px; padding: 18px; z-index: 3; border-radius: 10px; }
.term-panel { position: relative; }
.t-reldetail .rd-img { flex: 1; background: #222 center/contain no-repeat; min-height: 200px; }
.t-reldetail .rd-txt { flex: 1; overflow: auto; }
.t-reldetail .rd-txt p { white-space: pre-wrap; font: 16px/1.8 var(--serif); }
.t-reldetail .close-btn { position: absolute; right: 12px; top: 12px; }
.mg-row { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin: 8px 0; }
.mg-drum { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 92px; }
.mg-drum small, .mg-knob small, .mg-key small, .mg-lever small, .mg-crank small { color: var(--dim); font-size: 12px; text-align: center; }
.mg-flap { position: relative; width: 112px; height: 86px; background: #0a0b0c; border: 2px solid #3a3e40; border-radius: 6px; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: ns-resize; touch-action: none; box-shadow: inset 0 0 12px #000; }
.mg-flap b { font: 700 20px var(--font); color: #f0e8c8; z-index: 1; }
.mg-flap::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 2px; background: #000; }
.mg-flap .prev, .mg-flap .next { font-size: 11px; color: #6a6458; }
.mg-flap.flip b { animation: flip 0.18s ease-out; }
@keyframes flip { 0% { transform: scaleY(0.2); } 100% { transform: scaleY(1); } }
#term-body .mg-up, #term-body .mg-dn { padding: 2px 18px; font-size: 12px; }
.mg-knob { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.mg-k { position: relative; width: 150px; height: 150px; }
.mg-k .ticks .tick { position: absolute; transform: translate(-50%, -50%); font: 11px ui-monospace, monospace; color: #8a9a8e; }
.mg-k .ticks .tick.on { color: var(--amber); font-weight: 700; }
.mg-k .cap { position: absolute; left: 50%; top: 50%; width: 84px; height: 84px; margin: -42px 0 0 -42px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #5a5e60, #1a1c1e); border: 3px solid #2a2e30; box-shadow: 0 4px 10px #000; cursor: grab; touch-action: none; }
.mg-k .cap i { position: absolute; left: 50%; top: 6px; width: 6px; height: 26px; margin-left: -3px; background: #e8e0c8; border-radius: 3px; }
.mg-kbtn { display: flex; gap: 6px; align-items: center; }
.mg-kbtn b { min-width: 3.4em; text-align: center; color: var(--amber); }
.mg-key, .mg-lever, .mg-crank { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 120px; }
.mg-lock { width: 110px; height: 110px; border-radius: 50%; background: radial-gradient(circle, #2a2c2e 30%, #4a4e50 31%, #3a3e40 60%, #1a1c1e); display: flex; align-items: center; justify-content: center; }
.mg-bow { width: 64px; height: 64px; border-radius: 10px; background: #8a7a50 center/cover; border: 3px solid #c8b878; cursor: grab; touch-action: none; transition: transform 0.08s; }
.mg-key.done .mg-bow { border-color: var(--green); }
.mg-slot { position: relative; width: 46px; height: 130px; background: #0a0b0c; border: 2px solid #3a3e40; border-radius: 8px; }
.mg-handle { position: absolute; left: -10px; right: -10px; height: 30px; background: linear-gradient(#d84a3a, #8a2a20); border-radius: 6px; cursor: grab; touch-action: none; box-shadow: 0 3px 6px #000; }
.mg-lever.on .mg-handle { background: linear-gradient(#5ad07a, #2a7a3a); }
.mg-lever.off { opacity: 0.45; }
.mg-state { font: 700 13px ui-monospace, monospace; color: var(--amber); }
.mg-wheel { position: relative; width: 140px; height: 140px; border-radius: 50%; background: radial-gradient(circle, #3a3e40 18%, #1a1c1e 19%, #2a2e30 70%, #111 71%); cursor: grab; touch-action: none; }
.mg-arm { position: absolute; left: 50%; top: 50%; width: 10px; height: 62px; margin-left: -5px; transform-origin: 50% 0; background: #9a9ea2; border-radius: 5px; }
.mg-arm { margin-top: 0; }
.mg-arm i { position: absolute; left: -9px; bottom: -10px; width: 28px; height: 28px; border-radius: 50%; background: #6a4a2a; }
.mg-prog { width: 130px; height: 6px; background: #222; border-radius: 3px; overflow: hidden; }
.mg-prog i { display: block; height: 100%; width: 0; background: var(--amber); }
.mg-crank.done .mg-prog i { background: var(--green); }
.mg-cards { display: flex; flex-direction: column; gap: 10px; margin: 8px 0; }
.mg-slots { display: flex; gap: 8px; }
.mg-slotbox { flex: 1; min-height: 96px; border: 2px dashed #3a5a44; border-radius: 8px; padding: 6px; display: flex; flex-direction: column; gap: 6px; }
.mg-slotbox small { color: var(--dim); font-size: 12px; }
.mg-slotbox.hover { border-color: var(--amber); background: rgba(240, 192, 80, 0.08); }
.mg-tray { display: flex; flex-wrap: wrap; gap: 8px; min-height: 40px; padding: 6px; background: #0c100e; border-radius: 8px; }
.mg-card { background: #ece4cf; color: #1f1d1a; border-radius: 4px; padding: 8px 10px; font: 14px/1.5 var(--serif); cursor: grab; touch-action: none; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5); user-select: none; position: relative; z-index: 1; max-width: 100%; }
.mg-card small { display: block; color: #6a5a40; font: 12px var(--font); }
.mg-card.picked { outline: 3px solid var(--amber); }
.mg-card.dragging { z-index: 10; opacity: 0.9; box-shadow: 0 10px 24px #000; }
@media (max-width: 640px) {
  .mg-slots { flex-direction: column; }
  .mg-k { width: 120px; height: 120px; }
  .mg-flap { width: 92px; }
}
.t-why { font: 16px/1.6 var(--hand); color: #f4ecd6; margin: 0 0 8px; }
.t-why .who { display: inline-block; font: 700 11px var(--font); color: var(--amber); border: 1px solid rgba(240, 192, 80, 0.6); border-radius: 3px; padding: 0 4px; margin-right: 8px; vertical-align: 2px; }

/* phones and tablets (rule U13): every control a finger can hit, at least 44 px each way */
body.touch .close-btn, body.touch #intro-skip, body.touch #inv-actions button, body.touch .jr-btns button { min-height: 44px; min-width: 44px; }
body.touch .bk-tabs button { min-height: 44px; min-width: 44px; padding-top: 4px; padding-bottom: 4px; }
body.touch #term-body .t-help { width: 44px; height: 44px; }
body.touch #term-body .mg-up, body.touch #term-body .mg-dn { min-height: 44px; min-width: 50px; }

/* ===================================================================== 潮帰り集会所 */
:root { --sea: #6ab0d0; }
/* the tide gauge and the deep-water grace (spec §5: shown as numbers and signs, apart from the windmill) */
#tide { position: absolute; right: max(12px, env(safe-area-inset-right)); top: max(10px, env(safe-area-inset-top)); display: flex; gap: 8px; align-items: center; background: rgba(4, 14, 20, 0.66); border: 1px solid #2a4a5a; border-radius: 6px; padding: 5px 10px; font-size: 13px; color: #cfe6f0; max-width: 46vw; }
#tide .td-icon { color: var(--sea); }
#tide .td-bar { width: 70px; height: 6px; background: #1a2a32; border-radius: 3px; overflow: hidden; flex: none; }
#tide .td-bar i { display: block; height: 100%; background: var(--sea); }
#tide.high { border-color: #d8a040; }
#tide.high .td-bar i { background: #e09040; }
#cold { position: absolute; left: 50%; bottom: 150px; transform: translateX(-50%); width: min(70vw, 300px); background: rgba(4, 14, 20, 0.72); border: 1px solid #3a6a80; border-radius: 6px; padding: 6px 10px; text-align: center; }
#cold small { font-size: 12px; color: #cfe6f0; }
#cold span { display: block; height: 8px; margin-top: 4px; background: #1a2a32; border-radius: 4px; overflow: hidden; }
#cold i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #e05a3a, #6ab0d0); }
body.touch #cold { bottom: 200px; }
#hide-vents.boards { background: linear-gradient(90deg, #070605 0 18%, transparent 18% 22%, #0a0806 22% 100%); }
/* the talk (radio / phone): fixed size, the log scrolls inside */
.talk-panel { width: min(560px, 100%); height: min(520px, calc(100vh - 40px)); display: flex; flex-direction: column; background: #0e1416; border-color: #2a4a5a; }
.talk-top { display: flex; gap: 10px; align-items: center; font-weight: 700; color: #cfe6f0; margin-bottom: 8px; }
#talk-photo { width: 64px; height: 44px; background: #222 center/cover; border: 2px solid #8ab0c0; flex: none; }
#talk-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 6px 2px; }
.tk-line { max-width: 86%; background: #1a2a30; border: 1px solid #2a4a5a; border-radius: 10px 10px 10px 2px; padding: 7px 11px; font-size: 15px; line-height: 1.55; align-self: flex-start; animation: tkin 0.25s ease-out; }
.tk-line b { display: block; font-size: 11px; color: var(--sea); margin-bottom: 2px; }
.tk-line.me { align-self: flex-end; background: #2a2614; border-color: #6a5a28; border-radius: 10px 10px 2px 10px; }
.tk-line.me b { color: var(--amber); }
.tk-line .sys { color: var(--dim); font-size: 13px; }
@keyframes tkin { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
#talk-replies { margin-top: 8px; min-height: 48px; }
#talk-replies button { min-height: 48px; text-align: left; }
#talk-replies button.main { border-color: var(--amber); }
/* choices with locked endings */
#choice-buttons button.locked { opacity: 0.55; display: flex; flex-direction: column; gap: 2px; cursor: not-allowed; }
#choice-buttons button.locked small { font-size: 12px; color: var(--dim); }
/* the journal: work notes */
.jr-work { display: grid; gap: 8px; }
.jr-note { text-align: left; background: #ece4cf; color: #222; border: none; border-left: 4px solid #2a5a7a; border-radius: 3px; padding: 8px 12px; min-height: 48px; }
.jr-note b { display: block; font-size: 14px; }
.jr-note span { font: 13px var(--hand); color: #3a3a40; }
/* panels: P01 the roster board */
.t-p01 { flex-direction: column; align-items: stretch; }
.mg-roster { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.mg-board { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; background: #5a4230; border: 3px solid #3a2a1c; border-radius: 4px; padding: 6px; }
.mg-hook { position: relative; min-height: 92px; border-radius: 3px; display: flex; align-items: stretch; justify-content: center; padding-top: 8px; }
.mg-hook::before { content: ""; position: absolute; top: 2px; left: 50%; width: 6px; height: 6px; margin-left: -3px; border-radius: 50%; background: #b0a080; }
.mg-hook.want { outline: 2px dashed var(--amber); }
.mg-hook .mg-empty { align-self: center; font-size: 11px; color: #c8b090; }
.mg-tag { width: 100%; max-width: 46px; min-height: 80px; background: #ece6d6; color: #222; border-radius: 2px; display: flex; flex-direction: column; align-items: center; cursor: pointer; touch-action: none; box-shadow: 0 2px 3px rgba(0, 0, 0, 0.5); transition: transform 0.15s; }
.mg-tag i { width: 100%; height: 8px; border-radius: 2px 2px 0 0; }
.mg-tag.band-浜 i { background: #2a5a9a; }
.mg-tag.band-上 i { background: #3a7a4a; }
.mg-tag.band-転入 i { background: #ccc; }
.mg-tag b { font: 700 13px/1.15 var(--font); padding: 4px 0; }
.mg-tag.red { background: #a83028; color: #a83028; }
.mg-tag.red b { visibility: hidden; }
.mg-tag.red i { background: #8a2018; }
.mg-tag.picked { outline: 3px solid var(--amber); }
.mg-tag.dragging { opacity: 0.85; z-index: 5; position: relative; }
.mg-drawer { display: flex; gap: 8px; align-items: center; background: #2a2a2a; border: 1px solid #4a4a48; border-radius: 4px; padding: 6px 10px; min-height: 96px; }
.mg-drawer small { color: var(--dim); font-size: 12px; }
.mg-drawer .mg-tag { width: 46px; flex: none; }
.t-memo { background: #ece4cf; color: #222; border-radius: 3px; padding: 6px 10px; margin: 6px 0; }
.t-memo pre { font: 14px/1.6 var(--hand); margin: 2px 0 0; white-space: pre-wrap; }
.t-sel { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; margin: 6px 0; }
.t-sel .num { font-size: 18px; color: var(--amber); margin-right: 10px; }
/* P02 the tide chart */
.mg-chart { width: 100%; }
.mg-svg { width: 100%; max-height: 240px; background: #ece8da; border-radius: 4px; touch-action: none; }
.mg-svg .grid { stroke: rgba(40, 60, 90, 0.2); }
.mg-svg .lab { font: 11px var(--font); fill: #3a4a5a; }
.mg-svg .fc { fill: none; stroke: #2a4a8a; stroke-width: 2.5; stroke-dasharray: 6 4; }
.mg-svg .ob { fill: none; stroke: #c04a2a; stroke-width: 3; }
.mg-svg .pt circle { fill: #c04a2a; stroke: #fff; stroke-width: 2; cursor: ns-resize; }
.mg-svg .pt.empty circle { fill: #8a8a80; }
.mg-svg .pt text { font: 700 12px var(--font); fill: #222; }
.mg-legend { display: flex; gap: 14px; font-size: 12px; margin: 4px 0; }
.mg-legend .fc { color: #8ab0e0; }
.mg-legend .ob { color: #f08a6a; }
.mg-row3 { display: flex; justify-content: space-around; gap: 8px; }
.mg-col { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.mg-col small { color: var(--dim); }
#term-body .mg-col button { min-width: 48px; min-height: 44px; }
/* P03 the boat mirror */
.mg-mirror { display: flex; flex-wrap: wrap; gap: 18px; justify-content: center; align-items: center; }
.mg-mview { position: relative; padding-bottom: 16px; }
.mg-mview canvas { width: min(300px, 78vw); aspect-ratio: 300 / 240; border-radius: 50% / 45%; border: 6px solid #8a8e90; box-shadow: 0 0 0 2px #2a2a2a, inset 0 0 20px #000; display: block; }
.mg-mnote { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); font-size: 11px; color: var(--dim); white-space: nowrap; }
.mg-mpad { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.mg-mpad small { color: var(--dim); font-size: 12px; }
.mg-pad { width: 110px; height: 110px; border-radius: 50%; background: radial-gradient(circle, #2a2c2e, #121414); border: 2px solid #3a3e40; display: flex; align-items: center; justify-content: center; touch-action: none; cursor: grab; }
.mg-knob2 { width: 40px; height: 40px; border-radius: 50%; background: #8a6a40; border: 3px solid #c8a878; pointer-events: none; }
.mg-arrows { display: grid; grid-template-columns: repeat(4, 48px); gap: 4px; }
#term-body .mg-arrows button { min-height: 44px; font-size: 18px; color: #f0c050; }
/* P04 the valves */
.t-pipes { display: flex; justify-content: space-between; font-size: 12px; margin: 0 10px; }
.t-pipes .sea { color: var(--sea); }
.t-pipes .hill { color: var(--green); }
.mg-valve { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 104px; }
.mg-valve small { font-size: 12px; color: var(--dim); text-align: center; }
.mg-wheelv { position: relative; width: 92px; height: 92px; border-radius: 50%; border: 9px solid var(--c); box-shadow: 0 3px 8px #000, inset 0 0 6px #000; cursor: grab; touch-action: none; transition: transform 0.15s; }
.mg-wheelv i { position: absolute; left: 50%; top: 50%; width: 76px; height: 8px; margin: -4px 0 0 -38px; background: var(--c); border-radius: 4px; }
.mg-wheelv i + i { transform: rotate(90deg); }
.mg-valve .mg-vstate { color: var(--amber); }
.mg-valve.closed .mg-vstate { color: var(--red); }
/* P05 the light table */
.mg-light { display: flex; flex-direction: column; gap: 8px; }
.mg-table { position: relative; height: 170px; background: radial-gradient(ellipse, #fffbea, #e8e0c0); border: 4px solid #4a4e50; border-radius: 4px; overflow: hidden; }
.mg-table .pin { position: absolute; top: 10px; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; background: #5a5e60; box-shadow: 0 1px 2px #000; z-index: 3; }
.mg-reg { position: absolute; left: 0; right: 0; bottom: 10px; text-align: center; z-index: 4; color: #1a2a4a; }
.mg-reg b { font: 700 26px ui-monospace, monospace; background: rgba(255, 255, 240, 0.85); padding: 2px 10px; border-radius: 3px; }
.mg-reg small { display: block; font-size: 12px; color: #3a3a3a; }
.mg-reg span { font: 700 20px ui-monospace, monospace; }
.mg-sheettray { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; min-height: 82px; }
.mg-sheet { position: relative; width: 150px; height: 80px; background: rgba(220, 230, 240, 0.55); border: 1px solid #8a9aa8; border-radius: 2px; display: flex; align-items: flex-end; justify-content: center; padding: 4px; cursor: grab; touch-action: none; color: #1a2a3a; font-size: 12px; }
.mg-sheet i { position: absolute; top: 8px; width: 10px; height: 10px; border-radius: 50%; border: 2px solid #4a5a6a; }
.mg-sheet i:nth-child(1) { left: 14%; }
.mg-sheet i:nth-child(2) { left: 46%; }
.mg-sheet i:nth-child(3) { left: 78%; }
.mg-sheet.s1 { background: rgba(240, 230, 200, 0.6); }
.mg-sheet.s2 { background: rgba(230, 220, 230, 0.6); }
.mg-sheet.off { opacity: 0.35; cursor: not-allowed; }
.mg-sheet.aligned { position: absolute; width: 92%; height: 70%; pointer-events: none; }
.mg-sheet.dragging { z-index: 9; box-shadow: 0 6px 14px rgba(0, 0, 0, 0.5); }
.t-dial { align-items: flex-end; }
/* P06 the boards */
.t-p06 .board { display: block; height: 22px; max-width: 100%; background: linear-gradient(#7a8a7a, #5a6a5a); border: 1px solid #3a4a3a; border-radius: 2px; margin: 0 auto 4px; }
/* P07 the island map */
.t-clues { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 6px 0; }
.t-clues small { color: var(--dim); width: 100%; }
#term-body .t-clue { background: #ece4cf; color: #222; border-color: #8a7a5a; font-size: 13px; text-align: left; min-height: 44px; }
.mg-map { width: 100%; }
.mg-island { position: relative; height: 230px; background: #6a98b0; border-radius: 6px; overflow: hidden; touch-action: none; }
.mg-island .land { position: absolute; left: 6%; top: 8%; width: 76%; height: 84%; background: #d8d0a8; border-radius: 48% 40% 52% 44%; }
.mg-island .hill { position: absolute; left: 10%; top: 10%; width: 40%; height: 40%; background: #a8b888; border-radius: 50%; }
.mg-island .road { position: absolute; left: 36%; top: 30%; width: 30%; height: 4px; background: #7a5a3a; transform: rotate(38deg); transform-origin: left; }
#term-body .mg-place { position: absolute; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 1px; background: rgba(255, 255, 255, 0.75); color: #1a1a1a; border: 1px solid #5a5a50; padding: 3px 6px; min-height: 44px; min-width: 44px; font-size: 11px; }
#term-body .mg-place i { width: 10px; height: 10px; border-radius: 50%; background: #2a5a7a; }
#term-body .mg-place.on { border-color: var(--red); box-shadow: 0 0 0 2px var(--red); }
.mg-pin { position: absolute; transform: translate(-50%, -110%); width: 40px; height: 40px; border-radius: 50%; background: #c0302a; color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; cursor: grab; touch-action: none; z-index: 4; box-shadow: 0 3px 6px #000; border: 2px solid #fff; }
/* P08 routes and the bar */
.t-routes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 6px 0; }
#term-body .t-route { display: flex; flex-direction: column; text-align: left; min-height: 60px; }
#term-body .t-route small { color: var(--dim); font-size: 12px; }
#term-body .t-route.on { border-color: var(--green); background: #1e3a28; }
.mg-bar { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 150px; }
.mg-bar small { font-size: 12px; color: var(--dim); }
.mg-bartrack { position: relative; width: 150px; height: 46px; background: #0a0b0c; border: 2px solid #3a3e40; border-radius: 6px; }
.mg-barknob { position: absolute; top: 6px; width: 54px; height: 30px; background: linear-gradient(#9a9ea0, #5a5e60); border-radius: 4px; cursor: grab; touch-action: none; }
.mg-bar.done .mg-barknob { background: linear-gradient(#7ad890, #3a7a48); }
.t-warn { color: #f0b080; font-size: 13px; margin: 6px 0; }
.t-warn.dim { color: var(--dim); }
@media (max-width: 520px) {
  .mg-hook { min-height: 74px; }
  .mg-tag { min-height: 66px; }
  .mg-tag b { font-size: 11px; }
  .mg-board { gap: 2px; padding: 3px; }
  .t-routes { grid-template-columns: 1fr; }
  .mg-sheet { width: 120px; }
}
