/*
 * 色はぴたんのイラストから取る。
 *   背景 = 髪の水色、線 = 線画の焦げ茶、強調 = 目の琥珀色、差し色 = 耳の桃色
 * 枠線は #rough フィルターで少し揺らし、イラストの手描きの線に合わせる。
 */
:root {
  --sky: #dcecfa;
  --grid: #c4dbf1;
  --panel: #fbfaf7;
  --ink: #2b1710;
  --ink-2: #6e5d55;
  --hair: #a9d4ff;
  --hair-deep: #2f86d8;
  --ear: #ffc2e4;
  --eye: #ffb21e;
  --on: #2b1710;          /* 明るい差し色の上の文字 */
  --veil: rgba(220, 236, 250, .85);
  --dot: "DotGothic16", monospace;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --body: "Zen Kaku Gothic New", system-ui, sans-serif;
  --pad: max(16px, 4vw);
  --shadow: 4px 5px 0 var(--ink);
  --sticker: drop-shadow(3px 0 0 #fff) drop-shadow(-3px 0 0 #fff) drop-shadow(0 3px 0 #fff) drop-shadow(0 -3px 0 #fff) drop-shadow(5px 6px 0 rgba(43, 23, 16, .8));
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--sky); color: var(--ink);
  font: 16px/1.85 var(--body); overflow-x: hidden;
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 32px 32px; background-attachment: fixed;
}
a { color: inherit; }
img { display: block; max-width: 100%; height: auto; }
button { font: inherit; color: inherit; }
::selection { background: var(--eye); color: var(--ink); }
:focus-visible { outline: 3px solid var(--hair-deep); outline-offset: 3px; }
.defs { position: absolute; }

/* 手描き風の枠。背景と枠を ::before に描いて揺らす */
.sk { position: relative; isolation: isolate; }
.sk::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: var(--sk-bg, var(--panel)); border: 2px solid var(--ink); border-radius: 3px;
  box-shadow: var(--sk-shadow, var(--shadow)); filter: url(#rough);
}

#scene { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; }
main, .footer { position: relative; z-index: 2; }

/* ---------- bar ---------- */
.bar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center;
  height: 50px; padding-left: var(--pad); background: var(--panel); border-bottom: 2px solid var(--ink);
}
.bar-logo { display: flex; align-items: center; gap: 8px; text-decoration: none; font: 400 17px var(--dot); white-space: nowrap; }
.bar-logo img { image-rendering: pixelated; }

