/* ===================================================
   グリコでドカーン！ デザインシステム
   =================================================== */

/* ---------- リセット & ベース ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --color-bg: #1A1A2E;
  --color-surface: #16213E;
  --color-surface2: #0F3460;
  --color-red: #E74C3C;
  --color-red-dim: rgba(231, 76, 60, 0.2);
  --color-orange: #F39C12;
  --color-yellow: #F1C40F;
  --color-green: #2ECC71;
  --color-white: #FFFFFF;
  --color-text: #ECF0F1;
  --color-muted: #95A5A6;
  --color-border: rgba(255, 255, 255, 0.1);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-pill: 50px;

  --font: 'Noto Sans JP', system-ui, sans-serif;

  --step-height: 48px;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 画面管理 ---------- */
.screen {
  display: none;
  position: fixed;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

/* ---------- ボタン ---------- */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 20px;
  border: none;
  border-radius: var(--radius-pill);
  font-family: var(--font);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  text-decoration: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--color-red);
  color: #fff;
}

.btn-secondary {
  background: var(--color-surface2);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-accent {
  background: var(--color-orange);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--color-muted);
  font-size: 14px;
  padding: 10px;
}

.btn-icon {
  font-size: 20px;
}

/* ---------- 入力 ---------- */
.text-input {
  width: 100%;
  padding: 14px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-family: var(--font);
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
}

.text-input:focus {
  border-color: var(--color-red);
}

.text-input::placeholder {
  color: var(--color-muted);
}

.input-label {
  display: block;
  font-size: 12px;
  color: var(--color-muted);
  margin-bottom: 6px;
}

/* ---------- ユーティリティ ---------- */
.hidden {
  display: none !important;
}

.error-text {
  color: var(--color-red);
  font-size: 13px;
  margin-top: 6px;
  text-align: center;
}

/* ===================================================
   S1: ロビー
   =================================================== */
.lobby-inner {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 40px 24px 40px;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

.logo-area {
  text-align: center;
}

.logo-icon {
  font-size: 64px;
  animation: pulse 2s infinite;
}

@keyframes pulse {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.1);
  }
}

.logo-title {
  font-size: 32px;
  font-weight: 900;
  color: var(--color-white);
  text-shadow: 0 2px 8px rgba(231, 76, 60, 0.5);
  line-height: 1.2;
  margin-top: 12px;
}

.logo-tagline {
  margin-top: 12px;
  font-size: 16px;
  font-weight: 700;
  color: var(--color-orange);
  letter-spacing: 0.5px;
  line-height: 1.6;
  text-shadow: 0 1px 6px rgba(243, 156, 18, 0.3);
}

.name-input-area {
  display: flex;
  flex-direction: column;
}

.button-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.join-code-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}

.code-input {
  text-align: center;
  font-size: 24px;
  letter-spacing: 8px;
  font-weight: 700;
  text-transform: uppercase;
}

.stats-area {
  text-align: center;
  padding-top: 8px;
  border-top: 1px solid var(--color-border);
}

.stats-label {
  font-size: 12px;
  color: var(--color-muted);
  margin-bottom: 4px;
}

.stats-text {
  font-size: 16px;
  font-weight: 700;
}

/* ===================================================
   S1-A / S1-C: 待機画面
   =================================================== */
.waiting-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 60px 24px 40px;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
  text-align: center;
}

.screen-title {
  font-size: 20px;
  font-weight: 700;
}

.room-code-display {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 20px 40px;
  width: 100%;
}

.room-code-label {
  font-size: 12px;
  color: var(--color-muted);
  margin-bottom: 8px;
}

.room-code-value {
  font-size: 36px;
  font-weight: 900;
  letter-spacing: 8px;
  color: var(--color-orange);
}

.waiting-text {
  color: var(--color-muted);
  line-height: 1.8;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--color-border);
  border-top-color: var(--color-red);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.bomb-animation {
  font-size: 60px;
  animation: bombBounce 1.5s ease-in-out infinite;
}

@keyframes bombBounce {

  0%,
  100% {
    transform: translateY(0) scale(1);
  }

  50% {
    transform: translateY(-12px) scale(1.1);
  }
}

.queue-count {
  font-size: 14px;
  color: var(--color-muted);
}

