* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', 'Yu Gothic', 'Meiryo', sans-serif;
  background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
  color: #1f2937;
  min-height: 100vh;
  padding-bottom: 64px; /* バナー広告分の余白 */
}

.app-header {
  text-align: center;
  color: white;
  padding: 24px 16px 12px;
}

.app-header h1 {
  font-size: 1.6em;
  margin-bottom: 4px;
}

.app-header p {
  opacity: 0.8;
  font-size: 0.85em;
}

.screen {
  max-width: 900px;
  margin: 0 auto;
  padding: 16px;
}

.hidden {
  display: none !important;
}

/* ===== TOPカテゴリ画面 ===== */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.category-card {
  background: white;
  border-radius: 12px;
  padding: 18px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.25);
  cursor: pointer;
  transition: transform 0.15s;
  position: relative;
}

.category-card:not(.disabled):hover {
  transform: translateY(-3px);
}

.category-card.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.category-card .icon {
  font-size: 1.8em;
}

.category-card .title {
  font-weight: bold;
  margin-top: 6px;
}

.category-card .progress-bar {
  margin-top: 10px;
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
}

.category-card .progress-fill {
  height: 100%;
  background: #4f46e5;
}

.category-card .progress-label {
  font-size: 0.75em;
  color: #6b7280;
  margin-top: 4px;
}

.coming-soon-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: #6b7280;
  color: white;
  font-size: 0.7em;
  padding: 2px 8px;
  border-radius: 10px;
}

/* ===== カテゴリ詳細(小枠一覧) ===== */
.back-link {
  color: white;
  background: none;
  border: none;
  font-size: 0.95em;
  cursor: pointer;
  margin-bottom: 12px;
  text-decoration: underline;
}

.difficulty-group {
  margin-bottom: 22px;
}

.difficulty-group h3 {
  color: white;
  margin-bottom: 8px;
  font-size: 1.1em;
}

.subset-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}

.subset-card {
  background: white;
  border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.subset-card:hover {
  background: #f3f4f6;
}

.subset-card .subset-title {
  font-weight: bold;
  margin-bottom: 6px;
}

.subset-card .subset-meta {
  font-size: 0.8em;
  color: #6b7280;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tier-badge {
  font-size: 0.75em;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: bold;
}

.tier-badge.GOOD { background: #dbeafe; color: #1d4ed8; }
.tier-badge.GREAT { background: #fef3c7; color: #b45309; }
.tier-badge.FANTASTIC { background: #fce7f3; color: #be185d; }
.tier-badge.none { background: #f3f4f6; color: #9ca3af; }

/* ===== 出題画面 ===== */
.question-card {
  background: white;
  border-radius: 12px;
  padding: 22px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.3);
}

.question-progress {
  font-size: 0.85em;
  color: #6b7280;
  margin-bottom: 6px;
}

.question-tag {
  display: inline-block;
  background: #eef2ff;
  color: #4338ca;
  font-size: 0.75em;
  padding: 3px 10px;
  border-radius: 10px;
  margin-bottom: 10px;
}

.question-text {
  font-size: 1.15em;
  margin-bottom: 16px;
  line-height: 1.6;
}

.media-placeholder {
  background: #f3f4f6;
  border: 2px dashed #d1d5db;
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  color: #9ca3af;
  font-size: 0.85em;
  margin-bottom: 16px;
}

.choice-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.choice-btn {
  text-align: left;
  padding: 12px 16px;
  border-radius: 8px;
  border: 2px solid #e5e7eb;
  background: white;
  cursor: pointer;
  font-size: 1em;
  transition: all 0.15s;
}

.choice-btn:hover:not(:disabled) {
  border-color: #4f46e5;
}

.choice-btn.correct {
  background: #d1fae5;
  border-color: #10b981;
}

.choice-btn.incorrect {
  background: #fee2e2;
  border-color: #ef4444;
}

.choice-btn:disabled {
  cursor: default;
}

.feedback-box {
  margin-top: 18px;
  padding: 14px;
  border-radius: 8px;
  background: #f0f9ff;
  border-left: 4px solid #0284c7;
}

.feedback-box .result-label {
  font-weight: bold;
  margin-bottom: 6px;
}

.reference-box {
  margin-top: 12px;
  padding: 12px;
  background: #fffbeb;
  border-left: 4px solid #f59e0b;
  border-radius: 8px;
  overflow-x: auto;
}

.reference-box table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.9em;
}

.reference-box th, .reference-box td {
  border: 1px solid #e5e7eb;
  padding: 6px 8px;
  text-align: left;
}

.next-btn {
  margin-top: 18px;
  padding: 10px 24px;
  background: #4f46e5;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
}

/* ===== 結果画面 ===== */
.result-card {
  background: white;
  border-radius: 12px;
  padding: 28px;
  text-align: center;
  box-shadow: 0 6px 16px rgba(0,0,0,0.3);
}

.result-score {
  font-size: 3em;
  font-weight: bold;
  color: #4f46e5;
}

.result-count {
  color: #6b7280;
  margin-top: 4px;
}

.result-badge {
  margin-top: 14px;
  font-size: 1.1em;
}

.result-ad-placeholder {
  margin-top: 20px;
  padding: 22px 16px;
  background: #f3f4f6;
  border: 2px dashed #d1d5db;
  border-radius: 8px;
  color: #9ca3af;
  font-size: 0.85em;
}

.result-buttons {
  margin-top: 24px;
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.result-buttons button {
  padding: 12px 20px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-weight: bold;
}

.btn-top { background: #e5e7eb; color: #374151; }
.btn-retry { background: #f59e0b; color: white; }
.btn-next { background: #4f46e5; color: white; }
.btn-next:disabled { background: #c7d2fe; cursor: not-allowed; }

/* ===== 広告プレースホルダー ===== */
.banner-ad-placeholder {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: #374151;
  color: #d1d5db;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8em;
  z-index: 50;
}

.interstitial-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17,24,39,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.interstitial-box {
  background: white;
  border-radius: 12px;
  padding: 40px 50px;
  text-align: center;
}

.interstitial-box .ad-label {
  color: #9ca3af;
  font-size: 0.8em;
  margin-bottom: 10px;
}

.interstitial-box .ad-timer {
  font-size: 2em;
  font-weight: bold;
  color: #4f46e5;
  margin-bottom: 16px;
}

.interstitial-box button {
  padding: 10px 24px;
  background: #4f46e5;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
}

.interstitial-box button:disabled {
  background: #c7d2fe;
  cursor: not-allowed;
}

@media (max-width: 600px) {
  .result-score { font-size: 2.2em; }
  .interstitial-box { padding: 30px 24px; }
}
