:root {
  --bg-dark: #101216;
  --panel-bg: #1c1f26;
  --table-bg: #15221b;
  --table-border: #263e31;
  --text-main: #f0f0f0;
  --text-muted: #9e9e9e;
  --primary: #2196f3;
  --correct: #4caf50;
  --ok-color: #ff9800;
  --incorrect: #f44336;
  --btn-bg: #282c34;
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  margin: 0;
  padding: 0;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  justify-content: center;
}

.app-container {
  width: 100%;
  max-width: 480px;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}

.screen-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 10px 14px;
  justify-content: space-between;
}

.home-scroll, .result-scroll {
  overflow-y: auto;
  justify-content: flex-start;
  padding-bottom: 30px;
}

/* --- ホーム画面 --- */
.home-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.logo-badge {
  display: inline-block;
  background: #1e293b;
  color: #64b5f6;
  font-size: 0.7em;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 12px;
  letter-spacing: 0.5px;
}
.menu-btn {
  background: #252932;
  border: 1px solid #383e4c;
  color: #ddd;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.75em;
  font-weight: bold;
  cursor: pointer;
}

.home-header { text-align: center; margin: 4px 0 12px 0; }
.home-title { margin: 0; font-size: 1.6em; letter-spacing: 0.5px; }
.home-subtitle { margin: 4px 0 0 0; font-size: 0.78em; color: var(--text-muted); }

