/* Behind the Decision —「意思決定空間 / THE DECISION SPACE」
   3Dの二分木星座(canvas)の上に、ガラスのパネルが浮かぶ。ダーク×シャンパンゴールド、グレインの揺らぎ。 */

:root {
  --void: #07080b;
  --glass: rgba(10, 12, 16, .66);
  --glass-2: rgba(13, 16, 21, .82);
  --edge: rgba(201, 169, 106, .18);
  --edge-2: rgba(255, 255, 255, .08);
  --fg: #ece8dd;
  --fg-2: #b9b6ae;
  --dim: #767a86;
  --gold: #c9a96a;
  --gold-hi: #e2c484;
  --gold-dim: #8a7550;
  --ox: #a8503f;
  --gain: #8fc0a4;
  --loss: #cf8f6d;
  --disp: "Archivo", "Zen Kaku Gothic New", "Helvetica Neue", system-ui, sans-serif;
  --jp: "Zen Kaku Gothic New", "Hiragino Kaku Gothic ProN", "Yu Gothic", system-ui, sans-serif;
  --mono: "Roboto Mono", "SFMono-Regular", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
/* 横方向は切り取る。clip はスクロールバーを予約せず（hidden だと body が縦スクロール
   コンテナ化して15px予約→右に隙間＝「右による」の原因になる）縦スクロールも阻害しない。 */
html, body { max-width: 100%; overflow-x: clip; overscroll-behavior-x: none; }
body { color: var(--fg); background: var(--void); font-family: var(--jp); -webkit-font-smoothing: antialiased; }

/* 3D空間キャンバス（最背面・固定）。幅はCSSで固定＝JS側はこの表示サイズに合わせる。 */
#space { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; display: block; }

/* ビネット＋上方の微光 */
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background:
    radial-gradient(120% 90% at 50% 50%, transparent 55%, rgba(0, 0, 0, .55) 100%),
    radial-gradient(900px 420px at 18% -6%, rgba(201, 169, 106, .05), transparent 60%);
}
/* フィルムグレイン（揺らぎ） */
body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 9999; opacity: .05; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

#root { position: relative; z-index: 2; }

/* ===== 骨格 ===== */
.scene { min-height: 100vh; display: flex; flex-direction: column; animation: scene-in .5s ease both; }
@keyframes scene-in { from { opacity: 0 } to { opacity: 1 } }
.strip {
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  padding: 18px clamp(16px, 4vw, 44px);
}
.wm { font-family: var(--disp); font-weight: 900; font-size: .8rem; letter-spacing: .34em; text-transform: uppercase; color: var(--fg); }
.wm b { color: var(--gold); }
.strip-right { font-family: var(--mono); font-size: .72rem; color: var(--dim); letter-spacing: .05em; }
.strip-right b { color: var(--fg-2); }

.glass {
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(1.15);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
  border: 1px solid var(--edge);
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .8), inset 0 1px 0 rgba(255, 255, 255, .05);
}

/* ===== 稟議（プレイ画面）: 左ガラス板 + 右は空間 ===== */
.board { flex: 1; display: grid; grid-template-columns: 1fr; align-items: stretch; gap: 0; padding: 0 clamp(14px, 3vw, 40px) clamp(16px, 3vw, 36px); }
.panel { padding: clamp(24px, 3.4vw, 44px); align-self: center; animation: rise .6s cubic-bezier(.2, .9, .25, 1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(18px) } to { opacity: 1; transform: none } }

.kicker { font-family: var(--mono); font-size: .7rem; letter-spacing: .24em; text-transform: uppercase; color: var(--gold); margin: 0 0 14px; display: flex; align-items: baseline; gap: 12px; }
.kicker .n { font-family: var(--disp); font-weight: 900; font-size: 1rem; letter-spacing: .08em; color: var(--gold-hi); }
.headline { font-family: var(--disp); font-weight: 800; font-size: clamp(1.4rem, 2.6vw, 2rem); line-height: 1.18; letter-spacing: -.01em; margin: 0 0 8px; }
.lede { color: var(--fg-2); font-size: .93rem; line-height: 1.7; margin: 0 0 22px; max-width: 44ch; text-wrap: pretty; }

