/* 書体(SIL Open Font License 1.1 / 画面で使う文字に絞ったサブセット。LICENSES.md 参照)
   M PLUS Rounded 1c: Copyright 2016 The Rounded M+ Project Authors.
   Dela Gothic One: Copyright 2020 The Dela Gothic Project Authors (https://github.com/syakuzen/DelaGothic)
   https://openfontlicense.org */
@font-face { font-family: 'M PLUS Rounded 1c'; src: url(assets/fonts/mplus-rounded-medium.woff2) format('woff2'); font-weight: 100 600; font-display: swap; }
@font-face { font-family: 'M PLUS Rounded 1c'; src: url(assets/fonts/mplus-rounded-bold.woff2) format('woff2'); font-weight: 700 900; font-display: swap; }
@font-face { font-family: 'Dela Gothic One'; src: url(assets/fonts/dela-gothic-one.woff2) format('woff2'); font-weight: 100 900; font-display: swap; }
:root {
  --sky: #03040C;
  --day: #8FD3FF;
  --orange: #FF6B3D;
  --navy: #0E2240;
  --gold: #F1D7A0;
  --pink: #FF2E88;
  --hit: #FFE14D;
  --cyan: #3DF5FF;
  --text: #FFF8EC;
  --muted: rgba(255, 248, 236, .66);
  --card: rgba(14, 34, 64, .82);
  --line: rgba(160, 190, 255, .28);
  --body: 'M PLUS Rounded 1c', 'Hiragino Maru Gothic ProN', 'Hiragino Sans', 'Yu Gothic UI', 'Meiryo', sans-serif;
  --display: 'Dela Gothic One', 'Hiragino Maru Gothic ProN', 'Hiragino Sans', 'Yu Gothic UI', sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #2B3F66; }
body {
  color: var(--text); font-family: var(--body); font-weight: 700;
  overflow: hidden; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
/* スマホは全面、PC では中央に縦長 */
#app {
  position: fixed; top: 0; bottom: 0; left: 50%; transform: translateX(-50%);
  width: min(100vw, 480px, calc(100vh * .70)); /* dvh に対応していないブラウザ向け */
  width: min(100vw, 480px, calc(100dvh * .70)); overflow: hidden; background: var(--day);
}
@media (min-width: 500px) { #app { box-shadow: 0 0 0 1px rgba(160, 190, 255, .12), 0 0 60px rgba(70, 40, 130, .35); } }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; touch-action: manipulation; cursor: pointer; }
a { color: var(--cyan); }
.num { font-family: var(--display); font-weight: 400; font-variant-numeric: tabular-nums; }
.gold { color: var(--gold); }
.muted { color: var(--muted); font-weight: 500; }
.small { font-size: 12px; }

#stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* ---------- 上帯 ---------- */
#hud {
  position: absolute; z-index: 5; left: 0; right: 0; top: 0; height: 52px;
  display: flex; align-items: center; gap: 10px; padding: 0 8px 0 12px;
  margin-top: env(safe-area-inset-top); pointer-events: none;
}
.hud-score { min-width: 86px; font-size: 22px; line-height: 1; white-space: nowrap; color: var(--text); text-shadow: 0 2px 0 var(--navy), 0 0 6px rgba(14, 34, 64, .6); }
.hud-score small { font-size: 12px; margin-left: 2px; }
.hud-mid { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.hud-prog { position: relative; height: 10px; border-radius: 5px; background: rgba(14, 34, 64, .45); border: 1.5px solid rgba(14, 34, 64, .7); }
.hud-prog i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--cyan); border-radius: 4px; }
.hud-prog b { position: absolute; right: -6px; top: 50%; width: 16px; height: 16px; margin-top: -8px; border-radius: 50%; background: var(--orange); border: 2px solid var(--navy); }
.hud-next { font-size: 11px; line-height: 1; color: var(--text); text-shadow: 0 1px 0 var(--navy), 0 0 4px var(--navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.icon-btn {
  pointer-events: auto; width: 44px; height: 44px; border-radius: 12px; border: 1.5px solid var(--line);
  background: var(--card); display: grid; place-items: center; font-size: 22px; line-height: 1; padding: 0;
}
.pause-ico { width: 12px; height: 14px; border-left: 4px solid var(--text); border-right: 4px solid var(--text); }

/* ---------- 画面 ---------- */
.screen { position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; padding: env(safe-area-inset-top) 16px calc(env(safe-area-inset-bottom) + 12px); }
#title { justify-content: space-between; }
.brand { margin: 12px 0 0; text-align: center; font-size: 13px; letter-spacing: .2em; color: var(--navy); font-weight: 800; }
.title-art { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 0; }
.dogcv { display: block; width: 100%; }
#titleDog { flex: 1; min-height: 72px; max-height: 280px; }
.logo {
  margin: 4px 0 0; -webkit-text-stroke: 2px var(--navy); paint-order: stroke fill; font-family: var(--display); font-weight: 400; font-size: clamp(46px, 14vw, 62px); line-height: 1.05; letter-spacing: .02em;
  color: var(--text); text-shadow: 0 3px 0 var(--navy), 0 0 24px rgba(255, 46, 136, .45);
}
.tag { margin: 6px 0 0; font-size: 13px; color: var(--navy); font-weight: 800; background: rgba(255,248,236,.75); border-radius: 999px; padding: 3px 12px; text-align: center; }
.goal { margin: 4px 0 0; font-size: 13px; color: var(--navy); font-weight: 800; background: rgba(255,248,236,.75); border-radius: 999px; padding: 3px 12px; }
.title-ctl { display: flex; flex-direction: column; gap: 10px; padding-bottom: 4px; }
#titleMain { display: flex; flex-direction: column; gap: 10px; }
.best { margin: 0; text-align: center; font-size: 14px; color: var(--navy); min-height: 1.2em; }
.next-title { margin: 0; text-align: center; font-size: 12px; color: var(--navy); font-weight: 600; }
.next-title:empty { display: none; }
/* 背の低い画面ではタイトルの目標の行を省く(あそびかた・結果・プレイ中の上帯にも出している) */
@media (max-height: 600px) { .goal { display: none; } }
.title-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.night { margin: 0; text-align: center; font-size: 12px; color: var(--navy); font-weight: 700; }

/* ---------- ボタン ---------- */
.btn { display: block; border-radius: 14px; border: 1.5px solid var(--line); background: var(--card); min-height: 48px; padding: 8px 12px; transition: transform .08s, filter .08s; }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.main {
  width: 100%; min-height: 64px; border: none; background: var(--pink); color: #fff;
  font-family: var(--display); font-weight: 400; font-size: 22px; letter-spacing: .03em;
  box-shadow: 0 4px 0 #A3134F, 0 0 24px rgba(255, 46, 136, .35);
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.15;
}
.btn.main small { font-family: var(--body); font-size: 12px; font-weight: 700; opacity: .9; }
.btn.main.done { background: var(--card); box-shadow: none; border: 1.5px solid var(--line); font-size: 18px; }
.btn.sub { font-size: 15px; }
.btn.wide { width: 100%; }
a.btn { text-decoration: none; }
.btn.choice { min-height: 60px; font-size: 18px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.linkish { background: none; border: none; color: var(--navy); font-size: 13px; text-decoration: underline; min-height: 44px; padding: 6px 14px; align-self: center; font-weight: 500; }
.sound-ask { text-align: center; display: flex; flex-direction: column; gap: 10px; background: var(--card); border: 1.5px solid var(--line); border-radius: 16px; padding: 14px; }
.sound-ask .ask { margin: 0; font-size: 17px; }
.challenge { background: var(--card); border: 1.5px solid var(--gold); border-radius: 16px; padding: 12px; text-align: center; display: flex; flex-direction: column; gap: 6px; }
.challenge p { margin: 0; }
.chal-head { font-size: 13px; color: var(--gold); }
.chal-body { font-size: 17px; }
.challenge small { color: var(--muted); font-weight: 500; font-size: 12px; }
.chal-note { font-size: 13px; color: var(--gold); font-weight: 500; }

/* ---------- 一時停止 ---------- */
.overlay { position: absolute; inset: 0; z-index: 20; background: rgba(3, 4, 12, .72); display: grid; place-items: center; padding: 16px; }
.card { width: 100%; max-width: 340px; background: var(--card); border: 1.5px solid var(--line); border-radius: 18px; padding: 20px 16px; display: flex; flex-direction: column; gap: 12px; text-align: center; }
.card h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 26px; }
.card p { margin: 0; font-size: 13px; }
#btnQuit.armed { border-color: var(--gold); color: var(--gold); }

/* ---------- 結果 ---------- */
#result { background: rgba(14, 34, 64, .72); justify-content: space-between; overflow-y: auto; }
.res-body { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding-top: 14px; }
.res-head { margin: 0; font-size: 14px; color: var(--muted); }
.res-dog { height: 110px; width: 160px; }
.res-score { font-size: clamp(40px, 14vw, 64px); line-height: 1; white-space: nowrap; color: var(--text); text-shadow: 0 0 24px rgba(255, 225, 77, .35); }
.res-score small { font-size: 18px; margin-left: 4px; font-family: var(--body); }
.res-stamp { display: flex; align-items: center; gap: 10px; animation: stampIn .32s cubic-bezier(.2, 1.4, .4, 1) both; }
.res-stamp.slow { animation-duration: 1.07s; }
.res-stamp canvas { width: 96px; height: 96px; }
.stamp-text { display: flex; flex-direction: column; align-items: flex-start; }
.stamp-text small { font-size: 12px; color: var(--muted); }
.ladder { display: flex; gap: 4px; margin: 4px 0 2px; }
.ladder i { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid rgba(241, 215, 160, .45); }
.ladder i.on { background: var(--gold); border-color: var(--gold); }
.ladder i.cur { box-shadow: 0 0 0 2px rgba(241, 215, 160, .35); }
.stamp-text .res-next { white-space: nowrap; }
.stamp-text b { font-family: var(--display); font-weight: 400; font-size: 28px; color: var(--gold); }
@keyframes stampIn { from { transform: scale(1.6) rotate(-8deg); opacity: 0; } to { transform: none; opacity: 1; } }
.res-record {
  background: linear-gradient(90deg, transparent, rgba(241, 215, 160, .25), transparent); color: var(--gold);
  font-family: var(--display); font-weight: 400; font-size: clamp(16px, 5vw, 20px); padding: 6px 16px; white-space: nowrap; max-width: 100%;
  animation: fadeUp .4s ease both;
}
.res-record small { font-family: var(--body); font-weight: 700; font-size: 12px; margin-left: 6px; }
@keyframes fadeUp { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.res-emoji { margin: 2px 0 0; font-size: 20px; letter-spacing: 1px; word-break: break-all; max-width: 100%; }
.res-stats { margin: 0; font-size: 13px; color: var(--muted); font-weight: 500; display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 12px; }
.res-stats span { white-space: nowrap; }
.res-chal { margin: 0; font-size: 15px; color: var(--gold); }
.res-skip { margin: 4px 0 0; font-size: 12px; }
/* ボタン列は下端に貼り付ける(結果が長くても「もう1回」「シェア」が画面に入る) */
.res-btns {
  position: sticky; bottom: 0; z-index: 1; display: flex; flex-direction: column; gap: 10px; padding: 18px 16px 0; margin: auto -16px 0;
  background: linear-gradient(rgba(3, 4, 12, 0), rgba(3, 4, 12, .92) 18px); animation: fadeUp .25s ease both;
}
.res-btns .btn.main { min-height: 72px; font-size: 26px; }
.made { margin: 6px 0 0; text-align: center; font-size: 11px; color: var(--muted); letter-spacing: .08em; font-weight: 500; }
/* 背の低い画面: 犬を小さく、さらに低ければ隠す */
@media (max-height: 700px) {
  .res-body { gap: 4px; padding-top: 8px; }
  .res-dog { height: 72px; width: 110px; }
  .res-stamp canvas { width: 76px; height: 76px; }
  .stamp-text b { font-size: 24px; }
}
@media (max-height: 600px) {
  .res-dog { display: none; }
}

/* ---------- パネル ---------- */
.panel { position: absolute; inset: 0; z-index: 10; background: rgba(3, 4, 12, .985); display: flex; flex-direction: column; padding-top: env(safe-area-inset-top); }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px 8px 16px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 22px; }
.panel-head h2 small { font-family: var(--body); font-size: 14px; color: var(--gold); margin-left: 6px; }
.panel-body { flex: 1; overflow-y: auto; padding: 14px 16px calc(env(safe-area-inset-bottom) + 24px); display: flex; flex-direction: column; gap: 10px; -webkit-user-select: text; user-select: text; }
.prose { font-weight: 500; font-size: 14px; line-height: 1.7; display: block; }
.prose h3 { font-size: 16px; margin: 18px 0 6px; color: var(--gold); font-weight: 800; }
.prose h3:first-child { margin-top: 0; }
.prose p { margin: 0 0 8px; }
.prose ul { margin: 0 0 8px; padding-left: 1.2em; }
/* 文中のリンクも押しやすく(行の高さは変えずに押せる範囲を広げる) */
.prose a { display: inline-block; padding: 11px 2px; margin: -11px -2px; }
.tbl-wrap { overflow-x: auto; max-width: 100%; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { border-bottom: 1px solid var(--line); padding: 5px 4px; text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 700; white-space: nowrap; }
td:first-child { white-space: nowrap; }
td.n { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.rates { font-size: clamp(11.5px, 3.6vw, 12.5px); }
table.rates th.n { text-align: right; line-height: 1.3; }
table.rates th small { display: block; font-size: 10px; color: var(--gold); white-space: normal; }
table.rates td, table.rates th { padding: 5px 2px; }

.dex-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.dex-cell { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 6px 2px; text-align: center; min-width: 0; }
.dex-cell canvas { width: 100%; aspect-ratio: 1; display: block; }
.dex-cell b { display: block; font-size: 10.5px; line-height: 1.25; min-height: 2.5em; overflow-wrap: anywhere; }
.dex-cell small { display: block; font-size: 10px; color: var(--muted); font-weight: 500; }
.dex-cell.hz { border-color: rgba(255, 154, 154, .35); }

.set-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 52px; border-bottom: 1px solid var(--line); }
.set-row > span, .set-row > label { font-size: 15px; }
.set-row input[type=range] { flex: 1; max-width: 200px; accent-color: var(--pink); height: 32px; }
.seg { display: flex; border: 1.5px solid var(--line); border-radius: 12px; overflow: hidden; flex-shrink: 0; }
.seg button { background: none; border: none; min-height: 44px; min-width: 52px; padding: 0 10px; font-size: 14px; }
.seg button:disabled { opacity: .4; cursor: default; }
.seg button[aria-pressed=true] { background: var(--pink); color: #fff; }

.share-preview { display: grid; place-items: center; }
.share-preview img { width: min(56%, 210px); aspect-ratio: 9 / 16; border-radius: 12px; border: 1px solid var(--line); background: var(--navy); }
.share-inapp { margin: 0; font-size: 13px; font-weight: 500; color: var(--gold); border: 1px solid rgba(241, 215, 160, .45); border-radius: 10px; padding: 8px 10px; }
.share-text { margin: 0; font-size: 13px; font-weight: 500; word-break: break-all; background: var(--card); border-radius: 10px; padding: 8px 10px; }

#toast {
  position: absolute; z-index: 40; left: 16px; right: 16px; top: calc(env(safe-area-inset-top) + 60px); margin: 0;
  background: var(--navy); border: 1.5px solid var(--gold); color: var(--text); border-radius: 12px; padding: 10px 14px; font-size: 14px; text-align: center;
  animation: fadeUp .25s ease both;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- ぞろわん! 追加 ---------- */
#title .title-ctl { background: linear-gradient(rgba(14, 34, 64, 0), rgba(14, 34, 64, .55) 30px); margin: 0 -16px; padding: 30px 16px 4px; }
#title .title-ctl .linkish, #title .title-ctl .night, #title .title-ctl .best, #title .title-ctl .next-title { color: var(--text); }
.res-big { font-size: 13px; color: var(--muted); margin: 0; }
.res-big b { font-family: var(--display); font-weight: 400; font-size: clamp(28px, 9vw, 40px); color: var(--cyan); margin: 0 4px; }
.res-boss { margin: 0; font-family: var(--display); font-weight: 400; font-size: 18px; color: var(--gold); }
.res-tip { margin: 2px 0 0; font-size: 13px; color: var(--text); font-weight: 500; background: rgba(255, 255, 255, .08); border-radius: 10px; padding: 6px 10px; max-width: 100%; }
.howto { display: flex; gap: 10px; align-items: center; }
.howto canvas { width: 72px; height: 72px; flex: none; }
.gate-chip { display: inline-block; border-radius: 8px; padding: 0 6px; font-family: var(--display); font-weight: 400; color: var(--navy); }
.gate-chip.good { background: var(--cyan); }
.gate-chip.bad { background: var(--orange); }
#tipSqueeze { position: absolute; z-index: 4; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom) + 18px); text-align: center; pointer-events: none; font-size: 14px; color: var(--text); text-shadow: 0 1px 0 var(--navy), 0 0 6px var(--navy); }
