/* ===================================================================
   Cardano Q&A Bot — Apple / iMessage inspired visual design
   Light mode default, dark mode via prefers-color-scheme.
   CSS-only. No JS. No external resources.
=================================================================== */

:root {
  --bg: #f5f5f7;
  --header-bg: rgba(255, 255, 255, 0.72);
  --panel: #ffffff;
  --bot-bubble: #e9e9eb;
  --bot-bubble-text: #1d1d1f;
  --user-bubble-a: #0a84ff;
  --user-bubble-b: #007aff;
  --user-text: #ffffff;
  --text: #1d1d1f;
  --muted: #86868b;
  --accent: #0a84ff;
  --border: rgba(60, 60, 67, 0.13);
  --hairline: rgba(60, 60, 67, 0.16);
  --shadow-bubble: 0 1px 2px rgba(0, 0, 0, 0.06), 0 1px 1px rgba(0, 0, 0, 0.03);
  --shadow-pill: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-pill-hover: 0 4px 10px rgba(0, 0, 0, 0.1);
  --focus-ring: 0 0 0 3px rgba(10, 132, 255, 0.25);
  --scrollbar-thumb: rgba(0, 0, 0, 0.18);
  --chrome-text: #48484a;
  --chrome-bg: rgba(120, 120, 128, 0.12);
  --chrome-bg-hover: rgba(120, 120, 128, 0.2);
  --chrome-bg-active: rgba(120, 120, 128, 0.26);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1c1e;
    --header-bg: rgba(28, 28, 30, 0.72);
    --panel: #2c2c2e;
    --bot-bubble: #2c2c2e;
    --bot-bubble-text: #f5f5f7;
    --user-bubble-a: #0a84ff;
    --user-bubble-b: #0060df;
    --user-text: #ffffff;
    --text: #f5f5f7;
    --muted: #98989d;
    --accent: #0a84ff;
    --border: rgba(255, 255, 255, 0.12);
    --hairline: rgba(255, 255, 255, 0.1);
    --shadow-bubble: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-pill: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-pill-hover: 0 4px 12px rgba(0, 0, 0, 0.4);
    --focus-ring: 0 0 0 3px rgba(10, 132, 255, 0.35);
    --scrollbar-thumb: rgba(255, 255, 255, 0.2);
    --chrome-text: #c7c7cc;
    --chrome-bg: rgba(120, 120, 128, 0.24);
    --chrome-bg-hover: rgba(120, 120, 128, 0.32);
    --chrome-bg-active: rgba(120, 120, 128, 0.4);
  }
}

/* 手動切替: data-theme="dark" はOS設定より優先 */
:root[data-theme="dark"] {
  --bg: #1c1c1e;
  --header-bg: rgba(28, 28, 30, 0.72);
  --panel: #2c2c2e;
  --bot-bubble: #2c2c2e;
  --bot-bubble-text: #f5f5f7;
  --user-bubble-a: #0a84ff;
  --user-bubble-b: #0060df;
  --user-text: #ffffff;
  --text: #f5f5f7;
  --muted: #98989d;
  --accent: #0a84ff;
  --border: rgba(255, 255, 255, 0.12);
  --hairline: rgba(255, 255, 255, 0.1);
  --shadow-bubble: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-pill: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-pill-hover: 0 4px 12px rgba(0, 0, 0, 0.4);
  --focus-ring: 0 0 0 3px rgba(10, 132, 255, 0.35);
  --scrollbar-thumb: rgba(255, 255, 255, 0.2);
  --chrome-text: #c7c7cc;
  --chrome-bg: rgba(120, 120, 128, 0.24);
  --chrome-bg-hover: rgba(120, 120, 128, 0.32);
  --chrome-bg-active: rgba(120, 120, 128, 0.4);
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  /* ヒーローのティッカーは1200px超の幅を持ち、#hero-feed の overflow で切っている。
     アプリ内ブラウザ(X等)はCSS適用前の版面幅を採用することがあり、そのとき横に
     広いページと誤認してズーム+横スクロール状態で開く。ここで横あふれを塞ぐ */
  max-width: 100%;
  overflow-x: hidden;
  /* Android の WebView は本文を勝手に拡大することがある。拡大されると選択肢が
     画面幅を超え、下の中央寄せと相まって左に飛び出す。自動拡大を止める */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  max-width: 100%;
  overflow-x: hidden;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Hiragino Sans",
    "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
  /* 以前は display:flex + justify-content:center で中央に置いていたが、
     フレックス項目になると min-width の既定値や伸縮の解釈がブラウザで割れ、
     アプリ内ブラウザで列が画面外へ寄ったり、逆に潰れて1文字ずつ折り返す
     事故が起きた。中央寄せは margin だけで足りるので、フレックスをやめる */
  display: block;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#chat-app {
  width: 100%;
  max-width: 640px;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  background: var(--bg);
  position: relative;
}

/* ---------- Header: frosted glass ---------- */

/* ヘッダー行は廃止。「トップに戻る」は右上のフローティングボタンとして、
   会話が始まったときだけ表示する(ホーム画面では不要)。 */
#home-btn {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 30;
  appearance: none;
  background: var(--chrome-bg);
  border: none;
  color: var(--chrome-text);
  border-radius: 9999px;
  padding: 7px 14px;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: -0.01em;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0;
  pointer-events: none;
  transition: background-color 0.15s ease, transform 0.15s ease, opacity 0.25s ease;
}

#chat-app:has(#chat-log > .bubble:nth-child(2)) #home-btn {
  opacity: 1;
  pointer-events: auto;
}

/* ライト/ダーク手動切替(左上・常時表示) */
#theme-btn {
  position: absolute;
  top: 10px;
  left: 12px;
  z-index: 30;
  appearance: none;
  background: var(--chrome-bg);
  border: none;
  color: var(--chrome-text);
  border-radius: 9999px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: background-color 0.15s ease, transform 0.15s ease;
}

#theme-btn:hover {
  background: var(--chrome-bg-hover);
}

#theme-btn:active {
  transform: scale(0.92);
  background: var(--chrome-bg-active);
}

#home-btn:hover {
  background: var(--chrome-bg-hover);
}

#home-btn:active {
  transform: scale(0.96);
  background: var(--chrome-bg-active);
}

/* ---------- Hero (startup screen) ---------- */

#hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 15px 24px 10px;
  overflow: hidden;
  /* Must exceed the hero's max natural content height or content will clip. */
  max-height: 200px;
  opacity: 1;
  transform: translateY(0) scale(1);
  transition: max-height 0.5s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.35s ease, transform 0.4s cubic-bezier(0.22, 1, 0.36, 1),
    padding 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