.choices { border-top: 1px solid var(--edge-2); margin-bottom: 20px; }
.choice {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 16px; width: 100%;
  padding: 19px 8px; border: 0; border-bottom: 1px solid var(--edge-2); background: transparent;
  color: var(--fg); text-align: left; cursor: pointer; font-family: var(--jp);
  transition: background .15s, padding-left .15s, box-shadow .15s;
}
.choice:hover { background: rgba(201, 169, 106, .06); }
.choice .ab { font-family: var(--disp); font-weight: 900; font-size: 1.35rem; color: var(--gold-dim); width: 1.3em; transition: color .15s, transform .15s; }
.choice:hover .ab { color: var(--gold); transform: translateX(2px); }
.choice .ct { font-size: 1.02rem; line-height: 1.45; }
.choice .go { font-family: var(--mono); font-size: .7rem; color: var(--gold); letter-spacing: .12em; opacity: 0; transform: translateX(6px); transition: opacity .15s, transform .15s; }
.choice:hover .go { opacity: .8; transform: none; }
.choice.sel { background: rgba(201, 169, 106, .1); padding-left: 18px; box-shadow: inset 3px 0 0 var(--gold); }
.choice.sel .ab { color: var(--gold-hi); }
.choice.sel .go { opacity: 1; transform: none; }

.reason-cap { font-family: var(--mono); font-size: .66rem; letter-spacing: .16em; color: var(--dim); text-transform: uppercase; margin: 0 0 8px; }
.reason {
  width: 100%; background: rgba(0, 0, 0, .3); border: 1px solid var(--edge-2); border-left: 2px solid var(--gold-dim);
  color: var(--fg); font-family: var(--jp); font-size: .98rem; line-height: 1.7; padding: 14px 15px; min-height: 92px; resize: vertical;
}
.reason::placeholder { color: var(--dim); }
.reason:focus { outline: none; border-color: var(--gold); }

.btn { border: 0; font-family: var(--disp); font-weight: 800; cursor: pointer; letter-spacing: .04em; transition: transform .1s, background .15s, color .15s, border-color .15s, box-shadow .2s; }
.btn:active { transform: translateY(1px); }
.commit { display: inline-flex; align-items: center; gap: 12px; margin-top: 16px; background: linear-gradient(160deg, var(--gold-hi), var(--gold)); color: #171208; padding: 15px 26px; font-size: .95rem; box-shadow: 0 8px 30px -8px rgba(201, 169, 106, .45); }
.commit::after { content: "→"; font-family: var(--mono); transition: transform .15s; }
.commit:hover::after { transform: translateX(4px); }
.commit:hover { box-shadow: 0 10px 36px -6px rgba(201, 169, 106, .6); }
.commit:disabled { background: rgba(255, 255, 255, .06); color: var(--dim); box-shadow: none; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--fg-2); border: 1px solid var(--edge-2); padding: 12px 18px; font-size: .85rem; font-family: var(--jp); font-weight: 700; }
.btn.ghost:hover { border-color: var(--gold); color: var(--fg); }
.btn.ghost.sm { padding: 8px 13px; font-size: .76rem; }

/* 財務盤面チップ: 既定は静的（PCは board-side 内で中央寄せ＝板と高さを揃える）。 */
.board-side { position: relative; display: flex; align-items: center; justify-content: center; }
.ledger-float { width: min(320px, 100%); padding: 20px 22px; animation: rise .7s .12s cubic-bezier(.2, .9, .25, 1) both; }
.ledger-cap { font-family: var(--mono); font-size: .64rem; letter-spacing: .26em; text-transform: uppercase; color: var(--gold); margin: 0 0 3px; }
.ledger-co { font-family: var(--disp); font-weight: 800; font-size: .98rem; margin: 0 0 12px; }
.ledger { list-style: none; padding: 0; margin: 0 0 12px; }
.ledger li { display: flex; justify-content: space-between; align-items: baseline; padding: 7px 0; border-bottom: 1px solid var(--edge-2); }
.ledger .k { font-size: .76rem; color: var(--dim); }
.ledger .v { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: .84rem; }
.ledger .v.up { color: var(--gain); } .ledger .v.down { color: var(--loss); }
.spark { width: 100%; height: 40px; }
.spark .line { fill: none; stroke: var(--gold); stroke-width: 1.5; }
.spark .area { fill: rgba(201, 169, 106, .1); }

