/* app-template の最小スタイル。サービスごとに自由に書き換える。 */

:root {
  --theme: #0d1b3e;
  --bg: #0d1b3e;
  --fg: #f5f7ff;
  --accent: #4f7cff;
}

* { box-sizing: border-box; }

/* ダブルタップによる拡大を抑制する（タップ／クリック自体は妨げない）。
   touch-action は継承されないので、子要素まで効かせるため全要素に指定する。
   manipulation はパン（スクロール）を許すので、内部スクロール領域はそのまま動く。
   ピンチ拡大と画面スクロールの抑止は viewport.js が担当。 */
* { touch-action: manipulation; }

/* hidden 属性を確実に効かせる。.stage / .book-dialog などに display:flex を
   指定すると、著者スタイルがブラウザ標準の [hidden]{display:none} を上書きして
   要素が表示されてしまうため、!important で hidden を最優先にする。 */
[hidden] { display: none !important; }

/* ===== アクセシビリティ（全アプリ共通の土台） ===== */

/* 視覚的には隠すがスクリーンリーダーには読まれる（aria-live リージョン・SEO見出し用） */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* スキップリンク類: 通常は隠し、キーボードのTabでフォーカスされたときだけ画面左上に出現する */
.a11y-skip {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 10000;
  width: 1px;
  height: 1px;
  overflow: hidden;
  cursor: pointer;
}
.a11y-skip:focus {
  left: 8px;
  top: 8px;
  width: auto;
  height: auto;
  overflow: visible;
  padding: 10px 14px;
  border: 0;
  border-radius: 8px;
  background: #00323a;
  color: #7df9ff;
  font-size: 14px;
  font-weight: 800;
  white-space: normal;
  box-shadow: 0 0 0 2px #7df9ff, 0 4px 14px rgba(0, 0, 0, 0.5);
}

/* キーボード操作時のフォーカスを必ず見えるようにする（マウス時は出さない） */
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* 動きを減らす設定の利用者には、アニメーション・トランジションを抑える */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

html, body {
  margin: 0;
  padding: 0;
  /* アプリ的な操作感: 端での引っ張り更新・バウンド（オーバースクロール）を抑止。
     実スクロール／ピンチの禁止は viewport.js、ダブルタップ抑止は touch-action が担当。 */
  overscroll-behavior: none;
}

/* ルート（スクロールコンテナ）をビューポートに固定してスクロール不可にする。
   PWA(standalone)等で、わずかにスクロール可能なことが原因で画面が上下に
   発振（激しく震える）するのを防ぐ。スクロールはもともと抑止する方針。

   overflow:hidden だけだと、起動直後にレイアウトビューポートが視覚ビューポートより
   1〜2px 高くなった瞬間（flex 中央寄せ＋dvh のサブピクセル誤差）に、ドキュメントが
   ごくわずかにスクロール可能になってバウンドし続けることがある（再起動で寸法が確定すると治る）。
   html 自体を position:fixed でビューポートに固定し、ドキュメントスクロール自体を無くす。 */
html {
  position: fixed;
  inset: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
}

body {
  /* 固定した html を満たす（dvh 由来の動的な高さ変動を避ける＝発振防止）。 */
  height: 100%;
  overflow: hidden;
  /* ページ全体（自販機＋フッター）を画面中央（上下左右）に配置。
     コンテンツが画面より高いときは safe で上が切れないようにする。 */
  display: flex;
  flex-direction: column;
  justify-content: safe center;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

.app {
  /* 画面幅は自販機の幅に合わせて固定（左右の余白ぶんを足す）。
     スマホでは max-width 以下なら width:auto で画面いっぱいに収まる。 */
  width: 100%;
  max-width: calc(var(--machine-w) + 2.5rem);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 1rem;
}

/* ヘッダー: タイトルと音声ガイドボタンを同じ行に、説明文をタイトルの右下に置く。
   1行目: [タイトル(左)] ........ [音声ガイド(右)]
   2行目: ............... [昭和レトロ…令和によみがえる(右寄せ)] */
.app-header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  column-gap: 0.75rem;
  row-gap: 0.2rem;
  margin-bottom: 1.5rem;
}

.app-title {
  grid-column: 1;
  grid-row: 1;
  margin: 0;
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  font-weight: 800;
  line-height: 1.2;
}

.app-desc {
  grid-column: 1 / -1;
  grid-row: 2;
  margin: 0;
  text-align: left;   /* タイトルの左下に置く */
  opacity: 0.8;
  font-size: clamp(0.8rem, 3vw, 1rem);
}

/* 音声ガイドのトグルボタン。ON 状態は aria-pressed=true（.is-on）で見た目も変える。 */
.voice-btn {
  grid-column: 2;
  grid-row: 1;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.5rem 0.9rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: var(--fg);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}
.voice-btn.is-on {
  background: #00323a;
  border-color: #7df9ff;
  color: #7df9ff;
  box-shadow: 0 0 8px rgba(0, 229, 255, 0.55);
}

/* ===== 自販機本体 ===== */

:root {
  --machine-body: #6fc0b3;     /* 昭和のターコイズ自販機 */
  --machine-dark: #4e9e91;
  --machine-edge: #2e6b60;     /* 濃いターコイズの縁 */
  --machine-frame: #14110f;    /* ガラス枠・看板の黒 */
  --metal: #cdd2d8;
  --machine-w: 380px;          /* 自販機の最大幅（ページ幅もこれに合わせる） */
}