#hero-title {
  margin: 0;
  font-size: clamp(30px, 7vw, 40px);
  font-weight: 800;
  letter-spacing: -0.035em;
  color: var(--text);
  background: linear-gradient(
    100deg,
    #0a84ff 0%,
    #3d7bff 30%,
    #8b6cff 60%,
    #21d4c2 100%
  );
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  animation: hero-title-shift 7s ease-in-out infinite alternate;
  filter: drop-shadow(0 2px 14px rgba(61, 123, 255, 0.28));
}

@supports not (background-clip: text) {
  #hero-title {
    color: var(--text);
    background: none;
    filter: none;
  }
}

@keyframes hero-title-shift {
  from {
    background-position: 0% 50%;
  }
  to {
    background-position: 100% 50%;
  }
}

@media (prefers-reduced-motion: reduce) {
  #hero-title {
    animation: none;
  }
}

/* 解説はニュースフィード風に1行で流す */
#hero-feed {
  width: 100%;
  overflow: hidden;
  margin-top: 8px;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}

.feed-track {
  display: inline-flex;
  gap: 56px;
  white-space: nowrap;
  animation: feed-scroll 24s linear infinite;
  will-change: transform;
}

.feed-item {
  font-size: 13px;
  letter-spacing: -0.005em;
  color: var(--muted);
}

@keyframes feed-scroll {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(calc(-50% - 28px));
  }
}

@media (prefers-reduced-motion: reduce) {
  .feed-track {
    animation: none;
  }
}

/* Conversation started (2+ bubbles) -> collapse hero. Progressive enhancement:
   browsers without :has() simply keep the hero visible. */
#chat-app:has(#chat-log > .bubble:nth-child(2)) #hero {
  max-height: 0;
  opacity: 0;
  transform: translateY(-8px) scale(0.98);
  padding-top: 0;
  padding-bottom: 0;
  pointer-events: none;
}

/* ---------- Governance Skill promo (startup only) ---------- */

#promo {
  display: flex;
  justify-content: center;
  padding: 4px 16px 14px;
  overflow: hidden;
  /* ヒーロー+ヘッド+チャート+アプリ縦リストの自然高より大きく保つこと(超えると下が切れる) */
  max-height: 900px;
  opacity: 1;
  transition: max-height 0.5s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.35s ease,
    padding 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

#promo {
  flex-direction: column;
  align-items: center;
  gap: 9px;
}

#promo-head {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(580px, 100%);
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow-pill);
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

#promo-head:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  box-shadow: var(--shadow-pill-hover);
}

#promo-head:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.promo-hub-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  flex: none;
}

.promo-head-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.promo-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text);
}

.promo-desc {
  font-size: 11px;
  line-height: 1.45;
  color: var(--muted);
}

.promo-open {
  margin-left: auto;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent);
  flex: none;
}

/* アプリ一覧(縦リスト・アイコン左+解説右のiOS設定画面風) */
#promo-apps {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

#promo-apps .app {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 10px;
  border-radius: 12px;
  text-decoration: none;
  transition: transform 0.15s ease, background-color 0.15s ease;
}

#promo-apps .app:hover {
  background: var(--chrome-bg);
  transform: translateX(2px);
}

#promo-apps .app:active {
  transform: scale(0.98);
}

#promo-apps .app:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.app-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  flex: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.app-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.app-name {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

.app-desc {
  font-size: 11px;
  line-height: 1.4;
  color: var(--muted);
}

#chat-app:has(#chat-log > .bubble:nth-child(2)) #promo {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  #promo {
    transition: none;
  }
}

/* ---------- In-bubble rich content ---------- */

.bubble .em {
  color: var(--accent);
  font-weight: 650;
}

.bubble.user .em {
  color: inherit;
  text-decoration: underline;
}

.bubble.has-block {
  max-width: 94%;
  width: fit-content;
}

.tbl-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tbl-wrap table {
  border-collapse: collapse;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tbl-wrap th {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-align: left;
  padding: 4px 12px 6px 0;
  border-bottom: 1px solid var(--hairline);
}

.tbl-wrap td {
  padding: 7px 12px 7px 0;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.tbl-wrap tbody tr:last-child td {
  border-bottom: none;
}

.grade {
  font-weight: 700;
}

.grade-s {
  color: #30a46c;
}

.grade-a {
  color: var(--accent);
}

.drep-name {
  font-weight: 600;
}

.drep-id {
  font-size: 9.5px;
  color: var(--muted);
  word-break: break-all;
  white-space: normal;
  max-width: 300px;
  margin-top: 2px;
}

/* fit-content のバブルの中で iframe が潰れないよう、embed入りバブルは幅を固定する */
.bubble.has-block:has(.embed-box) {
  width: 94%;
  max-width: 94%;
}

.embed-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.embed-viewport {
  width: 100%;
  height: 420px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #ffffff;
}

.embed-box iframe {
  width: 100%;
  height: 100%;
  border: none;
  transform-origin: 0 0;
  display: block;
}

.embed-open {
  align-self: flex-end;
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
}

.embed-open:hover {
  text-decoration: underline;
}

/* ---------- Chat log ---------- */

#chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
}

/* Messenger-style: hug the bottom so the latest message + options sit just
   above the input bar, like iMessage/LINE, while preserving scroll-back. */
#chat-log > .bubble:first-child {
  margin-top: auto;
}

#chat-log::-webkit-scrollbar {
  width: 6px;
}

#chat-log::-webkit-scrollbar-track {
  background: transparent;
}

#chat-log::-webkit-scrollbar-thumb {
  background-color: var(--scrollbar-thumb);
  border-radius: 9999px;
}

.bubble {
  max-width: 78%;
  padding: 10px 15px;
  border-radius: 18px;
  line-height: 1.45;
  font-size: 15px;
  letter-spacing: -0.01em;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: var(--shadow-bubble);
  animation: bubble-in 0.25s ease-out both;
}

@keyframes bubble-in {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.bubble.bot {
  align-self: flex-start;
  background: var(--bot-bubble);
  color: var(--bot-bubble-text);
  border-bottom-left-radius: 5px;
}

.bubble.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--user-bubble-a), var(--user-bubble-b));
  color: var(--user-text);
  border-bottom-right-radius: 5px;
}

.bubble.has-block:has(.gatekeeper) {
  width: min(560px, calc(100% - 32px));
  max-width: min(560px, calc(100% - 32px));
  box-sizing: border-box;
}

/* ---------- Option pills ---------- */

#chat-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 2px 16px 12px;
}

.option-btn {
  appearance: none;
  max-width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 15px;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.01em;
  box-shadow: var(--shadow-pill);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease,
    background-color 0.15s ease;
  animation: bubble-in 0.25s ease-out both;
}

.option-btn:hover {
  border-color: var(--muted);
  transform: translateY(-1px);
  box-shadow: var(--shadow-pill-hover);
}

.option-btn:active {
  transform: translateY(0) scale(0.97);
  box-shadow: var(--shadow-pill);
}

