/* ============================================================
   すぐくる style.css
   平常時は「ありがちな明るいECサイト」を最優先で再現する。
   ゲームらしい装飾は一切出さない。
   進行（body[data-ph]）につれて色が静かに濁っていく。
   ============================================================ */
:root {
  --bg: #ffffff;
  --paper: #ffffff;
  --ink: #1c232e;
  --sub: #5f6b7a;
  --line: #e3e8ee;
  --accent: #ff6a00;      /* すぐくるオレンジ */
  --accent-dk: #e05a00;
  --link: #276bd2;
  --star: #ff9a1f;
  --ok: #1e8e3e;
  --sale: #c0392b;
  --shade: #f5f7fa;       /* 帯・チップ背景 */
  --radius: 8px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; } /* .overlay等のdisplay指定がhidden属性に勝ってしまうのを防ぐ */
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  transition: filter 2.5s ease, background 2.5s ease;
}
/* ---- 進行につれた劣化（気づくか気づかないかの範囲で） ---- */
body[data-ph="3"] { --bg: #fdfdfb; --shade: #f4f5f4; }
body[data-ph="4"] { --bg: #f9f8f4; --shade: #f0efe9; --line: #ddddd2; }
body[data-ph="5"] { --bg: #f3f1ea; --shade: #eae7dd; --line: #d4d2c4; --sub: #6b6b60; }
/* 劣化フィルタは body ではなく各セクションへ。
   ※bodyにfilterをかけると fixed要素の基準がビューポートでなくbodyになり、
     結末画面・FAB・チャット等が長いページで画面外へずれる（CSS仕様）。 */
body[data-ph="4"] .sitehead, body[data-ph="4"] .catnav, body[data-ph="4"] #app, body[data-ph="4"] footer,
body[data-ph="4"] .utilbar { filter: saturate(0.93); }
body[data-ph="5"] .sitehead, body[data-ph="5"] .catnav, body[data-ph="5"] #app, body[data-ph="5"] footer,
body[data-ph="5"] .utilbar { filter: saturate(0.82) contrast(1.03); }

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }

/* ============ 最上部ユーティリティバー（ポータル導線） ============ */
.utilbar {
  background: #1c232e; color: #cfd6df; font-size: 11px;
  display: flex; align-items: center; gap: 10px;
  padding: calc(4px + env(safe-area-inset-top)) 12px 4px;
}
.utilbar a { color: #cfd6df; }
.utilbar .sp { flex: 1; }
.utilbar .lang button {
  background: none; border: 1px solid #46505e; color: #cfd6df;
  border-radius: 4px; font-size: 10px; padding: 1px 7px; margin-left: 4px;
}
.utilbar .lang button[aria-pressed="true"] { background: #46505e; color: #fff; }
.audio-ctl { color: #cfd6df; }

/* ============ サイトヘッダー ============ */
.sitehead {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  padding: 10px 14px 8px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 40;
}
.logo {
  font-size: 24px; font-weight: 800; letter-spacing: 0.5px;
  color: var(--accent); white-space: nowrap; line-height: 1.1;
  background: none; border: none; padding: 0;
}
.logo small { display: block; font-size: 9px; font-weight: 600; color: var(--sub); letter-spacing: 2px; }
.searchbox { flex: 1 1 200px; display: flex; min-width: 160px; position: relative; }
.searchbox input {
  flex: 1; border: 2px solid var(--accent); border-right: none;
  border-radius: 6px 0 0 6px; padding: 7px 10px; font-size: 14px; outline: none;
  background: #fff; color: var(--ink);
  -webkit-user-select: text; user-select: text;
}
.searchbox button {
  border: 2px solid var(--accent); background: var(--accent); color: #fff;
  border-radius: 0 6px 6px 0; padding: 0 14px; font-size: 15px;
}
.suggest {
  position: absolute; top: 100%; left: 0; right: 44px; z-index: 60;
  background: #fff; border: 1px solid var(--line); border-top: none;
  border-radius: 0 0 6px 6px; box-shadow: 0 6px 14px rgba(20,30,45,.12);
}
.suggest div { padding: 7px 12px; font-size: 13px; }
.suggest div:hover { background: var(--shade); }
.suggest .sg-odd { color: #7b8794; }
.headicons { display: flex; gap: 4px; }
.hbtn {
  background: none; border: none; font-size: 11px; color: var(--ink);
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 2px 8px; border-radius: 6px; position: relative;
}
.hbtn:hover { background: var(--shade); }
.hbtn .ic { font-size: 20px; line-height: 1; }
.cartbadge {
  position: absolute; top: -2px; right: 2px;
  background: var(--accent); color: #fff; border-radius: 99px;
  font-size: 10px; font-weight: 700; min-width: 16px; height: 16px;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}
.greet { font-size: 11px; color: var(--sub); width: 100%; margin: -4px 0 0; }

/* ============ カテゴリナビ ============ */
.catnav {
  display: flex; gap: 8px; overflow-x: auto; padding: 8px 14px;
  background: var(--shade); border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}
.catnav::-webkit-scrollbar { display: none; }
.catnav button {
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  border-radius: 99px; padding: 4px 13px; font-size: 12px; white-space: nowrap;
}
.catnav button:hover { border-color: var(--accent); color: var(--accent); }

/* ============ 本文 ============ */
#app { max-width: 980px; margin: 0 auto; padding: 14px 14px 90px; min-height: 60vh; }
.crumb { font-size: 11px; color: var(--sub); margin: 2px 0 10px; }
.crumb a { color: var(--sub); }
h2.rowtitle { font-size: 16px; margin: 20px 0 8px; }
h2.rowtitle small { font-weight: normal; color: var(--sub); font-size: 11px; margin-left: 8px; }

/* ヒーローバナー */
.hero {
  background: linear-gradient(100deg, #ffe8d6, #fff3e8 55%, #e8f1ff);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 22px 20px; margin-bottom: 6px;
}
.hero b { font-size: 20px; color: var(--accent-dk); }
.hero p { margin: 4px 0 0; color: var(--sub); font-size: 12.5px; }

/* キャンペーンカード */
.msn {
  border: 1px dashed var(--accent); background: #fff8f2;
  border-radius: var(--radius); padding: 10px 14px; margin: 10px 0 4px;
}
.msn .msn-t { font-weight: 700; font-size: 13.5px; }
.msn ul { margin: 6px 0 0; padding: 0; list-style: none; font-size: 12.5px; }
.msn li { padding: 2px 0; }
.msn li.ok { color: var(--ok); }
.msn .msn-rw { font-size: 11px; color: var(--accent-dk); margin-top: 6px; }
.msn .msn-done { font-size: 11px; color: var(--ok); margin-top: 6px; font-weight: 700; }
.msn-last { border-color: #8a8378; background: #f2f0e9; }
.msn-last .msn-you { cursor: pointer; color: var(--link); text-decoration: underline; }
.msn li[data-act] { cursor: pointer; }
.msn li[data-act]:hover { color: var(--link); }
.msn li.ghost { color: #9aa4b0; }
.msn .msn-price { color: var(--sub); margin-left: 6px; }
.msn .msn-price.done { text-decoration: line-through; }
.msn .msn-bud { font-size: 11.5px; margin-top: 6px; }
.btn:disabled { background: #eceff2; border-color: #dde2e8; color: #a5adb8; cursor: not-allowed; }

/* ポイントチャレンジ＆すぐくじ */
.chal {
  border: 1px solid var(--line); background: var(--paper); border-radius: var(--radius);
  padding: 8px 14px; margin: 8px 0 0; font-size: 12.5px;
}
.chal b { color: var(--accent-dk); }
.kuji {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  border: 1px solid var(--line); background: var(--paper); border-radius: var(--radius);
  padding: 8px 14px; margin: 8px 0 0; font-size: 12.5px;
}
.kuji-t { font-weight: 700; }
.kuji-res { color: var(--accent-dk); flex: 1; min-width: 60px; }
.kuji-btn {
  background: var(--accent); color: #fff; border: none; border-radius: 99px;
  padding: 5px 16px; font-size: 12px; font-weight: 700;
}
.kuji-btn:disabled { background: #d8dde3; }
.kuji-cd { color: var(--sub); font-size: 11.5px; }

/* 商品グリッド */
.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.pcard {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px; display: flex; flex-direction: column; gap: 3px;
  transition: box-shadow .15s ease, transform .15s ease;
  position: relative;
}
.pcard:hover { box-shadow: 0 4px 14px rgba(20,30,45,.10); transform: translateY(-1px); }
.ptile {
  border-radius: 6px; height: 96px;
  display: flex; align-items: center; justify-content: center;
  font-size: 44px; margin-bottom: 3px; overflow: hidden;
}
.pname {
  font-size: 12.5px; line-height: 1.4; height: 2.8em; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.pstars { color: var(--star); font-size: 11px; letter-spacing: -1px; }
.pstars .rc { color: var(--link); letter-spacing: 0; margin-left: 4px; }
.pprice { font-size: 16px; font-weight: 700; }
.pprice small { font-size: 10px; font-weight: normal; color: var(--sub); }
.pprice .was { text-decoration: line-through; }
.badge-fast {
  display: inline-block; background: #fff1e6; color: var(--accent-dk);
  font-size: 10px; font-weight: 700; border-radius: 4px; padding: 0 5px;
  width: fit-content;
}
.badge-odd { background: #eef1f4; color: #5f6b7a; }
.badge-seen { background: #e8f1ff; color: #276bd2; }

/* 商品詳細 */
.pd { display: grid; grid-template-columns: 260px 1fr; gap: 20px; }
.pd .ptile { height: 220px; font-size: 96px; }
.pd h1 { font-size: 18px; margin: 0 0 6px; line-height: 1.45; }
.pd .pprice { font-size: 26px; }
.stockok { color: var(--ok); font-weight: 700; font-size: 13px; }
.stocklow { color: var(--sale); font-weight: 700; font-size: 13px; }
.viewers { font-size: 11.5px; color: var(--sale); margin: 2px 0; }
.deliv { font-size: 13px; margin: 6px 0; }
.deliv b { color: var(--ok); }
.qtyrow { margin: 8px 0; font-size: 13px; }
.qtyrow select { padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; background: #fff; color: var(--ink); }
.btn {
  display: block; width: 100%; max-width: 300px; text-align: center;
  border-radius: 99px; padding: 9px 0; font-size: 14px; font-weight: 700;
  border: 1px solid transparent; margin: 6px 0;
}
.btn-cart { background: #ffd814; border-color: #f0c500; color: #1c232e; }
.btn-cart:hover { background: #f5cd0d; }
.btn-buy { background: var(--accent); color: #fff; }
.btn-buy:hover { background: var(--accent-dk); }
.btn-ghost { background: var(--paper); border-color: var(--line); color: var(--ink); font-weight: normal; }
.pdesc { font-size: 13px; color: #333c48; margin-top: 10px; border-top: 1px solid var(--line); padding-top: 10px; }

/* レビュー */
.reviews { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 10px; }
.rev { border-bottom: 1px solid var(--line); padding: 9px 0; }
.rev .ru { font-size: 12px; font-weight: 700; }
.rev .rd { font-size: 11px; color: var(--sub); margin-left: 8px; }
.rev .rt { font-size: 13px; margin: 3px 0 2px; }
.rev .rh { font-size: 11px; color: var(--sub); }
.rev.creepy .rt { color: #2c3440; }

/* カート */
.cartrow {
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--line); padding: 10px 0;
}
.cartrow .ptile { width: 64px; height: 64px; font-size: 30px; flex: none; }
.cartrow .cn { flex: 1; font-size: 13px; }
.cartrow .cp { font-weight: 700; font-size: 15px; white-space: nowrap; }
.cartrow .rm { background: none; border: none; color: var(--link); font-size: 11px; }
.carttotal { text-align: right; font-size: 15px; margin: 12px 0; }
.carttotal b { font-size: 20px; color: var(--sale); }

/* チェックアウト */
.chk { max-width: 560px; }
.chkbox { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; background: var(--paper); }
.chkbox h3 { margin: 0 0 4px; font-size: 13px; color: var(--sub); font-weight: 600; }
.chkbox p { margin: 0; font-size: 14px; }
.chkbox .chg { float: right; font-size: 11px; }

/* アカウント */
.acc .chkbox { margin-bottom: 12px; }
.acc table { width: 100%; border-collapse: collapse; font-size: 13px; }
.acc td { padding: 4px 6px 4px 0; vertical-align: top; }
.acc td:first-child { color: var(--sub); width: 40%; }
.closelink { color: #9aa4b0; font-size: 11px; text-decoration: underline; background: none; border: none; padding: 0; margin-top: 18px; }

/* 迷路 */
.maze { max-width: 480px; margin: 30px auto; text-align: center; }
.maze .chkbox { text-align: left; }
.maze h2 { font-size: 17px; }
.maze .note { font-size: 11px; color: var(--sub); margin: 8px 0; }
.maze .btn { margin: 8px auto; }
.maze .btn-small {
  background: none; border: none; color: #9aa4b0; font-size: 11px;
  text-decoration: underline; display: block; margin: 10px auto 0;
}
.maze label { display: block; text-align: left; font-size: 13px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; margin: 6px 0; background: var(--paper); }
.progress { height: 8px; background: var(--shade); border-radius: 99px; overflow: hidden; margin: 16px 0; }
.progress span { display: block; height: 100%; background: var(--accent); width: 0%; transition: width .4s ease; }
.mazelog { font-family: ui-monospace, Consolas, monospace; font-size: 11px; color: #8a94a0; text-align: left; min-height: 48px; }

/* ============ フッター ============ */
footer {
  background: #232a35; color: #aeb6c0; font-size: 11px;
  padding: 18px 14px calc(70px + env(safe-area-inset-bottom));
  margin-top: 30px;
}
footer .flinks { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; }
footer .flinks button { background: none; border: none; color: #aeb6c0; font-size: 11px; text-decoration: underline; padding: 0; }
footer .copy { color: #77808c; }
.seo { max-width: 980px; margin: 8px auto 0; color: #77808c; }
.seo summary { cursor: pointer; }
.seo p { font-size: 11px; line-height: 1.7; }

/* ============ すぐるくん ============ */
.sugu-fab {
  position: fixed; right: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 80;
  width: 84px; height: 84px; border-radius: 50%;
  background: #fff; border: 3px solid var(--accent);
  box-shadow: 0 4px 14px rgba(20,30,45,.2);
  padding: 4px; display: flex; align-items: center; justify-content: center;
}
.sugu-fab svg { width: 100%; height: 100%; }
.sugu-fab .fabbadge {
  position: absolute; top: -2px; right: -2px; background: var(--sale); color: #fff;
  font-size: 11px; font-weight: 700; border-radius: 99px; min-width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
}
.sugu-bubble {
  position: fixed; right: 106px; bottom: calc(34px + env(safe-area-inset-bottom)); z-index: 82;
  background: #fff; border: 1.5px solid var(--accent);
  border-radius: 12px 12px 3px 12px; padding: 8px 12px;
  font-size: 12.5px; line-height: 1.5; max-width: 230px;
  box-shadow: 0 6px 18px rgba(20,30,45,.18); cursor: pointer;
  animation: bblpop .25s ease;
}
@keyframes bblpop { from { opacity: 0; transform: translateY(6px) scale(.95); } }
body[data-ph="4"] .sugu-bubble, body[data-ph="5"] .sugu-bubble { border-color: #8a8378; }
.chatpanel {
  position: fixed; right: 14px; bottom: calc(110px + env(safe-area-inset-bottom)); z-index: 81;
  width: min(320px, calc(100vw - 28px)); max-height: 420px;
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 10px 30px rgba(20,30,45,.25);
  display: flex; flex-direction: column; overflow: hidden;
}
.chathead {
  background: var(--accent); color: #fff; padding: 8px 12px;
  display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700;
}
.chathead .cface { width: 42px; height: 42px; background: #fff; border-radius: 50%; padding: 2px; }
.chathead .on { font-size: 10px; font-weight: normal; opacity: .9; }
.chathead .on::before { content: "●"; color: #7CFC9A; margin-right: 3px; }
.chatmsgs { padding: 10px; overflow-y: auto; flex: 1; min-height: 120px; }
.cmsg {
  background: var(--shade); border-radius: 12px 12px 12px 3px;
  padding: 7px 11px; font-size: 12.5px; margin: 5px 0; width: fit-content; max-width: 92%;
}
.cmsg.log { background: #1c232e; color: #9fe8b0; font-family: ui-monospace, Consolas, monospace; font-size: 11px; border-radius: 4px; }
.cmsg.cta { border: 1.5px solid var(--accent); color: var(--accent-dk); font-weight: 700; cursor: pointer; }
.cmsg.cta:hover { background: #fff1e6; }
.cmsg.typing { color: var(--sub); font-style: italic; }
.chatfaq { display: flex; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.chatfaq button {
  border: 1px solid var(--accent); color: var(--accent-dk); background: #fff;
  border-radius: 99px; font-size: 11px; padding: 3px 10px;
}

/* ============ オーバーレイ類 ============ */
.overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(18, 22, 28, .55);
  display: flex; align-items: center; justify-content: center; padding: 18px;
}
.ovcard {
  background: #fff; border-radius: 14px; max-width: 430px; width: 100%;
  padding: 22px 22px 16px; box-shadow: 0 18px 50px rgba(0,0,0,.35);
}
.ovcard h2 { margin: 0 0 8px; font-size: 18px; }
.ovcard p { font-size: 13px; color: #333c48; }
.ovcard .fine { font-size: 11px; color: var(--sub); }
.ovcard .btn { max-width: none; }
.ovcard .btn[disabled] { background: #eee; border-color: #ddd; color: #aaa; cursor: not-allowed; }

/* 入店お出迎え（でかでか挨拶） */
#welcome {
  position: fixed; inset: 0; z-index: 210;
  background: linear-gradient(180deg, #fff 30%, #fff3e8);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; transition: opacity .5s ease; cursor: pointer;
}
#welcome .wface { width: min(36vh, 68vw); transition: transform .65s cubic-bezier(.55,-.15,.75,.95), opacity .65s ease; }
#welcome .wface svg { width: 100%; height: auto; animation: wbounce .7s ease; }
@keyframes wbounce { 0% { transform: translateY(30px) scale(.7); opacity: 0; } 60% { transform: translateY(-8px) scale(1.04); opacity: 1; } 100% { transform: none; } }
#welcome h2 { margin: 6px 0 0; font-size: 30px; color: var(--accent-dk); letter-spacing: 2px; animation: wpop .5s ease .2s backwards; }
#welcome p { margin: 0; font-size: 14px; color: var(--sub); animation: wpop .5s ease .38s backwards; }
@keyframes wpop { from { opacity: 0; transform: translateY(10px); } }
#welcome.out { opacity: 0; pointer-events: none; }
#welcome.out h2, #welcome.out p { opacity: 0; transition: opacity .25s; }
.sugu-fab.landed { animation: fabland .45s ease; }
@keyframes fabland { 0% { transform: scale(1.6); } 55% { transform: scale(.92); } 100% { transform: scale(1); } }

/* ジャンプスケア（一瞬の顔フレーム） */
#scare {
  position: fixed; inset: 0; z-index: 600; background: #0a0508;
  display: none; align-items: center; justify-content: center;
}
#scare.on { display: flex; }
#scare svg { width: min(70vh, 90vw); height: auto; }
body.shake { animation: bodyshake .28s linear; }
@keyframes bodyshake {
  20% { transform: translate(7px, -5px); }
  45% { transform: translate(-6px, 5px); }
  70% { transform: translate(5px, 3px); }
  100% { transform: none; }
}

/* 空洞化した商品カード（Just すぐるくん） */
.pcard.hollow { pointer-events: none; opacity: .75; }
.pcard.hollow .ptile { background: #ececea !important; color: #b8b8b2; }
.pcard.hollow .pname { color: #9aa4b0; }

/* 偽500エラー */
#err500 {
  position: fixed; inset: 0; z-index: 550; background: #fff; color: #000;
  display: none; padding: 40px 8%;
  font-family: Georgia, "Times New Roman", serif;
}
#err500.on { display: block; }
#err500 h1 { font-size: 24px; font-weight: 700; margin: 0 0 12px; }
#err500 hr { border: none; border-top: 1px solid #999; margin: 10px 0; }
#err500 .srv { font-size: 13px; color: #444; font-style: italic; }
#err500 .ai { font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: #888; margin-top: 18px; }

/* 偽の注文通知トースト */
.toast {
  position: fixed; top: calc(10px + env(safe-area-inset-top)); right: 10px; z-index: 90;
  background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--ok);
  border-radius: 8px; padding: 10px 14px; font-size: 12.5px;
  box-shadow: 0 8px 24px rgba(20,30,45,.22); cursor: pointer;
  animation: toastin .35s ease; max-width: 260px;
}
@keyframes toastin { from { opacity: 0; transform: translateX(40px); } }

/* 主人公の内心（モノローグ） */
#mono {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(112px + env(safe-area-inset-bottom)); z-index: 85;
  background: rgba(28, 35, 46, .93); color: #e9edf2;
  padding: 10px 18px; border-radius: 12px; font-size: 13.5px; line-height: 1.7;
  max-width: min(500px, 92vw); cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
}
#mono.in { animation: monoin .35s ease; }
@keyframes monoin { from { opacity: 0; transform: translate(-50%, 8px); } }
.msn li.now { font-weight: 700; }
.msn li.now .msn-price { color: var(--accent-dk); }

/* 偽フリーズ */
#freeze { position: fixed; inset: 0; z-index: 400; display: none; cursor: wait; }
body.frozen #freeze { display: block; }
body.frozen * { animation-play-state: paused !important; transition: none !important; }

/* エンディング演出 */
.gone { opacity: 0 !important; transition: opacity .5s ease; pointer-events: none; }
body.collapse { background: #07090c !important; transition: background 1.4s ease; }
#whiteout {
  position: fixed; inset: 0; z-index: 520; background: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; color: #333; text-align: center; padding: 20px;
  opacity: 0; pointer-events: none; transition: opacity 1.1s ease;
}
#whiteout.on { opacity: 1; pointer-events: auto; }
#welcome.dark { background: #0a0508; }
#welcome.dark h2 { color: #cdbfae; }
#welcome.dark p { color: #8a94a0; }
#ending.white { background: #f3f1ec; color: #45443f; }
#ending.white .etitle { color: #7a786f; }
#ending.white .ecount { color: #97948a; }
#ending.white .elist { color: #97948a; }
#ending.white .elist .got { color: #5f5d55; }
#ending.white .trivia { background: #fff; border-color: #ddd9cf; color: #5f5d55; }
#ending .wm { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; opacity: .05; pointer-events: none; }
#ending .wm svg { width: min(90vh, 90vw); height: auto; }

/* エンディング */
#ending {
  position: fixed; inset: 0; z-index: 500; background: #07090c;
  color: #cfd6df; display: none; align-items: center; justify-content: center;
  padding: 20px; text-align: center;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
}
#ending.show { display: flex; animation: endfade 1.6s ease; }
/* 内容が画面より高い時に上下が切れないように（flex中央寄せ＋margin:autoの安全な組み合わせ） */
#ending > div:not(.wm) { margin: auto; max-width: 100%; padding: 24px 0 calc(24px + env(safe-area-inset-bottom)); }
@keyframes endfade { from { opacity: 0; } to { opacity: 1; } }
#ending .elines { font-size: 15px; line-height: 2.1; min-height: 200px; }
#ending .elines div { opacity: 0; animation: lineup .8s ease forwards; }
@keyframes lineup { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
#ending .etitle { color: #8a94a0; font-size: 12px; letter-spacing: 3px; margin: 22px 0 4px; }
#ending .ecount { color: #5f6b7a; font-size: 11px; margin-bottom: 14px; }
#ending .elist {
  max-width: 430px; margin: 0 auto 14px; text-align: left;
  font-size: 12px; color: #5f6b7a; line-height: 1.9;
}
#ending .elist .got { color: #cfd6df; }
#ending .trivia {
  max-width: 430px; margin: 0 auto 16px; text-align: left;
  border: 1px solid #2a323d; border-radius: 10px; padding: 10px 14px;
  font-size: 12px; color: #aeb6c0; background: #0d1117;
}
#ending .btn { display: inline-block; width: auto; padding: 9px 26px; }

/* グリッチ表現 */
.glitch { animation: glitch .18s steps(2) 1; }
@keyframes glitch {
  0% { transform: translate(0); }
  25% { transform: translate(-2px, 1px); text-shadow: 2px 0 #0ff, -2px 0 #f0f; }
  50% { transform: translate(1px, -1px); }
  75% { transform: translate(-1px, 0); text-shadow: -2px 0 #0ff, 2px 0 #f0f; }
  100% { transform: translate(0); }
}
.flicker { animation: flick 3.5s linear infinite; }
@keyframes flick {
  0%, 96%, 100% { opacity: 1; }
  97% { opacity: .35; }
  98% { opacity: 1; }
  99% { opacity: .6; }
}
.jitter { animation: jit 7s linear infinite; }
@keyframes jit {
  0%, 93%, 100% { transform: none; }
  94% { transform: translate(1px, -1px); }
  95% { transform: translate(-1px, 1px); }
  96% { transform: none; }
}

/* 分身カーソル */
#ghostcur {
  position: fixed; z-index: 300; width: 16px; height: 22px; display: none;
  pointer-events: none; opacity: .8;
}

/* ============ レスポンシブ ============ */
@media (max-width: 620px) {
  /* 結末画面：文字を少し詰めて1画面に収まりやすく */
  #ending .elines { font-size: 13.5px; line-height: 1.9; min-height: 0; }
  #ending .trivia { font-size: 11.5px; }
  /* スマホではチャットパネルを低くして買い物の邪魔をしない */
  .chatpanel { max-height: 42vh; }
  .chatmsgs { min-height: 60px; }
  .pd { grid-template-columns: 1fr; }
  .pd .ptile { height: 170px; font-size: 72px; }
  .grid { grid-template-columns: repeat(2, 1fr); }
  .logo { font-size: 20px; }
  .searchbox { order: 3; flex-basis: 100%; }
}
