/* ==========================================================================
   出世ルーレット — スタイルシート
   テーマ: 昭和の社内掲示ポスター / 表彰状
   暗所視認性、極太タイポグラフィ、大胆な色面
   ========================================================================== */

:root {
  /* コアカラーパレット（検証・調整済み） */
  --bg: #0e1620;
  --bg-subtle: #162434;
  --kami: #f3e9d2;
  --kami-pure: #faf6ed;
  --shu: #c8382e;
  --shu-dark: #8b1c15;
  --shu-light: #e65347;
  --ai: #17365d;
  --ai-light: #254a7b;
  --ai-dark: #0d213a;
  --kin: #c48e24;
  --kin-bright: #ffca36;
  --sumi: #1a1715;
  --sumi-light: #3d3936;
  --washi-border: #d4c5a9;
  
  /* 事業部カラー */
  --gfs-main: #185a36;
  --gfs-accent: #e5b338;
  --gfs-bg: #0f3620;
  
  --sai-main: #0077b6;
  --sai-accent: #00e5ff;
  --sai-bg: #003049;
  
  --mvh-main: #d84a1b;
  --mvh-accent: #ff8c42;
  --mvh-bg: #5c1f0b;

  /* システム */
  --font-gothic: "Zen Kaku Gothic New", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hiragino Sans", "Hiragino Kaku Gothic ProN", sans-serif;
  --font-mincho: "Shippori Mincho", "Yu Mincho", "Hiragino Mincho ProN", serif;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 14px;
  --shadow-block: 0 4px 0 #000;
  --shadow-heavy: 0 8px 0 #000;
}

/* リセット & ベース */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  background-color: var(--bg);
  color: var(--kami);
  font-family: var(--font-gothic);
  font-size: 16px;
  line-height: 1.4;
  user-select: none;
  -webkit-user-select: none;
}

/* 集中線・暗所ストライプ背景 */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    repeating-linear-gradient(
      -45deg,
      rgba(23, 54, 93, 0.25),
      rgba(23, 54, 93, 0.25) 20px,
      rgba(14, 22, 32, 0.4) 20px,
      rgba(14, 22, 32, 0.4) 40px
    );
  pointer-events: none;
  z-index: 0;
}

/* アプリケーション外枠 (モバイル375px基準、最大520pxで机に置いて見やすい) */
#app-container {
  position: relative;
  width: 100%;
  max-width: 500px;
  min-height: 100vh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.8);
  border-left: 2px solid var(--ai);
  border-right: 2px solid var(--ai);
  z-index: 1;
}

/* ヘッダー */
header.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--ai-dark);
  border-bottom: 3px solid var(--shu);
  z-index: 10;
}

.logo-badge {
  display: flex;
  align-items: center;
  gap: 6px;
}

.copia-tag {
  font-size: 11px;
  font-weight: 900;
  background: var(--shu);
  color: #fff;
  padding: 2px 6px;
  letter-spacing: 0.5px;
  border-radius: 2px;
}

.title-trigger {
  font-size: 18px;
  font-weight: 900;
  color: var(--kin-bright);
  letter-spacing: 1px;
  cursor: pointer;
  border: none;
  background: none;
  padding: 2px 4px;
  outline: none;
}
.title-trigger:focus-visible {
  outline: 2px dashed var(--kin-bright);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  background: var(--bg-subtle);
  border: 1px solid var(--ai-light);
  color: var(--kami);
  font-size: 18px;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.icon-btn:active {
  transform: scale(0.92);
}
.icon-btn:focus-visible {
  outline: 2px solid var(--kin-bright);
}
.icon-btn.muted {
  color: #888;
  border-color: #444;
}

/* 画面切り替え用コンテナ */
.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  padding: 14px 14px 20px;
  overflow-y: auto;
}
.screen.active {
  display: flex;
}

/* ==========================================================================
   ポスター・表彰状風の共通コンポーネント
   ========================================================================== */