/* コース別統計タブ */
.stats-container {
  background: var(--panel-bg);
  border: 1px solid #2a2e38;
  border-radius: 10px;
  padding: 8px;
  margin-bottom: 12px;
}
.stats-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}
.stat-tab {
  flex: 1;
  background: #14161b;
  border: 1px solid #2a2e38;
  color: #888;
  padding: 6px;
  border-radius: 6px;
  font-size: 0.75em;
  font-weight: bold;
  cursor: pointer;
}
.stat-tab.active {
  background: #1e293b;
  border-color: #64b5f6;
  color: #fff;
}
.stats-dashboard {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.stat-box {
  background: #14161b;
  border-radius: 6px;
  padding: 8px 4px;
  text-align: center;
}
.stat-value { font-size: 1.1em; font-weight: 800; color: #fff; }
.stat-label { font-size: 0.68em; color: var(--text-muted); margin-top: 2px; }

.about-card {
  background: #161920;
  border: 1px solid #282c37;
  border-radius: 8px;
  padding: 9px 12px;
  margin-bottom: 14px;
}
.about-title { font-size: 0.8em; font-weight: bold; color: #64b5f6; margin-bottom: 4px; }
.about-list { margin: 0; padding-left: 16px; font-size: 0.75em; color: #ccc; line-height: 1.45; }
.about-list li { margin-bottom: 3px; }

.section-label { font-size: 0.82em; font-weight: bold; color: #ddd; margin-bottom: 8px; }

.level-select-list { display: flex; flex-direction: column; gap: 8px; }
.level-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--panel-bg);
  border: 1px solid #343a46;
  border-radius: 10px;
  padding: 11px 14px;
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
}
.level-card:active { transform: scale(0.98); }
.level-card.locked { opacity: 0.5; background: #16181d; border-style: dashed; }
.level-card-left { display: flex; align-items: center; gap: 10px; }
.level-icon { font-size: 1.4em; }
.level-name { font-size: 0.9em; font-weight: bold; margin-bottom: 2px; display: flex; align-items: center; gap: 6px; }
.level-desc { font-size: 0.72em; color: var(--text-muted); }
.level-arrow { color: var(--primary); font-weight: bold; }
.coming-soon { background: #333; color: #aaa; font-size: 0.65em; padding: 2px 6px; border-radius: 4px; }
.daily-status-badge { font-size: 0.68em; padding: 2px 6px; border-radius: 4px; background: #2e3440; color: #aaa; }
.daily-status-badge.done { background: rgba(76, 175, 80, 0.2); color: #81c784; border: 1px solid #4caf50; }

.recent-history { display: flex; flex-direction: column; gap: 6px; }
.history-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--panel-bg);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.78em;
}

/* --- ゲーム画面 --- */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 6px;
  border-bottom: 1px solid #2a2e38;
  flex-shrink: 0;
}
.back-home-btn {
  background: transparent;
  border: 1px solid #444;
  color: #ccc;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.75em;
  cursor: pointer;
}
.session-profit-pill {
  font-size: 0.88em;
  font-weight: 800;
  color: #ffd700;
  background: #232730;
  padding: 3px 10px;
  border-radius: 12px;
  transition: transform 0.25s;
}
.session-profit-pill.increase { color: #4caf50; transform: scale(1.1); }
.session-profit-pill.decrease { color: #f44336; transform: scale(0.92); }

.level-badge { background: #2c313c; padding: 3px 8px; border-radius: 4px; font-size: 0.75em; font-weight: bold; }

.sub-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 5px 0;
  font-size: 0.8em;
  color: #64b5f6;
  font-weight: bold;
  flex-shrink: 0;
}
.progress-pill { background: #1e293b; color: #94a3b8; padding: 2px 8px; border-radius: 10px; font-size: 0.9em; }

.info-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--panel-bg);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.78em;
  color: var(--text-muted);
  flex-shrink: 0;
}
.pot-pill { color: #fff; font-weight: bold; }
.stack-pill { color: #e0e0e0; font-weight: bold; }

/* テーブルエリア */
.table-area {
  background: var(--table-bg);
  border: 2px solid var(--table-border);
  border-radius: 14px;
  padding: 9px 12px;
  margin: 5px 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 7px;
  flex-shrink: 0;
}
.villain-row { display: flex; justify-content: space-between; align-items: center; }
.villain-info { display: flex; align-items: center; gap: 8px; }
.villain-label { font-size: 0.8em; color: #ccc; font-weight: bold; }
.action-bubble {
  background: #28352e;
  border: 1px solid #435b4e;
  color: #fff;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.76em;
  font-weight: bold;
}
.board-area { display: flex; flex-direction: column; align-items: center; padding: 2px 0; }
.area-label { font-size: 0.68em; color: #81c784; letter-spacing: 1px; font-weight: bold; margin-bottom: 3px; }
.hero-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px dashed rgba(255,255,255,0.1);
  padding-top: 7px;
}
.hero-status { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.hero-badge { background: #4a148c; color: #fff; padding: 3px 10px; border-radius: 12px; font-size: 0.74em; font-weight: bold; }
.invest-text { font-size: 0.7em; color: #aaa; }

/* カード */
.cards-container { display: flex; gap: 6px; }
.card {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 52px;
  background-color: #ffffff;
  border-radius: 4px;
  font-size: 1.15em;
  font-weight: bold;
  box-shadow: 0 2px 4px rgba(0,0,0,0.4);
  color: #212121; /* デフォルトを白ではなく濃い黒に指定 */
}
.cards-container.mini .card { width: 32px; height: 44px; font-size: 0.95em; }
.card.back {
  background: repeating-linear-gradient(45deg, #b71c1c, #b71c1c 5px, #880e4f 5px, #880e4f 10px);
  border: 2px solid #e0e0e0;
  color: transparent;
}
.card.reveal { animation: flipCard 0.5s ease forwards; }
/* クラス名が正しく当たっている時のスート色 */
.card.s { color: #212121 !important; } /* スペード: 黒 */
.card.h { color: #d32f2f !important; } /* ハート: 赤 */
.card.d { color: #1976d2 !important; } /* ダイヤ: 青 */
.card.c { color: #2e7d32 !important; } /* クラブ: 緑 */

@keyframes flipCard {
  0% { transform: rotateY(90deg) scale(1.1); }
  100% { transform: rotateY(0deg) scale(1); }
}

/* インタラクションゾーン */
.interaction-zone {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 0;
}
.state-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  animation: fadeIn 0.2s ease-out;
}
.question-prompt {
  font-size: 0.84em;
  font-weight: bold;
  text-align: center;
  color: #fff;
  background: var(--panel-bg);
  padding: 8px 10px;
  border-radius: 6px;
  margin-bottom: 8px;
  line-height: 1.35;
}
.choices-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: auto;
}
.choice-btn {
  background-color: var(--btn-bg);
  color: var(--text-main);
  border: 1px solid #3d4350;
  padding: 13px 6px;
  border-radius: 8px;
  font-size: 0.85em;
  cursor: pointer;
  font-weight: bold;
  text-align: center;
}
.choice-btn:active { transform: scale(0.97); background-color: #383e4a; }

/* フィードバック */
.feedback-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; }
.feedback-grade { font-size: 1.1em; font-weight: 800; }
.feedback-grade.correct { color: var(--correct); }
.feedback-grade.ok { color: var(--ok-color); }
.feedback-grade.wrong { color: var(--incorrect); }
.selected-action-tag { font-size: 0.75em; background: #2c313c; padding: 3px 8px; border-radius: 4px; color: #ccc; }

/* フィードバックメッセージボックスの文字サイズと余白調整 */
.system-message {
  background-color: var(--panel-bg);
  border-left: 4px solid var(--primary);
  padding: 12px 14px;
  border-radius: 6px;
  font-size: 0.95em; /* 0.8emから大幅に拡大（約15pxでクッキリ読める） */
  line-height: 1.5;
  white-space: normal; /* 不要な空行・改行の暴走を防ぐ */
  margin-bottom: 10px;
  flex-grow: 1;
  overflow-y: auto;
}

.next-btn {
  width: 100%;
  color: white;
  border: none;
  padding: 12px;
  border-radius: 8px;
  font-size: 0.95em;
  font-weight: bold;
  cursor: pointer;
  background-color: var(--primary);
  flex-shrink: 0;
}
.next-btn.hand-btn { background-color: #f57c00; }
.share-btn { background-color: var(--correct); }

/* リザルト画面 */
.result-score-card {
  background: var(--panel-bg);
  padding: 12px;
  border-radius: 10px;
  text-align: center;
  margin: 8px 0 12px 0;
  border: 1px solid #2e3440;
}
.emoji-grid {
  font-size: 0.9em;
  background: var(--panel-bg);
  padding: 12px;
  border-radius: 8px;
  line-height: 1.75;
  text-align: center;
  margin-bottom: 14px;
}
.review-item { background: var(--panel-bg); border-radius: 6px; margin-bottom: 8px; overflow: hidden; border: 1px solid #333; }
.review-header { padding: 10px 14px; display: flex; justify-content: space-between; align-items: center; font-weight: bold; cursor: pointer; background: #252830; font-size: 0.82em; }
.review-body { padding: 12px; display: none; border-top: 1px solid #333; }

.premium-banner {
  background: linear-gradient(135deg, #2c2104, #1a1a1a);
  border: 1px solid #cda434;
  border-radius: 8px;
  padding: 15px;
  text-align: center;
  margin-top: 15px;
}
.premium-title { color: #e6c259; font-weight: bold; margin-bottom: 6px; font-size: 0.92em; }
.premium-desc { color: #ccc; font-size: 0.78em; margin-bottom: 12px; line-height: 1.4; }
.buy-btn { background: #cda434; color: #000; border: none; padding: 11px; border-radius: 30px; font-weight: bold; width: 100%; cursor: pointer; }

/* モーダル */
.modal-overlay {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-content {
  background: var(--panel-bg);
  border: 1px solid #383e4c;
  border-radius: 12px;
  width: 100%;
  padding: 16px;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #2e3440;
  padding-bottom: 10px;
  margin-bottom: 14px;
}
.close-modal-btn { background: transparent; border: none; color: #aaa; font-size: 1.1em; cursor: pointer; }
.account-box { background: #14161b; padding: 12px; border-radius: 8px; text-align: center; margin-bottom: 14px; }
.auth-btn { width: 100%; padding: 10px; border-radius: 6px; border: none; font-weight: bold; cursor: pointer; background: var(--primary); color: #fff; }
.menu-links { display: flex; flex-direction: column; gap: 8px; }
.menu-item-btn { background: #252932; border: 1px solid #343a46; color: #ddd; padding: 10px; border-radius: 6px; text-align: left; cursor: pointer; font-size: 0.85em; }
.menu-item-btn.danger { color: #ef5350; border-color: rgba(244,67,54,0.3); }

@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* アクション対比タグ */
.action-comparison {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}
.action-tag {
  font-size: 0.75em;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: bold;
}
.action-tag.user { background: #333; color: #aaa; }
.action-tag.best { background: rgba(76, 175, 80, 0.2); color: #81c784; border: 1px solid #4caf50; }

/* 各セクションの余白を適切に詰める */
.feedback-box-section {
  margin-bottom: 10px;
}
.feedback-box-title {
  font-weight: bold;
  font-size: 1.05em; /* 見出しを強調 */
  margin-bottom: 4px;
}
.feedback-box-title.wrong-title { color: #ff5252; }
.feedback-box-title.best-title { color: #81c784; }

.feedback-box-desc {
  color: #e0e0e0;
  font-size: 0.95em; /* 本文も読みやすいサイズに */
  line-height: 1.5;
  padding-left: 2px;
}