/* ==========================================================================
   DAILY PLAY — Game Screens & Board Styling (Dark & Light Theme)
   ========================================================================== */

/* ゲーム個別画面のレイアウト */
.game-viewport {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 50% 15%, #151c2e 0%, #0b0d14 80%);
  color: var(--text-primary);
  transition: background var(--transition-normal);
}

[data-theme="light"] .game-viewport {
  background: radial-gradient(circle at 50% 10%, #ffffff 0%, #f1f5f9 85%);
}

/* ゲーム専用ヘッダー（スマホで窮屈にならない設計） */
.game-header {
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(11, 13, 20, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 10px 16px;
}

[data-theme="light"] .game-header {
  background: rgba(255, 255, 255, 0.88);
}

.game-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1040px;
  margin: 0 auto;
  gap: 12px;
}

.game-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.95rem; /* 17.1px */
  font-weight: 700;
  color: var(--text-secondary);
  transition: color var(--transition-fast);
  white-space: nowrap;
}
.game-back-link:hover {
  color: var(--text-primary);
}

.game-title-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.game-title-sub-ja {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
}

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

/* インラインSVG＋テキストラベルの操作ボタン（文字化けゼロ・44px以上確保） */
.tool-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  min-width: 44px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.92rem; /* 16.5px */
  font-weight: 700;
  transition: all var(--transition-fast);
  cursor: pointer;
  white-space: nowrap;
}
[data-theme="light"] .tool-action-btn {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #334155;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.tool-action-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  color: var(--text-primary);
}
[data-theme="light"] .tool-action-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.tool-svg-icon {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* ゲームメインステージ */
.game-stage-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px 16px 28px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

/* スタート画面・リザルト画面（オーバーレイ/カード） */
.game-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(8, 10, 15, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
[data-theme="light"] .game-modal-overlay {
  background: rgba(15, 23, 42, 0.65);
}

.game-modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  max-width: 500px;
  width: 100%;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  animation: modalEnter 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}
[data-theme="light"] .game-modal-card {
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
}

@keyframes modalEnter {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

/* 開始モーダル専用のヘッダーバー（テーマ切替を配置） */
.modal-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.modal-theme-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 0.92rem; /* 16.5px */
  font-weight: 700;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-medium);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}
[data-theme="light"] .modal-theme-btn {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #334155;
}
.modal-theme-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  color: var(--text-primary);
}

.game-modal-tag {
  display: inline-block;
  font-size: 0.92rem; /* 16.5px */
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 5px 14px;
  border-radius: var(--radius-full);
}

.game-modal-title {
  font-size: 1.9rem;
  font-weight: 900;
  margin-bottom: 12px;
  line-height: 1.3;
}

.game-modal-desc {
  font-size: 1.05rem; /* 約19px */
  color: var(--text-secondary);
  margin-bottom: 22px;
  line-height: 1.65;
}

/* 開始モーダル内のルール説明欄（ライトモード時は明るく清潔感のある背景） */
.game-modal-rulebox {
  margin-top: 20px;
  font-size: 0.95rem; /* 17.1px */
  color: var(--text-secondary);
  text-align: left;
  background: rgba(0, 0, 0, 0.25);
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  line-height: 1.65;
}
[data-theme="light"] .game-modal-rulebox {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #334155;
}

.game-modal-rulebox strong {
  color: var(--text-primary);
  display: block;
  margin-bottom: 4px;
  font-size: 1rem;
}

/* 難易度選択セレクター */
.difficulty-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 22px;
}