.bar-coords { margin: 0; font: 12px var(--mono); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.bar nav { display: flex; margin-left: auto; height: 100%; }
.bar nav a { display: grid; place-items: center; padding: 0 16px; text-decoration: none; font-weight: 700; font-size: 14px; border-left: 2px solid var(--ink); }
.bar nav a:hover { background: var(--hair); }
.bar-sound, .bar-term { height: 100%; border: 0; border-left: 2px solid var(--ink); cursor: pointer; font: 700 12px var(--mono); }
.bar-sound { padding: 0 14px; background: var(--panel); min-width: 76px; }
.bar-sound:hover { background: var(--ear); }
.bar-sound[aria-pressed="false"] { color: var(--ink-2); }
.bar-term { padding: 0 18px; background: var(--eye); }
.bar-term:hover { background: var(--ink); color: var(--eye); }
@media (max-width: 760px) { .bar nav, .bar-coords { display: none; } .bar-sound { margin-left: auto; } }

/* ---------- hero ---------- */
.hero {
  min-height: calc(100svh - 50px); display: grid; grid-template-columns: 1.15fr .85fr; align-items: center; gap: 24px;
  padding: 40px var(--pad) 56px;
}
.hero-title { margin: 0 0 20px; line-height: .9; }
.ht-jp { display: block; font: 400 clamp(30px, 4vw, 54px)/1 var(--dot); margin-bottom: .25em; }
.ht-en {
  display: block; font: 900 clamp(92px, 17vw, 270px)/.82 var(--body); letter-spacing: -.055em;
  color: var(--panel); -webkit-text-stroke: 2px var(--ink); text-shadow: 6px 7px 0 var(--ink);
}
.hero-lead, .hero-facts { max-width: 33em; margin: 0 0 12px; }
.hero-lead { font-size: clamp(16px, 1.5vw, 19px); font-weight: 700; }
.hero-facts { color: var(--ink-2); }
.hero-lead, .hero-facts, .hero-hint { background: var(--veil); }
.hero-hint { margin: 20px 0 0; font-size: 14px; padding-left: 12px; border-left: 4px solid var(--eye); max-width: 33em; }
.hero-sticker { position: relative; justify-self: center; }
.sticker {
  --dx: 0px; --dy: 0px; --tilt: 0deg;
  border: 0; background: none; padding: 0; cursor: grab; width: min(36vw, 440px); touch-action: none; position: relative;
  transform: translate(var(--dx), var(--dy)) rotate(calc(5deg + var(--tilt)));
  transition: transform .55s cubic-bezier(.3, 1.8, .4, 1);
}
.sticker, .sticker img { user-select: none; -webkit-user-select: none; -webkit-user-drag: none; }
.sticker img { filter: var(--sticker); pointer-events: none; }
.sticker::after { content: ""; position: absolute; top: 4%; left: 40%; width: 110px; height: 28px; background: rgba(255, 194, 228, .8); transform: rotate(-10deg); }
.sticker.dragging { cursor: grabbing; transition: none; z-index: 5; }
.sticker.dragging img { filter: drop-shadow(3px 0 0 #fff) drop-shadow(-3px 0 0 #fff) drop-shadow(0 3px 0 #fff) drop-shadow(0 -3px 0 #fff) drop-shadow(14px 18px 0 rgba(43, 23, 16, .45)); }
.sticker.boing img { animation: boing .45s; }
@keyframes boing { 30% { transform: scale(1.1, .9); } 60% { transform: scale(.95, 1.05); } }
.say {
  position: absolute; left: -8%; top: 6%; margin: 0; padding: 8px 14px; max-width: 240px; font-weight: 700; font-size: 14px;
  opacity: 0; transform: translateY(6px); transition: .2s; pointer-events: none; z-index: 6;
}
.say.show { opacity: 1; transform: none; }
@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; padding-top: 24px; }
  .hero-sticker { order: -1; }
  .sticker { width: min(62vw, 290px); }
}

/* ---------- chatlog（ゲーム画面左下のチャット欄に見立てた更新履歴） ---------- */
.chatlog { list-style: none; margin: 22px 0 0; padding: 0; display: grid; gap: 2px; justify-items: start; font: 400 14px/1.5 var(--dot); }
.chatlog li { background: rgba(43, 23, 16, .72); color: #fff; padding: 2px 10px; text-shadow: 1px 1px 0 #3a2a22; }
.chatlog time { color: var(--hair); }
.chatlog a { color: var(--eye); text-decoration: none; }
.chatlog a:hover { text-decoration: underline; }
.chatlog li:nth-child(3) { opacity: .8; }
.chatlog li:nth-child(4) { opacity: .6; }

/* ---------- section ---------- */
.section { padding: 110px var(--pad) 40px; }
.sec-title { font: 400 clamp(40px, 6.5vw, 84px)/1.1 var(--dot); margin: 0 0 48px; }
.sec-title small { font: 700 16px var(--body); color: var(--ink-2); margin-left: 12px; }

/* ---------- works ---------- */
.work { display: grid; grid-template-columns: 5fr 7fr; gap: 0 56px; align-items: center; min-height: 78vh; padding: 32px 0; }
.work:nth-of-type(even) .work-text { order: 2; }
.work-text { min-width: 0; padding: 28px 30px; }
.work:nth-of-type(3n+2) .work-text { transform: rotate(-.6deg); }
.work:nth-of-type(3n) .work-text { transform: rotate(.5deg); }
.work-cat { margin: 0; font-size: 14px; font-weight: 700; color: var(--hair-deep); }
.work h3 { font: 900 clamp(28px, 3.2vw, 44px)/1.15 var(--body); margin: 4px 0 14px; letter-spacing: -.02em; overflow-wrap: anywhere; }
.work h3 a { text-decoration: none; }
.work h3 a:hover { background: linear-gradient(transparent 60%, var(--eye) 60%); }
.work-summary { font-weight: 700; margin: 0 0 6px; }
.work-detail { color: var(--ink-2); margin: 0 0 16px; font-size: 15px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0 0 20px; padding: 0; list-style: none; font-size: 13px; color: var(--ink-2); }
.tags li::before { content: "#"; color: var(--hair-deep); }
.work-links { display: flex; gap: 12px; flex-wrap: wrap; margin: 0; }
.work-links a { --sk-shadow: 3px 3px 0 var(--ink); padding: 6px 14px; font-weight: 700; font-size: 14px; text-decoration: none; transition: transform .1s; }
.work-links a:first-child { --sk-bg: var(--eye); }
.work-links a:hover { transform: translate(-1px, -2px); }
.work-slot { position: relative; margin: 0; aspect-ratio: 1; width: min(100%, 500px); justify-self: center; }
.work-slot img { width: 100%; height: 100%; object-fit: cover; border: 2px solid var(--ink); box-shadow: var(--shadow); }
body.gl .work-slot img { visibility: hidden; }
@media (max-width: 820px) {
  .work { grid-template-columns: 1fr; min-height: 0; gap: 24px; }
  .work:nth-of-type(even) .work-text { order: 0; }
  .work-slot { width: min(76%, 340px); order: -1; }
}

/* ---------- index ---------- */
.index-tools { display: grid; gap: 14px; margin-bottom: 24px; }
#index-q { width: min(100%, 420px); padding: 10px 14px; border: 2px solid var(--ink); border-radius: 3px; background: var(--panel); font: 15px var(--body); box-shadow: 3px 3px 0 var(--ink); outline: none; }
#index-q:focus { box-shadow: 3px 3px 0 var(--hair-deep); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.filter { --sk-shadow: none; border: 0; background: none; padding: 4px 12px; font-size: 13px; font-weight: 700; cursor: pointer; }
.filter small { font-weight: 400; margin-left: 6px; color: var(--ink-2); }
.filter:hover { --sk-bg: var(--hair); }
.filter.is-on { --sk-bg: var(--ink); color: var(--panel); }
.filter.is-on small { color: var(--eye); }
.index { list-style: none; margin: 0; padding: 4px 0; --sk-shadow: var(--shadow); }
@media (min-width: 1100px) { body.gl .index { margin-right: 260px; } }
.index li { border-bottom: 1px dashed var(--ink-2); }
.index li:last-child { border-bottom: 0; }
.index li[hidden], .index:not(.is-all) li.is-more { display: none; }
.index a { display: grid; grid-template-columns: minmax(170px, 1.1fr) 2fr 120px 48px; gap: 16px; align-items: baseline; padding: 10px 18px; text-decoration: none; font-size: 14px; }
.index a:hover { background: var(--hair); }
.ix-name { font-weight: 900; }
.ix-desc { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ix-cat { font-size: 12px; font-weight: 700; color: var(--hair-deep); }
.ix-year { font: 12px var(--mono); color: var(--ink-2); }
.index-more { --sk-bg: var(--eye); --sk-shadow: 3px 3px 0 var(--ink); margin-top: 18px; border: 0; background: none; padding: 8px 18px; font-weight: 700; cursor: pointer; }
.index-empty[hidden] { display: none; }
.index-empty { display: flex; align-items: flex-end; gap: 12px; padding-top: 24px; }
.index-empty img { width: 160px; filter: var(--sticker); transform: rotate(-6deg); animation: peekup .4s cubic-bezier(.3, 1.5, .5, 1); }
.index-empty p { margin: 0 0 24px; padding: 10px 16px; }
.index-empty b { font-family: var(--mono); }
@keyframes peekup { from { transform: translateY(60px) rotate(-6deg); opacity: 0; } }
.index-preview { position: fixed; z-index: 40; width: 280px; aspect-ratio: 16 / 9; object-fit: cover; pointer-events: none; border: 2px solid var(--ink); box-shadow: var(--shadow); opacity: 0; transform: rotate(-3deg); transition: opacity .15s; }
.index-preview.show { opacity: 1; }
@media (max-width: 820px) {
  .index a { grid-template-columns: 1fr auto; padding: 10px 12px; }
  .ix-desc, .ix-year { display: none; }
  .index-preview { display: none; }
}

/* ---------- inventory（ゲームの持ち物欄。ブロックと同じ世界観） ---------- */
.inventory { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 28px; }
.inv { --sk-bg: #c6c6c6; padding: 14px; }
.inv-label { margin: 0 0 10px; font: 400 16px var(--dot); }
.inv ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 4px; }
.slot {
  aspect-ratio: 1.5; display: grid; place-items: center; text-align: center; padding: 4px;
  font: 400 13px/1.2 var(--dot); background: #8b8b8b; color: #fff; text-shadow: 1px 1px 0 #3f3f3f;
  border: 2px solid; border-color: #373737 #fff #fff #373737; cursor: default;
}
.slot:hover, .slot:focus { background: #a7a7a7; outline: none; }
.inv ul { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); }
.slot { aspect-ratio: 1; align-content: center; gap: 6px; padding: 6px 4px; }
/* ロゴは台座なしでスロットに直接置き、持ち物欄のアイテムのように影だけ付ける */
.slot-icons { display: flex; justify-content: center; align-items: center; height: 38px; }
.slot-icons img { width: 34px; height: 34px; filter: drop-shadow(2px 2px 0 rgba(0, 0, 0, .35)); }
.slot-icons.is-pair img { width: 28px; height: 28px; }
.slot-icons img.is-pixel { image-rendering: pixelated; }
.slot-icons.is-pair img + img { margin-left: -6px; transform: translateY(6px); }
.slot:hover .slot-icons img, .slot:focus .slot-icons img { transform: scale(1.12); }
.slot:hover .slot-icons.is-pair img + img { transform: translateY(6px) scale(1.12); }
.slot-mark { height: 38px; display: grid; place-items: center; font: 400 22px var(--dot); color: #fff; text-shadow: 2px 2px 0 #3f3f3f; }
.slot-name { font-size: 12px; line-height: 1.2; }

/* ---------- log ---------- */
.log { display: grid; grid-template-columns: 1.3fr 1fr; gap: 48px; align-items: start; }
.history { list-style: none; margin: 0; padding: 0 0 0 26px; border-left: 3px solid var(--ink); }
.history li { position: relative; padding: 0 0 30px; }
.history li::before { content: ""; position: absolute; left: -36px; top: 6px; width: 16px; height: 16px; background: var(--eye); border: 2px solid var(--ink); }
.history b { display: block; font: 400 20px var(--dot); }
.history span { color: var(--ink-2); }
.unlocks { padding: 18px 22px; }
.unlocks h3 { margin: 0 0 4px; font: 400 16px var(--dot); }
.unlocks h3:not(:first-child) { margin-top: 18px; }
.unlocks ul { margin: 0; padding-left: 1.2em; }
@media (max-width: 820px) { .log { grid-template-columns: 1fr; } }

/* ---------- footer ---------- */
.footer { margin-top: 80px; padding: 18px var(--pad); background: var(--panel); border-top: 2px solid var(--ink); display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; font-size: 13px; }
.footer a { font-weight: 700; }
.footer p { margin: 0; color: var(--ink-2); }
.footer-hint { margin-left: auto !important; }
kbd { font: 12px var(--mono); border: 1px solid currentColor; border-radius: 3px; padding: 0 5px; }

/* ---------- courier（FTPちゃん / HTTPちゃんの配達） ---------- */
.courier { position: fixed; left: 0; bottom: 0; z-index: 46; display: flex; align-items: flex-end; gap: 8px; pointer-events: none; transform: translateX(-110%); transition: transform .45s cubic-bezier(.3, 1.3, .5, 1); }
.courier.show { transform: translateX(0); }
.courier-btn { pointer-events: auto; padding: 0; border: 0; background: none; cursor: pointer; }
.courier-btn:hover img { transform: rotate(3deg) translateY(-6px); }
.courier img { transition: transform .2s; width: 170px; filter: var(--sticker); margin: 0 0 -40px -10px; transform: rotate(8deg); }
.courier-log { margin-bottom: 24px; background: var(--ink); color: var(--panel); font: 12px var(--mono); padding: 8px 12px; min-width: 240px; border-radius: 3px; }
.courier-log i { display: block; height: 8px; border: 1px solid var(--panel); margin-top: 6px; }
.courier-log b { display: block; height: 100%; width: 0; background: var(--eye); }

/* ---------- block tip ---------- */
.block-tip { position: fixed; left: 0; top: 0; z-index: 44; pointer-events: none; opacity: 0; background: var(--panel); border: 2px solid var(--ink); border-radius: 3px; padding: 4px 10px; font-size: 12px; line-height: 1.4; box-shadow: 3px 3px 0 var(--ink); transition: opacity .1s; }
.block-tip.show { opacity: 1; }
.block-tip b { display: block; font: 400 13px var(--dot); }
.block-tip span { color: var(--ink-2); }
.block-tip.has-work { background: var(--eye); }
.block-tip.has-work span { color: var(--ink); }
@media (hover: none) { .block-tip { display: none; } }

/* ---------- loot ---------- */
.loot { position: fixed; inset: 0; z-index: 45; display: grid; place-items: center; background: rgba(43, 23, 16, .3); padding: 16px; }
.loot[hidden] { display: none; }
.loot-card { --sk-shadow: 7px 8px 0 var(--ink); display: grid; gap: 4px; width: min(360px, 100%); padding: 14px 14px 18px; text-decoration: none; animation: pop .35s cubic-bezier(.3, 1.6, .5, 1); }
.loot-card img[hidden] { display: none; }
.loot-card img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border: 2px solid var(--ink); margin-bottom: 10px; }
.loot-get { font: 400 15px var(--dot); background: var(--eye); justify-self: start; padding: 0 8px; }
.loot-body { display: grid; gap: 4px; }
.card-name { margin: 0; font-size: 22px; font-weight: 900; line-height: 1.3; }
.loot-card small { font-size: 13px; font-weight: 700; color: var(--hair-deep); }
.loot-card { position: relative; width: min(420px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; }
.loot-card p { margin: 0; font-size: 14px; color: var(--ink-2); }
.loot-close { position: absolute; top: 6px; right: 6px; z-index: 1; width: 32px; height: 32px; border: 2px solid var(--ink); background: var(--panel); font: 700 18px/1 var(--mono); cursor: pointer; }
.loot-close:hover { background: var(--ear); }
.loot-note { margin: 8px 0 2px; padding: 8px 10px; background: var(--sky); border-left: 4px solid var(--eye); }
.loot-note span { font: 400 13px var(--dot); }
.loot-note p { color: var(--ink); }
.loot-spec { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 8px 0 0; font-size: 13px; }
.loot-spec dt { color: var(--ink-2); }
.loot-spec dd { margin: 0; font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }
.loot-tags { font-size: 12px !important; color: var(--hair-deep) !important; }
.loot-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px !important; }
.loot-links a { padding: 3px 10px; border: 2px solid var(--ink); background: var(--eye); color: var(--ink); font-weight: 700; font-size: 13px; text-decoration: none; }
.loot-links a:hover { background: var(--ear); }
@keyframes pop { from { transform: scale(.6) rotate(-8deg); opacity: 0; } }

/* ---------- terminal ---------- */
.terminal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(43, 23, 16, .35); padding: 16px; }
.terminal[hidden] { display: none; }
.term-win { width: min(720px, 100%); height: min(480px, 80vh); display: flex; flex-direction: column; background: #1d120e; color: #f3ece6; border: 2px solid var(--ink); border-radius: 4px; box-shadow: 8px 9px 0 var(--eye); font: 13px/1.6 var(--mono); overflow: hidden; }
.term-bar { display: flex; align-items: center; background: var(--panel); color: var(--ink); border-bottom: 2px solid var(--ink); }
.term-bar p { margin: 0; padding: 6px 12px; font-weight: 700; }
.term-bar button { margin-left: auto; border: 0; border-left: 2px solid var(--ink); background: var(--ear); cursor: pointer; font-size: 18px; width: 40px; align-self: stretch; }
.term-out { flex: 1; overflow-y: auto; padding: 14px 16px; white-space: pre-wrap; word-break: break-word; }
.term-out .cmd { color: var(--hair); }
.term-out .err { color: #ff9a86; }
.term-in { display: flex; gap: 8px; padding: 10px 16px; border-top: 1px solid #4a3a33; }
.term-in label { color: var(--eye); }
.term-in input { flex: 1; background: none; border: 0; outline: none; color: inherit; font: inherit; }

/* ---------- toasts ---------- */
.toasts { position: fixed; top: 64px; right: 16px; z-index: 60; display: grid; gap: 10px; pointer-events: none; }
.toast { width: 290px; padding: 8px 12px; background: var(--ink); color: var(--panel); border-radius: 4px; font-size: 13px; line-height: 1.4; display: grid; grid-template-columns: 32px 1fr; gap: 10px; align-items: center; box-shadow: 3px 3px 0 var(--eye); animation: toast-in .3s steps(4), toast-out .3s 4s steps(4) forwards; }
.toast i { font-style: normal; font: 22px var(--dot); text-align: center; color: var(--eye); }
.toast b { display: block; font: 400 13px var(--dot); color: var(--eye); }
@keyframes toast-in { from { transform: translateY(-140%); } }
@keyframes toast-out { to { transform: translateY(-140%); opacity: 0; } }

.debug { position: fixed; left: 12px; bottom: 12px; z-index: 60; margin: 0; font: 11px/1.5 var(--mono); background: var(--ink); color: #b6ffb0; padding: 8px 12px; border-radius: 4px; }

/* ---------- bug mode ---------- */
body.bug { --sky: #1d120e; --grid: #33241e; --panel: #2b1d18; --ink: #f3ece6; --ink-2: #b9a79d; }
body.bug .ht-en { animation: glitch .25s steps(2) infinite; }
@keyframes glitch { 0% { transform: translate(3px, -2px) skewX(6deg); clip-path: inset(10% 0 30% 0); } 50% { transform: translate(-4px, 2px); clip-path: inset(40% 0 0 0); } }
.rain { position: fixed; top: -140px; width: 90px; z-index: 70; pointer-events: none; filter: var(--sticker); animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(calc(100vh + 280px)) rotate(540deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}

/* 実績の数字 */
.hero-facts .num { font: 400 1.9em/1 var(--dot); color: var(--ink); margin: 0 .12em; background: linear-gradient(transparent 62%, var(--eye) 62%); }
.hero-facts .num { white-space: nowrap; }
.history b, .history span { background: var(--veil); }

/* ---------- スマホ ---------- */
@media (max-width: 600px) {
  .bar-sound { min-width: 0; padding: 0 10px; }
  .chatlog { font-size: 13px; max-width: 100%; }
  .chatlog li { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .index a { padding: 8px 12px; font-size: 13px; }
  .courier img { width: 112px; margin-bottom: -24px; }
  .courier-log { min-width: 0; max-width: calc(100vw - 120px); font-size: 11px; margin-bottom: 16px; overflow-wrap: anywhere; }
  .loot { align-items: start; padding-top: 72px; }
}
/* ---------- キャラクター紹介 ---------- */
.chara { position: fixed; inset: 0; z-index: 48; display: grid; place-items: center; background: rgba(43, 23, 16, .35); padding: 16px; }
.chara[hidden] { display: none; }
.chara-card { position: relative; display: grid; grid-template-columns: 220px 1fr; gap: 16px; align-items: center; width: min(560px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; padding: 18px 20px; animation: pop .35s cubic-bezier(.3, 1.6, .5, 1); }
.chara-card img { width: 100%; filter: var(--sticker); user-select: none; }
.chara-text { display: grid; gap: 6px; }
.chara-text small { font: 12px var(--mono); color: var(--hair-deep); }
.chara-text b { font: 400 26px var(--dot); }
.chara-text p { margin: 0; font-size: 14px; color: var(--ink-2); }
@media (max-width: 600px) {
  .chara-card { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .chara-card img { width: 180px; }
}
@media (hover: none) { .hint-pc { display: none; } }

/* ---------- 夜（ダークモード） ---------- */
html[data-theme="dark"] {
  --sky: #121829; --grid: #1b2440; --panel: #1f1b26; --ink: #efe3d8; --ink-2: #b4a59b;
  --hair-deep: #8cc6ff; --veil: rgba(18, 24, 41, .85); --shadow: 4px 5px 0 #000;
  color-scheme: dark;
}
html[data-theme="dark"] .loot-card, html[data-theme="dark"] .chara-card { --sk-shadow: 7px 8px 0 #000; }
html[data-theme="dark"] .toast { background: #2a2433; color: var(--ink); }
html[data-theme="dark"] .sticker img, html[data-theme="dark"] .courier img, html[data-theme="dark"] .chara-card img { filter: drop-shadow(3px 0 0 #fff) drop-shadow(-3px 0 0 #fff) drop-shadow(0 3px 0 #fff) drop-shadow(0 -3px 0 #fff) drop-shadow(5px 6px 0 rgba(0, 0, 0, .8)); }
html[data-theme="dark"] .courier-log { background: #000; color: var(--ink); }
html[data-theme="dark"] .chatlog li { background: rgba(0, 0, 0, .6); }
::selection, .bar nav a:hover, .bar-sound:hover, .bar-theme:hover, .bar-dex:hover, .bar-term, .index a:hover, .block-tip.has-work,
.loot-get, .loot-links a, .work-links a:first-child, .loot-close:hover, .term-bar button { color: var(--on); }
body { transition: background-color .4s; }

/* ---------- テーマ・図鑑のボタン ---------- */
.bar-theme, .bar-dex { height: 100%; border: 0; border-left: 2px solid var(--ink); background: var(--panel); cursor: pointer; padding: 0 14px; font: 400 13px var(--dot); white-space: nowrap; }
.bar-theme:hover { background: var(--hair); }
.bar-dex:hover { background: var(--eye); }
.bar-dex { margin-left: auto; }
@media (max-width: 760px) { .bar-dex { margin-left: auto; } .bar-sound { margin-left: 0; } }
@media (max-width: 600px) { .bar-theme, .bar-dex { padding: 0 8px; font-size: 12px; } }

/* ---------- 作品図鑑 ---------- */
.dex { position: fixed; inset: 0; z-index: 44; display: grid; place-items: center; background: rgba(43, 23, 16, .35); padding: 16px; }
.dex[hidden] { display: none; }
.dex-win { position: relative; width: min(760px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; padding: 18px 18px 14px; animation: pop .35s cubic-bezier(.3, 1.6, .5, 1); }
.dex-title { margin: 0; font: 400 22px var(--dot); color: #3f3f3f; }
.dex-count { margin: 0 0 10px; font: 400 14px var(--dot); color: #3f3f3f; }
.dex-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 4px; }
.dex-slot { width: 100%; aspect-ratio: 1; padding: 3px; display: grid; place-items: center; cursor: pointer; }
.dex-slot img { width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; }
.dex-slot .slot-mark { height: auto; font-size: 18px; }
.dex-slot:not(.is-found) .dex-img, .dex-slot.is-found .dex-q { display: none; }
.dex-slot:not(.is-found) { cursor: default; font: 400 22px var(--dot); color: #5b5b5b; text-shadow: none; background: #7a7a7a; }
.dex-hint { margin: 10px 0 0; font-size: 12px; color: #3f3f3f; line-height: 1.5; }

/* ---------- sudo rm -rf / ---------- */
body.collapsed main > *, body.collapsed .footer {
  animation: crumble 1.6s var(--fall-d, 0s) cubic-bezier(.5, 0, .9, .4) forwards;
}
@keyframes crumble {
  0%, 12% { transform: translate(0, 0); }
  6% { transform: translate(-6px, 2px) rotate(-1deg); }
  100% { transform: translate(var(--fall-x, 0), 140vh) rotate(var(--fall-r, 20deg)); }
}
@media (prefers-reduced-motion: reduce) { body.collapsed main > *, body.collapsed .footer { animation: none; opacity: .2; } }
/* ---------- 作品の詳細ページ ---------- */
.work-page { max-width: 720px; margin: 0 auto; padding: 32px var(--pad) 0; }
.crumb { margin: 0 0 16px; font-size: 13px; color: var(--ink-2); }
.work-detail-card { width: 100%; padding: 20px 22px 24px; animation: none; }
.work-detail-card h1 { margin: 0; font-size: clamp(26px, 5vw, 36px); line-height: 1.3; font-weight: 900; }

/* ---------- 404 ---------- */
.nf { min-height: 100vh; display: flex; align-items: flex-end; justify-content: center; flex-wrap: wrap; gap: 8px; padding: 16px; }
.nf img { width: 220px; transform: rotate(-6deg); filter: var(--sticker); }
.nf-res { background: var(--panel); border: 2px solid var(--ink); box-shadow: 6px 6px 0 var(--ink); padding: 16px 20px; margin-bottom: 40px; font: 14px/1.7 var(--mono); }
.nf-res h1 { font: 400 56px/1 var(--dot); margin: 0 0 8px; }
.nf-res pre { margin: 0 0 12px; }
.nf-res a { display: inline-block; background: var(--eye); border: 2px solid var(--ink); padding: 4px 12px; color: var(--on); text-decoration: none; font-weight: 700; }
.loot-links a.loot-page { background: var(--panel); color: var(--ink); }