/* ===================================================
   S2: 地雷設置フェーズ
   =================================================== */
.placing-header {
  flex-shrink: 0;
  padding: 16px 16px 0;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}

.placing-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.placing-title {
  font-size: 16px;
  font-weight: 700;
}

.placing-subtitle {
  font-size: 12px;
  color: var(--color-muted);
  margin-bottom: 10px;
}

.timer-badge {
  background: var(--color-surface2);
  color: var(--color-white);
  font-size: 20px;
  font-weight: 900;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  min-width: 56px;
  text-align: center;
  transition: background 0.3s, color 0.3s;
}

.timer-badge.warn {
  background: var(--color-orange);
}

.timer-badge.danger {
  background: var(--color-red);
  animation: blink 0.5s step-end infinite;
}

@keyframes blink {
  50% {
    opacity: 0.4;
  }
}

.mine-counter {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 12px;
}

.mine-dots {
  font-size: 20px;
  letter-spacing: 4px;
  color: var(--color-orange);
}

.mine-count-text {
  font-size: 13px;
  color: var(--color-muted);
}

.placing-wait-msg {
  font-size: 13px;
  color: var(--color-green);
  padding-bottom: 10px;
}

.placing-board {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px;
}

/* インナーコンテナ: PCでの中央寄せ用 */
.placing-inner,
.game-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  background: var(--color-bg);
}

.placing-inner {
  overflow-y: hidden;
  /* ヘッダーとフッターを固定 */
}

.step-row {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--step-height);
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  transition: background 0.15s;
  border-radius: var(--radius-sm);
  padding: 0 8px;
}

.step-row:hover:not(.step-disabled) {
  background: rgba(255, 255, 255, 0.05);
}

.step-row.step-disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.step-row.step-has-mine {
  background: rgba(243, 156, 18, 0.1);
}

.step-number {
  font-size: 13px;
  color: var(--color-muted);
  width: 28px;
  text-align: right;
  flex-shrink: 0;
}

.step-content {
  flex: 1;
  height: 28px;
  display: flex;
  align-items: center;
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  font-size: 14px;
}

.step-mine-icon {
  font-size: 18px;
  margin-left: auto;
}

.placing-footer {
  flex-shrink: 0;
  padding: 12px 16px 24px;
  background: var(--color-bg);
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hint-text {
  font-size: 12px;
  color: var(--color-muted);
  text-align: center;
}

/* ===================================================
   S3: メインゲーム画面
   =================================================== */
.game-header {
  flex-shrink: 0;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
}

.player-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
}

.opponent-bar {
  background: rgba(231, 76, 60, 0.1);
}

.my-bar {
  background: rgba(52, 152, 219, 0.1);
}

.player-name {
  font-weight: 700;
  font-size: 14px;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-step {
  font-size: 16px;
  font-weight: 900;
  color: var(--color-white);
}

.player-marker {
  font-size: 16px;
}

/* 盤面 */
.game-board {
  flex: 1;
  overflow: hidden;
  position: relative;
  min-height: 0;
}

.board-scroll {
  height: 100%;
  overflow-y: auto;
  padding: 8px 16px;
  scroll-behavior: smooth;
}

.board-step {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--step-height);
  border-bottom: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0 8px;
  position: relative;
  transition: background 0.2s;
}

.board-step.step-goal {
  background: rgba(46, 204, 113, 0.1);
  border-bottom-color: var(--color-green);
}

.board-step.step-start {
  background: rgba(255, 255, 255, 0.05);
}

.board-step.revealed-mine {
  background: var(--color-red-dim);
}

.board-step-num {
  font-size: 12px;
  color: var(--color-muted);
  width: 24px;
  text-align: right;
  flex-shrink: 0;
}

.board-step-bar {
  flex: 1;
  height: 28px;
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  padding: 0 8px;
  gap: 6px;
  font-size: 14px;
  position: relative;
}

.board-step-label {
  font-size: 12px;
  color: var(--color-muted);
}

.pawn-my {
  font-size: 18px;
  animation: pawnBob 0.8s ease-in-out infinite;
}

.pawn-opp {
  font-size: 18px;
}

@keyframes pawnBob {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-3px);
  }
}

.mine-self-icon {
  font-size: 14px;
  margin-left: auto;
}