.nav-buttons {
  display: flex;
  gap: 8px;
  width: 100%;
  margin-top: 6px;
}

.nav-btn {
  appearance: none;
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--muted);
  padding: 7px 14px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.01em;
  transition: color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.nav-btn:hover {
  color: var(--text);
  border-color: var(--muted);
}

.nav-btn:active {
  transform: scale(0.96);
}

/* ---------- ADA price card (総合サイトカードと同格・その直下) ---------- */

#price-card,
#epoch-card {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(580px, 100%);
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow-pill);
}

#ada-price {
  font-variant-numeric: tabular-nums;
}

#chart-btn,
#epoch-btn {
  margin-left: auto;
  flex: none;
  appearance: none;
  background: var(--chrome-bg);
  border: none;
  color: var(--chrome-text);
  border-radius: 9999px;
  padding: 7px 13px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: background-color 0.15s ease;
}

#chart-btn:hover,
#epoch-btn:hover {
  background: var(--chrome-bg-hover);
}

#chart-btn:focus-visible,
#epoch-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ---------- 価格チャートパネル ---------- */

#chart-panel,
#epoch-panel {
  position: relative;
  width: min(580px, 100%);
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow-pill);
}

#chart-close,
#epoch-close {
  position: absolute;
  top: 8px;
  right: 10px;
  appearance: none;
  border: none;
  background: var(--chrome-bg);
  color: var(--chrome-text);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}

#chart-close:hover,
#epoch-close:hover {
  background: var(--chrome-bg-hover);
}

#chart-backdrop,
#epoch-backdrop {
  display: none;
}

/* スマホ: チャートはレイアウトを押し広げず、モーダルとして中央に表示
   (総合サイトカードなどが隠れないように) */
@media (max-width: 700px) {
  #chart-backdrop:not([hidden]),
  #epoch-backdrop:not([hidden]) {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 90;
    background: rgba(0, 0, 0, 0.45);
  }

  #chart-panel:not([hidden]),
  #epoch-panel:not([hidden]) {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(92vw, 430px);
    max-height: 82dvh;
    overflow-y: auto;
    z-index: 95;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  }
}

#chart-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.chart-tab {
  appearance: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 9999px;
  padding: 4px 12px;
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 600;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.chart-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.chart-tab:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

#chart-box {
  min-height: 150px;
  font-size: 12px;
  color: var(--muted);
}

#chart-box svg {
  display: block;
  width: 100%;
  height: 150px;
}

.chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart-area {
  fill: rgba(10, 132, 255, 0.1);
  stroke: none;
}

#chart-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.chg-up {
  color: #30a46c;
  font-weight: 700;
}

.chg-down {
  color: #e5484d;
  font-weight: 700;
}

/* ---------- 🎰 スロットマシン ---------- */

.slot-machine {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: min(360px, 100%);
  padding: 4px 0;
}

/* カジノ筐体 */
.slot-machine {
  position: relative;
  overflow: hidden;
}

.slot-cabinet {
  padding: 0 14px 14px;
  border-radius: 18px;
  background: linear-gradient(175deg, #33113f 0%, #1b0b2e 55%, #12071f 100%);
  border: 3px solid #d4a017;
  box-shadow:
    0 0 0 2px rgba(255, 215, 90, 0.25),
    0 10px 30px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.slot-marquee {
  margin: 0 -14px 10px;
  padding: 8px 10px 9px;
  border-radius: 14px 14px 0 0;
  background: linear-gradient(180deg, #7a1030, #4d081d);
  border-bottom: 2px solid #d4a017;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.slot-lights {
  display: flex;
  gap: 8px;
}

.bulb {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ffd75a;
  box-shadow: 0 0 6px #ffd75a;
  animation: bulb-blink 0.8s steps(1) infinite;
}

@keyframes bulb-blink {
  0%,
  49% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0.25;
  }
}

.slot-marquee-title {
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.22em;
  color: #ffd75a;
  text-shadow: 0 0 10px rgba(255, 215, 90, 0.7);
}

.slot-cabinet .slot-legend {
  color: #d9c9ef;
}

.slot-legend {
  font-size: 10.5px;
  color: var(--muted);
  text-align: center;
}

.slot-reels {
  display: flex;
  gap: 8px;
  justify-content: center;
  padding: 8px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 215, 90, 0.3);
}

.slot-reel {
  width: 84px;
  height: 84px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 2px solid #c9a35b;
  border-radius: 12px;
  background: linear-gradient(180deg, #fdfaf2 0%, #f3e9d2 45%, #e8d9b8 100%);
  overflow: hidden;
  box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.18), inset 0 -3px 8px rgba(0, 0, 0, 0.12);
}

.reel-icon {
  font-size: 30px;
  line-height: 1.1;
}

.reel-label {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #4d3a12;
  white-space: nowrap;
}

.slot-reel.spinning {
  filter: blur(0.6px);
  border-color: #ffd75a;
}

.slot-reel.stopped {
  animation: slot-stop-bounce 0.25s ease-out;
}

.slot-reel.aligned {
  border-color: #ffd75a;
  box-shadow:
    0 0 18px rgba(255, 215, 90, 0.75),
    inset 0 3px 8px rgba(0, 0, 0, 0.18);
  animation: slot-win-pulse 0.6s ease-out;
}

.slot-name {
  min-height: 18px;
  font-size: 13px;
  font-weight: 700;
  color: #f4ecff;
  text-align: center;
}

.slot-cabinet .slot-note {
  color: #b7a4d6;
}

.slot-joke {
  font-size: 12px;
  font-weight: 700;
  color: #ffd75a;
  margin-bottom: 6px;
}

.slot-desc {
  font-size: 11.5px;
  line-height: 1.55;
  color: #e6dcf5;
  margin-bottom: 8px;
}

.slot-cabinet .slot-result {
  color: #f4ecff;
}

.slot-cabinet .slot-stats {
  color: #f4ecff;
}

.slot-cabinet .slot-spin-btn {
  background: linear-gradient(180deg, #ff5a5a, #c81e3c);
  box-shadow: 0 4px 0 #7a0f24, 0 6px 14px rgba(0, 0, 0, 0.4);
}

.slot-cabinet .slot-spin-btn:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #7a0f24;
}

.slot-name-win {
  color: #d4a017;
}

.slot-name-bad {
  color: #e5484d;
}

.slot-coin {
  position: absolute;
  top: -20px;
  color: #f5b90a;
  font-weight: 900;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  animation: coin-fall 1.6s ease-in forwards;
  pointer-events: none;
  z-index: 5;
}

@keyframes coin-fall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  85% {
    opacity: 1;
  }
  100% {
    transform: translateY(240px) rotate(320deg);
    opacity: 0;
  }
}