/* ===== 決裁（結果） ===== */
.center-col { max-width: 760px; margin: 0 auto; padding: clamp(20px, 4vw, 48px) clamp(16px, 4vw, 40px); width: 100%; }
.verdict { padding: clamp(26px, 4vw, 46px); }
.verdict-wrap { display: grid; grid-template-columns: 1fr; justify-items: center; text-align: center; gap: clamp(22px, 4vw, 48px); align-items: center; margin-bottom: 8px; }
.thud { animation: thud .4s .34s both; }
@keyframes thud { 0% { transform: none } 25% { transform: translate(3px, 4px) } 50% { transform: translate(-4px, -2px) } 70% { transform: translate(2px, 2px) } 100% { transform: none } }

/* 3Dで叩き込まれる決裁印 */
.stamp {
  position: relative; width: clamp(118px, 15vw, 164px); aspect-ratio: 1; display: grid; place-items: center;
  border: 2.5px solid var(--ox); color: var(--ox); border-radius: 50%;
  font-family: var(--disp); font-weight: 900;
  animation: slam .55s cubic-bezier(.18, 1.2, .32, 1) both;
  will-change: transform, opacity, filter;
}
.stamp::before { content: ""; position: absolute; inset: 7px; border: 1px solid currentColor; border-radius: 50%; opacity: .55; }
.stamp::after { /* 着印の衝撃波 */
  content: ""; position: absolute; inset: -4px; border: 1.5px solid currentColor; border-radius: 50%;
  opacity: 0; animation: ring .6s .3s ease-out both;
}
.stamp.ng { border-color: #5b5e66; color: #878b96; }
/* 主役(成功/失敗)は place-items:center で円の中央へ。enは下部にキャプションとして絶対配置し中央をずらさない */
.stamp .jp { font-size: clamp(1.9rem, 3.3vw, 2.8rem); line-height: 1; }
.stamp .en { position: absolute; left: 0; right: 0; bottom: 17%; text-align: center;
  font-family: var(--mono); font-weight: 400; font-size: .56rem; letter-spacing: .3em; text-indent: .3em; text-transform: uppercase; }
@keyframes slam {
  0% { transform: perspective(760px) translateZ(560px) rotateX(42deg) rotate(-22deg); opacity: 0; filter: blur(7px); }
  55% { opacity: 1; }
  72% { transform: perspective(760px) translateZ(-26px) rotate(-7deg); filter: blur(0); }
  86% { transform: perspective(760px) translateZ(10px) rotate(-7deg); }
  100% { transform: perspective(760px) translateZ(0) rotate(-7deg); }
}
@keyframes ring { 0% { transform: scale(.8); opacity: .7 } 100% { transform: scale(1.55); opacity: 0 } }

.verdict-body .why { font-family: var(--mono); font-size: .7rem; color: var(--gold); letter-spacing: .18em; text-transform: uppercase; margin: 0 0 12px; }
/* 採点バッジ */
.score { font-family: var(--mono); letter-spacing: .06em; padding: 1px 8px; border: 1px solid; border-radius: 2px; text-transform: none; }
.score small { opacity: .6; font-size: .82em; }
.score.ok { color: var(--gain); border-color: rgba(143, 192, 164, .5); }
.score.ng { color: var(--loss); border-color: rgba(207, 143, 109, .5); }
.score-sm { font-family: var(--mono); font-size: .74rem; padding: 0 6px; border: 1px solid var(--edge-2); border-radius: 2px; }
.score-sm.ok { color: var(--gain); } .score-sm.ng { color: var(--loss); }
.history .crit { color: var(--gold-hi); font-size: .88rem; }
.verdict-body .comment { font-size: 1.08rem; line-height: 1.75; margin: 0; max-width: 44ch; animation: rise .5s .35s both; }

.delta-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--edge-2); border: 1px solid var(--edge-2); margin: 24px 0 0; }
.delta { background: rgba(0, 0, 0, .32); padding: 16px 18px; }
.delta .k { font-size: .74rem; color: var(--dim); margin-bottom: 6px; }
.delta .v { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: clamp(.95rem, 1.6vw, 1.12rem); }
.delta .d { font-family: var(--mono); font-size: .76rem; margin-left: 8px; }
.delta .d.up { color: var(--gain); } .delta .d.down { color: var(--loss); }
.notes { color: var(--dim); font-size: .82rem; border-left: 2px solid var(--gold-dim); padding-left: 12px; margin: 18px 0 0; }