/* ゲームフッター */
.game-footer {
  flex-shrink: 0;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: 10px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.timer-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.game-timer {
  font-size: 40px;
  font-weight: 900;
  color: var(--color-white);
  line-height: 1;
  transition: color 0.3s;
}

.game-timer.warn {
  color: var(--color-yellow);
}

.game-timer.danger {
  color: var(--color-red);
  animation: blink 0.5s step-end infinite;
}

.timer-label {
  font-size: 13px;
  color: var(--color-muted);
}

.janken-buttons {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.janken-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: 1;
  padding: 10px 4px;
  background: var(--color-surface2);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.janken-btn:active {
  transform: scale(0.95);
}

.janken-btn:hover {
  border-color: var(--color-red);
  background: rgba(231, 76, 60, 0.1);
}

.janken-btn.selected {
  background: rgba(231, 76, 60, 0.2);
  border-color: var(--color-red);
}

.janken-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.janken-icon {
  font-size: 28px;
}

.janken-name {
  font-size: 13px;
  font-weight: 700;
}

.janken-steps {
  font-size: 11px;
  color: var(--color-muted);
}

.waiting-hand-msg {
  text-align: center;
  font-size: 14px;
  color: var(--color-muted);
  padding: 8px 0;
}

/* ---------- 統合チャットタイムライン ---------- */
.chat-timeline-area {
  max-height: 100px;
  overflow-y: auto;
  border-top: 1px solid var(--color-border);
  padding-top: 6px;
  scroll-behavior: smooth;
}

.chat-timeline {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-entry {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  animation: chatFadeIn 0.3s ease-out;
  line-height: 1.4;
}

@keyframes chatFadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* システムログ */
.chat-entry.chat-system {
  color: var(--color-muted);
}

.chat-entry.chat-mine-hit {
  color: var(--color-red);
  font-weight: 700;
}

/* 自分のスタンプ */
.chat-entry.chat-stamp-mine {
  align-self: flex-end;
  background: rgba(52, 152, 219, 0.15);
  border: 1px solid rgba(52, 152, 219, 0.3);
  color: #7ec8e3;
  max-width: 85%;
  font-size: 13px;
  font-weight: 600;
}

/* 相手のスタンプ */
.chat-entry.chat-stamp-opp {
  align-self: flex-start;
  background: rgba(231, 76, 60, 0.15);
  border: 1px solid rgba(231, 76, 60, 0.3);
  color: #e8a09a;
  max-width: 85%;
  font-size: 13px;
  font-weight: 600;
}

.chat-stamp-sender {
  font-size: 10px;
  opacity: 0.7;
  margin-right: 4px;
}

/* ---------- スタンプパネル ---------- */
.stamp-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-top: 1px solid var(--color-border);
  padding-top: 8px;
}

.stamp-toggle-btn {
  align-self: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--color-surface2);
  border: 2px solid rgba(52, 152, 219, 0.4);
  border-radius: var(--radius-pill);
  padding: 8px 24px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

.stamp-toggle-icon {
  font-size: 18px;
  line-height: 1;
}

.stamp-toggle-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text);
  font-family: var(--font);
}

.stamp-toggle-btn:hover {
  background: rgba(52, 152, 219, 0.25);
  border-color: rgba(52, 152, 219, 0.8);
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

.stamp-toggle-btn:active {
  transform: translateY(0) scale(0.95);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.stamp-toggle-btn.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  box-shadow: 0 0 15px rgba(52, 152, 219, 0.6);
}

.stamp-toggle-btn.active .stamp-toggle-label {
  color: #fff;
}

/* パルス（注目）アニメーション */
@keyframes pulseAttention {
  0% {
    box-shadow: 0 0 0 0 rgba(52, 152, 219, 0.7);
    transform: scale(1);
  }

  50% {
    box-shadow: 0 0 0 12px rgba(52, 152, 219, 0);
    transform: scale(1.05);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(52, 152, 219, 0);
    transform: scale(1);
  }
}

.pulse-anim {
  animation: pulseAttention 1.5s infinite;
  border-color: var(--color-primary);
  background: rgba(52, 152, 219, 0.2);
}

.stamp-panel {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 0 4px;
  visibility: hidden;
}

.stamp-panel.open {
  max-height: 250px;
  opacity: 1;
  padding: 8px 4px 6px 4px;
  visibility: visible;
}

.stamp-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
}