@keyframes slot-stop-bounce {
  0% {
    transform: translateY(-8px);
  }
  60% {
    transform: translateY(2px);
  }
  100% {
    transform: translateY(0);
  }
}

@keyframes slot-win-pulse {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
  }
}

.slot-spin-btn {
  appearance: none;
  background: linear-gradient(135deg, var(--user-bubble-a), var(--user-bubble-b));
  border: none;
  color: #ffffff;
  border-radius: 9999px;
  padding: 10px 26px;
  cursor: pointer;
  font-size: 14.5px;
  font-weight: 700;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.slot-spin-btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.slot-spin-btn:active:not(:disabled) {
  transform: scale(0.96);
}

.slot-spin-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.slot-spin-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.slot-result {
  width: 100%;
  font-size: 12px;
}

.slot-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.slot-note {
  font-size: 10.5px;
  color: var(--muted);
}

@media (prefers-reduced-motion: reduce) {
  .slot-reel.aligned,
  .slot-reel.stopped,
  .slot-coin,
  .game-icon-gatekeeper {
    animation: none;
  }
}

/* ---------- 起動画面のゲームアイコン列 ---------- */

#game-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(18px, 4vw, 34px);
}

.game-row-standard {
  display: flex;
  justify-content: center;
  gap: clamp(10px, 2.6vw, 22px);
}

.game-row-featured {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 88px;
  padding: 14px clamp(18px, 4vw, 32px) 0;
  border-left: 1px solid rgba(55, 178, 255, 0.24);
  border-right: 1px solid rgba(55, 178, 255, 0.24);
}

.game-feature-label {
  position: absolute;
  z-index: 4;
  top: 0;
  left: 50%;
  translate: -50% 0;
  padding: 4px 8px;
  border: 1px solid rgba(53, 226, 180, 0.45);
  border-radius: 999px;
  color: #51e7bd;
  background: #092126;
  box-shadow: 0 0 12px rgba(53, 226, 180, 0.2);
  font: 850 7px/1 ui-monospace, monospace;
  letter-spacing: 0.13em;
  white-space: nowrap;
}

