/* 水切りシミュレーター：実写っぽい3Dの上に乗る、控えめな UI */
:root {
  --ink: #fff;
  --ink-soft: rgba(255, 255, 255, 0.78);
  --ink-faint: rgba(255, 255, 255, 0.5);
  --panel: rgba(18, 28, 30, 0.42);
  --panel-line: rgba(255, 255, 255, 0.16);
  --accent: #f3ead8;          /* 夕方前の光に寄せた生成り */
  --accent-ink: #1e2a2c;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.45), 0 0 18px rgba(0, 0, 0, 0.2);
  --serif: "Zen Old Mincho", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --sans: "Noto Sans JP", "Hiragino Sans", "Yu Gothic", system-ui, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --gutter: 20px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;           /* スクロールの跳ね返りを止める */
  background: #1d2a2c;
  color: var(--ink);
  font-family: var(--sans);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;         /* iOS の長押しメニュー */
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}
body { position: fixed; inset: 0; }

#scene {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  display: block;
  z-index: 0;
  touch-action: none;
}

/* 入力用の全画面オーバーレイ。aim のときだけ触れる */
#input-layer {
  position: fixed; inset: 0;
  z-index: 1;
  pointer-events: none;
  touch-action: none;
}
body[data-screen="aim"] #input-layer { pointer-events: auto; }

#ui {
  position: fixed; inset: 0;
  z-index: 2;
  pointer-events: none;
}

button, input { font: inherit; color: inherit; pointer-events: auto; }
button { -webkit-touch-callout: none; touch-action: manipulation; cursor: pointer; }

/* ---- 画面 ---- */
.screen {
  position: absolute; inset: 0;
  padding: calc(var(--safe-t) + 24px) calc(var(--safe-r) + var(--gutter)) calc(var(--safe-b) + 24px) calc(var(--safe-l) + var(--gutter));
  display: flex; flex-direction: column;
  opacity: 0; visibility: hidden;
  transition: opacity 0.45s ease, visibility 0s linear 0.45s;
  text-shadow: var(--shadow);
}
.screen.active { opacity: 1; visibility: visible; transition: opacity 0.45s ease; }
.screen:not(.active) * { pointer-events: none !important; }

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 18px;
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
  backdrop-filter: blur(14px) saturate(1.1);
  text-shadow: none;
}

.bottom-stack {
  margin-top: auto;
  display: flex; flex-direction: column; gap: 12px;
  width: 100%; max-width: 440px; align-self: center;
}

/* ---- ボタン ---- */
.btn {
  display: block; width: 100%;
  min-height: 56px;
  padding: 14px 20px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 17px; font-weight: 500; letter-spacing: 0.08em;
  transition: transform 0.12s ease, background 0.2s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: var(--accent); color: var(--accent-ink);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.22);
  text-shadow: none;
}
.btn-ghost {
  background: rgba(18, 28, 30, 0.32);
  border-color: rgba(255, 255, 255, 0.4);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  text-shadow: none;
}
.btn-link {
  background: none; border: 0;
  min-height: 48px; padding: 10px 16px;
  font-size: 15px; letter-spacing: 0.08em;
  color: var(--ink-soft);
  text-decoration: underline; text-underline-offset: 5px; text-decoration-color: rgba(255,255,255,0.4);
}
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; min-width: 0; font-size: 15px; padding: 14px 6px; letter-spacing: 0.02em; white-space: nowrap; }

/* ---- title ---- */
#screen-title {
  align-items: center; text-align: center;
  background: linear-gradient(to bottom, rgba(10,18,20,0.28), rgba(10,18,20,0) 35%, rgba(10,18,20,0) 55%, rgba(10,18,20,0.45));
}
.title-wrap { margin-top: 18vh; }
.title-main {
  margin: 0;
  font-family: var(--serif); font-weight: 700;
  font-size: clamp(72px, 24vw, 132px);
  letter-spacing: 0.18em; text-indent: 0.18em;
  line-height: 1.1;
  white-space: nowrap;
}
.title-sub {
  margin: 22px 0 0;
  font-family: var(--serif); font-size: 17px;
  letter-spacing: 0.14em; color: var(--ink-soft);
}
.title-actions {
  margin-top: auto; width: 100%; max-width: 380px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.safety {
  margin: 14px 0 0; padding: 10px 14px;
  font-size: 12.5px; line-height: 1.7; letter-spacing: 0.04em;
  color: var(--ink-soft);
  border-top: 1px solid rgba(255,255,255,0.22);
}
/* 振れない端末ではスワイプを主にする */
#ui.no-motion #btn-start-motion { display: none; }
#ui.no-motion #btn-start-swipe {
  min-height: 56px; width: 100%; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); text-decoration: none; text-shadow: none;
  font-size: 17px; font-weight: 500;
}