.diff-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 14px 12px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid var(--border-subtle);
  color: var(--text-secondary);
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
}
[data-theme="light"] .diff-btn {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.diff-btn strong {
  font-size: 1.15rem;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.diff-btn span {
  font-size: 0.95rem; /* 17.1px */
  color: var(--text-secondary);
}

.diff-btn[aria-checked="true"] {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--border-focus);
  color: var(--text-primary);
}
[data-theme="light"] .diff-btn[aria-checked="true"] {
  background: #e0f2fe;
  border-color: #0284c7;
}

/* プレイ中のステータスバー（日本語ラベル対応） */
.game-active-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 500px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 18px;
  margin-bottom: 14px;
}
[data-theme="light"] .game-active-status-bar {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.status-stat-group {
  display: flex;
  align-items: center;
  gap: 18px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.stat-label {
  font-size: 0.92rem; /* 16.5px：日本語ラベルを明瞭に */
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
}

.stat-value {
  font-size: 1.35rem;
  font-weight: 900;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

/* ==========================================================
   リバーシ（8×8）
   ========================================================= */
.reversi-mat {
  background: #141c2c;
  border: 3px solid #232f48;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
  border-radius: var(--radius-md);
  padding: 6px;
  width: min(calc(100vw - 28px), 430px);
  height: min(calc(100vw - 28px), 430px);
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  gap: 3px;
  touch-action: manipulation;
}

.reversi-square {
  background: #1c273e;
  border-radius: 4px;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  padding: 0;
  transition: background-color var(--transition-fast);
}

.reversi-square:hover:not(:disabled) {
  background: #253350;
}

.reversi-square.is-legal::after {
  content: "";
  width: 32%;
  height: 32%;
  border-radius: 50%;
  background: var(--color-reversi);
  box-shadow: 0 0 10px var(--color-reversi);
  opacity: 0.9;
  pointer-events: none;
}

.reversi-stone {
  width: 82%;
  height: 82%;
  border-radius: 50%;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.6);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.reversi-stone.black {
  background: radial-gradient(circle at 35% 35%, #475569 0%, #0f172a 70%, #020617 100%);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.reversi-stone.white {
  background: radial-gradient(circle at 35% 35%, #ffffff 0%, #e2e8f0 60%, #cbd5e1 100%);
  border: 1px solid rgba(0, 0, 0, 0.15);
}

/* ==========================================================
   神経衰弱（4×4 アートカード）
   ========================================================= */
.memory-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 10px;
  width: min(calc(100vw - 28px), 430px);
  height: min(calc(100vw - 28px), 430px);
  perspective: 1000px;
}

.art-card {
  position: relative;
  width: 100%;
  height: 100%;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  padding: 0;
}

.art-card.flipped {
  transform: rotateY(180deg);
}

.art-card.matched {
  transform: rotateY(180deg);
  opacity: 0.3;
  cursor: default;
}

.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-medium);
}

.card-face.back {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: var(--text-muted);
}
[data-theme="light"] .card-face.back {
  background: linear-gradient(135deg, #334155 0%, #1e293b 100%);
}

.card-back-pattern {
  width: 30px;
  height: 30px;
  opacity: 0.4;
}

.card-face.front {
  background: #182234;
  transform: rotateY(180deg);
  border: 2px solid var(--color-memory);
}
[data-theme="light"] .card-face.front {
  background: #ffffff;
}

.card-svg-symbol {
  width: 62%;
  height: 62%;
}

/* ==========================================================
   NUMBER FLOW（1画面収容・スクロール不要レイアウト）
   ========================================================= */
.math-board {
  max-width: 420px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
}

.math-question-card {
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 14px 14px;
  margin-bottom: 10px;
  position: relative;
}

.math-streak-badge {
  position: absolute;
  top: 8px;
  right: 12px;
  font-size: 0.92rem; /* 16.5px */
  font-weight: 800;
  color: var(--color-math);
  background: rgba(132, 204, 22, 0.14);
  border: 1px solid rgba(132, 204, 22, 0.35);
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

.math-equation-text {
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: 2px;
  margin-bottom: 8px;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.math-user-answer-screen {
  min-height: 50px;
  background: rgba(0, 0, 0, 0.35);
  border: 2px solid var(--border-medium);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--text-primary);
}
[data-theme="light"] .math-user-answer-screen {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.math-feedback-bar {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem; /* 17.1px */
  font-weight: 700;
  margin-bottom: 8px;
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  color: var(--text-secondary);
}

.math-feedback-bar.correct {
  color: var(--color-success);
  background: rgba(16, 185, 129, 0.15);
}

.math-feedback-bar.wrong {
  color: var(--color-danger);
  background: rgba(239, 68, 68, 0.15);
}

/* テンキー：高さ52pxでスリム化、全画面収容 */
.math-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.math-key {
  min-height: 52px;
  font-size: 1.5rem;
  font-weight: 800;
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  transition: all var(--transition-fast);
  cursor: pointer;
}
[data-theme="light"] .math-key {
  background: #ffffff;
  border-color: #cbd5e1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.math-key:hover {
  background: var(--bg-card-hover);
  border-color: var(--text-primary);
}
[data-theme="light"] .math-key:hover {
  background: #f1f5f9;
}
.math-key:active {
  transform: scale(0.96);
}

.math-key.util {
  font-size: 0.95rem; /* 17.1px */
  font-weight: 700;
  color: var(--text-secondary);
}

/* ==========================================================
   リザルト画面の装飾
   ========================================================= */
.result-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 20px;
  text-align: left;
}
[data-theme="light"] .result-stats-grid {
  background: #f8fafc;
  border-color: #e2e8f0;
}

.result-stat-cell strong {
  display: block;
  font-size: 1.35rem;
  font-weight: 900;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.result-stat-cell span {
  font-size: 0.92rem; /* 16.5px */
  color: var(--text-secondary);
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* スマホ表示での微調整 */
@media (max-width: 600px) {
  .game-header {
    padding: 8px 12px;
  }
  .game-header-inner {
    flex-wrap: wrap;
    gap: 8px;
  }
  .game-back-link {
    font-size: 0.95rem;
  }
  .game-title-badge {
    font-size: 1.05rem;
  }
  .game-title-sub-ja {
    font-size: 0.92rem; /* 16.5px以上 */
  }
  .game-stage-container {
    padding: 8px 10px 14px;
  }

  /* NUMBER FLOWの1画面収容最適化（スクロール不要でENTERまで快適に操作可能） */
  .math-board {
    max-width: 360px;
  }
  .math-question-card {
    padding: 10px 14px;
    margin-bottom: 6px;
  }
  .math-equation-text {
    font-size: 1.95rem;
    margin-bottom: 6px;
  }
  .math-user-answer-screen {
    min-height: 44px;
    font-size: 1.6rem;
  }
  .math-feedback-bar {
    min-height: 32px;
    margin-bottom: 6px;
    font-size: 0.92rem;
    padding: 4px 8px;
  }
  .math-keypad {
    gap: 6px;
    margin-bottom: 8px;
  }
  .math-key {
    min-height: 48px;
    font-size: 1.4rem;
  }
  .math-key.util {
    font-size: 0.95rem;
  }
  #mathSubmitBtn {
    min-height: 48px !important;
    font-size: 1.1rem !important;
  }
}
