/* モンティ・ホール実験場 — 固定ダークテーマ（ゲームショーの舞台照明風） */

:root {
  --bg: #14121c;
  --bg-spot: #241f33;
  --panel: #1e1a2b;
  --panel-edge: #2e2842;
  --fg: #ece7dd;
  --muted: #9a93a8;
  --gold: #e5b455;
  --gold-dim: #a8843e;
  --red: #b5443f;
  --red-deep: #8c332f;
  --switch: #e5b455;   /* 変えた人（グラフ） */
  --stay: #7a8fd4;     /* 変えなかった人（グラフ） */
  --win: #6fce9a;
  --radius: 12px;
}

* { box-sizing: border-box; }

/* display 指定を持つ要素でも hidden 属性を必ず勝たせる */
[hidden] { display: none !important; }

html { color-scheme: dark; }

body {
  margin: 0;
  background:
    radial-gradient(90rem 40rem at 50% -12rem, var(--bg-spot), transparent 65%),
    var(--bg);
  color: var(--fg);
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", sans-serif;
  line-height: 1.75;
  font-feature-settings: "palt";
}

main, .site-header { max-width: 720px; margin: 0 auto; padding: 0 20px; }

a { color: var(--gold); }

/* ---------- ヘッダー ---------- */

.site-header { padding-top: 40px; text-align: center; }

.marquee {
  margin: 0;
  color: var(--gold-dim);
  font-size: 11px;
  letter-spacing: .35em;
  text-indent: .35em; /* 中央揃えのための letter-spacing 補正 */
}

/* 電飾看板 */
.sign {
  display: inline-block;
  position: relative;
  margin: 10px auto 4px;
  padding: 15px 32px;
  background: linear-gradient(180deg, #221c33, #181427);
  border: 2px solid var(--gold-dim);
  border-radius: 16px;
  box-shadow: 0 0 46px rgba(229, 180, 85, .14), inset 0 0 26px rgba(0, 0, 0, .45);
}

.sign h1 {
  margin: 0;
  font-size: clamp(23px, 5.4vw, 36px);
  letter-spacing: .06em;
  text-shadow: 0 0 30px rgba(229, 180, 85, .35);
  white-space: nowrap;
}

/* 電球列（上下）。チカチカは background-position をコマ送り */
.sign::before,
.sign::after {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  height: 5px;
  background-image: radial-gradient(circle 2px at 8px 50%, var(--gold) 0 1.8px, transparent 2.4px);
  background-size: 16px 5px;
  background-repeat: repeat-x;
  animation: marquee-chase 1.2s steps(2) infinite;
}

.sign::before { top: 6px; }
.sign::after { bottom: 6px; animation-direction: reverse; }

@keyframes marquee-chase {
  to { background-position-x: 16px; }
}

.tagline { margin: 0 0 8px; color: var(--muted); font-size: 14px; }

/* 賑わい表示（今日のプレイ数・直近のプレイ） */
.live {
  display: flex;
  gap: 7px;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 13px;
  margin: 10px 0 0;
  font-variant-numeric: tabular-nums;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--win);
  box-shadow: 0 0 6px rgba(111, 206, 154, .8);
  animation: live-pulse 2s ease-in-out infinite;
}

@keyframes live-pulse {
  50% { opacity: .3; }
}

@media (prefers-reduced-motion: reduce) {
  .live-dot { animation: none; }
  .door-leaf, .door-back { transition-duration: .01s; }
  .sign::before, .sign::after { animation: none; }
  .door.burst::before { animation: none; }
  #chart circle.pulse { animation: none; opacity: 0; }
}

/* ---------- 亜種タブ ---------- */

.variant-tabs {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 28px;
}

.tab {
  appearance: none;
  border: 1px solid var(--panel-edge);
  background: var(--panel);
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  padding: 8px 18px;
  border-radius: 999px;
  cursor: pointer;
}

.tab.active {
  color: #1a1408;
  background: var(--gold);
  border-color: var(--gold);
  font-weight: 700;
}

.variant-desc {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin: 10px 0 0;
  min-height: 1.75em;
}

/* ---------- ステージ ---------- */

.stage {
  margin-top: 18px;
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, var(--panel), #191527);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  padding: 44px 20px 20px;
}

/* 緞帳: 上端の帯 + 垂れるスカラップ */
.stage::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 30px;
  background-image:
    radial-gradient(circle at 50% 0, var(--red) 0 14px, transparent 15px),
    linear-gradient(180deg, var(--red-deep), var(--red-deep));
  background-size: 34px 26px, 100% 11px;
  background-repeat: repeat-x, no-repeat;
  background-position: 0 9px, 0 0;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .35));
  pointer-events: none;
}

.host { display: flex; gap: 10px; align-items: flex-start; min-height: 3.2em; }
.host-icon { flex: none; }
.host-icon svg { width: 28px; height: auto; display: block; }
.host p { margin: 0; font-size: 15px; }