.stamp-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  background: var(--color-surface2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stamp-btn:hover {
  background: rgba(52, 152, 219, 0.15);
  border-color: rgba(52, 152, 219, 0.4);
}

.stamp-btn:active {
  transform: scale(0.93);
}

.stamp-btn.on-cooldown {
  opacity: 0.4;
  cursor: not-allowed;
}

.stamp-btn-emoji {
  font-size: 14px;
  flex-shrink: 0;
}

/* ===================================================
   S4: リザルト
   =================================================== */
.result-inner {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 40px 24px 60px;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

.result-header {
  text-align: center;
}

.result-emoji {
  font-size: 56px;
  margin-bottom: 8px;
}

.result-title {
  font-size: 28px;
  font-weight: 900;
}

.result-header.win .result-title {
  color: var(--color-green);
}

.result-header.lose .result-title {
  color: var(--color-muted);
}

.result-stats {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 16px;
  border: 1px solid var(--color-border);
}

.stats-section-title {
  font-size: 13px;
  color: var(--color-muted);
  font-weight: 700;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.stats-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  padding: 4px 0;
  border-bottom: 1px solid var(--color-border);
}

.stat-row:last-child {
  border-bottom: none;
}

.mine-map-area {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
}

.result-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ===================================================
   オーバーレイ共通
   =================================================== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 20, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}

/* じゃんけん解決 */
.resolve-inner {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.resolve-hands {
  display: flex;
  align-items: center;
  justify-content: space-around;
}

.resolve-hand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.hand-icon {
  font-size: 56px;
  animation: handReveal 0.3s ease-out;
}

@keyframes handReveal {
  from {
    transform: scale(0.5);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

.hand-owner {
  font-size: 13px;
  color: var(--color-muted);
}

.resolve-vs {
  font-size: 20px;
  font-weight: 900;
  color: var(--color-muted);
}

.resolve-result {
  font-size: 22px;
  font-weight: 900;
  color: var(--color-white);
}

.resolve-loser {
  font-size: 15px;
  color: rgba(255, 255, 255, 0.7);
  margin-top: 4px;
}

.resolve-mine-alert {
  background: var(--color-red);
  border-radius: var(--radius-md);
  padding: 14px;
  animation: shake 0.4s ease-out;
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  20%,
  60% {
    transform: translateX(-8px);
  }

  40%,
  80% {
    transform: translateX(8px);
  }
}

.resolve-mine-alert.mine-self {
  background: var(--color-orange);
}

.resolve-mine-text {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
}

/* ===================================================
   5連続あいこボーナスオーバーレイ
   =================================================== */
.draw-bonus-inner {
  background: var(--color-surface);
  border: 2px solid var(--color-yellow);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: bonusAppear 0.35s ease-out;
}

@keyframes bonusAppear {
  from {
    transform: scale(0.7);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

.draw-bonus-title {
  font-size: 28px;
  font-weight: 900;
  color: var(--color-yellow);
}

.draw-bonus-chooser {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-white);
}

.draw-bonus-prompt {
  font-size: 13px;
  color: var(--color-muted);
  margin-bottom: 4px;
}

.draw-bonus-buttons {
  display: flex;
  gap: 12px;
}

.draw-bonus-btn {
  flex: 1;
  flex-direction: column;
  gap: 4px;
  padding: 16px 8px;
}

.draw-bonus-btn-num {
  font-size: 24px;
  font-weight: 900;
}

.draw-bonus-btn-hand {
  font-size: 12px;
  opacity: 0.8;
}

.draw-bonus-wait {
  font-size: 14px;
  color: var(--color-muted);
  padding: 12px 0;
}

/* ===================================================
   ルール説明モーダル
   =================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}

.modal-overlay.hidden {
  display: none;
}

.modal-inner {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border, #eee);
}

.modal-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--color-text);
  margin: 0;
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--color-muted);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  line-height: 1;
}

.modal-close-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.modal-body {
  overflow-y: auto;
  padding: 16px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.rule-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rule-heading {
  font-size: 15px;
  font-weight: 800;
  color: var(--color-orange);
  margin: 0;
}

.rule-section p {
  font-size: 14px;
  color: var(--color-text);
  line-height: 1.6;
  margin: 0;
}

.rule-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rule-list li {
  font-size: 14px;
  color: var(--color-text);
  line-height: 1.5;
}

/* ロビーのインラインルール表示 */
.lobby-rules {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lobby-rules-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--color-text);
  margin: 0;
}

/* ゲームヘッダーのルールボタン */
.btn-rules-game {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}

.btn-rules-game:hover {
  background: rgba(255, 255, 255, 0.35);
}

/* トースト */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-green);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 15px;
  text-align: center;
  z-index: 200;
  animation: slideDown 0.3s ease-out;
  min-width: 200px;
}

@keyframes slideDown {
  from {
    transform: translateX(-50%) translateY(-20px);
    opacity: 0;
  }

  to {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
}

/* 盤面移動アニメーション */
@keyframes stepMove {
  0% {
    background: rgba(231, 76, 60, 0.4);
  }

  100% {
    background: transparent;
  }
}

.board-step.just-moved {
  animation: stepMove 0.6s ease-out;
}

/* ===================================================
   S1-B: CPU 難易度選択画面
   =================================================== */
.cpu-select-inner {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 40px 24px 40px;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
  min-height: 100%;
  justify-content: center;
}

.btn-difficulty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 16px 20px;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 700;
  text-align: left;
  color: #fff;
  border: none;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  width: 100%;
}

.btn-difficulty:active {
  transform: scale(0.98);
  opacity: 0.85;
}

.difficulty-easy {
  background: var(--color-green);
}

.difficulty-normal {
  background: var(--color-orange);
}

.difficulty-hard {
  background: var(--color-red);
}

.difficulty-stars {
  font-size: 18px;
}

.difficulty-name {
  font-size: 18px;
  font-weight: 900;
}

.difficulty-desc {
  font-size: 12px;
  font-weight: 400;
  opacity: 0.9;
}

/* ===================================================
   地雷被り解決じゃんけん画面
   =================================================== */
.conflict-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 24px;
  gap: 16px;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
  min-height: 100%;
  justify-content: center;
}

.conflict-subtitle {
  font-size: 15px;
  font-weight: 700;
  color: var(--color-orange);
  text-align: center;
  margin: 0;
}

.conflict-instructions {
  font-size: 14px;
  color: var(--color-muted);
  text-align: center;
  margin: 0;
}

.conflict-draw-msg {
  font-size: 15px;
  font-weight: 700;
  color: var(--color-orange);
  text-align: center;
  padding: 12px 16px;
  background: rgba(243, 156, 18, 0.15);
  border-radius: var(--radius-md);
  width: 100%;
}

/* 地雷再設置時のロック済みマス */
.step-locked {
  opacity: 0.75;
  cursor: default;
}

.step-locked-badge {
  font-size: 11px;
  margin-left: 4px;
}

/* 地雷再設置時の禁止マス */
.step-forbidden {
  opacity: 0.45;
  cursor: not-allowed;
}

/* スクロールバー */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 2px;
}

/* ---------- シェアセクション ---------- */
.share-section {
  padding: 16px 0 8px;
  border-top: 1px solid var(--color-border);
  text-align: center;
}

.share-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-muted);
  margin-bottom: 10px;
  letter-spacing: 0.05em;
}

.share-buttons {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 9px 14px;
  border-radius: var(--radius-pill);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  border: none;
  transition: opacity 0.15s;
}

.share-btn:active {
  opacity: 0.75;
}

.share-btn-x {
  background: #000;
  color: #fff;
}

.share-btn-line {
  background: #06C755;
  color: #fff;
}

.share-btn-copy {
  background: var(--color-surface2);
  color: var(--color-text);
}

/* ===================================================
   言語トグル
   =================================================== */
.lang-toggle-area {
  display: flex;
  justify-content: flex-end;
  margin-bottom: -12px;
}

.btn-lang-toggle {
  background: var(--color-surface2);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  padding: 6px 16px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  white-space: nowrap;
}

.btn-lang-toggle:hover {
  background: rgba(231, 76, 60, 0.15);
  border-color: var(--color-red);
}

.btn-lang-toggle:active {
  transform: scale(0.95);
}