/* ウルストス工房：坂道の町
   - ページ全体が1枚の世界（#world のキャンバス）。その上に「段」ごとの内容をのせる
   - 見出しはドット文字（DotGothic16）、本文は丸ゴシック（Zen Maru Gothic）
   - 文章はゲームのメッセージウィンドウ風の枠（.win）に入れる
   - --px（1ドットの大きさ）と --ground（段の地面の厚さ）は world.js が入れる */
:root {
  --px: 3px;
  --ground: 54px;
  --ink: #2a1a14;
  --win: #1d2547;
  --win-line: #ffffff;
  --win-text: #ffffff;
  --win-sub: #d7ddf3;
  --gold: #ffd76a;
  --link: #9fd8ff;
  --fire: #e8622c;
  --hdr: #2a1a14;
}
body.night { --hdr: #f6ecd9; }
* { box-sizing: border-box; }
/* 横はみ出し対策は html だけに付ける（body にも付けると、スマホでスクロールの慣性が効かなくなることがある） */
html { scroll-behavior: smooth; overflow-x: hidden; overflow-x: clip; }
body {
  margin: 0;
  position: relative;
  background: #7cc6f5;
  color: var(--ink);
  font-family: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  font-weight: 500;
  font-size: 17px;
  line-height: 1.9;
  letter-spacing: .02em;
}
body.night { background: #0b1028; }
a { color: inherit; }
canvas { display: block; image-rendering: pixelated; }
.wrap { position: relative; max-width: 860px; margin: 0 auto; padding: 0 16px; }
.wrap.wide { max-width: 1080px; }

/* 重なり順：世界（0） → 3匹（1） → 文章のウィンドウ（2）
   犬が階段でウィンドウの後ろを通るとき、階段と同じくウィンドウの奥に隠れる。
   段やヘッダーの「すき間」はクリックが下（犬や世界）に届くようにする */
#world { position: absolute; left: 0; top: 0; z-index: 0; pointer-events: none; }
header, main, footer { position: relative; z-index: 2; pointer-events: none; }
.win, .site-header .wrap > *, #spot-toast { pointer-events: auto; }

/* ---------- ヘッダー（空の上にそのままのせる） ---------- */
.site-header .wrap { max-width: 1180px; display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; padding-top: 12px; padding-bottom: 12px; flex-wrap: wrap; color: var(--hdr); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand .name { font-family: "Press Start 2P", monospace; font-size: 16px; line-height: 1.5; text-shadow: 2px 2px 0 rgba(255,255,255,.5); }
body.night .brand .name { text-shadow: 2px 2px 0 rgba(0,0,0,.5); }
.brand .name small { display: block; font-family: "DotGothic16", sans-serif; font-size: 15px; letter-spacing: .1em; }
nav { display: flex; gap: 4px 18px; flex-wrap: wrap; font-family: "DotGothic16", sans-serif; font-size: 18px; }
nav a { text-decoration: none; }
nav a:hover { text-decoration: underline; }
.controls { display: flex; gap: 8px; flex-wrap: wrap; }
.pxbtn {
  font: 700 15px "Zen Maru Gothic", sans-serif; color: var(--ink); background: #fff;
  border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); padding: 5px 12px; cursor: pointer;
}
.pxbtn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
a.pxbtn { display: inline-block; text-decoration: none; }
/* ミニゲーム（game/）への入口 */
a.pxbtn.game-link { display: block; margin: 10px 0 18px; padding: 10px 14px; background: var(--gold); color: var(--ink); font-size: 18px; line-height: 1.5; }
.game-link b { display: block; }
.game-link span { display: block; font-size: 14px; font-weight: 500; }
.game-link:focus-visible { outline: 3px solid var(--fire); outline-offset: 3px; }
/* 看板犬の段の入口：説明の枠の中に、はっきりしたボタンを置く */
.game-card {
  display: flex; align-items: center; gap: 14px; margin: 10px 0 18px; padding: 12px 14px; text-decoration: none;
  color: #fff !important; background: rgba(255,255,255,.07); border: 3px solid var(--gold); border-radius: 6px;
}
.gc-text { flex: 1; min-width: 0; }
.gc-text b { display: block; font-size: 18px; line-height: 1.5; color: var(--gold); }
.gc-text span { display: block; font-size: 14px; line-height: 1.6; }
.gc-btn {
  flex: none; padding: 10px 18px; font: 700 19px "Zen Maru Gothic", sans-serif; white-space: nowrap; color: var(--ink);
  background: var(--gold); border: 3px solid var(--ink); box-shadow: 4px 4px 0 #000;
}
.game-card:hover .gc-btn { background: #fff; }
.game-card:active .gc-btn { transform: translate(3px, 3px); box-shadow: 1px 1px 0 #000; }
.game-card:focus-visible { outline: 3px solid var(--fire); outline-offset: 3px; }
@media (max-width: 520px) {
  .game-card { flex-direction: column; align-items: stretch; gap: 10px; }
  .gc-btn { text-align: center; }
}

/* ---------- 段 ---------- */
.terrace { padding: 40px 0 calc(var(--px) * 74 + var(--ground)); }
.terrace.hero { padding-top: 24px; padding-bottom: calc(var(--px) * 162 + var(--ground)); }
.terrace.town { display: none; padding: 0; height: calc(var(--px) * 84 + var(--ground)); }
body.narrow-world .terrace.town { display: block; }
.site-footer { padding: 12px 0 28px; }
.analytics-note { margin: 6px 0 0; font-size: 12px; line-height: 1.6; opacity: .85; }

/* ---------- メッセージウィンドウ ---------- */
.win {
  position: relative;
  background: var(--win); color: var(--win-text);
  border: 4px solid var(--win-line); border-radius: 6px;
  box-shadow: 0 0 0 4px var(--ink), 8px 10px 0 4px rgba(42,26,20,.28);
  padding: 22px 28px 24px;
}
.win a { color: var(--link); }
.win h1, .win h2, .win h3 { font-family: "DotGothic16", sans-serif; font-weight: 400; color: var(--gold); letter-spacing: .04em; }
.win h1 { font-size: clamp(28px, 5vw, 42px); line-height: 1.35; margin: 0 0 10px; color: #fff; }
.win h1 em { font-style: normal; color: var(--gold); }
.win h2 { font-size: 30px; margin: 0 0 8px; line-height: 1.4; }
.win h2 small { display: block; font-family: "Press Start 2P", monospace; font-size: 11px; color: var(--link); letter-spacing: .1em; margin-bottom: 4px; }
.win p { margin: 0 0 8px; }
.lead { color: var(--win-sub); }
.hints { list-style: none; margin: 12px 0 0; padding: 12px 0 0; border-top: 2px dashed rgba(255,255,255,.35); color: var(--win-sub); font-size: 16px; }
.hints li { margin: 2px 0; }
.hints b { color: var(--gold); }
.play { margin: 6px 0 14px !important; padding: 8px 12px; border: 2px dashed var(--gold); border-radius: 4px; color: var(--gold); font-size: 15px; }
.play::before { content: "🐾 "; }
.pets { margin: 10px 0 0 !important; color: var(--win-sub); font-size: 15px; }
.pets b { color: #fff; font-size: 18px; }

/* ---------- 冒頭：あそびかた ---------- */
.tagline { font-size: 19px; font-weight: 700; line-height: 1.7; margin: 0 0 14px !important; }
.howto-title { font-size: 20px !important; margin: 0 0 8px !important; color: #fff !important; }
.howto { list-style: none; margin: 0 0 12px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 8px; }
.howto li { display: grid; grid-template-columns: 34px 1fr; grid-template-rows: auto auto; column-gap: 8px; align-items: center; padding: 8px 10px; border: 2px solid rgba(255,255,255,.45); border-radius: 6px; line-height: 1.35; }
.howto .ico { grid-row: 1 / 3; width: 34px; height: 34px; display: grid; place-items: center; font-size: 22px; border-radius: 6px; }
.howto b { font-size: 16px; color: #fff; }
.howto li > span:last-child { font-size: 14px; color: var(--win-sub); }
.ico.mark-play { background: var(--gold); color: var(--ink); font-size: 18px; }
.ico.mark-info { background: #5aa7e0; color: #fff; font-weight: 700; }

/* ---------- 事務所の灯りパネル ---------- */
#lights { width: min(560px, calc(100vw - 24px)); }
#lights .lights-help { margin: 0 0 10px; }
#lights .lights-faces { display: grid; text-align: center; font-size: 13px; color: var(--win-sub); margin-bottom: 4px; }
#lights .lights-grid { display: grid; gap: 8px; padding: 12px; background: #efe6d2; border: 3px solid var(--ink); border-radius: 4px; }
#lights .lights-corner { background: rgba(42,26,20,.15); border-radius: 2px; }
#lights .lw { aspect-ratio: 3 / 4; min-height: 44px; border: 3px solid var(--ink); border-radius: 3px; background: #9fc9e0; cursor: pointer; padding: 0; }
#lights .lw.on { background: var(--gold); box-shadow: 0 0 12px 2px rgba(255,215,106,.9) inset; }
#lights .lw:active { transform: scale(.95); }
#lights .lights-count { text-align: center; font-weight: 700; margin: 10px 0; color: var(--gold); }
#lights .row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- ミニゲームへの入口（大きなバナーと、いつも見える丸いボタン） ---------- */
.game-hero {
  position: relative; display: block; margin: 4px 0 20px; padding: 0 0 14px; text-align: center; text-decoration: none;
  color: #fff !important; background: #1b2340; border: 4px solid var(--gold); border-radius: 8px;
  box-shadow: 0 0 0 4px var(--ink), 6px 8px 0 4px rgba(0,0,0,.35); overflow: visible;
}
.game-hero:focus-visible { outline: 4px solid var(--fire); outline-offset: 6px; }
.gh-stage {
  position: relative; display: flex; align-items: flex-end; justify-content: center; gap: 0; height: 150px; overflow: hidden;
  border-radius: 4px 4px 0 0; border-bottom: 8px solid #7a4e33;
  background:
    linear-gradient(90deg, #b8483a 0 22px, transparent 22px calc(100% - 22px), #b8483a calc(100% - 22px)),
    repeating-linear-gradient(90deg, rgba(0,0,0,.18) 0 4px, transparent 4px 11px) left / 22px 100% no-repeat,
    radial-gradient(ellipse 46% 120% at 50% 0, #5a67a8 0, #2c3766 70%);
}
.gh-stage::before, .gh-stage::after {
  content: "✦"; position: absolute; color: var(--gold); font-size: 20px; animation: ghtwinkle 1.4s ease-in-out infinite;
}
.gh-stage::before { left: 16%; top: 14px; }
.gh-stage::after { right: 15%; top: 34px; font-size: 26px; animation-delay: .7s; }
.gh-dog { width: calc(var(--w) * .82); height: auto; image-rendering: pixelated; margin: 0 -9px; animation: ghhop .9s ease-in-out infinite; }
.gh-new {
  position: absolute; left: -12px; top: -14px; z-index: 2; padding: 2px 10px; transform: rotate(-8deg);
  font: 400 14px "Press Start 2P", monospace; color: #fff; background: var(--fire); border: 3px solid var(--ink);
  animation: ghnew 1.2s steps(2) infinite;
}
.gh-title { display: block; margin: 12px 8px 0; font: 400 clamp(26px, 7.4vw, 34px)/1.2 "DotGothic16", sans-serif; color: var(--gold); letter-spacing: .02em; }
.gh-title small { display: block; font-size: 14px; color: var(--link); letter-spacing: .2em; }
.gh-copy { display: block; margin: 6px 10px 12px; font-size: 15px; line-height: 1.6; font-weight: 700; }
.gh-btn {
  display: inline-block; padding: 10px 22px; font: 700 20px "Zen Maru Gothic", sans-serif; color: var(--ink);
  background: var(--gold); border: 3px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); animation: ghpulse 1.3s ease-in-out infinite;
}
.gh-btn small { display: block; font-size: 12px; font-weight: 500; }
.game-hero:hover .gh-btn, .game-hero:active .gh-btn { background: #fff; }
@keyframes ghhop { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
@keyframes ghtwinkle { 0%, 100% { opacity: .2; transform: scale(.7); } 50% { opacity: 1; transform: scale(1.15); } }
@keyframes ghnew { 0% { background: var(--fire); } 50% { background: #d8453b; } }
@keyframes ghpulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
.game-fab {
  position: fixed; right: 14px; bottom: 14px; z-index: 70; padding: 8px 14px; text-decoration: none;
  font: 700 15px "Zen Maru Gothic", sans-serif; color: var(--ink) !important; background: var(--gold);
  border: 3px solid var(--ink); border-radius: 999px; box-shadow: 3px 3px 0 var(--ink); animation: ghfab 2.4s ease-in-out infinite;
}
.game-fab:focus-visible { outline: 3px solid var(--fire); outline-offset: 3px; }
@keyframes ghfab { 0%, 86%, 100% { transform: translateY(0) rotate(0); } 90% { transform: translateY(-6px) rotate(-4deg); } 95% { transform: translateY(0) rotate(3deg); } }
/* スマホでは、左下の「肉球スタンプ」と同じ高さ・同じ大きさで、右下にならべる */
@media (max-width: 520px) { .game-fab { bottom: 14px; padding: 6px 11px; font-size: 14px; line-height: 1.45; } }
@media (max-width: 345px) { .game-fab { right: 8px; padding: 6px 8px; font-size: 13px; } }
@media (prefers-reduced-motion: reduce) { .gh-dog, .gh-btn, .gh-new, .game-fab, .gh-stage::before, .gh-stage::after { animation: none; } }

/* ---------- 肉球スタンプ ---------- */
#stamp-hud {
  position: fixed; left: 14px; bottom: 14px; z-index: 70;
  font: 700 15px "Zen Maru Gothic", sans-serif; color: #fff; background: var(--win);
  border: 3px solid #fff; border-radius: 6px; box-shadow: 0 0 0 3px var(--ink); padding: 6px 12px; cursor: pointer;
}
#stamp-hud.complete { background: var(--fire); }
#stamp-hud.pop { animation: hudpop .5s ease-out; }
@keyframes hudpop { 0% { transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } }
#stamp-flash {
  position: fixed; left: 50%; top: 18px; z-index: 80; transform: translate(-50%, -10px);
  background: var(--gold); color: var(--ink); border: 3px solid var(--ink); border-radius: 6px;
  padding: 8px 16px; font-weight: 700; opacity: 0; transition: opacity .25s, transform .25s; pointer-events: none; white-space: nowrap;
}
#stamp-flash.show { opacity: 1; transform: translate(-50%, 0); }
#stamp-list { list-style: none; padding: 0; margin: 10px 0; }
#stamp-list li { display: grid; grid-template-columns: 2em 1fr; align-items: start; padding: 6px 0; border-bottom: 2px dashed rgba(255,255,255,.25); color: var(--win-sub); }
#stamp-list li.ok { color: #fff; }
#stamp-list small { display: block; color: var(--link); font-size: 13px; }
#stamp-list em { font-style: normal; color: var(--win-sub); font-size: 15px; }
#stamp-list .paw { font-size: 20px; }
#stamps .complete { color: var(--gold); font-weight: 700; }
#stamps .row { display: flex; gap: 10px; flex-wrap: wrap; }
.pxbtn.ghost { background: transparent; color: var(--win-sub); border-color: var(--win-sub); box-shadow: none; }

.biz { list-style: none; padding: 0; margin: 14px 0 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.biz li { padding: 10px 14px; border: 2px solid rgba(255,255,255,.5); border-radius: 4px; }
.biz b { display: block; font-family: "DotGothic16", sans-serif; font-weight: 400; color: var(--gold); font-size: 20px; }
.biz span { font-size: 15px; color: var(--win-sub); }

.dogs { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; margin-top: 14px; }
.dog { display: flex; flex-direction: column; border: 3px solid #fff; border-radius: 4px; background: #283166; overflow: hidden; }
.dog .photo { aspect-ratio: 1; background: url("../img/dogs.jpg") no-repeat; background-size: 300%; border-bottom: 3px solid #fff; position: relative; }
.dog .photo canvas { position: absolute; left: 8px; bottom: 8px; background: rgba(246,236,217,.92); border: 3px solid var(--ink); padding: 4px; box-sizing: content-box; }
.dog .body { padding: 12px 16px 16px; }
.dog h3 { margin: 0; font-size: 30px; color: #fff; }
.dog h3 span { font-family: "Press Start 2P", monospace; font-size: 11px; color: var(--link); margin-left: 10px; }
.dog dl { margin: 8px 0 0; display: grid; grid-template-columns: 4.5em 1fr; gap: 4px 10px; font-size: 16px; }
.dog dt { color: var(--gold); font-weight: 700; }
.dog dd { margin: 0; }

.news { list-style: none; margin: 10px 0 0; padding: 0; }
.news li { display: grid; grid-template-columns: 7em 5.5em 1fr; gap: 12px; padding: 12px 0; border-bottom: 2px dashed rgba(255,255,255,.3); align-items: start; }
.news li:last-child { border-bottom: 0; }
.news time { color: var(--win-sub); }
.news b { font-weight: 700; }
.news p { margin: 4px 0 0; font-size: 16px; color: var(--win-sub); }
.tag { display: inline-block; font-size: 14px; font-weight: 700; border: 2px solid #fff; border-radius: 3px; padding: 0 6px; text-align: center; background: var(--gold); color: var(--ink); }
.tag.dog { background: #f2a8a0; }

table { width: 100%; border-collapse: collapse; margin-top: 6px; }
th, td { text-align: left; vertical-align: top; padding: 12px 8px; border-bottom: 2px dashed rgba(255,255,255,.3); }
tr:last-child th, tr:last-child td { border-bottom: 0; }
th { width: 7.5em; color: var(--gold); font-weight: 700; }
.history { margin: 0; padding: 0; list-style: none; }
.history li { display: grid; grid-template-columns: 7em 1fr; gap: 8px; }

.contact { text-align: center; }
.contact a.mail { display: inline-block; margin-top: 6px; font: 700 20px "Zen Maru Gothic", sans-serif; background: var(--fire); color: #fff; padding: 12px 22px; border: 3px solid #fff; border-radius: 4px; box-shadow: 0 0 0 3px var(--ink); text-decoration: none; }

.win.small { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding: 10px 18px; font-size: 15px; }
.secret { background: none; border: 0; color: var(--win-sub); font: inherit; cursor: pointer; padding: 0; text-decoration: underline; }

/* ---------- 建物をクリックしたときの吹き出しウィンドウ ---------- */
#spot-toast {
  position: absolute; z-index: 60; width: 300px; transform: translateY(-100%);
  background: var(--win); color: #fff; border: 4px solid #fff; border-radius: 6px; box-shadow: 0 0 0 4px var(--ink);
  padding: 10px 14px; font-size: 16px; line-height: 1.7; opacity: 0; pointer-events: none; transition: opacity .2s;
}
#spot-toast.show { opacity: 1; pointer-events: auto; }
#spot-toast b { display: block; font-family: "DotGothic16", sans-serif; font-weight: 400; font-size: 20px; color: var(--gold); }
#spot-toast span { display: block; }
#spot-toast em { font-style: normal; color: var(--gold); font-weight: 700; }

/* ---------- 3匹 ---------- */
#dog-layer { position: absolute; left: 0; top: 0; width: 100%; height: 0; z-index: 1; pointer-events: none; }
body.dogs-home #dog-layer { display: none; }
.dog-sprite { position: absolute; left: 0; top: 0; pointer-events: auto; cursor: pointer; will-change: transform; }
.dog-sprite canvas { width: 100%; height: 100%; filter: drop-shadow(0 3px 0 rgba(42,26,20,.2)); }
.dog-ball { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 9999; }
.dog-ball canvas { width: 100%; height: 100%; }
.bub {
  position: absolute; left: 0; top: 0; z-index: 10000;
  background: #fff; color: var(--ink); border: 3px solid var(--ink); border-radius: 4px;
  padding: 2px 10px; font: 700 15px/1.5 "Zen Maru Gothic", sans-serif; white-space: nowrap;
  opacity: 0; transition: opacity .2s; pointer-events: none;
}
.bub.show { opacity: 1; }
.heart { position: absolute; color: var(--fire); font-size: 20px; text-shadow: 1px 1px 0 var(--ink); animation: heart 1.1s ease-out forwards; pointer-events: none; }
@keyframes heart { to { transform: translate(var(--dx), -50px); opacity: 0; } }

dialog { border: 4px solid #fff; border-radius: 6px; box-shadow: 0 0 0 4px var(--ink); background: var(--win); color: #fff; max-width: 520px; padding: 24px; font: 500 17px/1.9 "Zen Maru Gothic", sans-serif; }
dialog::backdrop { background: rgba(27,35,64,.6); }
dialog h3 { margin: 0 0 8px; font-family: "Press Start 2P", monospace; font-size: 14px; color: var(--gold); }

@media (max-width: 640px) {
  body { font-size: 16px; }
  .win { padding: 18px 18px 20px; }
  .win h2 { font-size: 26px; }
  .news li { grid-template-columns: 1fr; gap: 2px; }
  th { width: 5.5em; }
  .history li { grid-template-columns: 1fr; gap: 0; }
  nav { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- LINEスタンプへのボタン（LINEの緑） ---------- */
.line-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; margin-top: 12px; min-height: 44px; padding: 8px 16px;
  background: #06c755; color: #fff !important; border: 3px solid #fff; border-radius: 999px; box-shadow: 0 0 0 3px var(--ink);
  font: 700 15px "Zen Maru Gothic", sans-serif; text-decoration: none;
}
.line-btn::before { content: "💬"; }
.line-btn::after { content: "↗"; font-size: 13px; }
.line-btn:hover { background: #05b04b; }
.line-btn.small { min-height: 36px; padding: 4px 12px; font-size: 14px; margin-top: 8px; }
#spot-toast .line-btn { display: inline-flex; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