/* 3 ステップの現在位置（選ぶ → 司会者が開ける → 決める）。終わった段は薄く、今の段は金 */
.steps {
  display: flex;
  gap: 6px 14px;
  flex-wrap: wrap;
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  font-size: 12px;
  color: var(--muted);
}
.steps li { display: inline-flex; align-items: center; gap: 6px; opacity: .55; }
.steps li[aria-current="step"] { opacity: 1; color: var(--fg); }
.steps li.done { opacity: .8; }
.step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  border: 1px solid var(--muted); font-size: 11px; font-variant-numeric: tabular-nums;
}
.steps li[aria-current="step"] .step-num { border-color: var(--gold); color: var(--gold); }
.steps li.done .step-num { border-color: var(--gold-dim); color: var(--gold-dim); }

.doors {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 18px 0 14px;
  position: relative;
}

/* 床: 各扉の下に落ちるスポットライトの光だまり */
.doors::after {
  content: "";
  position: absolute;
  left: -8px;
  right: -8px;
  bottom: -16px;
  height: 28px;
  background:
    radial-gradient(42% 90% at 16.7% 0, rgba(229, 180, 85, .13), transparent 70%),
    radial-gradient(42% 90% at 50% 0, rgba(229, 180, 85, .13), transparent 70%),
    radial-gradient(42% 90% at 83.3% 0, rgba(229, 180, 85, .13), transparent 70%);
  pointer-events: none;
}