/* ===== ログイン（空間の全景の上） ===== */
/* モバイルファースト: 既定は1カラム・上詰め。2カラムは min-width:1000px のPCのみ（下部）。 */
.gate2 { flex: 1; display: grid; grid-template-columns: 1fr; align-content: start; gap: clamp(20px, 4vw, 40px); padding: 24px clamp(16px, 4vw, 56px) clamp(24px, 4vw, 56px); }
.gate-copy .mark { font-family: var(--disp); font-weight: 900; font-size: clamp(2.4rem, 6vw, 4.8rem); line-height: 1.02; letter-spacing: -.02em; margin: 0; text-shadow: 0 8px 60px rgba(0, 0, 0, .8); }
.gate-copy .mark span { color: var(--gold); }
.gate-copy .tag { color: var(--fg-2); max-width: 40ch; line-height: 1.8; margin-top: 22px; text-shadow: 0 2px 20px rgba(0, 0, 0, .9); text-wrap: pretty; }
.gate-copy .tag b { color: var(--gold-hi); font-weight: 700; }
.gate-panel { padding: clamp(24px, 3vw, 38px); display: flex; flex-direction: column; gap: 14px; width: 100%; animation: rise .7s .1s both; }
/* グリッド/フレックス項目は既定 min-width:auto で「中身の最小幅」まで縮まず、
   狭い画面ではみ出す（＝カードが右に寄って見える）。0 を明示して画面幅まで縮ませる。 */
.gate2 > *, .gate-panel { min-width: 0; }
.gate-panel .input, .field .input, .reason { min-width: 0; max-width: 100%; }
.gate-copy .mark { overflow-wrap: anywhere; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-family: var(--mono); font-size: .64rem; letter-spacing: .18em; text-transform: uppercase; color: var(--dim); }
.field .input { background: rgba(0, 0, 0, .32); border: 1px solid var(--edge-2); border-bottom-color: var(--gold-dim); color: var(--fg); padding: 13px 14px; font-family: var(--jp); font-size: .98rem; }
.field .input:focus { outline: none; border-color: var(--gold); }
.field .input::placeholder { color: var(--dim); }

/* ===== 共通 ===== */
.eval { display: flex; align-items: center; gap: 16px; padding: 34px 0; }
.eval .t { font-family: var(--mono); letter-spacing: .12em; color: var(--fg-2); animation: pulse-t 1.6s ease-in-out infinite; }
@keyframes pulse-t { 50% { opacity: .45 } }
.spinner { width: 28px; height: 28px; border: 2px solid var(--edge-2); border-top-color: var(--gold); border-radius: 50%; animation: spin 1s linear infinite; flex: 0 0 auto; }
@keyframes spin { to { transform: rotate(360deg) } }
.err { color: var(--loss); min-height: 1.2em; font-size: .84rem; font-family: var(--mono); }
.muted { color: var(--dim); }
.row { display: flex; gap: 12px; align-items: stretch; flex-wrap: wrap; margin-top: 22px; }
.row .btn { margin-top: 0; }   /* commit の margin-top で縦ズレしないよう揃える */

.history summary { cursor: pointer; color: var(--gold); font-family: var(--mono); font-size: .74rem; letter-spacing: .1em; }
.history ol { padding-left: 18px; line-height: 1.65; margin-top: 12px; color: var(--fg-2); font-size: .92rem; }
.history li { margin-bottom: 12px; }
.history b.up { color: var(--gain); } .history b.down { color: var(--loss); }

