/* 深海解体所。深い青緑の港と、湿った紙の帳票。 */
:root {
  color-scheme: dark;
  --bg: #0d181c; --panel: #16262a; --panel2: #1d3236; --line: #365052; --ink: #e8ecdc; --muted: #a5bcb6; --mint: #a6d4b5; --amber: #eeb574; --danger: #ee9a86; --good: #a9e0b0;
  --paper-ink: #2c2014; --paper-muted: #5e4c34; --dot: 'DotGothic', 'Hiragino Kaku Gothic ProN', 'Yu Gothic', Meiryo, sans-serif; --sans: 'Hiragino Kaku Gothic ProN', 'Yu Gothic', Meiryo, sans-serif;
  --tabs-h: 54px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; color: var(--ink); background: var(--bg); font: 15px/1.65 var(--sans); padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom)); }
body.working .next-bar { display: none; }
body.at-title .top, body.at-title .tabs, body.at-title .next-bar, body.at-title main { display: none; }
h1, h2, h3, h4 { font-family: var(--dot); font-weight: 400; margin: 0 0 .4em; letter-spacing: .04em; }
h1 { font-size: 26px; } h2 { font-size: 19px; } h3 { font-size: 21px; } h4 { font-size: 17px; }
h2 small { font: 14px var(--sans); color: var(--muted); margin-left: 8px; letter-spacing: 0; }
p { margin: 0 0 .7em; }
small { font-size: 14px; }
button, .btn { font: inherit; color: inherit; cursor: pointer; border-radius: 0; touch-action: manipulation; min-height: 44px; padding: 8px 14px; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
button:disabled { cursor: default; opacity: .45; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
.primary { background: #c98440; color: #1b0f05; border: 0; box-shadow: inset -3px -3px 0 #8a5620, inset 3px 3px 0 #f0bb80; font-weight: 700; }
.primary:active:not(:disabled) { box-shadow: inset 3px 3px 0 #8a5620; }
.sub { background: #1f3438; border: 0; color: var(--ink); box-shadow: inset 0 0 0 2px var(--line); }
.muted { color: var(--muted); }
.good { color: var(--good); } .bad { color: var(--danger); }
.note { background: rgba(120,160,150,.12); padding: 6px 10px; border-left: 4px solid #5a8a80; }
strong { color: var(--amber); font-weight: 700; }
.money { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; font-family: var(--dot); }
.coin { width: 16px; height: 16px; image-rendering: pixelated; flex: none; }
.money.huge { font-size: 28px; } .money.huge .coin { width: 28px; height: 28px; }
.money.debt { color: #ffb4a0; }

/* 題名 */
.title { position: fixed; inset: 0; z-index: 30; background: #0a1a20 center 40% / cover no-repeat; image-rendering: pixelated; overflow: auto; }
.title-veil { position: fixed; inset: 0; background: linear-gradient(180deg, rgba(4,16,20,.82), rgba(4,16,20,.35) 45%, rgba(4,16,20,.9)); pointer-events: none; }
.title-in { position: relative; max-width: 560px; margin: 0 auto; padding: max(32px, 7vh) 18px 24px; display: flex; flex-direction: column; gap: 6px; min-height: 100%; }
.title h1 { font-size: clamp(44px, 12vw, 72px); line-height: 1.1; color: #f3e4c0; text-shadow: 4px 4px 0 #0a2024, -2px -2px 0 #0a2024; margin: 0; }
.title-eyebrow { font: 16px var(--dot); color: var(--amber); margin: 0; }
.title-copy { font: 17px var(--dot); color: #d8e8dc; margin: 6px 0 18px; }
.title-menu { display: flex; flex-direction: column; gap: 10px; margin-top: auto; padding-top: 16vh; }
.title-menu .big { min-height: 62px; font-size: 19px; flex-direction: column; gap: 0; font-family: var(--dot); }
.title-menu small { font: 14px var(--sans); }
.title-note { font-size: 14px; color: #c8d8d0; background: rgba(4,16,20,.72); padding: 8px 10px; margin: 0; }
.share-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.share-row > * { flex: 1 1 130px; font-size: 15px; }
.file-btn { position: relative; }

/* 上の帯 */
.top { position: sticky; top: 0; z-index: 12; display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; padding: 4px 8px; background: #0f2024; border-bottom: 2px solid var(--line); }
.top button { background: none; border: 0; padding: 0 4px; min-height: 44px; }
.top-day { flex-direction: column; align-items: flex-start !important; gap: 0; font: 14px/1.25 var(--dot); }
.top-day small { display: none; }
.top-body { min-width: 0; }
.meter { display: grid; grid-template-columns: 34px 1fr 28px; align-items: center; gap: 4px; font-size: 14px; line-height: 1.2; color: var(--muted); }
.meter b { color: var(--ink); font: 14px var(--dot); text-align: right; }
.bar { height: 8px; background: #06120f; position: relative; box-shadow: inset 0 0 0 1px #3c5a54; overflow: hidden; }
.bar i { position: absolute; inset: 0 auto 0 0; background: #8fc08a; transition: width .3s; }
.bar u { position: absolute; inset: 0 0 0 auto; background: repeating-linear-gradient(45deg, #5a2a24, #5a2a24 2px, #2a1412 2px, #2a1412 4px); }
.meter.fat .bar i { background: #d0a050; }
.ail-badge { display: block; font-size: 14px; line-height: 1.2; color: var(--danger); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-wallet { display: flex; align-items: center; gap: 4px; color: #ffe39c; }
#walletPile { width: 66px; height: 34px; image-rendering: pixelated; }
.wallet-num { font: 17px var(--dot); min-width: 3em; text-align: right; }
.next-bar { position: sticky; top: 56px; z-index: 11; width: 100%; background: #243a30; border: 0; border-bottom: 2px solid #4a6a50; text-align: left; justify-content: flex-start; min-height: 40px; padding: 4px 12px; font-size: 15px; }
.next-bar b { font: 14px var(--dot); color: #1a1006; background: var(--amber); padding: 0 6px; margin-right: 6px; }
main { max-width: 1180px; margin: 0 auto; padding: 8px 10px 16px; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 13; display: grid; grid-template-columns: repeat(5, 1fr); background: #0f2024; border-top: 2px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs button { background: none; border: 0; min-height: var(--tabs-h); font: 16px var(--dot); color: var(--muted); padding: 0; }
.tabs button.active { color: #1a1006; background: var(--amber); }
.tabs button.has { position: relative; }
.tabs button.has::after { content: ''; position: absolute; top: 8px; right: 12px; width: 8px; height: 8px; background: #ee7755; }

/* 市場 */
.panel { background: var(--panel); box-shadow: inset 0 0 0 2px var(--line); padding: 10px 12px; margin: 0 0 10px; }
.hero { position: relative; background: center 58% / cover no-repeat; image-rendering: pixelated; margin-bottom: 10px; box-shadow: inset 0 0 0 2px var(--line); }
.hero-in { background: linear-gradient(90deg, rgba(6,20,24,.92), rgba(6,20,24,.55)); padding: 12px 14px; }
.hero h1 { color: #f3e4c0; margin: 0 0 2px; }
.hero p { margin: 0 0 6px; }
.hero-stats { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 14px; color: #d0e0d8; }
.hero-stats b { font-family: var(--dot); color: var(--amber); font-weight: 400; }
.mentor { display: flex; gap: 10px; align-items: center; background: #203630; padding: 8px 10px; margin-bottom: 10px; box-shadow: inset 0 0 0 2px #4a6a50; }
.mentor p { margin: 0; }
.face { flex: none; width: 72px; height: 72px; position: relative; background: #0a1a1c; box-shadow: 0 0 0 2px #000, 0 0 0 4px #6a5a3a; }
.face img { width: 100%; height: 100%; display: block; image-rendering: pixelated; object-fit: cover; }
.face-fb { display: none; position: absolute; inset: 0; align-items: center; justify-content: center; font: 16px var(--dot); }
.face.noimg .face-fb { display: flex; }
.stock-row { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid #2c4446; }
.stock-row:has(> .stock-name:first-child) { grid-template-columns: 1fr auto; }
.stock-name small { display: block; color: var(--muted); font-size: 14px; }
.stock-btns { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.thumb { image-rendering: pixelated; display: block; width: 100%; background: #18312e; }
.thumb.small { width: 84px; }
.side-jobs { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-top: 10px; }
.side-jobs button { flex-direction: column; gap: 0; line-height: 1.3; padding: 6px 8px; }
.side-jobs small { font-size: 14px; font-weight: 400; }
.orders { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 8px; }
.order-tag { background: var(--wood) #c8a878; color: var(--paper-ink); padding: 8px 10px; box-shadow: inset 0 0 0 2px #5a3e20; display: flex; flex-direction: column; }
.order-tag em { font-style: normal; font-weight: 700; color: #7a2a10; }
.order-tag.done { opacity: .55; }
.zones { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; }
.zone { flex: none; width: 112px; background: #1a2e32; border: 0; box-shadow: inset 0 0 0 2px var(--line); flex-direction: column; align-items: flex-start; padding: 6px 8px; line-height: 1.25; text-align: left; font-size: 14px; }
.zone b { font: 18px var(--dot); color: var(--amber); }
.zone small { display: block; color: var(--muted); font-size: 14px; }
.zone.sel { background: #2e4a44; box-shadow: inset 0 0 0 3px var(--amber); }
.zone.locked { opacity: .55; }
.zone-desc { margin: 6px 0 0; color: var(--muted); }
.lots { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.tag-card { display: flex; flex-direction: column; align-items: stretch; text-align: left; gap: 3px; padding: 14px 8px 8px; position: relative; color: var(--paper-ink); background: var(--wood) #c8a878; border: 0; box-shadow: inset 0 0 0 2px #5a3e20, 3px 3px 0 #0a1416; clip-path: polygon(14px 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 0 100%, 0 14px); line-height: 1.3; }
.tag-card.huge { box-shadow: inset 0 0 0 3px #9c2a14, 3px 3px 0 #0a1416; }
.tag-card.sold { filter: grayscale(.8) brightness(.7); }
.tag-hole { position: absolute; top: 4px; left: 50%; width: 8px; height: 8px; margin-left: -4px; background: #0d181c; box-shadow: 0 0 0 2px #5a3e20; }
.tag-hole.big { position: relative; top: 0; left: 0; margin: 0 auto 8px; display: block; }
.tag-name { font: 17px var(--dot); }
.tag-meta { font-size: 14px; color: #4a3820; }
.tag-chips { display: flex; flex-wrap: wrap; gap: 3px; }
.chip { font-size: 14px; padding: 0 5px; line-height: 1.5; background: #334; color: #fff; white-space: nowrap; }
.chip.plain { background: #6a5a3a; }
.chip.order { background: #245a30; }
.g-parasite { background: #6a3a78; } .g-disease { background: #8a2c20; } .g-blemish { background: #5a5040; } .g-deform { background: #1c6070; } .g-prime { background: #a8741a; }
.tag-foot { display: flex; justify-content: space-between; align-items: center; font-size: 17px; margin-top: auto; }
.book-mark { font-size: 14px; padding: 0 4px; }
.book-mark.yes { background: #24503a; color: #fff; } .book-mark.no { background: #7a2a1c; color: #fff; }
.sold-mark { color: #7a1a10; font-family: var(--dot); }

/* 解体台 */
.work-empty { text-align: center; padding: 30px 10px; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.work-empty .stock-row { width: min(420px, 100%); }
.work-head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.work-head h2 { margin: 0; }
.work-actions { margin-left: auto; display: flex; gap: 6px; }
.work-actions button { min-height: 40px; padding: 4px 10px; font-size: 14px; }
.rail { display: flex; gap: 4px; overflow-x: auto; padding: 6px 0; scrollbar-width: thin; }
.rail-step { flex: none; min-height: 40px; padding: 2px 10px; background: var(--slip) #efe6d2; color: var(--paper-ink); border: 0; font-size: 14px; line-height: 1.2; max-width: 11em; box-shadow: inset 0 0 0 2px #8a7a5c; }
.rail-step:disabled { opacity: 1; filter: brightness(.55); }
.rail-step.cur { box-shadow: inset 0 0 0 3px #c9501c; filter: none; font-weight: 700; }
.rail-step.done { filter: brightness(.42) sepia(.6); text-decoration: line-through; }
.rail-step.opt { border-bottom: 4px dashed #5a8a80; }
.check { display: inline-block; width: 8px; height: 8px; background: #245a30; margin-right: 4px; }
.work-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 10px; align-items: start; }
.bench-view { position: relative; aspect-ratio: 8 / 5; background: #213b30; box-shadow: 0 0 0 2px #000; touch-action: none; overflow: hidden; }
#game { width: 100%; height: 100%; display: block; image-rendering: pixelated; touch-action: none; cursor: crosshair; user-select: none; -webkit-user-select: none; }
#labels { position: absolute; inset: 0; pointer-events: none; }
.bench-label { position: absolute; transform: translate(-50%, -100%); font: 14px/1.2 var(--dot); color: #fff; background: rgba(6,16,16,.72); padding: 0 3px; white-space: nowrap; }
.bench-toast { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); max-width: 92%; background: rgba(8,18,18,.92); color: #ffe6b8; font-size: 15px; line-height: 1.35; padding: 4px 10px; opacity: 0; transition: opacity .2s; pointer-events: none; box-shadow: 0 0 0 2px #6a5a3a; text-align: center; }
.bench-toast.on { opacity: 1; }
#injuryFlash { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: radial-gradient(circle, transparent 40%, rgba(170,30,20,.55)); }
#injuryFlash.hit { animation: hurt .4s; }
@keyframes hurt { 0% { opacity: 1; } 100% { opacity: 0; } }
.instruction { background: var(--panel); box-shadow: inset 0 0 0 2px var(--line); padding: 8px 10px; }
.ins-head { display: flex; justify-content: space-between; gap: 8px; font: 18px/1.3 var(--dot); }
.ins-head strong { color: var(--amber); font-weight: 400; }
.ins-head span { font-size: 15px; color: var(--muted); white-space: nowrap; }
.progress { height: 8px; background: #06120f; margin: 4px 0 6px; }
.progress i { display: block; height: 100%; background: var(--amber); width: 0; }
.instruction p { margin: 0 0 2px; font-size: 16px; line-height: 1.5; }
.instruction .why { color: var(--muted); font-size: 14px; }
.tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 6px; }
.tool { flex-direction: column; gap: 1px; background: #1f3438; border: 0; box-shadow: inset 0 0 0 2px var(--line); padding: 3px 2px; min-height: 52px; font-size: 14px; line-height: 1.15; }
.tool img { width: 24px; height: 24px; image-rendering: pixelated; }
.tool.active { background: #5a4220; box-shadow: inset 0 0 0 3px var(--amber); }
.tool.rec:not(.active) { box-shadow: inset 0 0 0 2px var(--amber); }
.tool-hint { font-size: 14px; color: var(--muted); margin: 4px 0; }
.vitals { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font-size: 14px; color: var(--muted); }
.vitals b { color: var(--ink); font: 17px var(--dot); }
.mini-bar { display: block; height: 6px; background: #06120f; }
.mini-bar i { display: block; height: 100%; background: #8fc08a; }
.work-btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.land-only { display: none !important; }
.work-btns button { flex: 1; min-height: 42px; font-size: 14px; }
.work-log { font-size: 14px; color: var(--muted); margin-top: 6px; }
.work-log p { margin: 0; line-height: 1.4; border-left: 3px solid #3c5a54; padding-left: 6px; margin-bottom: 2px; }

/* 窓 */
.overlay { position: fixed; inset: 0; z-index: 20; background: rgba(2,10,12,.72); display: flex; justify-content: center; align-items: flex-start; padding: 12px; overflow: auto; }
.overlay[hidden] { display: none; }
.modal { position: relative; width: min(620px, 100%); background: #14262a; box-shadow: 0 0 0 2px #000, 0 0 0 4px #4a6a60, 8px 8px 0 4px rgba(0,0,0,.4); padding: 14px; outline: none; }
.modal h2 { padding-right: 76px; }
.modal h2[hidden] { display: none; }
.close { position: absolute; right: 8px; top: 8px; z-index: 2; background: #1f3438; border: 0; box-shadow: inset 0 0 0 2px var(--line); min-height: 40px; font-size: 14px; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.modal-actions button { flex: 1 1 140px; }
.overlay.big .modal { box-shadow: 0 0 0 2px #000, 0 0 0 4px var(--amber), 0 0 40px 10px rgba(238,181,116,.3); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 8px 0; }
.grid2 > div { background: rgba(0,0,0,.12); padding: 4px 8px; font-size: 14px; line-height: 1.3; }
.grid2 b { display: block; font: 17px var(--dot); }
.preview { width: 100%; max-width: 400px; margin: 0 auto 6px; display: block; image-rendering: pixelated; }
.cond-list { list-style: none; padding: 0; margin: 8px 0; }
.cond-list li { display: flex; gap: 6px; align-items: flex-start; padding: 3px 0; flex-wrap: wrap; }
.cond-list span:not(.chip) { flex: 1 1 200px; }
.talk .modal { padding: 0; }
.talk-img { aspect-ratio: 16 / 9; max-height: 36vh; overflow: hidden; width: 100%; background: #0a1a1c; }
.talk-img img { width: 100%; height: 100%; object-fit: cover; display: block; image-rendering: pixelated; }
.talk-row { display: flex; gap: 12px; padding: 12px 14px 0; align-items: flex-start; }
.talk-name { font: 17px var(--dot); color: var(--amber); }
.talk-name small { font: 14px var(--sans); color: var(--muted); margin-left: 8px; }
.talk-text p { font-size: 17px; margin: 2px 0 0; }
.talk .modal-actions { padding: 0 14px 14px; }

/* 帳票: ドットの枠と紙の地 */
.paper { position: relative; color: var(--paper-ink); border: 12px solid transparent; border-image: var(--frameInk) 4 fill / 12px; image-rendering: pixelated; background: var(--washi); background-clip: padding-box; margin-bottom: 10px; }
.paper-in { position: relative; padding: 6px 8px; }
.paper .muted { color: var(--paper-muted); } .paper .good { color: #17602c; } .paper .bad { color: #9c2412; } .paper strong { color: #9c2412; }
.paper .note { background: rgba(90,70,40,.12); border-left-color: #6a5a3a; }
.paper h3 { color: var(--paper-ink); margin-bottom: 2px; }
.paper .money.debt { color: #9c2412; }
.paper .grid2 > div { background: rgba(90,70,40,.12); }
.paper.receipt, .paper.slip { background-image: var(--slip); border-image-source: var(--frameBlue); }
.paper.med { background-image: var(--med); border-image-source: var(--frameGreen); }
.paper.warn-paper { background-image: var(--red); border-image-source: var(--frameRed); }
.paper.appraisal { border-image-source: var(--frameGold); }
.paper.loan { background-image: var(--washi); }
.paper.tag-paper { background-image: var(--wood); }
.paper.bookpage { background-image: var(--washi); border-image-source: var(--frameInk); }
.receipt-head, .loan-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; border-bottom: 3px double var(--paper-ink); margin-bottom: 6px; padding-bottom: 2px; }
.receipt-head small, .loan-head small { font-size: 14px; color: var(--paper-muted); }
.receipt-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.receipt-table td { padding: 2px 4px; border-bottom: 1px dotted #8a7a5c; }
.receipt-table td:last-child { text-align: right; white-space: nowrap; }
.receipt-table .sum td { font-weight: 700; border-top: 2px solid var(--paper-ink); }
.receipt-fish { margin: 4px 0; font-weight: 700; }
.grade { float: right; font: 44px/1 var(--dot); color: #9c2412; text-align: center; margin-left: 10px; }
.grade small { display: block; font: 14px var(--sans); color: var(--paper-muted); }
.grade-S { color: #a8741a; text-shadow: 2px 2px 0 #f0d890; }
.chain-list { margin: 8px 0; padding: 6px 8px 6px 22px; background: rgba(156,36,18,.12); color: #7a1c0c; font-size: 15px; }
.paper:has(.stamp-paid) .paper-in { padding-bottom: 44px; }
.stamp-paid { position: absolute; right: 10px; bottom: 6px; font: 22px/1 var(--dot); color: rgba(30,90,50,.75); border: 3px solid rgba(30,90,50,.75); padding: 4px 6px; transform: rotate(-12deg); pointer-events: none; }
.stamp-paid.red { color: rgba(170,40,20,.72); border-color: rgba(170,40,20,.72); }
.tag-title { text-align: center; }
.tag-title small { color: var(--paper-muted); font-size: 14px; }
.relic-big { width: 220px; height: 140px; display: block; margin: 0 auto; image-rendering: pixelated; }
.debt-big { text-align: center; margin: 8px 0 4px; }
.debt-big small { display: block; font-size: 14px; color: var(--paper-muted); }
.debt-big .money { font-size: 32px; }
.debt-track { height: 10px; background: rgba(90,70,40,.3); margin-bottom: 8px; }
.debt-track i { display: block; height: 100%; background: #2a6a3a; }
.thumbs { display: flex; gap: 16px; justify-content: center; margin: 10px 0; }
.thumbs > div, .thumb-slot { text-align: center; }
.thumbs small { display: block; font-size: 14px; color: var(--paper-muted); line-height: 1.3; max-width: 130px; }
.thumb-img { width: 56px; height: 68px; image-rendering: pixelated; }
.thumb-slot { width: 130px; min-height: 96px; background: rgba(180,60,40,.1); border: 3px dashed #9c2412; color: #9c2412; font-weight: 700; }
.thumb-img.pressed { animation: stampIn .25s; }
@keyframes stampIn { from { transform: scale(1.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.credit-row { display: flex; gap: 8px; align-items: center; font-size: 15px; }
.credit-tag { flex: none; font: 16px var(--dot); padding: 3px 8px; background: var(--c); color: #120c06; box-shadow: inset 0 0 0 2px rgba(0,0,0,.5); }
.marks { display: flex; gap: 6px; align-items: center; margin: 8px 0; flex-wrap: wrap; font-size: 14px; }
.marks i { width: 18px; height: 18px; display: inline-block; box-shadow: inset 0 0 0 2px #9c2412; }
.marks i.on { background: #b4301c; }
.safe-pile { width: 100%; max-width: 540px; height: 110px; image-rendering: pixelated; display: block; background: #0e1c1c; box-shadow: inset 0 0 0 2px #3a2a18; }
.safe-row { margin: 6px 0; color: #ffe39c; }
.coin-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.coin-legend span { display: inline-flex; gap: 4px; align-items: center; }
.repay-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.repay-btns button { flex: 1 1 180px; }
.ledger-table { overflow-x: auto; }
.ledger-table table { width: 100%; border-collapse: collapse; font-size: 14px; }
.ledger-table th, .ledger-table td { padding: 3px 6px; border-bottom: 1px solid #2c4446; text-align: right; white-space: nowrap; }
.sleep-opts { display: grid; gap: 6px; }
.sleep-opt { display: grid; grid-template-columns: 1fr auto; text-align: left; background: rgba(255,255,255,.4); color: var(--paper-ink); border: 0; box-shadow: inset 0 0 0 2px #6a5a3a; padding: 6px 10px; line-height: 1.35; }
.sleep-opt small { grid-column: 1 / -1; font-size: 14px; color: var(--paper-muted); }
.book-head { display: flex; align-items: center; gap: 8px; border-bottom: 3px double var(--paper-ink); margin-bottom: 8px; }
.book-head img { width: 28px; height: 28px; image-rendering: pixelated; }
.book-head h3 { margin: 0; }
.plate { width: 100%; max-width: 400px; image-rendering: pixelated; display: block; margin: 0 auto 8px; box-shadow: 0 0 0 2px #6a5a3a; }
.book-quote { font-weight: 700; }
.step-list { padding-left: 24px; margin: 4px 0; }
.step-list li { padding: 1px 0; }
.step-list small { margin-left: 8px; color: var(--paper-muted); font-size: 14px; }
.chart-row { display: grid; grid-template-columns: 100px 1fr; gap: 10px; }
.chart { width: 100px; height: 133px; image-rendering: pixelated; background: #d8dccc; box-shadow: inset 0 0 0 2px #6a7a6a; }
.ail-list { list-style: none; padding: 0; margin: 6px 0; font-size: 15px; }
.ail-list li { padding: 3px 0; border-bottom: 1px dotted #6a7a6a; }
.ail-list b { margin-right: 6px; }
.ail-list em { font-style: normal; color: #9c2412; font-weight: 700; }
.ail-list li.sleep b { color: #1c5a6a; } .ail-list li.worsen b { color: #9c2412; }
.clinic-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.clinic-btns button { flex: 1 1 170px; }

/* 店・記録 */
.subtabs, .filters { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; align-items: center; }
.subtabs button, .filters button { background: #1f3438; border: 0; box-shadow: inset 0 0 0 2px var(--line); font: 16px var(--dot); flex: 1 1 auto; }
.filters button { font-size: 15px; }
.subtabs .active, .filters .active { background: var(--amber); color: #1a1006; }
.page-note { margin-bottom: 8px; }
.gear-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 10px; }
.gear { background: #1a2e32; box-shadow: inset 0 0 0 2px #2c4446; padding: 8px; margin-top: 6px; display: flex; flex-direction: column; gap: 4px; }
.gear b small { color: var(--muted); font-weight: 400; }
.gear span { font-size: 14px; color: var(--muted); }
.gear.owned { opacity: .72; }
.two { display: flex; gap: 6px; } .two button { flex: 1; }
.tool-ic { width: 28px; height: 28px; image-rendering: pixelated; }
.tool-shop { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 8px; }
.books { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 8px; }
.book { padding: 0; background: #1a2e32; border: 0; box-shadow: inset 0 0 0 2px var(--line); display: flex; align-items: stretch; text-align: left; justify-content: flex-start; line-height: 1.3; }
.spine { flex: none; width: 34px; background: hsl(var(--h), 34%, 26%); display: flex; align-items: center; justify-content: center; box-shadow: inset -3px 0 0 rgba(0,0,0,.35); }
.spine img { width: 24px; height: 24px; image-rendering: pixelated; }
.book-t { padding: 6px 8px; }
.book-t b { display: block; font-size: 14px; font-weight: 400; }
.book-t small { color: var(--muted); font-size: 14px; }
.book.owned .book-t small { color: var(--good); }
.codex { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.codex-card { flex-direction: column; align-items: stretch; background: #1a2e32; border: 0; box-shadow: inset 0 0 0 2px var(--line); padding: 4px; line-height: 1.3; text-align: left; font-size: 14px; }
.codex-card small { color: var(--muted); font-size: 14px; }
.pager { display: flex; justify-content: center; gap: 12px; align-items: center; margin: 10px 0; }
.shelf { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.shelf-slot { background: #2a2214; box-shadow: inset 0 0 0 2px #6a5a3a; padding: 6px; display: flex; flex-direction: column; gap: 3px; font-size: 14px; min-height: 90px; }
.shelf-slot canvas { width: 100%; max-width: 110px; image-rendering: pixelated; margin: 0 auto; }
.shelf-slot.empty { align-items: center; justify-content: center; color: var(--muted); }
.shelf-slot small { font-size: 14px; color: var(--muted); }
.relic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 8px; }
.relic-card { background: #1a2e32; padding: 6px; box-shadow: inset 0 0 0 2px var(--line); display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.relic-card canvas { width: 110px; image-rendering: pixelated; margin: 0 auto; }
.relic-card small { color: var(--muted); font-size: 14px; line-height: 1.4; }
.settings { display: flex; flex-wrap: wrap; gap: 8px; }
.settings > * { flex: 1 1 150px; }
.help { margin-bottom: 8px; } .help b { color: var(--amber); font-family: var(--dot); font-weight: 400; font-size: 16px; } .help p { margin: 0; }
.version { text-align: center; }

/* 結末 */
.ending { position: fixed; inset: 0; z-index: 25; background: #020a0c center / cover no-repeat; image-rendering: pixelated; overflow: auto; display: flex; align-items: flex-end; }
.ending[hidden] { display: none; }
.end-veil { position: fixed; inset: 0; background: linear-gradient(180deg, rgba(2,10,12,.15), rgba(2,10,12,.78) 45%, rgba(2,10,12,.95)); pointer-events: none; }
.end-in { position: relative; width: min(680px, 100%); margin: 0 auto; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
.end-title { font-size: 28px; color: #f3e4c0; text-shadow: 3px 3px 0 #000; }
.end-in p { font-size: 18px; text-shadow: 0 2px 2px #000; }
.end-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.end-btns button { flex: 1 1 160px; }
.end-list { list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 0; margin: 4px 0 10px; }
.end-list li { background: rgba(255,255,255,.08); padding: 4px 8px; font-family: var(--dot); color: var(--muted); }
.end-list li.seen { color: var(--amber); }
.notice { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 10px); transform: translate(-50%, 8px); z-index: 26; max-width: 92vw; width: max-content; background: #0a1a1c; color: #ffe6b8; padding: 6px 14px; box-shadow: 0 0 0 2px #6a5a3a; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; font-size: 16px; }
.notice.on { opacity: 1; transform: translate(-50%, 0); }
.coin-layer { position: fixed; inset: 0; z-index: 40; pointer-events: none; overflow: hidden; }
.fly-coin { position: absolute; left: -12px; top: -12px; width: 24px; height: 24px; image-rendering: pixelated; }

/* PC */
@media (min-width: 900px) {
  .work-layout { grid-template-columns: minmax(0, calc((100vh - 200px) * 1.6)) minmax(320px, 1fr); }
  .top { padding: 6px 16px; grid-template-columns: auto minmax(200px, 420px) auto; justify-content: space-between; }
  .top-day { flex-direction: row !important; gap: 12px; font-size: 17px; }
  .tabs { position: static; max-width: 1180px; margin: 0 auto; order: -1; }
  body { padding-bottom: 0; }
  .next-bar { top: 58px; }
}
/* 携帯（A12）: 窓の本文17px以上、小さい字14px以上 */
@media (max-width: 499px), (max-height: 499px) {
  .modal { font-size: 17px; padding: 10px; }
  .overlay { padding: 8px; }
  .receipt-table { font-size: 16px; }
  .cond-list li, .ail-list { font-size: 16px; }
  .paper { border-width: 9px; border-image-width: 9px; }
}
/* 縦の携帯 */
@media (max-width: 760px) {
  .work-layout { grid-template-columns: 1fr; }
  main { padding: 6px 6px 12px; }
  .wallet-num { font-size: 16px; min-width: 0; }
  #walletPile { width: 44px; }
  .chart-row { grid-template-columns: 76px 1fr; }
  .chart { width: 76px; height: 101px; }
  .shelf { grid-template-columns: 1fr; }
  .lots { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .tag-card { padding: 12px 6px 6px; }
}
/* 横の携帯 */
@media (max-height: 499px) {
  :root { --tabs-h: 44px; }
  .top { padding: 0 8px; grid-template-columns: auto 1fr auto; }
  .top button { min-height: 38px; }
  .meter { grid-template-columns: 30px 1fr 24px; }
  .meter.fat { display: none; }
  .ail-badge { display: none; }
  .next-bar { position: static; min-height: 32px; font-size: 14px; }
  .tabs button { min-height: 44px; font-size: 15px; }
  .hero { display: none; }
  body.working .next-bar { display: none; }
  body.working .top { display: none; }
  body.working .tabs { display: none; }
  body.working { padding-bottom: 0; }
  body.working main { padding: 2px 4px; max-width: none; }
  .work-head { display: none; }
  .work-btns .land-only { display: inline-flex !important; }
  .work-btns .land-only[hidden] { display: none !important; }
  .rail { padding: 2px 0; }
  .rail-step { min-height: 34px; }
  .work-layout { grid-template-columns: minmax(0, calc((100vh - 46px) * 1.6)) minmax(220px, 1fr); gap: 6px; }
  .work-side { max-height: calc(100vh - 44px); overflow-y: auto; }
  .tools { grid-template-columns: repeat(4, 1fr); }
  .tool { min-height: 46px; }
  .instruction p { font-size: 15px; }
  .ins-head { font-size: 16px; }
  .talk-img { max-height: 26vh; aspect-ratio: auto; height: 26vh; }
  .talk-row { padding-top: 6px; }
  .face { width: 56px; height: 56px; }
  .title-menu { padding-top: 12px; }
  .title-in { max-width: 700px; padding-top: 12px; }
  .title h1 { font-size: 40px; }
  .ending { align-items: flex-start; }
}
@media (prefers-reduced-motion: reduce) { #injuryFlash.hit { animation: none; } .thumb-img.pressed { animation: none; } }