/* ---- select ---- */
#screen-select {
  background: linear-gradient(to bottom, rgba(10,18,20,0.32), rgba(10,18,20,0) 22%);
}
.heading {
  margin: 4px 0 0; text-align: center;
  font-family: var(--serif); font-size: 19px; letter-spacing: 0.12em;
}
.stone-card { padding: 18px 20px 16px; }
.stone-card.pop { animation: rise 0.35s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.stone-label {
  margin: 0 0 10px;
  font-family: var(--serif); font-size: 22px; letter-spacing: 0.06em;
}
.stone-specs { display: flex; gap: 24px; margin: 0 0 12px; }
.stone-specs div { display: flex; align-items: baseline; gap: 8px; }
dt { font-size: 12px; color: var(--ink-faint); letter-spacing: 0.08em; }
dd { margin: 0; font-size: 15px; font-variant-numeric: tabular-nums; }
.bars { display: grid; gap: 8px; margin-bottom: 16px; }
.bar-row { display: grid; grid-template-columns: 3.5em 1fr; align-items: center; font-size: 12px; color: var(--ink-faint); }
.bar { height: 3px; border-radius: 3px; background: rgba(255,255,255,0.16); overflow: hidden; }
.bar i { display: block; height: 100%; background: rgba(255,255,255,0.82); border-radius: 3px; transition: width 0.4s ease; }

/* ---- aim ---- */
#screen-aim { align-items: center; }
#screen-aim .panel { pointer-events: none; }   /* 説明は触れても下の入力に通す */
.btn-back {
  align-self: flex-start;
  background: rgba(18, 28, 30, 0.32); border: 1px solid rgba(255,255,255,0.3);
  border-radius: 999px; min-height: 40px; padding: 8px 16px;
  font-size: 13px; letter-spacing: 0.06em; text-shadow: none;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.help { margin-top: 14px; padding: 14px 10px; width: 100%; max-width: 440px; transition: all 0.3s ease; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.steps li { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; font-size: 13px; line-height: 1.5; color: var(--ink-soft); counter-increment: step; }
.steps li::before { content: counter(step); font-family: var(--serif); font-size: 13px; color: var(--ink-faint); }
.steps svg { width: 100%; max-width: 110px; height: auto; }
.ln { fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.ln.faint { stroke-opacity: 0.45; }
.ln.dash { stroke-dasharray: 4 6; stroke-opacity: 0.7; }
.fill { fill: rgba(255,255,255,0.85); }
/* 2回目以降は小さく */
#ui.aim-again .help-motion { padding: 8px 8px; max-width: 320px; }
#ui.aim-again .steps svg { max-width: 54px; }
#ui.aim-again .steps li { font-size: 11px; gap: 2px; }
#ui.aim-again .steps li::before { display: none; }

.help-swipe { display: none; flex-direction: column; align-items: center; gap: 6px; max-width: 280px; }
.help-swipe p { margin: 0; font-size: 15px; letter-spacing: 0.08em; }
.swipe-arrow { width: 34px; height: 50px; animation: nudge 1.8s ease-in-out infinite; }
@keyframes nudge { 0%, 100% { transform: translateY(6px); opacity: 0.6; } 50% { transform: translateY(-6px); opacity: 1; } }
#ui.mode-swipe .help-motion { display: none; }
#ui.mode-swipe .help-swipe { display: flex; }

.aim-bottom { margin-top: auto; width: 100%; max-width: 440px; display: flex; flex-direction: column; gap: 10px; }
.meter { display: flex; align-items: center; gap: 4px; padding: 6px 18px 6px 8px; transition: border-color 0.2s ease; }
.meter svg { flex: 1; min-width: 0; height: auto; max-height: 90px; }
.meter.armed { border-color: rgba(255,255,255,0.5); }
.water { stroke: rgba(190, 220, 230, 0.75); stroke-width: 2; fill: none; }
.water.faint { stroke-opacity: 0.35; stroke-width: 1.5; }
.stone-line { stroke: rgba(255,255,255,0.55); stroke-width: 1.2; stroke-dasharray: 3 4; }
.stone-body { fill: rgba(205, 198, 186, 0.92); stroke: #fff; stroke-width: 1.2; }
.ref { stroke: rgba(255,255,255,0.3); stroke-width: 1; stroke-dasharray: 2 4; }
.arc { fill: none; stroke: var(--accent); stroke-width: 1.6; }
.dir { fill: none; stroke: rgba(255,255,255,0.5); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.meter-read { display: flex; flex-direction: column; align-items: flex-end; min-width: 70px; }
.meter-label { font-size: 11px; color: var(--ink-faint); letter-spacing: 0.08em; }
.meter-value { font-family: var(--serif); font-size: 22px; font-variant-numeric: tabular-nums; }
.meter-value b { font-size: 38px; font-weight: 700; }

.tilt-slider { display: none; align-items: center; gap: 14px; padding: 10px 18px; pointer-events: auto !important; }
.tilt-slider label { font-size: 12px; color: var(--ink-faint); white-space: nowrap; letter-spacing: 0.08em; }
#ui.mode-swipe .tilt-slider { display: flex; }
input[type="range"] {
  flex: 1; height: 44px; margin: 0; background: none;
  -webkit-appearance: none; appearance: none; touch-action: pan-x;
}
input[type="range"]::-webkit-slider-runnable-track { height: 3px; border-radius: 3px; background: rgba(255,255,255,0.35); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 28px; height: 28px; margin-top: -12.5px;
  border-radius: 50%; background: var(--accent); border: 0; box-shadow: 0 2px 8px rgba(0,0,0,0.35);
}
input[type="range"]::-moz-range-track { height: 3px; border-radius: 3px; background: rgba(255,255,255,0.35); }
input[type="range"]::-moz-range-thumb { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); border: 0; }

/* ---- flight ---- */
#screen-flight { align-items: center; justify-content: center; }
.skip-pop {
  font-family: var(--serif); font-weight: 700;
  font-size: clamp(110px, 38vw, 200px); line-height: 1;
  opacity: 0;
  text-shadow: 0 2px 6px rgba(0,0,0,0.35), 0 0 40px rgba(0,0,0,0.25);
}
.skip-pop.bump { animation: bump 1.1s cubic-bezier(.2,.8,.3,1) forwards; }
@keyframes bump {
  0% { opacity: 0; transform: scale(0.6); }
  14% { opacity: 1; transform: scale(1.08); }
  28% { transform: scale(1); }
  70% { opacity: 0.9; }
  100% { opacity: 0; transform: scale(1) translateY(-12px); }
}

/* ---- result ---- */
#screen-result {
  background: linear-gradient(to bottom, rgba(10,18,20,0.4), rgba(10,18,20,0.05) 40%, rgba(10,18,20,0.4));
}
/* 結果画面は下のボタン・フォロー欄が画面に収まらないことがあるので、縦にスクロールできるようにする（2026-11-09） */
#screen-result.active {
  overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  pointer-events: auto; touch-action: pan-y;
}
.result-main { margin-top: 8vh; text-align: center; }
.result-count { margin: 0; font-family: var(--serif); line-height: 1; }
.result-count b { font-size: clamp(110px, 36vw, 180px); font-weight: 700; font-variant-numeric: tabular-nums; }
.result-count span { font-size: 44px; font-weight: 700; margin-left: 6px; }
.result-dist { margin: 10px 0 0; font-family: var(--serif); font-size: 30px; letter-spacing: 0.04em; }
.result-note { margin: 12px 0 0; font-size: 14px; color: var(--ink-soft); letter-spacing: 0.06em; min-height: 1.4em; }
.result-detail { padding: 14px 18px; }
.stats { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.stats div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stats dd { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- toast ---- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-b) + 28px);
  transform: translate(-50%, 16px);
  max-width: calc(100% - 40px);
  padding: 12px 20px; border-radius: 999px;
  background: rgba(18, 28, 30, 0.78); color: #fff;
  font-size: 14px; letter-spacing: 0.04em; text-align: center;
  opacity: 0; transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 10; pointer-events: none;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 横長（パソコン）では少しゆったり */
@media (min-width: 760px) {
  .title-wrap { margin-top: 20vh; }
  .result-main { margin-top: 10vh; }
}
@media (max-height: 640px) {
  .title-wrap { margin-top: 8vh; }
  .result-main { margin-top: 2vh; }
  .result-count b { font-size: 96px; }
}

/* 投げた直後の表示（スマホの揺れが収まるまで） */
.throw-wait {
  position: absolute; left: 0; right: 0; top: 38%; text-align: center;
  font-family: 'Zen Old Mincho', serif; font-size: 44px; letter-spacing: 0.2em;
  text-shadow: 0 2px 12px rgba(0,0,0,.45); opacity: 0; transition: opacity .25s;
  pointer-events: none;
}
.throw-wait.show { opacity: 1; }

/* ===== v2：石ガチャ ===== */
:root {
  --r-good: #d9ead2;
  --r-rare: #bfe0ff;
  --r-legend: #f2cf7a;
  --r-joke: #ffb8a8;
}
[hidden] { display: none !important; }
.btn-zukan {
  position: absolute; top: calc(var(--safe-t) + 14px); right: calc(var(--safe-r) + 14px);
  min-height: 40px; padding: 8px 14px; border-radius: 999px;
  background: rgba(18, 28, 30, 0.34); border: 1px solid rgba(255,255,255,0.3);
  font-size: 13px; letter-spacing: 0.06em; text-shadow: none;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.btn-zukan b { font-weight: 500; font-variant-numeric: tabular-nums; margin-left: 4px; }
#screen-select .heading { margin-top: 52px; }

/* 探している間 */
.searching {
  position: absolute; left: 0; right: 0; top: 42%;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  font-family: var(--serif); font-size: 18px; letter-spacing: 0.12em;
  opacity: 0; transition: opacity 0.3s ease; pointer-events: none;
}
#ui.searching-on .searching { opacity: 1; }
.steps-anim { display: flex; gap: 10px; height: 18px; align-items: flex-end; }
.steps-anim i {
  width: 7px; height: 11px; border-radius: 50% 50% 45% 45%;
  background: rgba(255,255,255,0.85); opacity: 0.15;
  animation: step 1.6s infinite;
}
.steps-anim i:nth-child(odd) { transform: translateY(-6px); }
.steps-anim i:nth-child(2) { animation-delay: 0.4s; }
.steps-anim i:nth-child(3) { animation-delay: 0.8s; }
.steps-anim i:nth-child(4) { animation-delay: 1.2s; }
@keyframes step { 0%, 100% { opacity: 0.15; } 20%, 45% { opacity: 0.9; } }
.btn:disabled, .btn-link:disabled { opacity: 0.5; pointer-events: none; }

/* 石カード */
.stone-card { position: relative; overflow: hidden; }
.stone-name { margin: 0 0 4px; font-family: var(--serif); font-size: 22px; line-height: 1.35; letter-spacing: 0.04em; padding-right: 72px; }
.stone-type { margin: 0 0 8px; font-size: 12px; color: var(--ink-faint); letter-spacing: 0.06em; display: flex; gap: 10px; }
.stone-card .stone-label { margin: 0; font-family: inherit; font-size: inherit; letter-spacing: inherit; }
.stone-flavor { margin: 0 0 12px; font-family: var(--serif); font-size: 14px; color: var(--ink-soft); }
.btn-share-stone { display: block; margin: 6px auto -4px; font-size: 14px; }
.rarity-badge {
  position: absolute; top: 14px; right: 14px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.08em;
  color: var(--accent-ink); background: var(--ink);
}
.rarity-good { border-color: rgba(217, 234, 210, 0.45); }
.rarity-good .rarity-badge { background: var(--r-good); }

.stone-card.rarity-rare {
  border-color: rgba(191, 224, 255, 0.7);
  box-shadow: 0 0 22px rgba(150, 205, 255, 0.35), inset 0 0 30px rgba(150, 205, 255, 0.12);
  animation: rise 0.35s ease-out, glowRare 2.6s ease-in-out infinite;
}
.rarity-rare .rarity-badge { background: var(--r-rare); }
.rarity-rare .stone-name { color: #e4f2ff; text-shadow: 0 0 14px rgba(150, 205, 255, 0.6); }
@keyframes glowRare {
  0%, 100% { box-shadow: 0 0 18px rgba(150, 205, 255, 0.28), inset 0 0 26px rgba(150, 205, 255, 0.1); }
  50% { box-shadow: 0 0 30px rgba(150, 205, 255, 0.5), inset 0 0 34px rgba(150, 205, 255, 0.18); }
}

.stone-card.rarity-legend {
  border-color: rgba(242, 207, 122, 0.85);
  background: linear-gradient(160deg, rgba(70, 55, 22, 0.55), rgba(18, 28, 30, 0.5));
  box-shadow: 0 0 34px rgba(242, 200, 100, 0.45), inset 0 0 36px rgba(242, 200, 100, 0.14);
  animation: legendIn 0.7s cubic-bezier(.2,.9,.3,1.2), glowLegend 2.2s ease-in-out 0.7s infinite;
}
.rarity-legend .rarity-badge { background: linear-gradient(135deg, #ffe7a8, #e0b04f); }
.rarity-legend .stone-name { color: #ffe6a6; text-shadow: 0 0 16px rgba(242, 200, 100, 0.7); }
.stone-card.rarity-legend::after {
  content: ""; position: absolute; inset: -40% auto -40% -60%; width: 40%;
  background: linear-gradient(100deg, transparent, rgba(255, 236, 180, 0.35), transparent);
  transform: skewX(-20deg); pointer-events: none;
  animation: sheen 3.2s ease-in-out 0.4s infinite;
}
@keyframes legendIn {
  0% { opacity: 0; transform: translateY(24px) scale(0.92); filter: brightness(2); }
  60% { opacity: 1; transform: translateY(-4px) scale(1.02); filter: brightness(1.4); }
  100% { transform: none; filter: none; }
}
@keyframes glowLegend {
  0%, 100% { box-shadow: 0 0 26px rgba(242, 200, 100, 0.35), inset 0 0 30px rgba(242, 200, 100, 0.1); }
  50% { box-shadow: 0 0 44px rgba(242, 200, 100, 0.6), inset 0 0 40px rgba(242, 200, 100, 0.2); }
}
@keyframes sheen { 0% { left: -60%; } 55%, 100% { left: 130%; } }

.stone-card.rarity-joke {
  border: 1px dashed rgba(255, 184, 168, 0.8);
  background: linear-gradient(160deg, rgba(80, 40, 50, 0.5), rgba(18, 28, 30, 0.45));
}
.rarity-joke .rarity-badge {
  background: var(--r-joke); transform: rotate(-8deg);
  animation: wobble 1.4s ease-in-out infinite;
}
.rarity-joke .stone-name { color: #ffd6cc; }
@keyframes wobble { 0%, 100% { transform: rotate(-8deg); } 50% { transform: rotate(6deg) scale(1.06); } }

/* レア度の小さな札 */
.rarity-chip {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-shadow: none;
  color: var(--accent-ink); background: rgba(255,255,255,0.85);
}
.rarity-chip.rarity-common { background: rgba(255,255,255,0.18); color: #fff; font-weight: 500; }
.rarity-chip.rarity-good { background: var(--r-good); }
.rarity-chip.rarity-rare { background: var(--r-rare); }
.rarity-chip.rarity-legend { background: linear-gradient(135deg, #ffe7a8, #e0b04f); }
.rarity-chip.rarity-joke { background: var(--r-joke); }

/* 結果画面の石 */
.result-stone {
  margin: 8px 0 0; display: flex; justify-content: center; align-items: center; gap: 8px;
  font-family: var(--serif); font-size: 16px; letter-spacing: 0.04em;
}

/* 図鑑 */
.zukan {
  position: absolute; inset: 0; z-index: 8;
  display: flex; align-items: flex-end; justify-content: center;
  padding: calc(var(--safe-t) + 48px) calc(var(--safe-r) + 12px) calc(var(--safe-b) + 12px) calc(var(--safe-l) + 12px);
  background: rgba(8, 14, 16, 0.4);
  pointer-events: auto; text-shadow: none;
  animation: fadeIn 0.25s ease;
}
.zukan[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } }
.zukan-panel {
  width: 100%; max-width: 480px; max-height: 100%;
  display: flex; flex-direction: column;
  background: rgba(18, 28, 30, 0.95);
  animation: rise 0.3s ease-out;
}
.zukan-head { display: flex; align-items: baseline; gap: 12px; padding: 18px 18px 10px; }
.zukan-title { margin: 0; font-family: var(--serif); font-size: 20px; letter-spacing: 0.1em; }
.zukan-sum { margin: 0; font-size: 13px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.btn-close {
  margin-left: auto; min-height: 40px; padding: 6px 14px; border-radius: 999px;
  background: none; border: 1px solid rgba(255,255,255,0.3); font-size: 13px;
}
.zukan-list {
  list-style: none; margin: 0; padding: 4px 12px 16px;
  display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: max-content; align-content: start; gap: 8px;
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; overscroll-behavior: contain;
}
.zukan-list li {
  display: block;
  min-height: 48px; padding: 8px 10px; border-radius: 12px;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.08);
  font-size: 13px;
}
.zukan-list li.unknown { color: var(--ink-faint); letter-spacing: 0.2em; }
.zukan-list .z-name { display: block; margin-bottom: 4px; font-family: var(--serif); font-size: 14px; }
.zukan-list .z-count { margin-left: 6px; font-size: 11px; color: var(--ink-faint); }
.zukan-list li.rarity-rare { border-color: rgba(191, 224, 255, 0.45); }
.zukan-list li.rarity-legend { border-color: rgba(242, 207, 122, 0.6); background: rgba(242, 207, 122, 0.08); }
.zukan-list li.rarity-joke { border-color: rgba(255, 184, 168, 0.45); border-style: dashed; }

/* 向き合わせの案内 */
.calib-note {
  position: absolute; left: 20px; right: 20px; top: 34%; padding: 18px 20px; border-radius: 18px;
  background: rgba(20, 28, 30, .62); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  text-align: center; font-size: 19px; line-height: 1.6; text-shadow: 0 1px 4px rgba(0,0,0,.4); white-space: pre-line;
  opacity: 0; transition: opacity .25s; pointer-events: none; z-index: 30;
}
.calib-note.show { opacity: 1; }
.btn-recalib {
  position: absolute; right: 16px; top: calc(env(safe-area-inset-top) + 14px); display: none;
  padding: 8px 14px; border-radius: 999px; border: 1px solid rgba(255,255,255,.35);
  background: rgba(20, 28, 30, .45); font-size: 13px; pointer-events: auto;
}
.btn-recalib.show { display: block; }

/* ===== v3：探すボタンを左上へ・コンパクトなカード・図鑑の写真 ===== */
.btn-corner {
  position: absolute; top: calc(var(--safe-t) + 14px);
  min-height: 40px; padding: 8px 14px; border-radius: 999px;
  background: rgba(18, 28, 30, 0.34); border: 1px solid rgba(255,255,255,0.3);
  font-size: 13px; letter-spacing: 0.06em; text-shadow: none;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.btn-shuffle { left: calc(var(--safe-l) + 14px); right: auto; }
.btn-zukan { right: calc(var(--safe-r) + 14px); }
.btn-corner:disabled { opacity: 0.55; }

/* カードは小さく。カードの上のタップは下に通さない（カードの外は通す） */
.stone-card { padding: 12px 16px 12px; pointer-events: auto; }
.stone-card .stone-name { font-size: 19px; margin: 0 0 2px; padding-right: 64px; }
.stone-meta {
  margin: 0 0 4px; display: flex; flex-wrap: wrap; gap: 4px 12px;
  font-size: 12px; color: var(--ink-soft); font-variant-numeric: tabular-nums;
}
.stone-card .stone-flavor { margin: 0 0 10px; font-size: 13px; }
.stone-card .rarity-badge { top: 12px; right: 12px; }
.stone-card .btn { min-height: 50px; padding: 12px 16px; }
#screen-select .bottom-stack { gap: 0; }

/* 図鑑：写真つき3列 */
.zukan-list { grid-template-columns: repeat(3, 1fr); }
.zukan-list li { padding: 6px 6px 8px; text-align: center; cursor: pointer; }
.zukan-list li.unknown { cursor: default; }
.z-thumb {
  position: relative; aspect-ratio: 1; margin-bottom: 6px; border-radius: 9px; overflow: hidden;
  background: radial-gradient(circle at 50% 40%, rgba(255,255,255,0.12), rgba(255,255,255,0.03));
}
.z-thumb .z-photo { display: block; width: 100%; height: 100%; object-fit: cover; }
/* まだの種類：シルエット */
.zukan-list li.unknown .z-thumb::after {
  content: ""; position: absolute; left: 22%; right: 22%; top: 36%; bottom: 30%;
  border-radius: 50% 46% 52% 48% / 58% 52% 48% 42%;
  background: rgba(0, 0, 0, 0.45); box-shadow: 0 6px 8px -4px rgba(0,0,0,0.4);
}
.zukan-list li.found .z-thumb:empty::after {
  content: ""; position: absolute; inset: 40%; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.25); border-top-color: rgba(255,255,255,0.7);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.zukan-list .z-name { font-size: 12.5px; line-height: 1.35; margin-bottom: 3px; }
.zukan-list li.unknown .z-name { letter-spacing: 0.1em; }
.zukan-list .rarity-chip { font-size: 10px; padding: 1px 7px; }
.zukan-list .z-count { margin-left: 4px; }

/* 図鑑：1つを大きく */
.zukan-panel { position: relative; }
.zukan-detail {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 16px 18px 20px; border-radius: inherit;
  background: #172426; overflow-y: auto;
  animation: fadeIn 0.2s ease;
}
.zukan-detail[hidden] { display: none; }
.zd-back { align-self: flex-start; margin: 0 0 4px; }
.zd-photo {
  width: min(100%, 340px); aspect-ratio: 1; border-radius: 16px; overflow: hidden;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12);
}
.zd-photo .z-photo { display: block; width: 100%; height: 100%; object-fit: cover; }
.zd-photo.rarity-rare { border-color: rgba(191,224,255,0.7); box-shadow: 0 0 24px rgba(150,205,255,0.35); }
.zd-photo.rarity-legend { border-color: rgba(242,207,122,0.85); box-shadow: 0 0 30px rgba(242,200,100,0.45); }
.zd-photo.rarity-joke { border: 1px dashed rgba(255,184,168,0.8); }
.zd-name { margin: 6px 0 0; display: flex; align-items: center; gap: 8px; font-family: var(--serif); font-size: 19px; text-align: center; }
.zd-type { margin: 0; font-size: 13px; color: var(--ink-faint); }
.zd-flavor { margin: 0; font-family: var(--serif); font-size: 14px; color: var(--ink-soft); }
.zd-share { max-width: 260px; margin-top: 6px; }

/* ===== v4：左右の水平・音のボタン ===== */
.meter { gap: 2px; padding-right: 10px; }
.meter > svg { flex: 1 1 auto; }
.level {
  flex: 0 0 auto; width: 84px; display: flex; flex-direction: column; align-items: center;
  padding-left: 8px; margin-left: 4px; border-left: 1px solid rgba(255,255,255,0.14);
}
.level svg { width: 76px; height: auto; display: block; }
.vial { fill: rgba(255,255,255,0.08); stroke: rgba(255,255,255,0.5); stroke-width: 1.2; }
.vial-mark { stroke: rgba(255,255,255,0.45); stroke-width: 1; }
.bubble { fill: #ffcf9e; transition: cx 0.08s linear, fill 0.2s; }
.level #level-stone .stone-body { transition: fill 0.2s; }
.level-read { font-size: 12px; letter-spacing: 0.04em; color: #ffcf9e; font-variant-numeric: tabular-nums; white-space: nowrap; }
.level.is-level .bubble { fill: #bfe8c4; }
.level.is-level .level-read { color: #bfe8c4; }
.level.is-level #level-stone .stone-body { stroke: #bfe8c4; }
.meter-read { min-width: 60px; }

.btn-sound {
  position: absolute; z-index: 6;
  top: calc(var(--safe-t) + 62px); right: calc(var(--safe-r) + 14px);
  width: 40px; height: 40px; padding: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(18, 28, 30, 0.34); border: 1px solid rgba(255,255,255,0.3);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.btn-sound svg { width: 20px; height: 20px; }
.btn-sound .spk { fill: #fff; }
.btn-sound .waves, .btn-sound .mute { fill: none; stroke: #fff; stroke-width: 1.8; stroke-linecap: round; }
.btn-sound .mute { display: none; }
.btn-sound.off .waves { display: none; }
.btn-sound.off .mute { display: inline; }
.btn-sound.off { opacity: 0.7; }
body[data-screen="title"] .btn-sound { top: calc(var(--safe-t) + 14px); }
body[data-screen="flight"] .btn-sound { display: none; }
/* お知らせのベル（/news.js）。タイトル画面だけ、音のボタンの左 */
.btn-news {
  position: absolute; z-index: 6;
  top: calc(var(--safe-t) + 14px); right: calc(var(--safe-r) + 64px);
  width: 40px; height: 40px; padding: 0; border-radius: 50%;
  display: none; align-items: center; justify-content: center; color: #fff;
  background: rgba(18, 28, 30, 0.34); border: 1px solid rgba(255,255,255,0.3);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
body[data-screen="title"] .btn-news { display: flex; }
#ui.pc-only-on .btn-news { visibility: hidden; }
#screen-aim .help { margin-top: 44px; }

/* ===== v5：ランキング ===== */
.btn-ranking-link { margin-top: -6px; font-size: 14px; }
.corner-left {
  position: absolute; top: calc(var(--safe-t) + 14px); left: calc(var(--safe-l) + 14px);
  display: flex; gap: 8px;
}
.corner-left .btn-corner { position: static; }
.ranking-panel { height: 100%; }

.share-row .btn-primary { flex: 1.25; }
.submit-status { margin: 8px 0 0; min-height: 1.4em; font-size: 15px; letter-spacing: 0.04em; color: var(--ink-soft); }
.submit-status b { font-family: var(--serif); font-size: 22px; color: #fff; margin: 0 2px; }
.submit-status .sep { margin: 0 8px; color: var(--ink-faint); }
.submit-status.busy { color: var(--ink-faint); }
.submit-status.fail { font-size: 13px; color: var(--ink-faint); }
.submit-status.top b { color: var(--r-legend); }

/* ランキング一覧（図鑑の枠を使う） */
.ranking { z-index: 9; }
.rank-tabs { display: flex; gap: 6px; margin: 0 14px 8px; padding: 4px; border-radius: 999px; background: rgba(255,255,255,0.07); }
.rank-tab {
  flex: 1; min-height: 40px; border: 0; border-radius: 999px; background: none;
  font-size: 14px; letter-spacing: 0.1em; color: var(--ink-soft);
}
.rank-tab.active { background: var(--accent); color: var(--accent-ink); font-weight: 500; }
.rank-state { margin: 0; padding: 0 18px; font-size: 13px; color: var(--ink-faint); text-align: center; }
.rank-state:empty { display: none; }
.rank-state.busy, .rank-state.empty, .rank-state.fail { padding: 40px 24px; line-height: 1.7; }
.rank-state.busy::before {
  content: ""; display: block; width: 18px; height: 18px; margin: 0 auto 10px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.2); border-top-color: rgba(255,255,255,0.8); animation: spin 0.9s linear infinite;
}
.rank-list {
  list-style: none; margin: 0; padding: 0 10px 14px;
  overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; overscroll-behavior: contain;
  flex: 1 1 auto; min-height: 0;
}
.rank-row {
  display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 10px;
  min-height: 52px; padding: 6px 10px; border-radius: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.rk-rank { font-family: var(--serif); font-size: 17px; text-align: center; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.rk-who { min-width: 0; display: flex; flex-direction: column; }
.rk-name { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rk-stone { font-size: 11px; color: var(--ink-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rk-stone.rarity-good { color: var(--r-good); }
.rk-stone.rarity-rare { color: var(--r-rare); }
.rk-stone.rarity-legend { color: var(--r-legend); }
.rk-stone.rarity-joke { color: var(--r-joke); }
.rk-score { display: flex; flex-direction: column; align-items: flex-end; font-variant-numeric: tabular-nums; }
.rk-score b { font-family: var(--serif); font-size: 20px; font-weight: 700; }
.rk-score small { font-size: 12px; margin-left: 2px; font-weight: 400; }
.rk-sub { font-size: 11px; color: var(--ink-faint); }
/* 上位3位 */
.rank-row.top { background: rgba(255,255,255,0.05); border-bottom-color: transparent; margin-bottom: 4px; }
.rank-row.top .rk-rank {
  width: 32px; height: 32px; line-height: 32px; margin: 0 auto; border-radius: 50%;
  font-weight: 700; color: var(--accent-ink);
}
.rank-row.top1 .rk-rank { background: linear-gradient(135deg, #ffe7a8, #d9a845); box-shadow: 0 0 14px rgba(242,200,100,0.5); }
.rank-row.top2 .rk-rank { background: linear-gradient(135deg, #f2f2f2, #b9bfc4); }
.rank-row.top3 .rk-rank { background: linear-gradient(135deg, #f1c9a3, #b98256); }
.rank-row.top1 { background: rgba(242,207,122,0.1); }
.rank-row.top1 .rk-score b { color: #ffe6a6; }
/* 自分の行 */
.rank-row.mine { background: rgba(243, 234, 216, 0.16); box-shadow: inset 3px 0 0 var(--accent); }
.rank-row.mine .rk-name::after { content: "（あなた）"; font-size: 11px; color: var(--accent); margin-left: 4px; }

/* ニックネーム入力 */
.name-modal {
  position: absolute; inset: 0; z-index: 12; pointer-events: auto;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(8, 14, 16, 0.5); animation: fadeIn 0.2s ease; text-shadow: none;
}
.name-panel { width: 100%; max-width: 380px; padding: 20px 18px 18px; background: rgba(18, 28, 30, 0.95); }
.name-title { margin: 0 0 12px; font-family: var(--serif); font-size: 18px; letter-spacing: 0.08em; text-align: center; }
.name-input {
  display: block; width: 100%; min-height: 52px; padding: 10px 16px; border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.3); background: rgba(255,255,255,0.08);
  font-size: 18px; color: #fff; text-align: center; outline: none;
  -webkit-user-select: text; user-select: text; touch-action: manipulation;
}
.name-input:focus { border-color: var(--accent); }
.name-hint { margin: 8px 0 14px; font-size: 12px; color: var(--ink-faint); text-align: center; }
.name-hint.warn { color: #ffcf9e; }

/* ===== v6：スマホ前提（安全の確認・パソコン・センサーの案内） ===== */
#btn-start-swipe { display: none !important; }
#ui.no-motion #btn-start-motion { display: block; }

.overlay {
  position: absolute; inset: 0; z-index: 11; pointer-events: auto;
  display: flex; align-items: center; justify-content: center;
  padding: calc(var(--safe-t) + 24px) calc(var(--safe-r) + 24px) calc(var(--safe-b) + 24px) calc(var(--safe-l) + 24px);
  background: rgba(12, 20, 22, 0.72);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  text-shadow: none; animation: fadeIn 0.3s ease;
}
.overlay[hidden] { display: none; }
.ov-inner { width: 100%; max-width: 400px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.ov-title { margin: 0 0 22px; font-family: var(--serif); font-size: 26px; letter-spacing: 0.14em; }
.ov-lead { margin: 0 0 18px; font-size: 16px; line-height: 1.8; color: var(--ink-soft); }
.ov-note { margin: 0 0 22px; font-size: 13px; line-height: 1.7; color: var(--ink-faint); }
.ov-note.strong { color: #ffcf9e; }
.ov-icon { width: 56px; height: 56px; margin-bottom: 10px; }
.ov-inner .btn { max-width: 320px; }

.safety-list { list-style: none; margin: 0 0 30px; padding: 0; width: 100%; display: grid; gap: 18px; text-align: left; }
.safety-list li { display: grid; grid-template-columns: 48px 1fr; align-items: center; gap: 14px; }
.safety-list svg { width: 44px; height: 44px; }
.safety-list span { font-size: 18px; line-height: 1.5; letter-spacing: 0.03em; }
.safety-list small { display: block; font-size: 13px; color: var(--ink-faint); margin-top: 2px; }
.ln.strong { stroke: #ffcf9e; stroke-width: 2.4; }

/* パソコン：3D の上に軽く重ねる */
.overlay-pc { background: linear-gradient(to bottom, rgba(12,20,22,0.25), rgba(12,20,22,0.6)); -webkit-backdrop-filter: none; backdrop-filter: none; }
.overlay-pc .ov-title { font-size: 64px; font-weight: 700; letter-spacing: 0.2em; text-indent: 0.2em; margin-bottom: 14px; text-shadow: var(--shadow); }
.overlay-pc .ov-lead { color: #fff; text-shadow: var(--shadow); }
.qr {
  width: 220px; height: 220px; padding: 10px; border-radius: 18px; background: #fff;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
  display: flex; align-items: center; justify-content: center;
}
.qr svg { width: 100%; height: 100%; display: block; }
.qr.qr-failed { color: #333; font-size: 13px; padding: 20px; }
.qr-url { margin: 14px 0 0; font-size: 13px; color: var(--ink-soft); word-break: break-all; -webkit-user-select: text; user-select: text; text-shadow: var(--shadow); }
#ui.pc-only-on .screen, #ui.pc-only-on .btn-sound { visibility: hidden; }
.overlay-sensor .ov-title { font-size: 21px; letter-spacing: 0.06em; line-height: 1.5; text-wrap: balance; margin-bottom: 16px; }
.ov-lead, .ov-note { text-wrap: pretty; }

/* 一覧へのリンク（123studio.jp の玄関） */
.home-link { display: block; text-align: center; margin-top: 4px; font-size: 13px; color: rgba(255,255,255,.7); text-decoration: underline; pointer-events: auto; }

/* 文字だけの小さなボタン（ランキングを見る・名前を変える） */
.link-btn { display: block; margin: 2px auto 0; padding: 8px 14px; background: none; border: 0; color: rgba(255,255,255,.85);
  font-size: 14px; letter-spacing: .04em; text-decoration: underline; text-underline-offset: 3px; pointer-events: auto; }
.rank-rename { margin-top: 10px; }

/* ===== v7：シーズン ===== */
.rank-seasons { display: flex; gap: 6px; margin: 0 14px 8px; }
.rank-seasons[hidden] { display: none; }
.season-btn {
  min-height: 34px; padding: 4px 14px; border-radius: 999px;
  background: none; border: 1px solid rgba(255,255,255,0.22);
  font-size: 12.5px; letter-spacing: 0.06em; color: var(--ink-soft);
}
.season-btn.active { border-color: rgba(243,234,216,0.8); color: #fff; background: rgba(243,234,216,0.12); }
.rank-ended {
  margin: 0 14px 8px; padding: 6px 12px; border-radius: 10px;
  background: rgba(255,255,255,0.06); font-size: 12px; color: var(--ink-faint); text-align: center; letter-spacing: 0.06em;
}
.rank-ended[hidden] { display: none; }
.season-tag { display: inline-block; margin-right: 10px; font-size: 12px; color: var(--ink-faint); letter-spacing: 0.06em; vertical-align: 2px; }