/* 昭和ポスター帯見出し */
.poster-ribbon {
  background: var(--shu);
  color: var(--kami-pure);
  font-weight: 900;
  font-size: 14px;
  letter-spacing: 2px;
  text-align: center;
  padding: 6px 12px;
  transform: rotate(-0.5deg);
  border: 2px solid var(--sumi);
  box-shadow: 2px 3px 0 var(--sumi);
  margin-bottom: 12px;
}

/* 表彰状・辞令風ペーパーカード */
.kami-card {
  background-color: var(--kami);
  color: var(--sumi);
  border: 3px solid var(--shu);
  border-radius: var(--radius-sm);
  padding: 14px;
  box-shadow: 4px 6px 0 var(--sumi);
  position: relative;
  margin-bottom: 14px;
}

.kami-card::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  right: 3px;
  bottom: 3px;
  border: 1px solid var(--washi-border);
  pointer-events: none;
}

/* ==========================================================================
   Screen 1: セットアップ画面
   ========================================================================== */

.setup-hero {
  text-align: center;
  padding: 16px 0 12px;
}

.hero-main-title {
  font-size: 34px;
  font-weight: 900;
  color: var(--kin-bright);
  text-shadow: 3px 3px 0 var(--shu), 5px 5px 0 var(--sumi);
  letter-spacing: 2px;
  line-height: 1.15;
}

.hero-sub {
  font-size: 13px;
  font-weight: 700;
  color: var(--kami);
  margin-top: 6px;
  background: var(--ai);
  display: inline-block;
  padding: 3px 10px;
  border-radius: 2px;
}

.company-purpose-box {
  background: rgba(23, 54, 93, 0.4);
  border: 1px solid var(--ai-light);
  padding: 8px 12px;
  margin-bottom: 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: #cadbee;
  text-align: center;
}

.company-purpose-box strong {
  color: var(--kin-bright);
  font-weight: 900;
}

/* プレイヤー登録リスト */
.player-setup-box {
  background: var(--bg-subtle);
  border: 2px solid var(--ai-light);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 16px;
}

.setup-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.setup-label {
  font-size: 15px;
  font-weight: 900;
  color: var(--kin-bright);
  letter-spacing: 1px;
}

.player-count-badge {
  font-size: 12px;
  background: var(--ai);
  color: #fff;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 700;
}

.player-input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.text-input {
  flex: 1;
  background: #091017;
  border: 2px solid var(--ai-light);
  color: #fff;
  padding: 10px 12px;
  font-size: 15px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  outline: none;
}
.text-input:focus {
  border-color: var(--kin-bright);
  box-shadow: 0 0 0 2px rgba(255, 202, 54, 0.25);
}

.btn-add-player {
  background: var(--shu);
  color: #fff;
  border: 2px solid var(--sumi);
  padding: 0 16px;
  font-size: 15px;
  font-weight: 900;
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: 2px 2px 0 #000;
}
.btn-add-player:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 #000;
}

.players-list-scroll {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 4px;
}

.player-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #0d1a29;
  border: 1px solid var(--ai-light);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}

.player-item-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.player-index {
  font-size: 12px;
  font-weight: 900;
  background: var(--ai);
  color: var(--kin-bright);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.player-name-text {
  font-size: 16px;
  font-weight: 900;
  color: #fff;
}

.btn-remove-player {
  background: none;
  border: none;
  color: #d16666;
  font-size: 18px;
  padding: 4px 8px;
  cursor: pointer;
  font-weight: 900;
}

/* 3事業部プレビューカード */
.dept-intro-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  margin-bottom: 16px;
}

.dept-mini-card {
  border-radius: var(--radius-sm);
  padding: 8px 6px;
  text-align: center;
  border: 2px solid rgba(0, 0, 0, 0.4);
}

.dept-mini-card.gfs {
  background: var(--gfs-bg);
  border-color: var(--gfs-accent);
}
.dept-mini-card.sai {
  background: var(--sai-bg);
  border-color: var(--sai-accent);
}
.dept-mini-card.mvh {
  background: var(--mvh-bg);
  border-color: var(--mvh-accent);
}

