/* 届けるな ― the HUD, the terminals, the papers, the menus. Phones (375 px, touch) and PC. */
:root {
  --bg: #07090b;
  --ink: #e6e8e4;
  --dim: #9aa29e;
  --line: #3a4248;
  --panel: rgba(14, 18, 20, 0.94);
  --amber: #ffcc4a;
  --red: #ff4a3a;
  --green: #6dffa0;
  --font: "Noto Sans JP", "Yu Gothic", "Hiragino Sans", sans-serif;
  --serif: "Zen Old Mincho", "Yu Mincho", 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; }
button { font: inherit; color: inherit; }
.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.55); 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(255, 204, 74, 0.45); } 100% { background: rgba(0, 0, 0, 0.55); } }
#work { position: absolute; right: max(12px, env(safe-area-inset-right)); top: max(10px, env(safe-area-inset-top)); display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
#clock { font: 700 15px/1 ui-monospace, "Consolas", monospace; background: rgba(0, 0, 0, 0.55); padding: 6px 10px; border-radius: 6px; color: var(--green); letter-spacing: 1px; }
#work-chip { display: flex; gap: 8px; align-items: center; background: rgba(0, 0, 0, 0.6); border: 1px solid var(--line); padding: 5px 10px; border-radius: 6px; font-size: 13px; }
#work-id { font-weight: 700; }
#work-status { padding: 1px 8px; border-radius: 10px; background: #2a3238; }
#work-status.s-確定, #work-status.s-宛先確定 { background: #7a1e14; color: #fff; }
#work-status.s-隔離済 { background: #1e4a2e; }
#work-status.s-仮登録 { background: #5a4a10; }
#work-where { color: var(--dim); font-size: 12px; }
#sensor { display: flex; align-items: center; gap: 6px; background: rgba(0, 0, 0, 0.6); border: 1px solid #5a2620; padding: 4px 10px; border-radius: 6px; font-size: 13px; }
#sensor .led { width: 10px; height: 10px; border-radius: 50%; background: var(--red); box-shadow: 0 0 8px var(--red); animation: led 0.8s steps(2) infinite; }
#sensor.near .led { animation-duration: 0.35s; }
#sensor.chase { border-color: var(--red); }
#sensor-arrow { display: inline-block; font-size: 14px; transition: transform 0.1s linear; }
body.lowflash #sensor .led { animation: none; }
@keyframes led { 50% { opacity: 0.25; } }
#crosshair { position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%; background: rgba(255, 255, 255, 0.7); box-shadow: 0 0 2px #000; }
#crosshair.aim { width: 10px; height: 10px; margin: -5px 0 0 -5px; 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.65); 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; }
#carry-hint { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); font-size: 12px; background: rgba(0, 0, 0, 0.6); padding: 4px 12px; border-radius: 12px; color: var(--dim); white-space: nowrap; }
body.touch #carry-hint { bottom: 210px; }
#toast { position: absolute; left: 50%; bottom: 64px; transform: translateX(-50%); width: min(92vw, 640px); text-align: center; font-size: 15px; line-height: 1.6; background: rgba(0, 0, 0, 0.72); padding: 10px 16px; border-radius: 8px; opacity: 0; transition: opacity 0.2s; pointer-events: auto; }
#toast.show { opacity: 1; }
body.touch #toast { bottom: auto; top: 96px; }
#subtitle { position: absolute; left: 50%; bottom: 120px; transform: translateX(-50%); width: min(90vw, 600px); text-align: center; font: 17px/1.6 "Zen Kurenaido", var(--font); color: #f0ead8; text-shadow: 0 0 6px #000, 0 0 2px #000; opacity: 0; transition: opacity 0.4s; }
#subtitle.show { opacity: 1; }
body.touch #subtitle { bottom: 220px; }
#stamp { position: absolute; left: 50%; top: 34%; transform: translate(-50%, -50%) rotate(-8deg) scale(1.6); font: 700 34px var(--serif); color: var(--red); border: 4px solid var(--red); padding: 4px 18px; border-radius: 6px; opacity: 0; }
#stamp.show { animation: stamp 1.8s ease-out; }
@keyframes stamp { 0% { opacity: 0; transform: translate(-50%, -50%) rotate(-8deg) scale(1.9); } 12% { opacity: 1; transform: translate(-50%, -50%) rotate(-8deg) scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -50%) rotate(-8deg) scale(1); } }
#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; color: #cfe; display: none; max-width: 52vw; }
body.debug #debug { display: block; }