.machine {
  position: relative;          /* 落書き風バージョン表記の基準 */
  transition: opacity 0.28s ease;  /* モード切替時のフェード */
  margin: 0 auto;
  max-width: var(--machine-w); /* 実機に近い縦長プロポーション */
  width: 100%;                 /* スマホでは親（.app）いっぱいに縮む */
  padding: 0.9rem 0.9rem 1.1rem;
  /* 自販機全体のエイジング: 角のサビ・退色のムラ・雨だれ（縦筋）を
     ベースのターコイズ塗装に重ねて、長年屋外に置かれた古びた質感にする。 */
  background:
    /* 四隅のサビ */
    radial-gradient(58% 42% at 1% 1%, rgba(124, 74, 30, 0.5), transparent 60%),
    radial-gradient(52% 38% at 99% 6%, rgba(112, 66, 27, 0.42), transparent 62%),
    radial-gradient(66% 44% at 100% 100%, rgba(96, 55, 22, 0.5), transparent 60%),
    radial-gradient(58% 40% at 0% 97%, rgba(120, 70, 28, 0.42), transparent 62%),
    /* 退色・くすみのムラ */
    radial-gradient(120% 80% at 50% 16%, rgba(255, 255, 255, 0.06), transparent 55%),
    radial-gradient(95% 72% at 32% 78%, rgba(0, 0, 0, 0.22), transparent 60%),
    /* 雨だれ（縦の汚れ筋） */
    repeating-linear-gradient(90deg,
      transparent 0 9px,
      rgba(0, 0, 0, 0.05) 9px 10px,
      transparent 10px 26px),
    /* ベースのターコイズ塗装 */
    linear-gradient(180deg, var(--machine-body), var(--machine-dark));
  border: 5px solid var(--machine-edge);
  border-radius: 14px;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.22),
    inset 0 -3px 8px rgba(0, 0, 0, 0.25),
    inset 0 0 22px rgba(38, 24, 10, 0.30),   /* 内側ににじむ汚れ・くすみ */
    0 14px 30px rgba(0, 0, 0, 0.5);
}

/* 近くの街灯がチカチカ点滅して筐体に反射する様子（装飾・クリック透過）。
   斜めの光の帯＋上方からの淡い光を screen 合成で重ね、不規則に明滅させる。 */
.machine-reflection {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  border-radius: 14px;        /* 筐体の角丸に合わせる */
  background:
    linear-gradient(118deg,
      rgba(255, 255, 255, 0) 8%,
      rgba(214, 234, 255, 0.22) 21%,
      rgba(255, 255, 255, 0.30) 24%,
      rgba(214, 234, 255, 0.22) 27%,
      rgba(255, 255, 255, 0) 40%),
    radial-gradient(130% 70% at 82% -15%, rgba(200, 224, 255, 0.28), transparent 60%);
  mix-blend-mode: screen;
  opacity: 0.6;
  animation: streetlight-flicker 6.5s linear infinite;
}

/* 故障気味の蛍光灯／街灯のような不規則な明滅 */
@keyframes streetlight-flicker {
  0%   { opacity: 0.55; }
  3%   { opacity: 0.12; }
  4%   { opacity: 0.6; }
  6%   { opacity: 0.2; }
  7%   { opacity: 0.55; }
  30%  { opacity: 0.5; }
  31%  { opacity: 0.08; }
  32%  { opacity: 0.55; }
  46%  { opacity: 0.52; }
  47%  { opacity: 0.15; }
  48%  { opacity: 0.3; }
  49%  { opacity: 0.58; }
  70%  { opacity: 0.5; }
  72%  { opacity: 0.1; }
  73%  { opacity: 0.55; }
  88%  { opacity: 0.45; }
  89%  { opacity: 0.6; }
  90%  { opacity: 0.18; }
  91%  { opacity: 0.55; }
  100% { opacity: 0.55; }
}

/* モード切替時のフェード（フェードアウト→商品入れ替え→フェードイン） */
.machine.is-fading { opacity: 0; }

/* バージョン番号（筐体への落書き／マーカー書き風） */
.machine-graffiti {
  position: absolute;
  z-index: 3;
  right: 12px;
  bottom: 14px;
  transform: rotate(-9deg);
  font-family: "Comic Sans MS", "Chalkboard SE", "Yu Gothic", cursive;
  font-weight: 900;
  font-size: 1.15rem;
  color: rgba(231, 76, 60, 0.7);              /* 赤マーカー風 */
  text-shadow: 0 0 1px rgba(0, 0, 0, 0.5), 1px 1px 0 rgba(255, 255, 255, 0.15);
  letter-spacing: 0.04em;
  pointer-events: none;                        /* 操作の邪魔をしない */
  user-select: none;
}