.dept-mini-name {
  font-size: 12px;
  font-weight: 900;
  color: #fff;
  margin-bottom: 2px;
}
.dept-mini-card.gfs .dept-mini-name { color: var(--gfs-accent); }
.dept-mini-card.sai .dept-mini-name { color: var(--sai-accent); }
.dept-mini-card.mvh .dept-mini-name { color: var(--mvh-accent); }

.dept-mini-desc {
  font-size: 10px;
  font-weight: 700;
  color: #cbd5e1;
  line-height: 1.25;
}

/* メインアクションボタン */
.btn-primary-action {
  width: 100%;
  background: linear-gradient(180deg, #e64233 0%, #b82b22 100%);
  color: #fff;
  border: 3px solid #ffe175;
  border-radius: var(--radius-md);
  padding: 16px 20px;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 2px;
  cursor: pointer;
  box-shadow: 0 6px 0 #4a0f0b, 0 10px 16px rgba(0, 0, 0, 0.5);
  transition: transform 0.08s, box-shadow 0.08s;
  text-align: center;
  margin-top: 6px;
}
.btn-primary-action:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #4a0f0b, 0 4px 8px rgba(0, 0, 0, 0.5);
}
.btn-primary-action:focus-visible {
  outline: 3px solid var(--kin-bright);
}

/* ==========================================================================
   Screen 1.5: 事業部配属ガチャ画面
   ========================================================================== */

#screen-gacha {
  text-align: center;
}

.gacha-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 20px 0;
}

.gacha-cur-player-banner {
  font-size: 14px;
  color: var(--kin-bright);
  font-weight: 900;
  margin-bottom: 4px;
}

.gacha-target-player-name {
  font-size: 32px;
  font-weight: 900;
  color: #fff;
  margin-bottom: 20px;
  text-shadow: 2px 2px 0 var(--ai);
}

.gacha-slot-box {
  width: 100%;
  max-width: 320px;
  background: #000;
  border: 4px solid var(--kin-bright);
  border-radius: var(--radius-lg);
  padding: 24px 16px;
  box-shadow: 0 0 30px rgba(255, 202, 54, 0.35), inset 0 0 20px rgba(0, 0, 0, 0.9);
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}

.gacha-slot-slot {
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  transition: transform 0.15s;
}

.gacha-dept-badge {
  font-size: 36px;
  font-weight: 900;
  letter-spacing: 2px;
  margin-bottom: 6px;
}

.gacha-dept-subtitle {
  font-size: 14px;
  font-weight: 900;
  color: #cbd5e1;
}

.gacha-dept-perk {
  font-size: 13px;
  font-weight: 700;
  margin-top: 8px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

/* ==========================================================================
   Screen 2: メインゲームプレイ画面（1m離れても即座に読める極太デザイン）
   ========================================================================== */

#screen-game {
  padding-bottom: 12px;
  position: relative;
}

/* 上部ステータス帯: 手番進行・事業部所属 */
.game-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.turn-indicator-badge {
  background: var(--ai);
  border: 2px solid var(--ai-light);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
}

/* 事業部所属バッジ (常時目立つ) */
.active-dept-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 900;
  padding: 4px 12px;
  border-radius: 20px;
  border: 2px solid #000;
  box-shadow: 2px 2px 0 #000;
}
.active-dept-pill.gfs {
  background: var(--gfs-accent);
  color: #0b2915;
}
.active-dept-pill.sai {
  background: var(--sai-accent);
  color: #002238;
}
.active-dept-pill.mvh {
  background: var(--mvh-accent);
  color: #3b1103;
}

/* 現在のプレイヤー名 (1m離れても読める特大サイズ) */
.active-player-billboard {
  text-align: center;
  margin-bottom: 8px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-sm);
}

.billboard-label {
  font-size: 11px;
  color: #94a3b8;
  font-weight: 900;
  letter-spacing: 1px;
}

.active-player-name {
  font-size: clamp(26px, 7vw, 36px);
  font-weight: 900;
  color: #ffffff;
  letter-spacing: 1.5px;
  line-height: 1.1;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}