/* ---- 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: 132px; height: 132px; 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: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%; background: rgba(255, 255, 255, 0.35); }
#t-buttons { position: absolute; right: max(12px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(2, 72px); gap: 8px; pointer-events: auto; }
#t-buttons button { height: 52px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, 0.35); background: rgba(20, 24, 26, 0.7); font-size: 14px; touch-action: none; }
#t-buttons button.big { grid-column: span 2; height: 60px; background: rgba(255, 204, 74, 0.28); border-color: var(--amber); font-size: 17px; font-weight: 700; }
#t-buttons button.on { background: rgba(255, 204, 74, 0.45); }
#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.62); padding: 16px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; width: min(560px, 100%); max-height: calc(100vh - 32px); 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: #1c2226; border-radius: 6px; padding: 6px 12px; cursor: pointer; 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: #1a2024; cursor: pointer; 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: #1a2024; 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(520px, 100%); max-height: calc(100vh - 80px); overflow: auto; background: #e9e2cc center/cover; color: #1d1c1a; padding: 26px 26px 22px; border-radius: 2px; box-shadow: 0 8px 40px rgba(0, 0, 0, 0.7); position: relative; }
#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; }
#doc-body.hand { font: 19px/1.9 "Zen Kurenaido", var(--serif); color: #232a44; }
#doc .hint { color: #cfd4d0; }

/* inventory */
.inv-box { width: min(720px, 100%); }
#inv-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px; }
#inv-list button { text-align: left; padding: 8px; border-radius: 6px; border: 1px solid var(--line); background: #1a2024; cursor: pointer; font-size: 13px; min-height: 40px; }
#inv-list button.sel { border-color: var(--amber); }
#inv-list .empty { color: var(--dim); font-size: 13px; }
#inv-detail { margin: 12px 0; min-height: 60px; padding: 10px; border: 1px dashed var(--line); border-radius: 6px; font-size: 14px; line-height: 1.7; }
#inv-name { font-weight: 700; color: var(--amber); }
#inv-actions button { margin-top: 8px; margin-right: 8px; padding: 6px 12px; border-radius: 6px; border: 1px solid var(--line); background: #2a1a18; cursor: pointer; }
.inv-docs .sub { font-size: 13px; color: var(--dim); margin: 8px 0 4px; }
#doc-list { display: flex; flex-wrap: wrap; gap: 6px; }
#doc-list button { font-size: 12px; padding: 5px 8px; border-radius: 5px; border: 1px solid var(--line); background: #1a2024; cursor: pointer; }