/* 上部の黒い看板「BOOK'S & VIDEO」 */
.machine-top {
  margin-bottom: 0.7rem;
  padding: 0.55rem 0.6rem;
  background: linear-gradient(180deg, #1d1a17, var(--machine-frame));
  border: 2px solid #000;
  border-radius: 6px;
  text-align: center;
}
.machine-sign {
  font-weight: 900;
  font-size: clamp(1.1rem, 5.5vw, 1.7rem);
  letter-spacing: 0.06em;
  color: #f3f4ef;
  text-shadow: 0 1px 0 #000, 0 0 8px rgba(255, 255, 255, 0.25);
}

/* 中段: ガラスケース + 右の機構 */
.machine-mid {
  display: flex;
  gap: 0.6rem;
  align-items: stretch;
}

/* ガラスケース（黒い太枠の中に商品棚） */
.machine-window {
  position: relative;
  flex: 1 1 auto;
  padding: 6px;
  background: var(--machine-frame);
  border: 3px solid #000;
  border-radius: 6px;
  box-shadow: inset 0 0 0 2px #2a2520;
}
/* ガラスの反射（装飾・クリック透過） */
.machine-glass {
  position: absolute;
  inset: 6px;
  pointer-events: none;
  border-radius: 3px;
  background: linear-gradient(115deg,
    rgba(255, 255, 255, 0.18) 0%,
    rgba(255, 255, 255, 0.05) 18%,
    rgba(255, 255, 255, 0) 40%);
}

/* 自販機内部の照明ランプ（庫内の上部から商品を照らす光）。
   外側の蛍光灯反射(.machine-reflection)とは別系統で、より速く不規則に明滅する。
   棚の上に screen 合成で重ね、上端に集中した光が庫内でチカチカする様子を出す。 */
.machine-lamp {
  position: absolute;
  inset: 6px;
  pointer-events: none;
  border-radius: 3px;
  background:
    radial-gradient(120% 55% at 50% -10%,
      rgba(255, 247, 214, 0.55) 0%,
      rgba(255, 238, 188, 0.26) 28%,
      transparent 62%);
  mix-blend-mode: screen;
  animation: lamp-flicker 2.7s steps(1, end) infinite;
}

/* 庫内ランプの不規則な明滅（接触不良気味の照明）。
   steps(1) で「カチッと切り替わる」感じにして、街灯のなめらかな反射と差をつける。 */
@keyframes lamp-flicker {
  0%, 100% { opacity: 0.9; }
  6%  { opacity: 0.35; }
  8%  { opacity: 0.95; }
  10% { opacity: 0.5; }
  12% { opacity: 0.9; }
  38% { opacity: 0.85; }
  39% { opacity: 0.18; }
  41% { opacity: 0.9; }
  62% { opacity: 0.88; }
  63% { opacity: 0.45; }
  65% { opacity: 0.92; }
  66% { opacity: 0.28; }
  68% { opacity: 0.9; }
  86% { opacity: 0.8; }
  87% { opacity: 0.5; }
  89% { opacity: 0.9; }
}

/* 右側のコイン投入・操作機構（装飾）。小ランプ（点滅）＋大ランプ（コイン枚数）。 */
.machine-mech {
  flex: 0 0 46px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;     /* ランプ群を中央に置く */
  gap: 0.55rem;
  padding: 0.55rem 0.3rem;
  background: linear-gradient(180deg, #e7eef0, #aebcc0);
  border: 2px solid var(--machine-edge);
  border-radius: 6px;
}
/* コイン投入口近くの小さなランプ。薄くチカチカ点滅する。
   コインが1枚以上＝黄、0枚＝赤（.is-empty）。 */
.mech-lamp {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff3b0, #ffd21f 55%, #b8860b);
  box-shadow: 0 0 4px rgba(255, 210, 40, 0.7);
  animation: mech-lamp-blink 3.4s steps(1, end) infinite;
}
.mech-lamp.is-empty {
  background: radial-gradient(circle at 35% 30%, #ffd9d9, #ff4d4d 60%, #a30f0f);
  box-shadow: 0 0 5px rgba(255, 70, 70, 0.8);
}
/* 大ランプ（コイン枚数）。縦に6個並べ、コイン枚数ぶんを下から点灯する。 */
.coin-lamps {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.coin-lamp {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #555, #1f1f1f);  /* 消灯 */
  box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.8);
}
.coin-lamp.is-on {
  background: radial-gradient(circle at 35% 30%, #d8ffe2, #34d058 60%, #0d7a2e); /* 点灯 */
  box-shadow: 0 0 6px rgba(52, 208, 88, 0.85), inset 0 0 1px rgba(0, 0, 0, 0.4);
}
/* 次の自動補充までのセグ液晶（59→00／満タンは「--」）。
   ペカラーのクレジット表示と同じ7セグ字体（赤・skew）。大きさは従来どおり。 */
.coin-seg {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 3px;
  min-width: 30px;
  height: 18px;
  padding: 2px 3px;
  border-radius: 3px;
  background: #000;
  border: 1px solid #2a0908;
  box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.9);
  overflow: hidden;
}
/* 7セグの1桁。skewで縦棒がわずかに傾く7セグらしい字体になる。 */
.coin-seg .seg-digit {
  position: relative;
  width: 9px;
  height: 14px;
  flex-shrink: 0;
  transform: skewX(-6deg);
}
.coin-seg .seg-digit i {
  position: absolute;
  background: rgba(255, 59, 48, 0.08); /* 消灯セグメント（ゴースト） */
  border-radius: 1px;
}
.coin-seg .seg-digit i.on {
  background: #ff3b30;
  box-shadow: 0 0 4px rgba(255, 59, 48, 0.95), 0 0 9px rgba(255, 59, 48, 0.55);
}
/* 横セグメント: a=上 g=中央 d=下 */
.coin-seg .s-a, .coin-seg .s-g, .coin-seg .s-d {
  left: 1.6px;
  right: 1.6px;
  height: 1.6px;
}
.coin-seg .s-a { top: 0; }
.coin-seg .s-g { top: 50%; margin-top: -0.8px; }
.coin-seg .s-d { bottom: 0; }
/* 縦セグメント: f=左上 e=左下 b=右上 c=右下 */
.coin-seg .s-b, .coin-seg .s-c, .coin-seg .s-e, .coin-seg .s-f {
  width: 1.6px;
  height: calc(50% - 2px);
}
.coin-seg .s-f { left: 0; top: 1.5px; }
.coin-seg .s-e { left: 0; bottom: 1.5px; }
.coin-seg .s-b { right: 0; top: 1.5px; }
.coin-seg .s-c { right: 0; bottom: 1.5px; }
/* 薄い明滅（低めの不透明度で行き来する） */
@keyframes mech-lamp-blink {
  0%, 100% { opacity: 0.5; }
  20% { opacity: 0.22; }
  22% { opacity: 0.55; }
  48% { opacity: 0.3; }
  50% { opacity: 0.5; }
  76% { opacity: 0.18; }
  79% { opacity: 0.5; }
}

/* 商品棚（ガラスの内側に雑誌が並ぶ） */
.machine-rack {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  padding: 0.5rem;
  background:
    repeating-linear-gradient(90deg,
      transparent 0, transparent calc(33.33% - 1px),
      rgba(0, 0, 0, 0.5) calc(33.33% - 1px), rgba(0, 0, 0, 0.5) 33.33%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.01)),
    #0e0b14;
  border-radius: 3px;
}

@media (max-width: 380px) {
  .machine-rack { grid-template-columns: repeat(2, 1fr); }
}

/* 下部のカンバン（「エロい作品入荷しました」等）。
   基本色は銅色で、緑青（パティナ）・くすみ・斑のエイジング処理を施した銅板に見せる。 */
.machine-push {
  --copper-light: #e6a667;
  --copper: #b87333;            /* 基本色＝銅色 */
  --copper-dark: #6e3f1c;
  margin: 0.7rem auto 0;
  max-width: 70%;
  padding: 0.5rem 0.7rem;
  background:
    /* 緑青（パティナ）の斑点 */
    radial-gradient(58% 52% at 18% 28%, rgba(58, 157, 140, 0.55), transparent 70%),
    radial-gradient(52% 60% at 83% 74%, rgba(40, 120, 110, 0.5), transparent 70%),
    radial-gradient(34% 42% at 62% 18%, rgba(72, 172, 150, 0.42), transparent 70%),
    /* 下からのくすみ・汚れ */
    radial-gradient(85% 120% at 50% 135%, rgba(0, 0, 0, 0.45), transparent 60%),
    /* 細かな斑（ざらつき・腐食ムラ） */
    repeating-linear-gradient(58deg, rgba(0, 0, 0, 0.10) 0 2px, transparent 2px 5px),
    /* 銅のベース＋当たり光 */
    linear-gradient(160deg, var(--copper-light), var(--copper) 46%, var(--copper-dark));
  /* ボタンに見えないようフラットに: 隆起の影・縁取り・面取りハイライトを排除。 */
  border: 1px solid rgba(63, 36, 16, 0.6);
  border-radius: 2px;
  text-align: center;
  font-weight: 900;
  font-size: clamp(0.9rem, 4vw, 1.15rem);
  letter-spacing: 0.12em;
  color: #2a1606;               /* 刻印（彫り込み）風の濃い色 */
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);  /* 軽い彫り込みのみ */
  box-shadow: inset 0 0 12px rgba(40, 90, 70, 0.28);  /* 内側のくすみだけ。隆起なし */
}

/* 1つの本ボタン（スロット） */
.slot {
  position: relative;          /* 左下の商品ランプの基準 */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.4rem 0.45rem;
  background: linear-gradient(180deg, #2a2030, #181018);
  border: 2px solid #3a2c44;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}
.slot:hover {
  transform: translateY(-2px);
  border-color: var(--machine-edge);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.5);
}
.slot:active { transform: translateY(0) scale(0.98); }

/* 商品ランプ（棚の各商品の左下）: 在庫あり=緑 / 売り切れ=赤 */
.slot-lamp {
  position: absolute;
  left: 6px;
  bottom: 6px;
  z-index: 3;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #d8ffe2, #34d058 60%, #0d7a2e);
  box-shadow: 0 0 5px rgba(52, 208, 88, 0.8), inset 0 0 1px rgba(0, 0, 0, 0.4);
}

/* 売り切れ（買われた）商品: ランプ赤・画像グレー・操作不可の見た目 */
.slot.is-sold { cursor: default; }
.slot.is-sold:hover { transform: none; border-color: #3a2c44; box-shadow: none; }
.slot.is-sold .slot-lamp {
  background: radial-gradient(circle at 35% 30%, #ffdada, #ff4d4d 60%, #a30f0f);
  box-shadow: 0 0 6px rgba(255, 60, 60, 0.85), inset 0 0 1px rgba(0, 0, 0, 0.4);
}
.slot.is-sold .cover { opacity: 0.85; }

/* ===== 表紙（CSS で生成） ===== */
.cover {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  /* 表紙の幅を基準に中の文字を拡縮する（cqw）。棚の小コマでも取り出し口でも
     同じ割合で文字が収まり、縦書きの段組が崩れて見切れるのを防ぐ。 */
  container-type: inline-size;
  border-radius: 4px;
  background:
    linear-gradient(160deg, color-mix(in srgb, var(--cover-bg) 88%, #fff 12%), var(--cover-bg));
  border: 1px solid rgba(0, 0, 0, 0.35);
  box-shadow:
    inset 0 0 0 3px color-mix(in srgb, var(--cover-accent) 70%, transparent),
    0 3px 8px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
/* 背表紙の影 */
.cover::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 8%;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.35), transparent);
}

.cover-inner {
  position: absolute;
  inset: 8%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: center;
  color: #fff;
}
.cover-top {
  font-size: clamp(0.5rem, 8cqw, 0.75rem);
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--cover-accent);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}
.cover-title {
  font-size: clamp(0.7rem, 15cqw, 1.2rem);
  font-weight: 900;
  line-height: 1.2;
  writing-mode: vertical-rl;
  align-self: flex-end;        /* 縦書きの先頭（右の列）から表示する */
  max-height: 78%;
  max-width: 2.6em;            /* 縦書き2列ぶんに制限（段組の崩れ防止） */
  overflow: hidden;
  /* 収まらない末尾（左側）はフェードして切る */
  -webkit-mask-image: linear-gradient(to left, #000 80%, transparent);
  mask-image: linear-gradient(to left, #000 80%, transparent);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.7);
}
.cover-genre {
  font-size: clamp(0.5rem, 8cqw, 0.75rem);
  font-weight: 700;
  padding: 0.1rem 0.3rem;
  align-self: center;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  color: var(--cover-accent);
}
/* スロット番号バッジ */
.cover-no {
  position: absolute;
  z-index: 2;
  top: 4px;
  right: 4px;
  min-width: 1.4em;
  height: 1.4em;
  padding: 0 0.2em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  background: #fff;
  color: #111;
  font-size: 0.7rem;
  font-weight: 900;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* 大きい表紙（詳細ダイアログ用） */
.cover-lg {
  width: 160px;
  flex: 0 0 160px;
}
.cover-lg .cover-title { font-size: 1.3rem; }

/* 実画像の表紙（DMM/FANZA の商品画像） */
.cover-photo { box-shadow: 0 3px 8px rgba(0, 0, 0, 0.45); background: #0e0b14; }
/* 詳細ダイアログの大きい表紙は、余白（レターボックス）の地色を
   ウィンドウ(.book-dialog-inner)と同色にして馴染ませる。 */
.cover-lg.cover-photo { background: #1d1530; }
.cover-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}
/* 小画像を使う箇所（詳細・取り出し口・ズーム）は見切れさせず全体表示 */
.cover-lg .cover-img,
.tray-book .cover-img,
.zoom-cover .cover-img { object-fit: contain; }

/* 商品棚の表紙はブラーをかける（DMM／FANZA どちらのタブでも。番号バッジは残す）。
   取り出した本・詳細はブラーなし。 */
.machine-rack .cover-img,
.machine-rack .cover-inner { filter: blur(2px); }

/* 売り切れ（買われた）商品の画像はグレースケールにして暗くする（ブラーより優先）。 */
.slot.is-sold .cover-img,
.slot.is-sold .cover-inner { filter: grayscale(1) brightness(0.6); }

/* コイン0枚（品切れ/故障風）: 庫内蛍光灯OFF・棚の本を全グレー・在庫ランプ消灯。
   （取り出し口の本は対象外＝手に入れた1冊はそのまま見える） */
.machine.is-no-coins .machine-lamp { animation: none; opacity: 0; }
.machine.is-no-coins .slot-lamp { opacity: 0; }
.machine.is-no-coins .slot .cover-img,
.machine.is-no-coins .slot .cover-inner { filter: grayscale(1) brightness(0.45); }
/* 消灯中は取得済み（売り切れ）の表紙を黒く塗りつぶし、未取得（暗いグレー）と区別できるようにする。 */
.machine.is-no-coins .slot.is-sold .cover-img,
.machine.is-no-coins .slot.is-sold .cover-inner { filter: brightness(0); }
/* 文字だけの表紙は地色・枠・背表紙が .cover 本体にあるため、本体も黒くしないと塗りつぶしにならない。 */
.machine.is-no-coins .slot.is-sold .cover { background: #000; box-shadow: none; }
.machine.is-no-coins .slot.is-sold .cover::before { content: none; }

/* ===== 取り出し口 ===== */
.machine-tray {
  margin-top: 0.8rem;
  padding: 0.6rem 0.8rem 0.8rem;
  background: linear-gradient(180deg, #14130f, #0a0908);
  border: 3px solid var(--machine-edge);
  border-radius: 8px;
}
.tray-slot {
  /* 商品が落ちても大きさが変わらないよう高さを固定（落下の前後で変わらない）。
     浅い取り出し口に雑誌が寝かせて入っているように、高さは控えめにする。 */
  height: clamp(66px, 20vw, 86px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem;
  background: #0a0405;
  border-radius: 8px;
  box-shadow: inset 0 4px 14px rgba(0, 0, 0, 0.85);
}
.tray-empty {
  margin: 0;
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.45);
}

/* コイン切れ時に取り出し口へ出す広告バナー（別タブで開く）。 */
.tray-promo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  max-width: 100%;
  padding: 0.5rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  color: #fff8d6;
  background: linear-gradient(180deg, #b8860b, #8a5a00);
  border: 2px solid #ffd76a;
  border-radius: 8px;
  box-shadow: 0 0 8px rgba(255, 200, 70, 0.5);
  cursor: pointer;
}
.tray-promo:hover,
.tray-promo:focus-visible {
  background: linear-gradient(180deg, #d49b14, #a76d00);
  outline: 2px solid #fff;
  outline-offset: 2px;
}
.tray-promo-lamp { flex: 0 0 auto; }

/* 落ちてきた本（取り出し口のボタン）。
   「開く」ボタンは置かず、雑誌そのものが無造作に（ランダムな角度で）転がっている見た目。
   雑誌＝ボタンなので、これをタップ／クリックで開く。--tilt は app.js が1冊ごとに乱数で与える。 */
.tray-book {
  display: block;
  width: clamp(110px, 34vw, 144px);   /* 従来比 1.2 倍 */
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  /* perspective() で奥行きを付け、雑誌を寝かせる（奥＝上端が遠ざかる）。
     さらに乱数の傾き(--tilt)で無造作に置かれた雰囲気にする。
     translateY で取り出し口内の見た目位置を上方向へ寄せる。 */
  transform: translateY(-20px) perspective(560px) rotateX(54deg) rotate(var(--tilt, 0deg));
  transform-origin: center bottom;
  /* 床に落ちた雑誌の影 */
  filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.6));
}
/* 雑誌は表紙いっぱい。右下に紙束を重ねて「厚み」を出す。 */
.tray-book .cover {
  width: 100%;
  box-shadow:
    1px 1px 0 #ece6d6,
    2px 2px 0 #ddd5c2,
    3px 3px 0 #cfc6b1,
    4px 4px 0 #c0b6a0,
    5px 6px 0 #afa48d,
    6px 8px 11px rgba(0, 0, 0, 0.5);
}
.tray-book.is-dropping {
  animation: book-drop 0.6s cubic-bezier(0.3, 1.4, 0.5, 1) both;
}
/* 高評価（星4.1以上）の本にまとう、ぼわぼわ光るオーラ。雑誌の背後で大きく脈動させる。 */
.tray-book.is-special::before,
.zoom-cover.is-special::before {
  content: "";
  position: absolute;
  inset: -28%;
  z-index: -1;
  border-radius: 16px;
  background: radial-gradient(closest-side,
    rgba(255, 244, 185, 1),
    rgba(255, 198, 50, 0.8) 50%,
    rgba(255, 165, 15, 0.35) 72%,
    transparent 86%);
  filter: blur(13px);
  pointer-events: none;
  animation: aura-bowa 1.5s ease-in-out infinite;
}
@keyframes aura-bowa {
  0%, 100% { opacity: 0.65; transform: scale(0.95); }
  50% { opacity: 1; transform: scale(1.32); }
}
/* オーラの本は取り出し口でブルブル震える（雑誌＝.cover を細かく揺らす。
   3D変形は親(.tray-book)が持つので、ここは平面内の小刻みなジッターにする）。 */
.tray-book.is-special .cover {
  animation: tray-shake 0.16s steps(2, end) infinite;
}
@keyframes tray-shake {
  0%   { transform: translate(0, 0) rotate(0); }
  25%  { transform: translate(-1.6px, 1px) rotate(-1deg); }
  50%  { transform: translate(1.6px, -1px) rotate(1deg); }
  75%  { transform: translate(-1px, -1.4px) rotate(0.6deg); }
  100% { transform: translate(1px, 1.4px) rotate(-0.6deg); }
}
/* 落下の着地点は乱数の傾き(--tilt)。奥行き(perspective+rotateX)を保ったまま着地する。 */
@keyframes book-drop {
  0% { transform: translateY(-130px) perspective(560px) rotateX(54deg) rotate(-16deg); opacity: 0; }
  60% { transform: translateY(-12px) perspective(560px) rotateX(54deg) rotate(calc(var(--tilt, 0deg) + 4deg)); opacity: 1; }
  100% { transform: translateY(-20px) perspective(560px) rotateX(54deg) rotate(var(--tilt, 0deg)); }
}

/* ===== ズーム／ガチャン演出ステージ ===== */
.stage {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(2px);
}
.zoom-cover {
  transform: scale(0.4);
  opacity: 0;
  transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.4s ease;
  width: min(60vw, 240px);
}
.zoom-cover.is-zoomed { transform: scale(1); opacity: 1; }
.zoom-cover.is-falling {
  animation: zoom-fall 0.7s ease-in forwards;
}
@keyframes zoom-fall {
  0% { transform: scale(1) translateY(0) rotate(0); opacity: 1; }
  100% { transform: scale(0.5) translateY(60vh) rotate(12deg); opacity: 0; }
}

/* ===== 本の詳細ダイアログ ===== */
.book-dialog {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  /* スマホのカメラ部（ノッチ/パンチホール）に閉じるボタン等が隠れないよう、
     セーフエリア分を余白に確保する（viewport-fit=cover 対応）。 */
  padding:
    max(1.25rem, env(safe-area-inset-top))
    max(1.25rem, env(safe-area-inset-right))
    max(1.25rem, env(safe-area-inset-bottom))
    max(1.25rem, env(safe-area-inset-left));
  background: rgba(0, 0, 0, 0.7);
}
.book-dialog-inner {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.4rem;
  background: #1d1530;
  border: 2px solid var(--accent);
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}
.book-dialog-close {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  z-index: 10;
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  line-height: 1;
  background: rgba(255, 255, 255, 0.12);
  color: var(--fg);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  cursor: pointer;
}
.book-dialog-close:hover { background: rgba(255, 255, 255, 0.2); }

.book-dialog-body {
  display: flex;
  gap: 1.2rem;
  flex-wrap: wrap;
  /* 横並び(PC)では画像を上下中央に。縦積み(スマホ)では画像を左右中央に。
     PCでは .book-info が伸びて行を埋めるため justify-content は実質効かない。 */
  justify-content: center;
  align-items: center;
}
.book-info { flex: 1 1 220px; min-width: 200px; }
.book-info-title {
  margin: 0.2rem 0 0.4rem;
  font-size: 1.45rem;
  font-weight: 900;
}
.book-info-meta {
  margin: 0 0 0.6rem;
  font-size: 0.85rem;
  opacity: 0.8;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
/* 平均評価の星（年の左）。下段グレー＋上段の金を割合ぶん重ねて半星・端数を表現。 */
.book-stars {
  position: relative;
  display: inline-block;
  flex: 0 0 auto;
  line-height: 1;
  white-space: nowrap;
  font-size: 1rem;
  letter-spacing: 1px;
}
.book-stars.is-none {
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.8rem;
  letter-spacing: normal;
}
.book-stars .stars-bg { color: rgba(255, 255, 255, 0.25); }
.book-stars .stars-fill {
  position: absolute;
  top: 0;
  left: 0;
  overflow: hidden;
  color: #ffcf3f;
}
.book-info-catch {
  margin: 0 0 0.6rem;
  font-weight: 700;
  color: #ffd24a;
}
.book-info-desc {
  margin: 0 0 1.1rem;
  font-size: 0.95rem;
}

.book-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}
.book-action {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 0.65rem 1rem;
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
a.book-action:hover { filter: brightness(1.08); }

/* 「作品ページへ」のアイコン＝大ランプ。点灯＝コイン補充可／消灯＝補充済み。 */
.work-lamp {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #555, #1f1f1f);  /* 消灯 */
  box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.8);
}
.work-lamp.is-on {
  background: radial-gradient(circle at 35% 30%, #d9ffe0, #34d058 55%, #0d7a2e); /* 点灯 */
  box-shadow: 0 0 8px rgba(52, 208, 88, 0.9);
  animation: work-lamp-glow 1.4s ease-in-out infinite;
}
@keyframes work-lamp-glow {
  0%, 100% { box-shadow: 0 0 5px rgba(52, 208, 88, 0.7); }
  50% { box-shadow: 0 0 12px rgba(52, 208, 88, 1); }
}
.book-action:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.book-actions-note {
  flex-basis: 100%;
  margin: 0.3rem 0 0;
  font-size: 0.78rem;
  opacity: 0.7;
}

/* ===== 詳細の「雑誌のように開く」 ===== */
/* 表紙はタップで開くボタン */
.cover-open {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.cover-open:disabled { cursor: default; }
.cover-open-hint {
  margin-top: 0.6rem;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--accent);
}

/* 開いた状態: 大きい画像が詳細ウィンドウ全体を覆う。リンクは画像の上に残す。 */
/* 雑誌パネルはセーフエリア（カメラ部を除いた領域）いっぱいに広げる。
   高さ・幅は親(.book-dialog のセーフエリア余白付きコンテンツ領域 = 100%)に収め、
   閉じるボタン(右上 0.6rem)がカメラ部に隠れないようにする。 */
.book-dialog-inner:has(.book-dialog-body.is-spread) {
  width: 96vw;
  width: min(96vw, 100%);
  max-width: 100%;
  height: 94vh;
  height: min(94dvh, 100%);
  max-height: 100%;
  padding: 0;
  overflow: hidden;
  /* 拡大画面は外枠（アクセントのボーダー・角丸・影）を消して画像だけにする。 */
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.book-spread {
  position: absolute;
  inset: 0;
  z-index: 5;
  overflow: hidden;
  border-radius: 0;
  background: #000;
  cursor: pointer;
}
.spread-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform-origin: left center;
  animation: book-open 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
@keyframes book-open {
  0% { transform: scaleX(0); opacity: 0.5; }
  100% { transform: scaleX(1); opacity: 1; }
}

/* パラパラめくれる演出（左綴じの紙が連続でめくれる） */
.book-flip {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  perspective: 1200px;
  overflow: hidden;
}
.book-flip-page {
  position: absolute;
  top: 0;
  left: 0;
  width: 50%;
  height: 100%;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.7), rgba(220, 220, 220, 0.9));
  border-right: 1px solid rgba(0, 0, 0, 0.2);
  transform-origin: left center;
  animation: page-turn 0.5s ease-in forwards;
}
@keyframes page-turn {
  0% { transform: rotateY(0); opacity: 0.95; }
  100% { transform: rotateY(-172deg); opacity: 0; }
}

/* 開いた状態でのリンクボタン＋説明（画像の上に重ねる） */
.book-spread .book-actions {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 7;
  margin: 0;
  padding: 0.9rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0));
}
.book-spread .book-actions-note { color: rgba(255, 255, 255, 0.85); opacity: 1; }

/* ダイアログ表示中は背面スクロールを抑える */
body.dialog-open { overflow: hidden; }

/* 商品タップ時の暗転（ズーム）・ダイアログ表示中は、画面下のセーフエリア等に
   body の地色（紺）が明るく残らないよう、全体を黒地にして暗転を画面全体へ行き渡らせる。 */
body.dialog-open,
body:has(.stage:not([hidden])) {
  background: #000;
}

/* reduced-motion: 演出系アニメーションを無効化（基盤の指定に加えて明示） */
@media (prefers-reduced-motion: reduce) {
  .machine-lamp { animation: none; }
  .mech-lamp { animation: none; opacity: 0.4; }
  .work-lamp.is-on { animation: none; }
  .tray-book.is-dropping { animation: none; }
  .zoom-cover { transition: none; }
  /* オーラは脈動を止めて静止表示（高評価であることは伝える）。震えも止める。 */
  .tray-book.is-special::before,
  .zoom-cover.is-special::before { animation: none; opacity: 0.85; transform: none; }
  .tray-book.is-special .cover { animation: none; }
  .spread-img { animation: none; }
  /* 街灯の明滅は止め、淡い反射だけ静止表示にする */
  .machine-reflection { animation: none; opacity: 0.35; }
}

/* ===== モード切り替え（DMM / FANZA） ===== */
.mode-switch {
  display: flex;
  gap: 0.4rem;
  margin: 0 auto 1rem;
  max-width: var(--machine-w);
}
.mode-btn {
  flex: 1 1 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35em;
  padding: 0.5rem 0.6rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: var(--fg);
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  cursor: pointer;
}
.mode-btn.is-active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 8px rgba(79, 124, 255, 0.5);
}
.mode-badge {
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1;
  padding: 0.15em 0.35em;
  border-radius: 4px;
  background: #b3203a;
  color: #fff;
}

/* ===== 年齢確認ダイアログ ===== */
.age-dialog {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(0, 0, 0, 0.8);
}
.age-dialog-inner {
  width: 100%;
  max-width: 420px;
  padding: 1.6rem 1.4rem;
  background: #1d1530;
  border: 2px solid var(--accent);
  border-radius: 14px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}
.age-title {
  margin: 0 0 0.7rem;
  font-size: 1.35rem;
  font-weight: 900;
}
.age-desc {
  margin: 0 0 1.3rem;
  font-size: 0.95rem;
  line-height: 1.7;
}
.age-actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.age-btn {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  border: 0;
}
.age-yes {
  background: var(--accent);
  color: #fff;
}
.age-no {
  background: rgba(255, 255, 255, 0.1);
  color: var(--fg);
  border: 1px solid rgba(255, 255, 255, 0.25);
}

/* ===== アクセス解析画面 ===== */
.analytics-dialog {
  position: fixed;
  inset: 0;
  z-index: 130;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.85);
}
.analytics-inner {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 760px;
  height: 90vh;
  padding: 1rem 1.1rem 1.2rem;
  background: #1d1530;
  border: 2px solid var(--accent);
  border-radius: 14px;
}
.analytics-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
}
.analytics-head .age-title { margin: 0; }

/* 上下2パネル（上=日別 / 下=時間別）。各パネルは横スクロール、右が最新。 */
.stat-panel {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-top: 0.6rem;
  padding: 0.6rem;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 10px;
}
.stat-title {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  font-weight: 800;
  color: #9be7ff;
}
.stat-scroll {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 0.3rem;
  /* ネイティブのスクロールバーは隠す（黄色いカスタムバーで操作する） */
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.stat-scroll::-webkit-scrollbar { display: none; }
.stat-bar {
  flex: 0 0 auto;
  width: 26px;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
}
.stat-count {
  font-size: 0.62rem;
  line-height: 1;
  margin-bottom: 1px;
  white-space: nowrap;
  color: rgba(255, 255, 255, 0.85);
}
.stat-fillwrap {
  flex: 1 1 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end; /* 下詰め＝人数は棒(fill)の頂点のすぐ上に並ぶ */
  align-items: center;
}
.stat-fill {
  flex: 0 0 auto; /* 列フレックスでも指定した高さ(%)を保つ */
  width: 100%;
  /* 下＝シアン → 上＝マゼンタのネオングラデーション */
  background: linear-gradient(to top, #19e0ff 0%, #4aa6ff 35%, #9b5cff 70%, #e83cff 100%);
  border-radius: 4px 4px 0 0;
  min-height: 2px;
}
.stat-label {
  font-size: 0.6rem;
  color: rgba(255, 255, 255, 0.6);
  white-space: nowrap;
  /* 時間番号(0〜23)は横書き。1桁/2桁で高さが変わらないよう行高を固定する。 */
  line-height: 1;
  height: 1em;
}
.stat-empty { margin: auto; color: rgba(255, 255, 255, 0.5); font-size: 0.85rem; }

/* 日別の棒（タップで選択）。日付ラベルが入るぶん時間別より少し広め。 */
.stat-bar-day {
  width: 30px;
  padding: 0;
  background: none;
  border: 0;
  color: var(--fg);
  cursor: pointer;
}
.stat-bar-day .stat-label { font-size: 0.55rem; }
/* 選択中の日は棒を明るく・ラベルを強調する */
.stat-bar-day.is-active .stat-fill {
  box-shadow: 0 0 8px rgba(232, 60, 255, 0.9), 0 0 4px rgba(25, 224, 255, 0.8);
  outline: 1px solid rgba(255, 255, 255, 0.85);
}
.stat-bar-day.is-active .stat-label {
  color: #ffd24a;
  font-weight: 800;
}
.stat-bar-day.is-active .stat-count { color: #fff; }

/* 黄色いカスタムスクロールバー（◀ つまみ ▶）。画像に寄せたデザイン。 */
.stat-scrollbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 0.45rem;
  padding: 0 2px;
}
.stat-scrollbar.is-hidden { visibility: hidden; }
.stat-arrow {
  flex: 0 0 auto;
  width: 26px;
  height: 18px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}
.stat-arrow::before {
  content: "";
  display: block;
  width: 0;
  height: 0;
  margin: 0 auto;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
}
.stat-arrow-l::before { border-right: 13px solid #f5a623; }
.stat-arrow-r::before { border-left: 13px solid #f5a623; }
.stat-arrow:hover::before { filter: brightness(1.15); }
.stat-arrow:active::before { filter: brightness(0.9); }
.stat-track {
  position: relative;
  flex: 1 1 auto;
  height: 14px;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 8px;
}
.stat-thumb {
  position: absolute;
  top: 1px;
  left: 0;
  height: 12px;
  min-width: 28px;
  background: linear-gradient(180deg, #ffe27a, #f5b400);
  border-radius: 7px;
  box-shadow: 0 0 4px rgba(245, 180, 0, 0.6);
  cursor: grab;
  touch-action: none;
}
.stat-thumb:active { cursor: grabbing; }

/* ===== フッター（クレジット表示） ===== */
.site-footer {
  /* 自販機と同じ幅で中央寄せ */
  max-width: calc(var(--machine-w) + 2.5rem);
  margin: 0 auto;
  padding: 0 1.25rem 2.5rem;
  text-align: center;
}
.credit {
  margin: 0;
  font-size: 0.8rem;
  opacity: 0.75;
}
.credit a {
  color: var(--accent);
  font-weight: 700;
}