/* 役職階層ピラミッド / ステータス表示 */
.role-pyramid-container {
  background: #091018;
  border: 2px solid var(--ai-light);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  margin-bottom: 12px;
}

.pyramid-level-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  margin-bottom: 4px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  border-left: 5px solid transparent;
  transition: all 0.2s ease;
}

.pyramid-level-row.reached {
  background: rgba(23, 54, 93, 0.5);
  border-left-color: var(--ai-light);
}

.pyramid-level-row.current {
  background: var(--shu);
  border-left-color: var(--kin-bright);
  transform: scale(1.02);
  box-shadow: 0 4px 10px rgba(200, 56, 46, 0.5);
}

.pyramid-level-row.current .pyramid-role-title {
  color: #ffffff;
  font-size: 20px;
  font-weight: 900;
}

.pyramid-level-row.ceo-blocked {
  opacity: 0.45;
  filter: grayscale(1);
}

.pyramid-role-title {
  font-size: 15px;
  font-weight: 900;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 6px;
}

.pyramid-role-status {
  font-size: 12px;
  font-weight: 900;
  color: #cbd5e1;
}

/* 現在役職の大看板（最重要視覚要素） */
.current-rank-card {
  background: var(--kami);
  color: var(--sumi);
  border: 4px solid var(--shu);
  border-radius: var(--radius-md);
  padding: 14px 12px;
  text-align: center;
  box-shadow: 0 6px 0 #000;
  margin-bottom: 14px;
  position: relative;
}

.rank-card-tag {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--shu);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  padding: 2px 12px;
  border-radius: 10px;
  border: 2px solid var(--sumi);
  letter-spacing: 1px;
  white-space: nowrap;
}

.current-rank-name {
  font-size: clamp(34px, 9vw, 46px);
  font-weight: 900;
  color: var(--shu);
  letter-spacing: 4px;
  line-height: 1.1;
  text-shadow: 1px 1px 0 #fff;
}

.current-rank-sub {
  font-size: 13px;
  font-weight: 800;
  color: var(--sumi-light);
  margin-top: 4px;
}