.modal-bg { position: fixed; inset: 0; z-index: 100; background: rgba(4, 5, 7, .7); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { width: 100%; max-width: 470px; max-height: 84vh; overflow: auto; padding: 26px; background: var(--glass-2); backdrop-filter: blur(20px); border: 1px solid var(--edge); }
.modal h3 { font-family: var(--disp); margin: 0 0 14px; }
.fin-table { width: 100%; border-collapse: collapse; }
.fin-table td { padding: 10px 4px; border-bottom: 1px solid var(--edge-2); font-size: .88rem; }
.fin-table td:first-child { color: var(--dim); }
.fin-table td.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* 財務諸表（P/L 報告式・B/S 勘定式） */
.modal-fin { max-width: 1060px; }
.modal-head { margin-bottom: 16px; }
.modal-head h3 { font-family: var(--disp); margin: 2px 0 0; font-size: 1.15rem; }
.stmt-grid { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(460px, 1.5fr); gap: 26px; align-items: start; }
.stmt-title { font-family: var(--mono); font-size: .7rem; letter-spacing: .16em; text-transform: uppercase; color: var(--gold); font-weight: 400; margin: 0 0 10px; padding-bottom: 8px; border-bottom: 1px solid var(--gold-dim); }
.stmt-title span { color: var(--dim); margin-left: 6px; }
.stmt-guide { font-size: .74rem; line-height: 1.6; color: var(--dim); margin: 0 0 12px; }
/* 財務表の増減（直近の決定による） */
.stmt-d { font-family: var(--mono); font-size: .68rem; margin-left: 8px; letter-spacing: 0; }
.stmt-d.up { color: var(--gain); } .stmt-d.down { color: var(--loss); } .stmt-d.flat { color: var(--dim); }
.stmt-legend { font-size: .72rem; color: var(--dim); margin: 16px 0 0; padding-top: 12px; border-top: 1px solid var(--edge-2); }
.stmt-legend .lg { font-family: var(--mono); }
.stmt-legend .lg.neg { color: var(--loss); } .stmt-legend .lg.up { color: var(--gain); } .stmt-legend .lg.down { color: var(--loss); }
.stmt { width: 100%; border-collapse: collapse; }
.stmt td { padding: 8px 2px; font-size: .85rem; border-bottom: 1px solid var(--edge-2); }
.stmt td.l { color: var(--fg-2); }
.stmt td.v { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--fg); white-space: nowrap; }
.stmt td.v.neg { color: var(--loss); }
.stmt td.v.neg::before { content: "△"; margin-right: 1px; }
.stmt .r-sub td.l { padding-left: 14px; color: var(--dim); }
.stmt .r-head td { font-weight: 700; }
.stmt .r-head td.l { color: var(--fg); }
.stmt .r-sum td { border-top: 1px solid var(--gold-dim); border-bottom: 1px solid var(--gold-dim); font-weight: 700; }
.stmt .r-sum td.l { color: var(--fg); }
.stmt .r-sum td.v { color: var(--gold-hi); }
/* 空行は合計行(r-sum)と同じ枠線厚(上下1px・透明)にして、左右テーブルの行高を一致させる＝資産合計と負債純資産合計を揃える */
.stmt .r-blank td { border-top: 1px solid transparent; border-bottom: 1px solid transparent; }
/* B/S 勘定式: 1つの4列表（左右の合計を必ず同じ行に＝ズレない） */
.bs-wrap { overflow-x: auto; }                 /* 狭い画面では横スクロール（レイアウトは崩さない） */
.bs-acct { width: 100%; }
.bs-acct td { padding: 8px 2px; font-size: .8rem; border-bottom: 1px solid var(--edge-2); vertical-align: baseline; }
.bs-acct .bl { color: var(--fg-2); white-space: nowrap; }
.bs-acct .bv { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--fg); white-space: nowrap; }
.bs-acct .bv.neg { color: var(--loss); }
.bs-acct .bv.neg::before { content: "△"; margin-right: 1px; }
.bs-acct td:nth-child(2) { border-right: 1px solid var(--edge-2); padding-right: 16px; }   /* 左右の仕切り */
.bs-acct td:nth-child(3) { padding-left: 16px; }
.bs-acct .bs-sum { border-top: 1px solid var(--gold-dim); border-bottom: 1px solid var(--gold-dim); font-weight: 700; }
.bs-acct .bv.bs-sum { color: var(--gold-hi); }
.bs-acct .bl.bs-sum { color: var(--fg); }
.bs-cap2 { font-size: .72rem; color: var(--fg-2); padding-bottom: 6px; border-bottom: 1px dashed var(--edge-2); }
@media (max-width: 680px) { .stmt-grid { grid-template-columns: 1fr; gap: 20px; } }
@media (max-width: 400px) { .bs-acct td, .bs-acct .stmt-d { font-size: .72rem; } }