.game-app {
  appearance: none;
  background: transparent;
  border: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.game-app:hover {
  transform: translateY(-2px) scale(1.04);
}

.game-app:active {
  transform: scale(0.94);
}

.game-app:focus-visible {
  outline: none;
  border-radius: 14px;
  box-shadow: var(--focus-ring);
}

.game-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.game-icon-slot {
  background: linear-gradient(135deg, #0a84ff, #0060df);
}

.game-icon-drep {
  background: linear-gradient(135deg, #8b6cff, #5b3df0);
}

.game-icon-battle {
  background: linear-gradient(135deg, #ff6b4a, #d3323e);
}

.game-icon-runner {
  background: linear-gradient(135deg, #21d4c2, #0a9c76);
}

.game-icon-gatekeeper {
  position: relative;
  background: linear-gradient(135deg, #172445, #087cff 62%, #20d3b0);
  box-shadow: 0 0 0 1px rgba(126, 230, 255, 0.46), 0 0 18px rgba(8, 124, 255, 0.64), 0 0 32px rgba(32, 211, 176, 0.28);
  animation: risk-icon-glow 2.2s ease-in-out infinite;
}

.game-app-featured .app-name {
  color: var(--text);
  font-weight: 850;
}

.game-app-featured {
  margin-top: 7px;
}

.game-feature-note {
  margin-top: -3px;
  color: var(--muted);
  font-size: 8px;
}

@keyframes risk-icon-glow {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.06); filter: brightness(1.22); box-shadow: 0 0 0 3px rgba(80, 208, 255, 0.16), 0 0 25px rgba(8, 124, 255, 0.78), 0 0 42px rgba(32, 211, 176, 0.38); }
}

@media (max-width: 620px) {
  .game-row-featured { min-height: 80px; justify-content: center; padding: 14px clamp(8px, 2.4vw, 16px) 0; }
}

/* ---------- 🛡 Exchange Gatekeeper ---------- */

.gatekeeper {
  --gate-blue: #31a8ff;
  --gate-green: #35e2b4;
  --gate-red: #ff6376;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  overflow: hidden;
  border: 1px solid rgba(80, 185, 255, 0.28);
  border-radius: 18px;
  color: #edf8ff;
  background:
    linear-gradient(rgba(43, 153, 225, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(43, 153, 225, 0.05) 1px, transparent 1px),
    radial-gradient(circle at 82% 0, rgba(24, 131, 255, 0.2), transparent 38%),
    #071222;
  background-size: 22px 22px, 22px 22px, auto, auto;
  box-shadow: 0 22px 60px rgba(0, 18, 45, 0.28);
}

.gatekeeper-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 16px;
  border-bottom: 1px solid rgba(83, 190, 255, 0.18);
  background: rgba(3, 13, 28, 0.82);
}

.gatekeeper-brand { display: flex; align-items: center; gap: 9px; }
.gatekeeper-brand > span:last-child { display: flex; flex-direction: column; gap: 1px; }
.gatekeeper-brand strong { font-size: 11px; letter-spacing: 0.13em; }
.gatekeeper-brand small { color: rgba(182, 224, 255, 0.56); font-size: 8px; letter-spacing: 0.16em; }

.gatekeeper-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  clip-path: polygon(50% 0, 92% 16%, 86% 72%, 50% 100%, 14% 72%, 8% 16%);
  color: #04111f;
  background: linear-gradient(145deg, #71d2ff, #2be2ac);
  font-weight: 950;
}

.gatekeeper-score {
  color: #9edcff;
  font: 700 9px/1.2 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.gatekeeper-progress { height: 3px; background: rgba(101, 194, 255, 0.09); }
.gatekeeper-progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--gate-blue), var(--gate-green)); transition: width 0.3s ease; box-shadow: 0 0 14px var(--gate-blue); }

.gatekeeper-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 420px;
  padding: 20px;
}

.gatekeeper-case-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.gatekeeper-badge, .gatekeeper-risk {
  padding: 4px 8px;
  border: 1px solid rgba(69, 181, 255, 0.28);
  border-radius: 999px;
  color: #8ed5ff;
  background: rgba(20, 113, 181, 0.12);
  font: 800 8px/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0.12em;
}
.gatekeeper-risk { color: #ff91a0; border-color: rgba(255, 99, 118, 0.32); background: rgba(255, 99, 118, 0.09); }
.gatekeeper-body h3 { margin: 1px 0 0; color: #fff; font-size: clamp(18px, 4vw, 24px); letter-spacing: 0.02em; }
.gatekeeper-story { margin: -1px 0 1px; padding: 11px 12px; border-left: 3px solid var(--gate-blue); color: rgba(226, 243, 255, 0.88); background: rgba(39, 139, 211, 0.08); font-size: 11.5px; line-height: 1.65; }
.gatekeeper-story span { display: block; margin-bottom: 4px; color: #73caff; font: 850 8px/1 ui-monospace, monospace; letter-spacing: 0.16em; }

.gatekeeper-fields { display: grid; gap: 1px; overflow: hidden; border: 1px solid rgba(97, 193, 255, 0.16); border-radius: 11px; background: rgba(91, 183, 255, 0.12); }
.gatekeeper-fields > div { display: grid; grid-template-columns: minmax(92px, 0.32fr) 1fr; gap: 10px; align-items: start; padding: 10px 12px; background: rgba(3, 14, 30, 0.88); }
.gatekeeper-fields span { color: rgba(169, 217, 246, 0.66); font-size: 10px; }
.gatekeeper-fields code { color: #e9f7ff; font: 650 10px/1.45 ui-monospace, SFMono-Regular, Consolas, monospace; overflow-wrap: anywhere; }
.gatekeeper-prompt { margin: 2px 0 0; color: #fff; font-size: 14px; font-weight: 800; }

.gatekeeper-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.gatekeeper-action, .gatekeeper-next {
  appearance: none;
  border: 1px solid rgba(115, 205, 255, 0.26);
  border-radius: 10px;
  color: #eefaff;
  background: rgba(16, 55, 87, 0.72);
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
  transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease;
}
.gatekeeper-action { display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 48px; }
.gatekeeper-action span { font: 900 15px/1 ui-monospace, monospace; }
.gatekeeper-action.is-send { border-color: rgba(53, 226, 180, 0.3); }
.gatekeeper-action.is-stop { border-color: rgba(255, 99, 118, 0.36); }
.gatekeeper-action:hover:not(:disabled), .gatekeeper-next:hover { transform: translateY(-1px); border-color: #6bd1ff; }
.gatekeeper-action:disabled { cursor: default; opacity: 0.48; }
.gatekeeper-action.is-answer { opacity: 1; color: #031810; border-color: var(--gate-green); background: var(--gate-green); box-shadow: 0 0 20px rgba(53, 226, 180, 0.22); }
.gatekeeper-action.is-wrong { opacity: 1; border-color: var(--gate-red); background: rgba(255, 99, 118, 0.28); }

.gatekeeper-result { display: none; padding: 12px 14px; border-radius: 11px; font-size: 11px; line-height: 1.55; }
.gatekeeper-result.is-correct, .gatekeeper-result.is-wrong { display: flex; flex-direction: column; gap: 7px; }
.gatekeeper-result.is-correct { border: 1px solid rgba(53, 226, 180, 0.35); background: rgba(53, 226, 180, 0.09); }
.gatekeeper-result.is-wrong { border: 1px solid rgba(255, 99, 118, 0.38); background: rgba(255, 99, 118, 0.09); }
.gatekeeper-result strong { color: #fff; letter-spacing: 0.04em; }
.gatekeeper-result p { margin: 0; color: rgba(229, 246, 255, 0.86); }
.gatekeeper-result small { color: #8fd7ff; }
.gatekeeper-next { align-self: flex-end; min-width: 150px; margin-top: 2px; padding: 9px 13px; background: linear-gradient(135deg, #087cff, #0eaaa8); }
.gatekeeper-next.is-sent { color: #041710; background: var(--gate-green); }
.gatekeeper-seal { display: grid; place-items: center; align-self: center; width: 82px; height: 82px; margin-top: 22px; border: 2px solid var(--gate-green); border-radius: 50%; color: var(--gate-green); font: 950 26px/1 ui-monospace, monospace; box-shadow: 0 0 34px rgba(53, 226, 180, 0.2), inset 0 0 22px rgba(53, 226, 180, 0.08); }
.gatekeeper-rank-name { align-self: center; margin: -8px 0 0; color: var(--gate-green); font: 850 11px/1 ui-monospace, monospace; letter-spacing: 0.16em; }
.gatekeeper-rank-copy { align-self: center; max-width: 390px; margin: 0; color: rgba(220, 242, 255, 0.8); font-size: 11px; line-height: 1.55; text-align: center; }
.gatekeeper-body > .gatekeeper-finish-score { align-self: center; margin: -4px 0 0; color: #92dcff; font: 800 12px/1 ui-monospace, monospace; letter-spacing: 0.12em; }
.gatekeeper-finish-note { margin: 0; padding: 12px; border: 1px solid rgba(99, 192, 255, 0.16); border-radius: 10px; color: rgba(215, 239, 255, 0.76); background: rgba(2, 13, 28, 0.55); font-size: 11px; line-height: 1.55; }
.gatekeeper-cleared { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; }
.gatekeeper-cleared span { padding: 4px 7px; border-radius: 999px; color: var(--gate-green); background: rgba(53, 226, 180, 0.09); font: 750 8px/1 ui-monospace, monospace; }
.gatekeeper-cleared span.is-locked { color: var(--gate-red); background: rgba(255, 99, 118, 0.1); }
.gatekeeper-transfer-status { align-self: flex-start; padding: 5px 9px; border: 1px solid rgba(255, 190, 72, 0.4); border-radius: 999px; color: #ffd37b; background: rgba(255, 176, 38, 0.1); font: 800 9px/1 ui-monospace, monospace; letter-spacing: 0.12em; }
.gatekeeper-transfer-card { display: grid; gap: 1px; overflow: hidden; border: 1px solid rgba(91, 194, 255, 0.2); border-radius: 12px; background: rgba(91, 194, 255, 0.13); }
.gatekeeper-transfer-card > div { display: grid; grid-template-columns: 90px 1fr; gap: 12px; padding: 11px 12px; background: rgba(3, 14, 30, 0.9); }
.gatekeeper-transfer-card span { color: rgba(173, 220, 247, 0.65); font-size: 10px; }
.gatekeeper-transfer-card code { color: #fff; font: 700 10px/1.5 ui-monospace, monospace; overflow-wrap: anywhere; }
.gatekeeper-transfer-caution { margin: 0; padding: 10px 12px; border-left: 3px solid #ffc354; color: rgba(240, 247, 252, 0.85); background: rgba(255, 177, 50, 0.08); font-size: 11px; line-height: 1.5; }
.gatekeeper-transfer-actions { display: grid; grid-template-columns: 1fr 1.25fr; gap: 8px; margin-top: auto; }
.gatekeeper-transfer-actions .gatekeeper-next { width: 100%; min-width: 0; margin: 0; }
.gatekeeper-cancel { background: rgba(23, 59, 84, 0.75); }
.gatekeeper-final-no { border-color: rgba(53, 226, 180, 0.48); background: linear-gradient(135deg, #118b75, #20c99d); }
.gatekeeper-send-final { border-color: rgba(255, 99, 118, 0.5); background: linear-gradient(135deg, #d83c55, #ff6a65); box-shadow: 0 10px 28px rgba(255, 70, 90, 0.2); }
.gatekeeper-danger-mark { display: grid; place-items: center; align-self: center; width: 84px; height: 84px; margin-top: 20px; clip-path: polygon(50% 0, 100% 100%, 0 100%); color: #180307; background: var(--gate-red); font: 950 40px/1 ui-monospace, monospace; padding-top: 20px; filter: drop-shadow(0 0 20px rgba(255, 99, 118, 0.32)); }
.gatekeeper-safe-mark { display: grid; place-items: center; align-self: center; width: 84px; height: 84px; margin-top: 20px; border: 2px solid var(--gate-green); border-radius: 50%; color: var(--gate-green); font: 950 40px/1 ui-monospace, monospace; box-shadow: 0 0 28px rgba(53, 226, 180, 0.22); }
.gatekeeper-body .gatekeeper-danger-title { color: var(--gate-red); text-align: center; }
.gatekeeper-body .gatekeeper-safe-title { color: var(--gate-green); text-align: center; }
.gatekeeper-danger-copy { margin: 0; padding: 14px; border: 1px solid rgba(255, 99, 118, 0.35); border-radius: 11px; color: rgba(255, 235, 238, 0.9); background: rgba(255, 99, 118, 0.09); font-size: 11.5px; line-height: 1.65; }
.gatekeeper-safe-copy { margin: 0; padding: 14px; border: 1px solid rgba(53, 226, 180, 0.35); border-radius: 11px; color: rgba(230, 255, 247, 0.9); background: rgba(53, 226, 180, 0.09); font-size: 11.5px; line-height: 1.65; }
.gatekeeper-danger-facts { display: grid; gap: 5px; color: #ff9eaa; font-size: 10px; }
.gatekeeper-danger-facts span:not(.is-mismatch) { color: rgba(205, 237, 255, 0.78); }
.gatekeeper-danger-facts .is-mismatch { color: #ff8191; font-weight: 800; }

@media (max-width: 520px) {
  #game-row { gap: 10px 14px; }
  .game-icon { width: 44px; height: 44px; }
  .game-app .app-name { font-size: 9px; }
  .gatekeeper-top { align-items: flex-start; padding: 11px 12px; }
  .gatekeeper-score { white-space: normal; text-align: right; }
  .gatekeeper-body { min-height: 440px; padding: 15px 12px; }
  .gatekeeper-fields > div { grid-template-columns: 82px 1fr; padding: 8px 9px; }
  .gatekeeper-actions { grid-template-columns: 1fr; }
  .gatekeeper-action { min-height: 40px; }
  .gatekeeper-transfer-actions { grid-template-columns: 1fr; }
  .bubble.has-block:has(.gatekeeper) { width: calc(100% - 16px); max-width: calc(100% - 16px); padding-inline: 8px; }
}

/* ---------- 🏃 ADAランナー ---------- */

.runner-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  color: #eef8ff;
}

.runner-stage {
  position: relative;
  width: 100%;
  isolation: isolate;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 24px 70px rgba(0, 19, 48, 0.34), inset 0 0 0 1px rgba(122, 220, 255, 0.14);
}

.runner-canvas {
  width: 100%;
  height: auto;
  border: 1px solid rgba(100, 211, 255, 0.25);
  border-radius: 18px;
  cursor: pointer;
  touch-action: manipulation;
  display: block;
}

/* ゲーム画面内オーバーレイ(タイトル/章選択/説明/結果) */
.runner-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px;
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 10%, rgba(43, 176, 255, 0.22), transparent 42%),
    linear-gradient(180deg, rgba(3, 12, 29, 0.42), rgba(3, 8, 19, 0.82));
  backdrop-filter: blur(5px) saturate(125%);
  -webkit-backdrop-filter: blur(5px) saturate(125%);
  overflow-y: auto;
}

.runner-overlay::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(180deg, transparent 0 3px, rgba(255, 255, 255, 0.018) 4px);
  mix-blend-mode: screen;
}

.runner-overlay > * {
  position: relative;
  z-index: 1;
}

.runner-overlay[data-view="title"] {
  gap: 6px;
  padding-block: 10px;
}

.runner-overlay[data-view="title"] .runner-title {
  font-size: clamp(20px, 4vw, 25px);
  line-height: 1.05;
}

.runner-overlay[data-view="title"] .runner-btn-main {
  padding-block: 8px;
}

.runner-overlay[data-view="title"] .runner-stage-btn {
  padding-block: 5px;
}

.runner-overlay[data-view="title"] .runner-stage-number {
  width: 28px;
  height: 28px;
}

.runner-overlay.hidden {
  display: none;
}

.runner-title {
  font-size: clamp(20px, 4.5vw, 28px);
  font-weight: 900;
  letter-spacing: 0.08em;
  color: #ffffff;
  text-align: center;
  text-shadow: 0 0 22px rgba(86, 206, 255, 0.72);
}

.runner-title-good {
  color: #21d4c2;
}

.runner-title-bad {
  color: #ff7a7a;
}

.runner-sub {
  font-size: 10px;
  letter-spacing: 0.2em;
  color: rgba(178, 230, 255, 0.78);
  text-align: center;
  margin-top: -5px;
}

.runner-rules {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11.5px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.92);
  text-align: left;
  width: min(390px, 96%);
  padding: 10px 14px;
  border: 1px solid rgba(120, 215, 255, 0.17);
  border-radius: 12px;
  background: rgba(3, 13, 30, 0.42);
}

.runner-btn {
  appearance: none;
  border: 1px solid rgba(126, 217, 255, 0.28);
  background: rgba(12, 39, 67, 0.64);
  color: #ffffff;
  border-radius: 12px;
  padding: 10px 18px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  width: min(390px, 96%);
  transition: background-color 0.15s ease, transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.runner-btn:hover {
  background: rgba(20, 66, 103, 0.78);
  border-color: rgba(132, 226, 255, 0.62);
  box-shadow: 0 0 24px rgba(52, 184, 255, 0.16);
}

.runner-btn:active {
  transform: scale(0.97);
}

.runner-btn-main {
  background: linear-gradient(135deg, #087cff, #0ecbc4);
  border: 1px solid rgba(192, 247, 255, 0.55);
  box-shadow: 0 10px 30px rgba(0, 132, 255, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  letter-spacing: 0.04em;
}

.runner-btn-sub {
  background: rgba(0, 0, 0, 0.16);
  border-color: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.7);
  font-weight: 500;
}

.runner-stage-btn {
  display: grid;
  grid-template-columns: 34px 1fr 22px;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  text-align: left;
}

.runner-stage-btn-1 { --runner-card: #29c6ff; }
.runner-stage-btn-2 { --runner-card: #ff5d9b; }
.runner-stage-btn-3 { --runner-card: #24e0b0; }

.runner-stage-number {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  color: #071222;
  background: var(--runner-card);
  box-shadow: 0 0 18px color-mix(in srgb, var(--runner-card) 45%, transparent);
  font-size: 11px;
  font-weight: 900;
}

.runner-stage-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 1px;
}

.runner-stage-copy strong {
  color: #fff;
  font-size: 12.5px;
}

.runner-stage-copy small {
  color: rgba(209, 236, 255, 0.64);
  font-size: 9.5px;
  font-weight: 500;
}

.runner-stage-arrow {
  color: var(--runner-card);
  font-size: 17px;
}

.runner-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.runner-canvas:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.runner-hud {
  align-self: flex-end;
  margin-top: -1px;
  padding: 4px 9px;
  border: 1px solid rgba(54, 171, 219, 0.22);
  border-radius: 999px;
  background: rgba(10, 42, 62, 0.09);
  font-size: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  text-align: right;
}

@media (max-width: 520px) {
  .runner-overlay {
    justify-content: flex-start;
    padding: 14px 10px;
  }

  .runner-overlay[data-view="title"] {
    padding-top: 18px;
  }

  .runner-btn {
    padding-block: 8px;
  }

  .runner-stage-btn {
    padding-block: 7px;
  }

  .runner-rules {
    font-size: 10px;
    gap: 2px;
    padding-block: 7px;
  }
}

.runner-lessons {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.lesson {
  font-size: 11.5px;
  line-height: 1.5;
  padding: 7px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.lesson-worst {
  color: var(--text);
  background: rgba(229, 72, 77, 0.1);
  border-color: rgba(229, 72, 77, 0.35);
}

.lesson-best {
  color: var(--text);
  background: rgba(48, 164, 108, 0.1);
  border-color: rgba(48, 164, 108, 0.35);
}

.lesson-moral {
  color: var(--muted);
  font-size: 10.5px;
  border: none;
  padding: 0 2px;
}

/* ---------- ⚔️ SPOカードバトル ---------- */

.battle-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.battle-header {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.battle-arena {
  display: flex;
  gap: 10px;
  width: 100%;
  justify-content: center;
}

/* トレーディングカード風 */
.battle-card {
  position: relative;
  flex: 1;
  max-width: 224px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border-radius: 16px;
  background: var(--bg);
  border: 3px solid transparent;
  background-clip: padding-box;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

/* レアリティ枠(グラデーションボーダー) */
.battle-card::before {
  content: "";
  position: absolute;
  inset: -3px;
  z-index: -1;
  border-radius: 16px;
}

.rarity-s {
  border-color: #d4a017;
  box-shadow: 0 6px 20px rgba(212, 160, 23, 0.35);
}

.rarity-a {
  border-color: #8b6cff;
  box-shadow: 0 6px 20px rgba(139, 108, 255, 0.3);
}

.rarity-b {
  border-color: #3d7bff;
  box-shadow: 0 6px 18px rgba(61, 123, 255, 0.25);
}

/* ホロ光沢: 登場時に一度走る */
.card-reveal::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    115deg,
    transparent 30%,
    rgba(255, 255, 255, 0.35) 48%,
    rgba(255, 255, 255, 0.08) 52%,
    transparent 70%
  );
  transform: translateX(-120%);
  animation: card-shine 0.9s ease-out 0.15s forwards;
  pointer-events: none;
}

@keyframes card-shine {
  to {
    transform: translateX(120%);
  }
}

.card-head {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 2px 4px 0;
}

.card-rarity {
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.rarity-s .card-rarity {
  color: #d4a017;
}

.rarity-a .card-rarity {
  color: #8b6cff;
}

.rarity-b .card-rarity {
  color: #3d7bff;
}

.card-name {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text);
}

/* アート面(Tickerから生成される固有の紋章) */
.card-art {
  position: relative;
  height: 74px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.card-emblem {
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
}

/* カード裏面 */
.battle-card.face-down {
  border-color: var(--border);
  padding: 0;
}

.card-back {
  flex: 1;
  min-height: 228px;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.05) 0 8px, transparent 8px 16px),
    linear-gradient(160deg, #1b2340, #0d1020);
  border-radius: 12px;
}

.card-back span {
  font-size: 44px;
  font-weight: 900;
  color: rgba(120, 150, 255, 0.5);
  text-shadow: 0 0 24px rgba(80, 120, 255, 0.5);
}

/* 能力メーター */
.card-stats {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.battle-stat {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 8px;
  padding: 4px 8px 5px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 10.5px;
  color: var(--text);
  text-align: left;
  width: 100%;
}

.battle-stat-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

button.battle-stat {
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.12s ease;
}

button.battle-stat:hover {
  border-color: var(--accent);
  background: var(--chrome-bg);
  transform: translateX(2px);
}

.battle-stat-label {
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 600;
  white-space: nowrap;
}

.battle-stat-value {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.battle-meter {
  display: block;
  height: 4px;
  border-radius: 2px;
  background: var(--chrome-bg);
  overflow: hidden;
}

.battle-meter-fill {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--user-bubble-a), #21d4c2);
}

.battle-stat-active {
  border-color: var(--accent);
  background: rgba(10, 132, 255, 0.12);
}

@media (prefers-reduced-motion: reduce) {
  .card-reveal::after {
    animation: none;
    opacity: 0;
  }
}

.battle-verdict {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  min-height: 18px;
}

.battle-controls {
  display: flex;
  justify-content: center;
}

/* ---------- おすすめツールの折りたたみ ---------- */

#promo-more {
  width: min(580px, 100%);
}

#promo-more summary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  list-style: none;
  cursor: pointer;
  padding: 8px 14px;
  border-radius: 9999px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--chrome-text);
  background: var(--chrome-bg);
  transition: background-color 0.15s ease;
  user-select: none;
}

#promo-more summary::-webkit-details-marker {
  display: none;
}

#promo-more summary:hover {
  background: var(--chrome-bg-hover);
}

#promo-more summary:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

#promo-more .chev {
  transition: transform 0.2s ease;
}

#promo-more[open] .chev {
  transform: rotate(180deg);
}

#promo-more[open] summary {
  margin-bottom: 8px;
}

.calc-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
}

#ada-amount {
  width: 110px;
  padding: 4px 10px;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
  appearance: textfield;
}

#ada-amount::-webkit-outer-spin-button,
#ada-amount::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

#ada-amount:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

#ada-total {
  color: var(--muted);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.epoch-lbl {
  font-size: 11.5px;
  color: var(--muted);
  flex: none;
}

#epoch-date {
  padding: 3px 8px;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 11.5px;
  font-family: inherit;
}

#epoch-date:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

#epoch-result {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text);
}

#epoch-body {
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--text);
}

#epoch-body b { color: var(--accent); }

#epoch-body ol {
  margin: 8px 0 0;
  padding-left: 1.2em;
}

/* ---------- Input bar ---------- */

#free-text-form {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--hairline);
  background: var(--header-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}

#free-text-input {
  flex: 1;
  padding: 11px 16px;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  letter-spacing: -0.01em;
  outline: none;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

#free-text-input::placeholder {
  color: var(--muted);
}

#free-text-input:focus {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

#free-text-form button[type="submit"] {
  appearance: none;
  background: linear-gradient(135deg, var(--user-bubble-a), var(--user-bubble-b));
  border: none;
  color: #fff;
  padding: 11px 20px;
  border-radius: 9999px;
  cursor: pointer;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  box-shadow: var(--shadow-pill);
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  flex-shrink: 0;
}

#free-text-form button[type="submit"]:hover {
  box-shadow: var(--shadow-pill-hover);
}

#free-text-form button[type="submit"]:active {
  transform: scale(0.96);
  box-shadow: var(--shadow-pill);
}

/* ---------- Focus states (unified) ---------- */

#home-btn:focus-visible,
.option-btn:focus-visible,
.nav-btn:focus-visible,
#free-text-form button[type="submit"]:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .bubble,
  .option-btn {
    animation: none;
  }

  #home-btn,
  .option-btn,
  .nav-btn,
  #free-text-input,
  #free-text-form button[type="submit"],
  #hero {
    transition: none;
  }
}

/* ---------- Small screens ---------- */

/* スマホ: ヒーロー+プロモが縦に収まらないため、
   ヒーローを詰め、プロモはこの領域内でスクロールさせて
   挨拶バブルと選択肢の表示域を必ず確保する */
@media (max-width: 700px) {
  /* 縦が足りないときフレックスがここも圧縮し、overflow:hidden のせいで
     ティッカーの行が途中で切れる。ヒーローは縮ませず、圧縮は
     スクロールできる #promo に寄せる */
  #hero {
    flex: none;
    padding: 10px 16px 6px;
  }

  /* タイトル行を詰めてフィード1行分の高さを空ける */
  #hero-title {
    font-size: 23px;
    line-height: 1.15;
  }

  /* ヒーローは外側のフレックスで圧縮され、縮み分がすべてこの行に乗って
     文字が上下とも切れていた。縮ませずに1行分を必ず確保する */
  #hero-feed {
    flex: none;
    margin-top: 6px;
  }

  .feed-item {
    font-size: 11.5px;
    line-height: 1.5;
  }

  #promo {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    max-height: 54dvh;
    /* 中央寄せのままだと、あふれた分が上にはみ出してスクロールで戻れず、
       先頭のガバナンスSkillカードが上端で切れる。上寄せにして必ず届くようにする */
    justify-content: flex-start;
    gap: 8px;
    padding: 2px 14px 6px;
    /* 画面が短い端末では入りきらずスクロールになるので、下端に影を敷いて
       「続きがある」ことを示す。
       mask は使わないこと: 子孫を丸ごと切り抜くため、この中にある
       チャートのモーダル(position:fixed)まで promo の枠で切られる */
    box-shadow: inset 0 -16px 14px -14px rgba(0, 0, 0, 0.22);
  }

  #promo-head {
    padding: 8px 12px;
  }

  /* ゲーム列(2段)はプロモの自然高の大半を占め、max-height を超えて
     下端のラベルが切れる。段の形は保ったまま一回り小さくする */
  #game-row {
    gap: clamp(8px, 2.6vw, 16px);
  }

  .game-row-standard {
    gap: clamp(6px, 1.8vw, 14px);
  }

  .game-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    font-size: 17px;
  }

  .game-app {
    gap: 4px;
  }

  .game-app .app-name {
    font-size: 10px;
  }

  /* 620px 以下は上罫線+バッジの縦積みレイアウト(1319行)なので、
     そちらの形は保ったまま高さだけ詰める */
  .game-row-featured {
    min-height: 0;
    padding-top: 13px;
  }

  #price-card,
  #epoch-card {
    padding: 8px 12px;
  }

  /* 選択肢は数が多いので一回り小さく(横幅は文字量ぶんあるので押しやすさは保てる) */
  .option-btn {
    padding: 7px 14px;
    min-height: 40px;
    font-size: 13px;
  }

  /* エポック帯は「委任日 + 入力欄 + 結果」で、そのままだと横が1pxほど足りずに
     折り返し、さらに type=date が普通の入力欄より背が高いぶん、価格カードより
     縦を食う。文字と入力欄を詰めて1行に収める */
  .epoch-lbl,
  #epoch-result {
    font-size: 10.5px;
  }

  #epoch-date {
    padding: 0 5px;
    height: 21px;
    font-size: 10.5px;
  }

  .calc-row {
    gap: 5px;
  }

  /* 選択肢は5段に折り返すので、1段あたりの高さが全体に効く */
  .option-btn {
    min-height: 34px;
    padding: 5px 13px;
    font-size: 12.5px;
  }

  #chat-options {
    gap: 5px;
    padding: 2px 14px 10px;
  }

  #chat-log {
    min-height: 60px;
  }

  .app-desc {
    font-size: 10.5px;
  }
}