/* 次の役職への挑戦レート表示 */
.next-challenge-box {
  background: var(--bg-subtle);
  border: 2px solid var(--ai-light);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.next-target-text {
  font-size: 14px;
  font-weight: 900;
  color: var(--kin-bright);
}

.next-rate-details {
  display: flex;
  gap: 12px;
  font-size: 13px;
  font-weight: 900;
}

.rate-fail-val {
  color: #f87171;
}
.rate-perk-bonus {
  color: #34d399;
  font-size: 11px;
}

/* 辞令/称賛/イベント表示領域（可変） */
.status-bulletin-area {
  min-height: 70px;
  margin-bottom: 14px;
}

.bulletin-card {
  background: #132233;
  border: 2px solid var(--ai-light);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  color: #e2e8f0;
  line-height: 1.4;
  position: relative;
}

.bulletin-card.event {
  border-color: #f59e0b;
  background: #271e0c;
  color: #fef3c7;
}

.bulletin-card.praise {
  border-color: #10b981;
  background: #08291f;
  color: #d1fae5;
}

.bulletin-card.demotion {
  border-color: var(--shu);
  background: #2a1111;
  color: #fee2e2;
  font-family: var(--font-mincho);
}

.bulletin-tag {
  font-size: 10px;
  font-weight: 900;
  padding: 2px 6px;
  border-radius: 2px;
  display: inline-block;
  margin-bottom: 4px;
  letter-spacing: 0.5px;
}
.bulletin-card.event .bulletin-tag { background: #f59e0b; color: #000; }
.bulletin-card.praise .bulletin-tag { background: #10b981; color: #000; }
.bulletin-card.demotion .bulletin-tag { background: var(--shu); color: #fff; }

/* 2大アクションボタン（特大・親指でミスなく押せる配置） */
.game-action-controls {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 6px;
}

.btn-roulette-roll {
  width: 100%;
  min-height: 68px;
  background: linear-gradient(180deg, #d83a2d 0%, #a82017 100%);
  color: #ffffff;
  border: 4px solid #fbd34d;
  border-radius: var(--radius-md);
  font-size: clamp(24px, 6vw, 30px);
  font-weight: 900;
  letter-spacing: 4px;
  cursor: pointer;
  box-shadow: 0 6px 0 #52130e, 0 10px 20px rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.08s, box-shadow 0.08s;
}
.btn-roulette-roll:active:not(:disabled) {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #52130e, 0 4px 10px rgba(0, 0, 0, 0.6);
}
.btn-roulette-roll:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(0.8);
  box-shadow: none;
}
.btn-roulette-roll:focus-visible {
  outline: 3px solid #ffca36;
}

.btn-lock-in {
  width: 100%;
  min-height: 48px;
  background: var(--ai);
  color: #e2e8f0;
  border: 2px solid var(--ai-light);
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 2px;
  cursor: pointer;
  box-shadow: 0 4px 0 #081626;
  transition: transform 0.08s, background 0.15s;
}
.btn-lock-in:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #081626;
}
.btn-lock-in:hover:not(:disabled) {
  background: var(--ai-light);
  color: #fff;
}
.btn-lock-in:focus-visible {
  outline: 2px solid var(--kin-bright);
}

/* 他のプレイヤーの現況一覧（折りたたみまたは下部表示） */
.players-overview-dock {
  margin-top: 14px;
  background: rgba(0, 0, 0, 0.35);
  border-top: 2px solid var(--ai-dark);
  padding: 8px 6px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  border-radius: var(--radius-sm);
}

.player-dock-chip {
  flex-shrink: 0;
  padding: 4px 8px;
  background: #09131d;
  border: 1px solid var(--ai-light);
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 4px;
}
.player-dock-chip.current-turn {
  border-color: var(--kin-bright);
  background: var(--ai);
}
.player-dock-chip.done {
  opacity: 0.65;
}

/* ==========================================================================
   Task A: 溜め & リビール演出オーバーレイ
   ========================================================================== */

#suspense-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1000;
  background: rgba(10, 16, 25, 0.95);
  backdrop-filter: blur(8px);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
#suspense-overlay.active {
  display: flex;
}

/* 溜め（サスペンス）フェーズのアニメーション */
.suspense-box {
  width: 90%;
  max-width: 380px;
  text-align: center;
  position: relative;
  z-index: 2;
}

.suspense-gear-wrap {
  position: relative;
  width: 140px;
  height: 140px;
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.suspense-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 6px dashed var(--kin-bright);
  animation: spin-gear 1.6s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.suspense-inner-core {
  width: 90px;
  height: 90px;
  background: radial-gradient(circle, #c8382e 0%, #59100a 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: #fff;
  border: 3px solid #ffca36;
  box-shadow: 0 0 30px rgba(255, 202, 54, 0.6);
  animation: pulse-core 0.4s ease-in-out infinite alternate;
}

.suspense-title {
  font-size: 22px;
  font-weight: 900;
  color: var(--kin-bright);
  letter-spacing: 3px;
  margin-bottom: 8px;
}

.suspense-bar-shell {
  width: 100%;
  height: 20px;
  background: #000;
  border: 2px solid var(--ai-light);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  margin-bottom: 10px;
}

.suspense-bar-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #d83a2d, #ffca36);
  transition: width 1.6s cubic-bezier(0.1, 0.7, 0.1, 1);
}

.suspense-status-msg {
  font-size: 14px;
  color: #cbd5e1;
  font-weight: 700;
}

/* ==========================================================================
   リビール（結果開示）フェーズ
   ========================================================================== */

.reveal-container {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 92%;
  max-width: 420px;
  position: relative;
  z-index: 3;
}
.reveal-container.active {
  display: flex;
}

/* 成功リビール */
.reveal-container.success .stamp-mark {
  border: 6px solid var(--shu);
  color: var(--shu);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 0 50px rgba(200, 56, 46, 0.7), inset 0 0 20px rgba(200, 56, 46, 0.2);
}

/* 失敗リビール（左遷） */
.reveal-container.fail .stamp-mark {
  border: 6px solid #111;
  color: #fff;
  background: #8b1c15;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.9), inset 0 0 20px #000;
}

/* CEO到達リビール（超特別） */
.reveal-container.ceo .stamp-mark {
  border: 8px double #fff;
  color: #000;
  background: linear-gradient(135deg, #ffe066 0%, #ffca36 50%, #d48b11 100%);
  box-shadow: 0 0 80px rgba(255, 215, 0, 0.9);
}

.stamp-mark {
  font-size: clamp(48px, 12vw, 68px);
  font-weight: 900;
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  letter-spacing: 6px;
  transform: scale(3) rotate(-15deg);
  opacity: 0;
  margin-bottom: 16px;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.3);
}

.reveal-container.active .stamp-mark {
  animation: stamp-drop 0.4s cubic-bezier(0.1, 0.9, 0.2, 1) forwards;
}

.reveal-card {
  width: 100%;
  background: var(--kami);
  color: var(--sumi);
  border: 4px solid var(--shu);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
  opacity: 0;
  transform: translateY(20px);
}
.reveal-container.active .reveal-card {
  animation: card-appear 0.3s 0.35s ease-out forwards;
}

.reveal-role-title {
  font-size: 26px;
  font-weight: 900;
  color: var(--shu);
  margin-bottom: 8px;
}

.reveal-text-body {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.5;
  color: var(--sumi);
  margin-bottom: 16px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 4px;
}

.btn-dismiss-reveal {
  width: 100%;
  background: var(--ai);
  color: #fff;
  border: 2px solid var(--sumi);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 1px;
  cursor: pointer;
}
.btn-dismiss-reveal:focus-visible {
  outline: 3px solid var(--kin-bright);
}

/* 画面フラッシュ背景 */
.flash-effect {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
}
.flash-effect.flash-success {
  background: radial-gradient(circle, rgba(255, 202, 54, 0.85) 0%, rgba(200, 56, 46, 0.6) 100%);
  animation: flash-burst 0.6s ease-out forwards;
}
.flash-effect.flash-fail {
  background: radial-gradient(circle, rgba(200, 56, 46, 0.9) 0%, rgba(0, 0, 0, 0.95) 100%);
  animation: flash-burst 0.6s ease-out forwards;
}
.flash-effect.flash-ceo {
  background: radial-gradient(circle, #fff 0%, rgba(255, 215, 0, 0.9) 50%, rgba(200, 56, 46, 0.8) 100%);
  animation: flash-burst 0.8s ease-out forwards;
}

/* ==========================================================================
   Screen 3: 順位発表画面 (結果一覧 & 最下位の安全な罰ゲーム)
   ========================================================================== */

#screen-ranking {
  text-align: center;
}

.ranking-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.rank-item-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-subtle);
  border: 2px solid var(--ai-light);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.rank-item-card.top1 {
  background: linear-gradient(90deg, #2b1f0d, #14283f);
  border-color: var(--kin-bright);
  box-shadow: 0 0 15px rgba(255, 202, 54, 0.3);
}

.rank-item-card.last-place {
  background: #231111;
  border-color: var(--shu);
}

.rank-num-badge {
  font-size: 20px;
  font-weight: 900;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--ai);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.rank-item-card.top1 .rank-num-badge {
  background: var(--kin-bright);
  color: #000;
}

.rank-player-col {
  text-align: left;
  flex: 1;
  margin-left: 12px;
}

.rank-player-name {
  font-size: 18px;
  font-weight: 900;
  color: #fff;
}

.rank-player-dept {
  font-size: 11px;
  font-weight: 700;
}

.rank-role-badge {
  font-size: 16px;
  font-weight: 900;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: var(--ai-dark);
  color: var(--kin-bright);
  border: 1px solid var(--ai-light);
}

.rank-role-badge.locked {
  background: var(--shu);
  color: #fff;
  border-color: var(--shu-light);
}

/* 最下位 罰ゲーム掲示板 */
.batsu-notice-board {
  background: var(--kami);
  color: var(--sumi);
  border: 4px solid var(--shu);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: 0 6px 0 #000;
  margin-bottom: 20px;
  position: relative;
}

.batsu-headline {
  font-size: 16px;
  font-weight: 900;
  color: var(--shu);
  margin-bottom: 6px;
  letter-spacing: 1px;
}

.batsu-content-text {
  font-size: 15px;
  font-weight: 800;
  color: var(--sumi);
  line-height: 1.4;
  padding: 10px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 4px;
}

/* ==========================================================================
   Task D: デバッグ画面モーダル & シミュレータ
   ========================================================================== */

#debug-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(6px);
  align-items: center;
  justify-content: center;
  padding: 16px;
}
#debug-modal.active {
  display: flex;
}

.debug-window {
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  background: #0d1622;
  border: 3px solid var(--kin-bright);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.9);
}