.data-table { width: 100%; border-collapse: collapse; margin-top: 14px; }
.data-table th, .data-table td { padding: 13px 10px; border-bottom: 1px solid var(--edge-2); text-align: left; }
.data-table th { font-family: var(--mono); font-size: .66rem; letter-spacing: .16em; text-transform: uppercase; color: var(--gold); font-weight: 400; }
.data-table td.num, .data-table th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.data-table tr.me td { background: rgba(201, 169, 106, .1); }
.rankno { font-family: var(--disp); font-weight: 900; color: var(--gold-dim); }

/* 講師 */
.dash-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.create-room { display: flex; gap: 12px; margin-bottom: 16px; }
.create-room .input { flex: 1; background: rgba(0, 0, 0, .32); border: 1px solid var(--edge-2); border-bottom-color: var(--gold-dim); color: var(--fg); padding: 13px 14px; font-family: var(--jp); }
.create-room .input:focus { outline: none; border-color: var(--gold); }
.new-code { border: 1px solid var(--gold); padding: 14px 16px; margin-bottom: 16px; display: flex; align-items: baseline; gap: 14px; background: rgba(201, 169, 106, .07); }
.new-code b { font-family: var(--mono); font-size: 1.35rem; letter-spacing: .22em; color: var(--gold-hi); }
.review { border: 1px solid var(--edge-2); border-left: 2px solid var(--gold-dim); padding: 16px 18px; margin-bottom: 12px; background: rgba(0, 0, 0, .25); }
.review-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.review-head .metric { font-family: var(--mono); font-size: .82rem; color: var(--fg-2); font-variant-numeric: tabular-nums; }
.spacer { flex: 1; }

/* ===== ルーム管理（講師ダッシュボード） ===== */
.btn.commit.sm { padding: 9px 15px; font-size: .8rem; margin-top: 0; }
.btn.commit.sm::after { content: none; }
.btn.ghost.danger { color: var(--loss); border-color: rgba(207, 143, 109, .28); }
.btn.ghost.danger:hover { border-color: var(--loss); color: #e6a988; }

.room-list { display: grid; gap: 12px; margin-top: 14px; }
.room-card { border: 1px solid var(--edge-2); border-left: 2px solid var(--gold-dim); background: rgba(0, 0, 0, .25); padding: 16px 18px; }
.room-card.is-closed { border-left-color: var(--dim); opacity: .82; }
.rc-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
/* コードを各カードの主役に（発行直後だけ大きい、をやめて全ルーム大きく） */
.rc-code {
  font-family: var(--mono); font-size: clamp(1.5rem, 5.5vw, 1.9rem); font-weight: 500;
  letter-spacing: .2em; line-height: 1; color: var(--gold-hi);
  background: transparent; border: 0; cursor: pointer; padding: 2px 0;
  position: relative;
}
.rc-code::after { content: "⧉"; font-size: .8rem; margin-left: 10px; color: var(--gold-dim); vertical-align: middle; }
.rc-code:hover { color: var(--gold); }
.rc-code:hover::after { color: var(--gold); }
.badge { font-family: var(--mono); font-size: .62rem; letter-spacing: .12em; text-transform: uppercase; padding: 3px 8px; border: 1px solid; }
.badge.on { color: var(--gain); border-color: rgba(143, 192, 164, .4); }
.badge.off { color: var(--dim); border-color: var(--edge-2); }
.rc-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; margin-bottom: 14px; font-size: .84rem; color: var(--fg-2); }
.rc-meta .rc-title { color: var(--fg); }
.rc-meta .rc-dot { color: var(--dim); }
.rc-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.room-card.just-made { animation: cardpop 1s ease both; }
@keyframes cardpop {
  0% { box-shadow: 0 0 0 0 rgba(201, 169, 106, .5); border-left-color: var(--gold-hi); }
  100% { box-shadow: 0 0 0 0 rgba(201, 169, 106, 0); }
}

