*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
:root{
  --paper:#f5efe3;--paper2:#efe7d6;--ink:#2c2620;--muted:#7a6f5d;
  --wood:#9a6a3a;--wood-dark:#6b4521;--line:#ddd1b8;--radius:10px;
}
html{scroll-behavior:smooth}
body{
  font-family:"Hiragino Kaku Gothic ProN","Yu Gothic",system-ui,sans-serif;
  background:var(--paper);color:var(--ink);min-height:100vh;
  display:flex;flex-direction:column;
}
a{color:inherit;text-decoration:none}

/* ── ヘッダー ── */
.site-header{
  background:linear-gradient(180deg,var(--wood),var(--wood-dark));
  color:#fff8ec;padding:14px 22px;display:flex;align-items:baseline;gap:14px;
  flex-wrap:wrap;box-shadow:0 2px 10px rgba(0,0,0,.18);
  position:sticky;top:0;z-index:50;
}
.brand{font-size:1.35rem;font-weight:800;letter-spacing:.04em}
.brand-sub{font-size:.82rem;opacity:.85}

#app{flex:1;width:100%;max-width:1180px;margin:0 auto;padding:24px 18px 40px}

.site-footer{
  font-size:.74rem;color:var(--muted);text-align:center;
  padding:16px;border-top:1px solid var(--line);background:var(--paper2);
}