.debug-header {
  background: var(--ai-dark);
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--ai-light);
}

.debug-title {
  font-size: 16px;
  font-weight: 900;
  color: var(--kin-bright);
}

.btn-close-debug {
  background: none;
  border: none;
  color: #fff;
  font-size: 20px;
  font-weight: 900;
  cursor: pointer;
}

.debug-body {
  padding: 14px;
  overflow-y: auto;
  font-size: 13px;
}

.debug-sec-title {
  font-size: 13px;
  font-weight: 900;
  color: var(--kin-bright);
  border-left: 4px solid var(--shu);
  padding-left: 6px;
  margin: 12px 0 8px;
}
.debug-sec-title:first-child { margin-top: 0; }

.debug-field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 10px;
}

.debug-slider-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.debug-slider {
  flex: 1;
  accent-color: var(--shu);
  cursor: pointer;
}

.debug-val-display {
  font-weight: 900;
  width: 44px;
  text-align: right;
  color: #fff;
}

.btn-run-sim {
  width: 100%;
  background: var(--shu);
  color: #fff;
  border: 2px solid var(--sumi);
  padding: 12px;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 1px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  margin-top: 10px;
}

.sim-results-box {
  margin-top: 12px;
  background: #060b10;
  border: 1px solid var(--ai-light);
  border-radius: var(--radius-sm);
  padding: 10px;
  font-family: monospace;
}