/* トースト（コピー等のフィードバック） */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px); z-index: 200;
  background: var(--glass-2); backdrop-filter: blur(14px); border: 1px solid var(--edge);
  color: var(--fg); font-size: .84rem; padding: 11px 18px; letter-spacing: .02em;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  .stamp { animation: fade-in .3s both; } .thud { animation: none; } .stamp::after { animation: none; }
  .scene, .panel, .ledger-float, .gate-panel, .verdict-body .comment { animation: none; }
  @keyframes fade-in { from { opacity: 0 } to { opacity: 1 } }
}

/* ===== スマホ最適化 ===== */
@media (max-width: 600px) {
  .strip { padding: 14px 16px; flex-wrap: wrap; gap: 4px 12px; }
  .wm { font-size: .72rem; letter-spacing: .26em; }
  .strip-right { font-size: .66rem; }
  .board { padding: 2vh 12px 16px; }
  .panel { padding: 20px 16px; }
  .headline { font-size: clamp(1.3rem, 6vw, 1.7rem); }
  .lede { font-size: .9rem; margin-bottom: 18px; }
  .choice { padding: 16px 4px; gap: 12px; }
  .choice .ab { font-size: 1.2rem; }
  .choice .ct { font-size: .98rem; }
  .choice .go { display: none; }
  .reason { font-size: 16px; }              /* iOS のズーム防止に16px */
  .field .input, .create-room .input { font-size: 16px; }
  .commit { width: 100%; justify-content: center; padding: 15px 20px; }
  .gate2 { padding: 20px 16px 32px; align-content: start; gap: 24px; }  /* スマホは上詰め（中央/下寄せしない） */
  .gate-copy { padding-top: 0; }
  .gate-copy .mark { font-size: clamp(2.2rem, 12vw, 3.4rem); }
  .gate-copy .tag { font-size: .9rem; line-height: 1.7; margin-top: 16px; max-width: none; }  /* カードと同幅（張り出し感の解消） */
  .gate-panel { padding: 20px 16px; }
  .center-col { padding: 18px 14px 40px; }
  .verdict { padding: 22px 16px; }
  .delta-grid { grid-template-columns: 1fr; }
  .dash-head { flex-wrap: wrap; }
  .create-room { flex-direction: column; }
  .create-room .btn { width: 100%; }
  /* テーブルは横スクロールで溢れさせない */
  .data-table { display: block; overflow-x: auto; white-space: nowrap; }
  .rc-date { margin-left: 0; width: 100%; }
  .rc-actions .btn { flex: 1 1 auto; text-align: center; }
  .modal { padding: 20px 16px; }
  .toast { left: 12px; right: 12px; bottom: 16px; transform: translateY(20px); text-align: center; }
  .toast.show { transform: translateY(0); }
}

/* 中間幅（タブレット等）: 財務チップは板の下に回す。1カラムは既定なので指定不要。 */
@media (max-width: 999px) {
  .board { padding-top: 4vh; }
  .board-side { display: block; }               /* スマホ: 板の下に普通に流す */
  .ledger-float { width: 100%; margin-top: 16px; }
  .verdict-body .comment { max-width: none; }
  /* gate はグリッドをやめ単純なブロック積みに（ブロックは親を絶対にはみ出さない＝右寄り皆無）。 */
  .gate2 { display: block; }
  .gate-panel { margin-top: clamp(20px, 5vw, 36px); }
}

/* PC（十分に広い時だけ）2カラムに戻す。viewport解釈が曖昧な端末では既定の1カラムのまま。
   ワイド画面で右に無駄な空白が広がらないよう、コンテンツ幅に上限を付けて中央寄せする。 */
@media (min-width: 1000px) {
  .board { grid-template-columns: minmax(380px, 520px) minmax(300px, 360px); justify-content: space-between;
           align-self: center; width: 100%; max-width: 1200px; gap: clamp(24px, 5vw, 80px); }
  .board-side { justify-content: flex-end; }
  .gate2 { grid-template-columns: 1.1fr .9fr; align-content: center; align-items: center; gap: clamp(20px, 4vw, 60px);
           align-self: center; width: 100%; max-width: 1200px; }
  .gate-panel { justify-self: end; max-width: 440px; }
  .verdict-wrap { grid-template-columns: auto 1fr; justify-items: initial; text-align: left; }
}