/* terminal */
.term-panel { background: #0a1410; border-color: #2a5a3a; font-family: ui-monospace, var(--font); }
.term-head { display: flex; align-items: center; gap: 10px; justify-content: space-between; color: var(--green); font-weight: 700; margin-bottom: 10px; }
.lamp { width: 14px; height: 14px; border-radius: 50%; background: #233; margin-left: auto; }
.lamp.red { background: var(--red); box-shadow: 0 0 12px var(--red); }
.lamp.green { background: var(--green); box-shadow: 0 0 12px var(--green); }
#term-lines { font-size: 15px; line-height: 1.8; color: #c8f8d8; white-space: pre-wrap; margin-bottom: 10px; }
#term-warn { border: 2px solid var(--amber); background: rgba(255, 204, 74, 0.12); color: var(--amber); padding: 8px; border-radius: 6px; font-size: 13px; margin: 8px 0; }
#term-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
#term-buttons button { position: relative; overflow: hidden; flex: 1 1 46%; padding: 11px 8px; border-radius: 6px; border: 1px solid #2a5a3a; background: #12261a; color: #d8ffe4; cursor: pointer; font-size: 14px; text-align: left; touch-action: none; }
#term-buttons button.key { flex: 0 0 calc(20% - 7px); text-align: center; }
#term-buttons button.danger { border-color: #7a3020; background: #2a1410; }
#term-buttons button.off { opacity: 0.45; }
#term-buttons button .why { display: block; font-size: 11px; color: var(--dim); }
#term-buttons button .num { color: var(--amber); margin-right: 6px; }
#term-buttons button .fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: rgba(255, 204, 74, 0.35); pointer-events: none; }
#term-toast { min-height: 1.6em; margin-top: 10px; font-size: 14px; color: #fff3c8; line-height: 1.6; }

/* 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(255, 204, 74, 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; } }

/* 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.4; filter: saturate(0.6); }
#title .title-inner { position: relative; width: min(460px, 100%); text-align: center; }
#title .series { font-size: 12px; color: var(--dim); letter-spacing: 2px; }
#title h1 { font: 700 56px/1.1 var(--serif); margin: 10px 0 2px; letter-spacing: 8px; text-shadow: 0 0 18px rgba(255, 60, 40, 0.35); }
#title .sub { font: 18px var(--serif); letter-spacing: 6px; color: #d8d0c0; }
#title .rule { margin: 18px auto 8px; padding: 8px 12px; border-top: 1px solid #5a2620; border-bottom: 1px solid #5a2620; font: 15px var(--serif); color: #ffd8c8; }
#title .meta { font-size: 13px; color: var(--dim); }
#title .headphones { margin-top: 12px; font-size: 12px; color: var(--dim); }
#title .warn { margin-top: 4px; }
.title-menu { max-width: 320px; margin: 16px auto; }
#chapter-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; max-width: 360px; margin: 0 auto 10px; }
#chapter-list button { padding: 8px; border-radius: 6px; border: 1px solid var(--line); background: #1a2024; cursor: pointer; font-size: 13px; }

/* 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-label { width: min(78vw, 520px); aspect-ratio: 4 / 5; background: #f2efe4; color: #111; border: 8px solid #111; padding: 6% 7%; transform: scale(0.2); opacity: 0; position: relative; font-family: var(--font); }
#death.go #death-label { animation: label 2.6s ease-in forwards; }
@keyframes label { 0% { transform: scale(0.15); opacity: 0; } 25% { opacity: 1; } 100% { transform: scale(1.08); opacity: 1; } }
.dl-head { font: 700 clamp(20px, 6vw, 34px) var(--font); border-bottom: 4px solid #111; padding-bottom: 6px; }
#death-name { font: 700 clamp(28px, 9vw, 54px) var(--font); margin-top: 18%; min-height: 1.3em; }
.dl-bar { height: 22%; margin-top: 12%; background: repeating-linear-gradient(90deg, #111 0 4px, transparent 4px 7px, #111 7px 9px, transparent 9px 14px); }
#death-stamp { position: absolute; right: 8%; bottom: 10%; font: 700 clamp(22px, 7vw, 40px) var(--serif); color: #c01e14; border: 4px solid #c01e14; padding: 2px 10px; transform: rotate(-10deg) scale(2); opacity: 0; }
#death-stamp.on { animation: dstamp 0.25s ease-out forwards; }
@keyframes dstamp { to { transform: rotate(-10deg) scale(1); opacity: 1; } }
#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.85; }
#ending-text { position: absolute; left: 50%; bottom: 12%; 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: 22px; 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); cursor: pointer; }

/* result */
.result-panel { text-align: center; width: min(600px, 100%); }
.result-code { font-size: 13px; color: var(--dim); letter-spacing: 2px; }
.result-title { font: 700 30px 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(3, 1fr); gap: 6px; margin: 10px 0; }
.result-grid div { background: #1a2024; border-radius: 6px; padding: 8px 4px; font-size: 12px; color: var(--dim); }
.result-grid b { display: block; font-size: 18px; color: var(--ink); margin-top: 2px; }
#result-ends { 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: #11161a; }
.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: 54px; background: #0a0c0e center/cover no-repeat; border-radius: 4px; margin-bottom: 4px; }
#gallery-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
#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: #1a2024; cursor: pointer; }
.share-buttons .share-x { background: #000; border-color: #444; }
.share-buttons .share-fb { background: #1b4f9a; }
.share-buttons .share-line { background: #06a04a; }
.share-buttons .share-ig { background: linear-gradient(45deg, #f2a43a, #d9406a, #7a46c8); border: none; }
.share-note { font-size: 12px; color: var(--dim); min-height: 1.4em; }

@media (max-width: 520px) {
  #objective { font-size: 12px; max-width: 58vw; padding: 5px 8px; }
  #work-chip { font-size: 11px; flex-wrap: wrap; justify-content: flex-end; max-width: 40vw; }
  #title h1 { font-size: 44px; }
  #gallery-list, #result-ends { grid-template-columns: repeat(2, 1fr); }
  #term-buttons button { flex: 1 1 100%; }
  #term-buttons button.key { flex: 0 0 calc(20% - 7px); }
  .result-grid b { font-size: 15px; }
}
@media (max-height: 460px) {
  .panel { padding: 10px 12px; }
  #term-lines { font-size: 13px; line-height: 1.55; }
  #term-buttons button { padding: 7px 8px; }
}