.sim-stat-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  font-size: 12px;
}

.sim-bar-shell {
  width: 100%;
  height: 12px;
  background: #111;
  border-radius: 2px;
  overflow: hidden;
  margin: 2px 0 6px;
}
.sim-bar-fill {
  height: 100%;
  background: var(--kin-bright);
}

/* ==========================================================================
   アニメーション定義
   ========================================================================== */

@keyframes spin-gear {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes pulse-core {
  from { transform: scale(0.95); }
  to { transform: scale(1.05); }
}

@keyframes stamp-drop {
  0% { transform: scale(3.5) rotate(-18deg); opacity: 0; }
  60% { transform: scale(0.95) rotate(-3deg); opacity: 1; }
  100% { transform: scale(1) rotate(-4deg); opacity: 1; }
}

@keyframes card-appear {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes flash-burst {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

/* 画面揺れ (Screen Shake) */
.shake-fail {
  animation: screen-shake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes screen-shake {
  10%, 90% { transform: translate3d(-3px, 0, 0); }
  20%, 80% { transform: translate3d(5px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-6px, 0, 0); }
  40%, 60% { transform: translate3d(6px, 0, 0); }
}

/* ==========================================================================
   アクセシビリティ (prefers-reduced-motion)
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
  }
  .shake-fail {
    animation: none !important;
  }
}

/* ==========================================================================
   レスポンシブ (画面幅・横向き対応)
   ========================================================================== */
@media (max-height: 580px) and (orientation: landscape) {
  #app-container {
    max-width: 640px;
  }
  .role-pyramid-container {
    display: none;
  }
  .btn-roulette-roll {
    min-height: 52px;
    font-size: 20px;
  }
}
