/* 二択当て（claude_direct_haiku-5.5）。この版のページでだけ読み込まれる。クラスは rb- で統一 */

body:has(.rb) {
  background: radial-gradient(120% 90% at 50% 0%, #2c2356 0%, #161230 55%, #0c0a1a 100%) fixed;
  color: #f3f0ff;
}
/* main の余白は外して、.rb が「ヘッダーとフッターの間」（--yz-stage-h）にちょうど収まるようにする */
body:has(.rb) > main {
  box-sizing: border-box;
  min-height: 0;
  margin: 0 auto;   /* 共通テーマの main（最大幅960px・中央寄せ）の自動余白を残す */
  padding: 0;
  background: transparent;
}

[hidden] { display: none !important; }

/* ---- 画面全体: ヘッダーとフッターの間に、1画面で収める ---- */
.rb {
  position: relative;
  box-sizing: border-box;
  width: 100%;
  max-width: 560px;
  height: var(--yz-stage-h);
  margin-block: 0;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 6px 16px 10px;
  overflow: hidden;
}

/* ---- 上: 見出し・連勝・ベスト・強さ ---- */
.rb-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.rb-title {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: 0.04em;
}
.rb-sub {
  margin: 2px 0 0;
  font-size: 12px;
  opacity: 0.7;
}
.rb-iconbtn {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
}

.rb-meters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.rb-meter {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.07);
}
.rb-label {
  font-size: 12px;
  opacity: 0.75;
}
.rb-num {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.rb-meter-streak .rb-num {
  color: #ffd166;
}

.rb-levels {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.rb-level {
  padding: 7px 4px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.rb-level.is-on {
  background: #f3f0ff;
  border-color: transparent;
  color: #1c1733;
  font-weight: 700;
}
.rb-levelnote {
  margin: 0;
  min-height: 1.4em;
  font-size: 12px;
  opacity: 0.75;
  text-align: center;
}

/* ---- 中: CPU の予想（選ぶまで伏せる）と、結果の一言 ---- */
.rb-cpu {
  text-align: center;
}
.rb-cpu-label {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.12em;
  opacity: 0.75;
}
.rb-cpu-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-width: 128px;
  height: 46px;
  margin: 6px auto 4px;
  padding: 0 18px;
  border-radius: 999px;
  font-size: 22px;
  font-weight: 800;
  box-sizing: border-box;
}
.rb-cpu-chip.rb-pending {
  background: rgba(255, 255, 255, 0.06);
  border: 2px dashed rgba(255, 255, 255, 0.35);
  color: rgba(255, 255, 255, 0.7);
}
.rb-cpu-chip.is-red {
  background: #ff5a5f;
  color: #fff;
}
.rb-cpu-chip.is-blue {
  background: #3f7cf0;
  color: #fff;
}
.rb-result {
  margin: 0;
  min-height: 2.6em;
  font-size: 15px;
  line-height: 1.3;
}

/* ---- 直近の履歴 ---- */
.rb-history {
  margin: 0;
}
.rb-history-label {
  margin: 0 0 4px;
  font-size: 11px;
  opacity: 0.65;
}
.rb-history-list {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.rb-h {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 0 3px;
  border-radius: 8px;
  font-size: 10px;
  line-height: 1.2;
}
.rb-h.is-red { background: rgba(255, 90, 95, 0.25); }
.rb-h.is-blue { background: rgba(63, 124, 240, 0.28); }
.rb-h.is-read { outline: 1px solid rgba(255, 255, 255, 0.35); }
.rb-h-me {
  font-weight: 700;
}
.rb-h-cpu {
  display: block;
  width: 70%;
  height: 4px;
  margin-top: 3px;
  border-radius: 2px;
}
.rb-h-cpu.is-red { background: #ff5a5f; }
.rb-h-cpu.is-blue { background: #3f7cf0; }
.rb-h-mark {
  font-size: 10px;
  opacity: 0.8;
}
.rb-h-empty {
  grid-column: 1 / -1;
  padding: 6px 0;
  font-size: 12px;
  opacity: 0.6;
  text-align: center;
}

/* ---- 下: 赤・青の大きなボタン ---- */
.rb-choices {
  flex: 1 1 auto;
  min-height: 118px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.rb-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0;
  border: 0;
  border-radius: 22px;
  color: #fff;
  font: inherit;
  font-size: clamp(28px, 7.5vw, 40px);
  font-weight: 900;
  letter-spacing: 0.08em;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.08s ease, box-shadow 0.08s ease, opacity 0.2s ease;
}
.rb-btn-red {
  background: linear-gradient(180deg, #ff7a7a 0%, #e0303a 100%);
  box-shadow: 0 9px 0 #8f1620, 0 0 28px rgba(255, 90, 95, 0.35);
}
.rb-btn-blue {
  background: linear-gradient(180deg, #6aa7ff 0%, #2459d6 100%);
  box-shadow: 0 9px 0 #14357f, 0 0 28px rgba(63, 124, 240, 0.35);
}
.rb-btn:not(:disabled):active {
  transform: translateY(5px);
}
.rb-btn-red:not(:disabled):active { box-shadow: 0 4px 0 #8f1620; }
.rb-btn-blue:not(:disabled):active { box-shadow: 0 4px 0 #14357f; }
.rb-btn:disabled {
  opacity: 0.4;
  cursor: default;
  filter: saturate(0.6);
}
.rb-btn-key {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  opacity: 0.85;
}
.rb-btn:focus-visible,
.rb-next:focus-visible,
.rb-level:focus-visible,
.rb-iconbtn:focus-visible,
.rb-primary:focus-visible,
.rb-secondary:focus-visible {
  outline: 3px solid #ffd166;
  outline-offset: 3px;
}

.rb-actions {
  min-height: 44px;
}
.rb-next {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  background: #ffd166;
  color: #1c1733;
  font: inherit;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
}

/* ---- 重ねる画面（続き・ゲームオーバー） ---- */
.rb-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(8, 6, 18, 0.72);
}
.rb-card {
  width: 100%;
  max-width: 320px;
  padding: 22px 20px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 20px;
  background: #221b40;
  text-align: center;
  box-sizing: border-box;
}
.rb-card-title {
  margin: 0 0 8px;
  font-size: 22px;
}
.rb-card-text {
  margin: 0 0 16px;
  font-size: 15px;
  line-height: 1.5;
}
.rb-card-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.rb-primary,
.rb-secondary {
  padding: 11px 16px;
  border-radius: 999px;
  font: inherit;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
}
.rb-primary {
  border: 0;
  background: #ffd166;
  color: #1c1733;
}
.rb-secondary {
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: transparent;
  color: inherit;
}

/* ---- 遊び方・統計（ダイアログ） ---- */
.rb-dialog {
  width: min(92vw, 480px);
  max-height: 86vh;
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: 20px;
  background: #1d1736;
  color: #f3f0ff;
  overflow: auto;
}
.rb-dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
}
.rb-dialog-body {
  padding: 18px 18px 16px;
}
.rb-dialog-title {
  margin: 0 0 6px;
  font-size: 20px;
}
.rb-dialog-h {
  margin: 14px 0 6px;
  font-size: 14px;
  color: #ffd166;
}
.rb-list {
  margin: 0;
  padding-left: 1.2em;
  font-size: 14px;
  line-height: 1.6;
}
.rb-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0;
}
.rb-stat {
  margin: 0;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
}
.rb-stat dt {
  font-size: 12px;
  opacity: 0.75;
}
.rb-stat dd {
  margin: 2px 0 0;
  font-size: 20px;
  font-weight: 800;
}
.rb-dialog-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 18px;
}

/* ---- 低い画面（横持ちのスマホなど）: 余白を詰める ---- */
@media (max-height: 640px) {
  .rb {
    gap: 6px;
    padding-top: 4px;
  }
  .rb-sub,
  .rb-levelnote {
    display: none;
  }
  .rb-num {
    font-size: 22px;
  }
  .rb-cpu-chip {
    height: 36px;
    font-size: 18px;
  }
  .rb-history-label {
    display: none;
  }
}

/* ---- 広い画面（PC） ---- */
@media (min-width: 768px) {
  .rb {
    max-width: 720px;
    padding: 12px 24px 18px;
    gap: 14px;
  }
  .rb-title {
    font-size: 28px;
  }
  .rb-btn {
    border-radius: 28px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rb-btn {
    transition: none;
  }
}