@media (max-width: 400px) {
  .bubble {
    max-width: 85%;
  }

  #free-text-form {
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  }

  #hero-title {
    font-size: 22px;
  }

  /* 5つ横並びのまま収めるため、幅の狭い端末ではもう一段小さくする。
     入りきらないとボタンが縮んでラベルだけ枠外にはみ出し、
     promo の overflow で左右の端が切れる */
  #game-row {
    gap: 8px;
  }

  .game-row-standard {
    gap: 5px;
  }

  .game-icon {
    width: 34px;
    height: 34px;
    font-size: 17px;
  }

  /* 360px 級では長いラベルが2行になる。切るよりは折り返す */
  .game-app .app-name {
    font-size: 9px;
    line-height: 1.25;
    text-align: center;
  }

  .game-row-featured {
    padding-left: 7px;
    padding-right: 7px;
  }
}

#tools-popup {
  width: min(480px, calc(100vw - 24px));
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 20px 70px rgba(0, 0, 0, .3);
  overflow-y: auto;
  overscroll-behavior: contain;
}
#tools-popup::backdrop { background: rgba(0, 0, 0, .4); }
.tools-popup-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; font-size: 13px; }
.tools-popup-head button { flex: none; width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--chrome-bg); color: var(--text); font-size: 25px; cursor: pointer; }
#tools-popup #promo-apps { gap: 4px; }
#tools-popup .app-icon { width: 36px; height: 36px; border-radius: 9px; }
#tools-popup #promo-apps .app { gap: 10px; padding: 7px 4px; }
#tools-popup .app-desc { font-size: 11px; line-height: 1.4; }
body:has(#tools-popup[open]) { overflow: hidden; }