/* ── DQ俯瞰マップ（トップページ）── */
.map-intro{
  max-width:900px;margin:0 auto;padding:22px 4px 8px;
  display:grid;grid-template-columns:1fr auto;gap:20px;align-items:end;
}
.map-intro-text h2{margin:0 0 6px;font-size:1.5rem;font-weight:900;letter-spacing:-.01em}
.map-intro-text p{margin:0;color:var(--muted);font-size:.9rem;max-width:480px;line-height:1.7}
.map-actions{display:flex;flex-wrap:wrap;justify-content:flex-end;align-items:center;gap:8px;max-width:430px}
.favorites-btn{
  display:inline-flex;align-items:center;gap:6px;
  min-height:38px;padding:8px 16px;border-radius:20px;
  background:var(--paper2);border:1px solid var(--line);
  color:var(--ink);font-size:.82rem;font-weight:700;cursor:pointer;
  white-space:nowrap;transition:.14s;
}
.favorites-btn:hover{background:var(--wood);color:#fff;border-color:var(--wood)}
.favorites-btn .fav-count{
  background:var(--wood);color:#fff;border-radius:10px;
  padding:1px 7px;font-size:.72rem;font-weight:800;
  transition:.14s;
}
.favorites-btn:hover .fav-count{background:#fff;color:var(--wood)}
.stamps-btn{background:#fff8e8;border-color:#c9ab73}
.discovery-count{font-size:.78rem;color:var(--wood-dark);font-weight:700;white-space:nowrap;padding:4px 8px}
.today-hint{
  display:inline-block;margin-top:4px;font-size:.84rem;
  background:var(--paper2);border:1px solid var(--line);
  border-radius:20px;padding:3px 11px;
}
.today-hint a{color:var(--wood-dark);font-weight:700;text-decoration:none}
.today-hint a:hover{text-decoration:underline}

.map-wrap{max-width:900px;margin:0 auto;padding:4px 0 28px}

/* ── 今日の本屋さんぽ ── */
.daily-quest{
  max-width:900px;margin:12px auto 16px;padding:15px 18px;
  background:#fffaf0;border:1px solid #d8c49c;border-left:5px solid var(--wood);
  border-radius:var(--radius);box-shadow:0 2px 8px rgba(75,52,24,.08);
}
.daily-quest.complete{border-left-color:#3f8b4b;background:#f4fbef}
.daily-quest-header{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:10px}
.daily-quest-header strong{font-size:1rem;color:var(--wood-dark)}
.daily-quest.complete .daily-quest-header strong{color:#2f7139}
.daily-progress{font-size:.78rem;font-weight:800;background:var(--paper2);border-radius:20px;padding:3px 10px;white-space:nowrap}
.daily-store-list{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}
.daily-store{display:flex;align-items:center;gap:7px;padding:8px 10px;border:1px solid var(--line);border-radius:8px;background:#fff;font-size:.82rem;font-weight:700;min-width:0}
.daily-store:hover{border-color:var(--wood);background:#fffdf8}
.daily-store.completed{color:#367440;background:#eef8e8;border-color:#a8c99d}
.daily-complete{margin-top:9px;font-size:.74rem;color:var(--muted);text-align:right}

.map-header{text-align:center;padding:8px 0 10px}
.map-header-main{
  display:block;font-size:1.1rem;font-weight:900;
  color:var(--ink);letter-spacing:.06em;
}
.map-header-sub{
  display:block;font-size:.78rem;color:var(--muted);margin-top:3px;
  letter-spacing:.03em;
}

/* 町マップグリッド */
.town-map{
  display:grid;
  grid-template-columns:repeat(5,1fr);
  gap:3px;
  background:#1e4010;
  border:3px solid #0e2808;
  border-radius:3px;
  padding:4px;
  /* 芝生タイルパターン */
  background-image:
    repeating-linear-gradient(0deg,rgba(0,0,0,.08) 0 1px,transparent 1px 14px),
    repeating-linear-gradient(90deg,rgba(0,0,0,.08) 0 1px,transparent 1px 14px);
}

/* 芝セル（土台） */
.map-cell{
  background:#3a7022;
  border:1px solid rgba(0,0,0,.22);
  border-radius:2px;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:flex-end;
  padding:2px 2px 5px;
  min-height:110px;
  position:relative;
}

/* 草地のみ（建物なし） */
.map-grass{
  background:
    radial-gradient(circle at 25% 35%,#4a8a2a,transparent 55%),
    radial-gradient(circle at 70% 65%,#3a7018,transparent 55%),
    #3a7022;
}

/* プレイヤー広場 */
.map-plaza{
  background:#c0a038;
  background-image:
    repeating-linear-gradient(0deg,rgba(0,0,0,.06) 0 1px,transparent 1px 10px),
    repeating-linear-gradient(90deg,rgba(0,0,0,.06) 0 1px,transparent 1px 10px);
  border-color:#8a7020;
  justify-content:center;gap:3px;
}
.player{
  font-size:1.55rem;line-height:1;
  animation:bob 1.8s ease-in-out infinite;
}
@keyframes bob{
  0%,100%{transform:translateY(0)}
  50%{transform:translateY(-4px)}
}
.plaza-label{
  font-size:.48rem;font-weight:900;color:#4a3000;letter-spacing:.05em;
}

/* 案内所セル */
.map-info-cell{
  background:#e0d060;
  background-image:
    repeating-linear-gradient(0deg,rgba(0,0,0,.05) 0 1px,transparent 1px 10px),
    repeating-linear-gradient(90deg,rgba(0,0,0,.05) 0 1px,transparent 1px 10px);
  border-color:#a09020;
  justify-content:center;gap:1px;
}
.info-icon{font-size:1.2rem;line-height:1}
.info-label{font-size:.48rem;font-weight:900;color:#504010}
.info-count{font-size:.44rem;color:#706020}

/* ── 書店タイル（クリッカブル建物）── */
.map-tile{
  display:flex;flex-direction:column;align-items:center;
  text-decoration:none;color:inherit;width:100%;
  transition:transform .15s,filter .15s;
  position:relative;
}
.map-tile:hover,.map-tile:focus-visible{
  transform:translateY(-7px);
  filter:drop-shadow(0 8px 12px rgba(0,0,0,.55));
  z-index:10;outline:none;
}
.map-tile.visited{filter:drop-shadow(0 0 3px rgba(255,224,120,.75))}
.quest-marker,.visited-marker{
  position:absolute;top:-5px;right:1px;z-index:12;display:grid;place-items:center;
  min-width:22px;height:22px;padding:0 4px;border-radius:50%;background:#fff8d8;border:2px solid #b88122;
  color:#76500e;font-size:.7rem;font-weight:900;box-shadow:0 2px 5px rgba(0,0,0,.28);
}
.quest-marker.completed{background:#e8f7df;border-color:#3c8b48;color:#2c7138}
.visited-marker{background:#f5ead6;border-color:#9a6a3a;color:#76502b}

/* 屋根 */
.bld-roof{
  width:90%;height:13px;
  background:color-mix(in srgb,var(--store) 80%,#000 20%);
  border-radius:2px 2px 0 0;
  border-top:1px solid rgba(255,255,255,.25);
  border-left:1px solid rgba(255,255,255,.12);
  border-right:1px solid rgba(0,0,0,.35);
}

/* 建物本体 */
.bld-body{
  width:90%;
  background:#f0e8d4;
  border-left:2px solid var(--store);
  border-right:2px solid var(--store);
  padding:3px 3px 2px;
  display:flex;flex-direction:column;align-items:center;gap:3px;
}
.bld-windows{display:flex;gap:4px}
.bld-win{
  width:10px;height:9px;
  background:#a8c8e0;border:1px solid #5890b0;
  transition:background .3s,border-color .3s,box-shadow .3s;
}
.bld-win.lit{
  background:#ffe060;border-color:#c89020;
  box-shadow:0 0 5px rgba(255,200,0,.7);
}
.bld-icon{font-size:1.45rem;line-height:1}

/* 入口ドア */
.bld-door{
  width:38%;height:10px;
  background:var(--store);
  border-radius:2px 2px 0 0;
  border:1px solid rgba(0,0,0,.25);border-bottom:none;
  margin-top:2px;
}

/* 店名 */
.bld-name{
  font-size:.6rem;font-weight:800;
  text-align:center;color:var(--ink);
  line-height:1.2;margin-top:2px;
  width:100%;white-space:nowrap;
  overflow:hidden;text-overflow:ellipsis;
}

/* 営業ステータスバッジ */
.store-status{
  font-size:.56rem;font-weight:700;
  padding:1px 4px;border-radius:3px;
  margin-top:2px;
  background:rgba(0,0,0,.65);color:#bbb;
  white-space:nowrap;line-height:1.4;
}
.store-status[data-status="open"]{
  background:rgba(0,80,0,.85);color:#a0ffa0;
}
.store-status[data-status="closed"]{
  background:rgba(110,0,0,.85);color:#ffa0a0;
}

/* ── テーマ別建物スタイル ── */
/* 🐈 猫書店 — 木造あたたか */
.bld-cat .bld-body{background:#ede0b8}
.bld-cat .bld-roof{border-radius:4px 4px 0 0}

/* 🚀 未来書店 — 近未来・クール */
.bld-future .bld-body{background:#d0e8f4;border-width:1px}
.bld-future .bld-roof{
  background:color-mix(in srgb,var(--store) 60%,#999);border-radius:0;
}
.bld-future .bld-win{background:#50d0ff;border-color:#2090d0}
.bld-future .bld-win.lit{background:#00ffff;box-shadow:0 0 6px #0ff4}

/* 🕯️ 深夜書店 — ダーク・神秘 */
.bld-midnight .bld-body{background:#22223a;border-color:var(--store)}
.bld-midnight .bld-win{background:#2a2a50;border-color:#4444a0}
.bld-midnight .bld-win.lit{background:#c0a0ff;border-color:#9060ff;box-shadow:0 0 6px #80f}

/* ⚔️ 異世界書店 — 城砦風 */
.bld-fantasy .bld-roof{
  height:14px;clip-path:polygon(0 100%,12% 0,25% 100%,37% 0,50% 100%,63% 0,75% 100%,88% 0,100% 100%);
  border-radius:0;
}
.bld-fantasy .bld-body{background:#d8d0c0}

/* 🌈 こども書店 — カラフル */
.bld-kids .bld-roof{
  background:linear-gradient(90deg,#ff6b6b,#ffd93d,#6bcb77,#4d96ff);
}
.bld-kids .bld-win{border-radius:50%}
.bld-kids .bld-win.lit{background:#ffd93d;box-shadow:0 0 5px #fd0}

/* 🔍 謎解き書店 — 重厚 */
.bld-mystery .bld-body{background:#e8e0f4}
.bld-mystery .bld-win{background:#c0b0e0;border-color:#8060c0}

/* 📜 歴史書店 — レンガ風 */
.bld-history .bld-body{
  background:repeating-linear-gradient(
    180deg,#e8d0b0 0 5px,#d8c0a0 5px 6px
  );
}

/* 🍳 食卓書店 — あたたかオレンジ */
.bld-kitchen .bld-body{background:#f4e4cc}

/* ── 凡例 ── */
.map-legend{
  display:flex;justify-content:center;gap:16px;
  padding:8px 0 2px;flex-wrap:wrap;
}
.legend-item{font-size:.7rem;color:var(--muted)}
.legend-item.open{color:#1a7a1a;font-weight:700}
.legend-item.closed{color:#9a1a1a;font-weight:700}
.legend-item.hint{font-size:.65rem;opacity:.7}

/* タグ（棚ヘッダーで共通利用） */
.store-tag{font-size:.68rem;background:var(--paper2);color:var(--muted);border-radius:20px;padding:2px 9px;border:1px solid var(--line)}

/* ── 棚（書店内）── */
.shelf-header{
  background:linear-gradient(180deg,var(--store),color-mix(in srgb,var(--store) 70%,#000));
  color:#fff;border-radius:var(--radius);padding:16px 20px;margin-bottom:8px;
  display:flex;align-items:center;gap:14px;flex-wrap:wrap;
  box-shadow:0 3px 12px rgba(0,0,0,.18);
}
.shelf-back{
  background:rgba(255,255,255,.18);border:1px solid rgba(255,255,255,.4);
  color:#fff;padding:7px 14px;border-radius:20px;font-size:.82rem;cursor:pointer;
  white-space:nowrap;transition:.14s;
}
.shelf-back:hover{background:rgba(255,255,255,.32)}
.shelf-title{display:flex;align-items:center;gap:12px;flex:1;min-width:0}
.shelf-title .emoji{font-size:2rem}
.shelf-title h1{font-size:1.25rem;font-weight:800}
.shelf-title p{font-size:.78rem;opacity:.9;margin-top:2px}
.shelf-tags{display:flex;flex-wrap:wrap;gap:6px;margin:10px 2px 18px}
.shelf-tags .store-tag{background:#fffdf8}
.shelf-count{font-size:.8rem;color:var(--muted);margin:0 2px 12px}

/* 本の並ぶ棚 */
.book-grid{
  display:grid;gap:14px;
  grid-template-columns:repeat(auto-fill,minmax(130px,1fr));
}
@media(min-width:700px){.book-grid{grid-template-columns:repeat(auto-fill,minmax(150px,1fr))}}
.book{
  position:relative;aspect-ratio:2/3;border-radius:6px;overflow:hidden;
  background:#e8ddc6;box-shadow:0 2px 6px rgba(0,0,0,.18);
  transition:transform .18s,box-shadow .18s;
}
.book:hover{transform:translateY(-5px) scale(1.03);box-shadow:0 14px 30px rgba(0,0,0,.32);z-index:3}
.book img{width:100%;height:100%;object-fit:cover;display:block}
/* 書影なし → 背表紙スタイル */
.book-nocover{width:100%;height:100%;display:flex;flex-direction:column;
  justify-content:space-between;padding:10px 8px;
  background:var(--spine-bg,#1a3a5c);color:var(--spine-fg,#fff);
  border-left:4px solid rgba(255,255,255,.2)}
.book-nocover .spine-title{font-size:.72rem;font-weight:700;line-height:1.45;
  -webkit-line-clamp:6;display:-webkit-box;-webkit-box-orient:vertical;overflow:hidden;
  letter-spacing:.02em}
.book-nocover .spine-author{font-size:.62rem;opacity:.75;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.book-nocover .spine-mark{font-size:1.1rem;opacity:.4;align-self:flex-end}
.new-badge{position:absolute;top:7px;left:7px;background:#e3503e;color:#fff;
  font-size:.6rem;font-weight:800;padding:2px 6px;border-radius:4px;letter-spacing:.04em;
  box-shadow:0 1px 3px rgba(0,0,0,.3)}
.fav-badge{position:absolute;top:7px;right:7px;font-size:.85rem;line-height:1;
  filter:drop-shadow(0 1px 2px rgba(0,0,0,.4));pointer-events:none}
.fav-btn{border-color:rgba(255,200,0,.5)!important;transition:.14s!important}
.fav-btn.fav-active{background:rgba(180,100,0,.5)!important;border-color:#ffa500!important}
.book.discovered{box-shadow:0 2px 6px rgba(0,0,0,.18),0 0 0 2px rgba(212,166,72,.55)}
.discovered-badge{
  position:absolute;left:7px;bottom:7px;z-index:2;background:rgba(255,247,213,.95);color:#79550d;
  border:1px solid #d6ac50;border-radius:10px;padding:2px 6px;font-size:.55rem;font-weight:800;
  box-shadow:0 1px 3px rgba(0,0,0,.25);pointer-events:none;
}

/* ホバー時のオーバーレイ */
.book-over{position:absolute;inset:0;opacity:0;transition:opacity .18s;
  background:linear-gradient(to top,rgba(20,14,6,.97) 50%,rgba(20,14,6,.35) 100%);
  display:flex;flex-direction:column;justify-content:flex-end;padding:11px;color:#fff}
.book:hover .book-over,.book:focus-within .book-over{opacity:1}
.book-over .ot{font-size:.76rem;font-weight:700;line-height:1.35;margin-bottom:3px;
  -webkit-line-clamp:3;display:-webkit-box;-webkit-box-orient:vertical;overflow:hidden}
.book-over .oa{font-size:.68rem;color:#e8d9bb;margin-bottom:2px;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.book-over .od{font-size:.66rem;color:#c9b893;margin-bottom:7px}
.book-links{display:flex;flex-wrap:wrap;gap:5px}
.book-link{font-size:.66rem;padding:3px 9px;border-radius:12px;white-space:nowrap;
  border:1px solid rgba(255,255,255,.4);color:#fff;background:rgba(0,0,0,.35);transition:.12s}
.book-link.buy{background:#bf0000;border-color:#bf0000}
.book-link:hover{filter:brightness(1.2)}

/* ── 状態表示 ── */
.state{text-align:center;padding:64px 20px;color:var(--muted)}
.state .big{font-size:2.6rem;margin-bottom:14px}
.spinner{width:34px;height:34px;border:3px solid var(--line);border-top-color:var(--wood);
  border-radius:50%;animation:spin .7s linear infinite;margin:0 auto 16px}
@keyframes spin{to{transform:rotate(360deg)}}
.notice{max-width:560px;margin:40px auto;background:#fffdf8;border:1px solid var(--line);
  border-left:4px solid #e0a800;border-radius:var(--radius);padding:20px 22px}
.notice h3{font-size:1rem;margin-bottom:10px;color:#9a6a00}
.notice p{font-size:.86rem;color:var(--ink);line-height:1.8}
.notice code{background:var(--paper2);padding:2px 6px;border-radius:4px;font-size:.82em}
.notice a{color:var(--wood);text-decoration:underline}

/* ── スタンプ帳 ── */
.stamps-page{max-width:960px;margin:0 auto}
.stamps-summary{display:grid;grid-template-columns:repeat(3,1fr);gap:10px;margin:16px 0}
.stamp-stat{display:flex;flex-direction:column;align-items:center;gap:3px;padding:14px 10px;background:#fffaf0;border:1px solid var(--line);border-radius:9px;text-align:center}
.stamp-stat strong{font-size:1.15rem;color:var(--wood-dark)}
.stamp-stat span{font-size:.72rem;color:var(--muted)}
.stamp-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px}
.stamp-card{position:relative;min-width:0;padding:16px;border-radius:10px;border:2px dashed var(--line);background:#f7f1e5;transition:transform .14s,box-shadow .14s,border-color .14s}
.stamp-card:hover,.stamp-card:focus-visible{transform:translateY(-3px);box-shadow:0 7px 16px rgba(75,52,24,.15);outline:none}
.stamp-card.visited{background:linear-gradient(145deg,#fffdf7,color-mix(in srgb,var(--store) 10%,#fff));border:2px solid color-mix(in srgb,var(--store) 65%,#9a6a3a)}
.stamp-card.unvisited{opacity:.65;filter:grayscale(.65)}
.stamp-card-title{display:flex;align-items:center;gap:8px;margin-bottom:10px;min-width:0}
.stamp-card-title span{font-size:1.55rem}
.stamp-card-title strong{font-size:.92rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.stamp-status{font-size:.76rem;font-weight:800;color:var(--muted);margin-bottom:6px}
.stamp-card.visited .stamp-status{color:color-mix(in srgb,var(--store) 75%,#493015)}
.stamp-meta{font-size:.7rem;color:var(--muted);line-height:1.55}

/* ── 達成トースト ── */
.game-toast{
  position:fixed;left:50%;bottom:24px;z-index:1000;transform:translate(-50%,18px);
  min-width:min(340px,calc(100vw - 32px));padding:13px 18px;border-radius:10px;
  background:#3c2b1a;color:#fff8e8;box-shadow:0 8px 24px rgba(0,0,0,.32);
  opacity:0;transition:opacity .2s,transform .2s;pointer-events:none;text-align:center;
}
.game-toast.show{opacity:1;transform:translate(-50%,0)}
.game-toast strong,.game-toast span{display:block}
.game-toast strong{font-size:.92rem}.game-toast span{font-size:.74rem;margin-top:3px;opacity:.86}

@media(max-width:700px){
  #app{padding:16px 10px 32px}
  .map-intro{grid-template-columns:1fr;align-items:start;gap:12px;padding-top:12px}
  .map-actions{justify-content:flex-start;max-width:none}
  .daily-store-list{grid-template-columns:1fr}
  .daily-complete{text-align:left}
  .stamp-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
  .stamps-summary{gap:6px}.stamp-stat{padding:11px 5px}.stamp-stat strong{font-size:1rem}
}

@media(max-width:430px){
  .site-header{padding:11px 13px}.brand{font-size:1.15rem}.brand-sub{font-size:.72rem}
  .favorites-btn{padding:7px 11px;font-size:.76rem}.discovery-count{width:100%;padding-left:2px}
  .daily-quest{padding:13px 12px}.daily-quest-header strong{font-size:.9rem}
  .stamp-grid{grid-template-columns:1fr}.stamp-card{padding:14px}
  .town-map{gap:2px;padding:3px}.map-cell{min-height:96px}.bld-name{font-size:.52rem}.store-status{font-size:.49rem}
}