.door {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  position: relative;
  aspect-ratio: 5 / 7;
  perspective: 700px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.door-back { transition: opacity .5s; }

/* 結果表示時、車のない扉を落として「車はここ」を一目にする（ラベルチップは落とさない） */
.door.dim .door-back,
.door.dim .door-leaf { opacity: .4; }

/* 扉の上のラベルチップ（あなた / 最初） */
.door-tag {
  position: absolute;
  top: -9px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.5;
  padding: 1px 10px;
  border-radius: 999px;
  background: var(--gold);
  color: #1a1408;
  white-space: nowrap;
  opacity: 0;
  transition: opacity .3s;
  pointer-events: none;
}

.door-tag.on { opacity: 1; }

.door-tag.was {
  background: var(--panel);
  color: var(--muted);
  border: 1px solid var(--panel-edge);
}

.door:disabled { cursor: default; }

.door-back {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(60% 60% at 50% 42%, #35304a, #201c30);
  border: 1px solid var(--panel-edge);
  border-radius: 10px;
}

.prize { display: grid; place-items: center; }
.prize svg { width: clamp(46px, 13vw, 74px); height: auto; }
.prize .i-car { filter: drop-shadow(0 0 12px rgba(229, 180, 85, .45)); }

.door-leaf {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, var(--red) 0%, var(--red-deep) 70%);
  border: 2px solid var(--gold-dim);
  border-radius: 10px;
  transform-origin: left center;
  transition: transform .65s cubic-bezier(.6, 0, .3, 1), opacity .5s;
  backface-visibility: hidden;
  box-shadow: inset 0 0 0 6px rgba(0,0,0,.14), 0 6px 18px rgba(0,0,0,.35);
}

/* ノブ */
.door-leaf::after {
  content: "";
  position: absolute;
  right: 10%;
  top: 50%;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 8px rgba(229, 180, 85, .8);
}

.door-num {
  color: var(--gold);
  font-size: clamp(22px, 6vw, 34px);
  font-weight: 700;
  border: 2px solid var(--gold-dim);
  border-radius: 50%;
  width: 2em;
  height: 2em;
  display: grid;
  place-items: center;
}

.door.open .door-leaf { transform: rotateY(-108deg); }

/* 勝利時だけ、車の扉の背後から放射光 */
.door.burst::before {
  content: "";
  position: absolute;
  inset: -42%;
  background: repeating-conic-gradient(from 8deg, rgba(229, 180, 85, .26) 0deg 7deg, transparent 7deg 26deg);
  -webkit-mask-image: radial-gradient(closest-side, #000 30%, transparent 78%);
  mask-image: radial-gradient(closest-side, #000 30%, transparent 78%);
  animation: burst-in 1s ease-out both;
  pointer-events: none;
}

@keyframes burst-in {
  from { opacity: 0; transform: scale(.55) rotate(-14deg); }
  to { opacity: 1; transform: none; }
}

.door.picked .door-leaf { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(229,180,85,.45), 0 6px 18px rgba(0,0,0,.35); }

.door.won .door-back { box-shadow: inset 0 0 30px rgba(229, 180, 85, .5); border-color: var(--gold); }

@media (hover: hover) {
  .door:not(:disabled):hover .door-leaf { transform: rotateY(-10deg); }
  .door.picked:not(:disabled):hover .door-leaf { transform: none; }
}

/* ---------- アクション・結果 ---------- */

.actions, .result { display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap; margin-top: 16px; }

.result { flex-direction: column; gap: 6px; }

.result .verdict {
  margin: 4px 0 0;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: .12em;
  text-align: center;
}

.verdict.win { color: var(--gold); text-shadow: 0 0 26px rgba(229, 180, 85, .55); }
.verdict.lose { color: #8f88a0; }
.verdict.accident { color: var(--red); }

.result .verdict-sub {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

.btn {
  appearance: none;
  font: inherit;
  font-size: 15px;
  padding: 10px 22px;
  border-radius: 999px;
  border: 1px solid var(--panel-edge);
  background: var(--panel);
  color: var(--fg);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

.btn.primary {
  background: var(--gold);
  border-color: var(--gold);
  color: #1a1408;
  font-weight: 700;
}

.btn:not(:disabled):active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; }

.result .verdict-tally { margin: 2px 0 6px; color: var(--muted); font-size: 13px; text-align: center; line-height: 1.7; }
.result .verdict-tally a { color: var(--gold); text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; }

.me { text-align: center; color: var(--muted); font-size: 13px; margin: 14px 0 0; min-height: 1.2em; }

/* ---------- 統計 ---------- */

section { margin-top: 44px; }

h2 { font-size: 20px; margin: 0 0 14px; letter-spacing: .04em; }
.h2-sub { font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 6px; }

.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.card {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.card h3 { margin: 0; font-size: 13px; color: var(--muted); font-weight: 600; }

/* 実測値は得点板風（inset パネル + 発光数字） */
.card .big {
  margin: 7px 0 0;
  display: inline-block;
  padding: 3px 14px;
  font-size: clamp(24px, 5.6vw, 32px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
  background: linear-gradient(180deg, #131020, #1a1628);
  border: 1px solid #2c2544;
  border-radius: 8px;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, .55);
}

.card .sub { margin: 5px 0 0; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.card-switch .big { color: var(--switch); text-shadow: 0 0 16px rgba(229, 180, 85, .55); }
.card-stay .big { color: var(--stay); text-shadow: 0 0 16px rgba(122, 143, 212, .55); }
.card-accident { grid-column: 1 / -1; }
.card-accident .big { color: var(--red); font-size: 22px; text-shadow: 0 0 16px rgba(181, 68, 63, .55); }

.chart-wrap {
  position: relative;
  margin-top: 14px;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  padding: 10px 8px 6px;
}

#chart { display: block; width: 100%; height: auto; }

/* 自分のプレイが線に入った瞬間のパルス */
#chart circle.pulse {
  transform-box: fill-box;
  transform-origin: center;
  animation: chart-pulse .9s ease-out forwards;
}

@keyframes chart-pulse {
  from { transform: scale(1); opacity: .9; }
  to { transform: scale(3.4); opacity: 0; }
}

.chart-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 0 20px;
}

.legend { display: flex; gap: 16px; justify-content: center; font-size: 12px; color: var(--muted); margin: 8px 0 0; }
.lg-switch { color: var(--switch); }
.lg-stay { color: var(--stay); }

/* ---------- 反論 ---------- */

.objection p { font-size: 14px; color: var(--muted); }
.react-buttons { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.react-note { min-height: 1.2em; font-size: 13px; color: var(--gold); margin: 10px 0 0; }
.react-stats {
  margin-top: 12px;
  display: inline-block;
  font-size: 14px;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  padding: 10px 18px;
}

.react-stats p { margin: 4px 0; display: flex; align-items: center; gap: 8px; }
.react-stats .env { display: inline-flex; flex: none; }
.react-stats .env svg { width: 18px; height: auto; }
.react-stats strong { color: var(--fg); font-variant-numeric: tabular-nums; }
#convinced-summary { color: var(--muted); font-size: 13px; }

/* ---------- 解説 ---------- */

.explain details {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  padding: 0 18px;
  margin-bottom: 10px;
}

.explain summary {
  cursor: pointer;
  padding: 13px 0;
  font-weight: 600;
  font-size: 15px;
  list-style-position: outside;
}

.explain details p { font-size: 14px; color: #c9c3d4; margin-top: 0; }
.explain details[open] summary { border-bottom: 1px solid var(--panel-edge); margin-bottom: 12px; }

.explain table { border-collapse: collapse; font-size: 13px; margin: 4px 0 12px; width: 100%; }
.explain th, .explain td { border: 1px solid var(--panel-edge); padding: 6px 8px; text-align: center; }
.explain th { background: #262138; font-weight: 600; }

/* ---------- フッター ---------- */

.site-footer {
  margin: 52px 0 40px;
  padding-top: 24px;
  border-top: 1px solid var(--panel-edge);
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.x-post { margin-bottom: 14px; }
.site-footer .copyright { margin: 0; font-size: 12px; }

@media (max-width: 480px) {
  .doors { gap: 9px; }
  .cards { gap: 9px; }
}
/* キーボード操作のフォーカス表示（共通）。outline-none を指定した部品はそれぞれの focus スタイルが勝つ */
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
