/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0a0e1a;
  --bg2:      #111628;
  --surface:  #1a2035;
  --surface2: #222c45;
  --accent:   #00e5ff;
  --accent2:  #ff6b35;
  --gold:     #ffd700;
  --green:    #00e676;
  --red:      #ff3d71;
  --text:     #e8f0ff;
  --text-dim: #7a8aaa;
  --radius:   16px;
  --shadow:   0 8px 32px rgba(0,229,255,0.12);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Noto Sans JP', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== BACKGROUND GLOBE EFFECT ===== */
.bg-globe {
  position: fixed;
  top: -200px; right: -200px;
  width: 700px; height: 700px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 40%,
    rgba(0,229,255,0.06) 0%,
    rgba(0,100,200,0.04) 40%,
    transparent 70%);
  border: 1px solid rgba(0,229,255,0.08);
  animation: rotateGlobe 40s linear infinite;
  pointer-events: none;
  z-index: 0;
}
@keyframes rotateGlobe {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ===== 国旗画像 (flagcdn.com PNG) ===== */
.question-flag-img {
  height: clamp(80px, 20vw, 140px);
  width: auto;
  max-width: 100%;
  border-radius: 6px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.5);
  object-fit: contain;
}
.option-flag-img {
  height: 52px;
  width: auto;
  max-width: 100%;
  border-radius: 4px;
  object-fit: contain;
  pointer-events: none;
}

/* ===== SITE NAV ===== */
.site-nav {
  margin-bottom: 8px;
}
.btn-site-top {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.82rem;
  padding: 6px 14px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  transition: all 0.2s;
}
.btn-site-top:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(0,229,255,0.06);
}

/* ===== ADS ===== */
.ad-banner {
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 8px 16px;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.bottom-ad { border-top: 1px solid rgba(255,255,255,0.04); border-bottom: none; margin-top: 12px; }
/* プレースホルダー（AdSense導入前の表示用） */
.ad-placeholder {
  width: 100%; max-width: 728px;
  height: 90px;
  background: rgba(255,255,255,0.03);
  border: 1px dashed rgba(255,255,255,0.1);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 12px;
}
.ad-placeholder.small {
  max-width: 336px; height: 280px;
  margin: 16px auto;
}
.ad-inline { width: 100%; }
/* AdSense本番コード用: ins要素はwidth:100%で自動リサイズ */
.ad-banner ins.adsbygoogle,
.ad-inline ins.adsbygoogle {
  display: block;
  width: 100%;
}

/* ===== APP WRAPPER ===== */
.app-wrapper {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 16px;
  position: relative;
  z-index: 1;
  min-height: calc(100vh - 200px);
}

/* ===== SCREENS ===== */
.screen { display: none; animation: fadeIn 0.4s ease; }
.screen.active { display: block; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== TITLE SCREEN ===== */
.title-header {
  text-align: center;
  padding: 32px 0 40px;
}
.globe-icon {
  font-size: 64px;
  display: block;
  animation: float 3s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-10px); }
}
.title-main {
  font-family: 'Zen Dots', cursive;
  font-size: clamp(2.4rem, 8vw, 4rem);
  background: linear-gradient(135deg, var(--accent), #4fc3f7, var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 4px;
  margin-top: 8px;
}
.title-sub {
  color: var(--text-dim);
  font-size: 1rem;
  letter-spacing: 6px;
  margin-top: 4px;
  text-transform: uppercase;
}

/* MODE GRID */
.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-bottom: 28px;
}
.mode-card {
  background: var(--surface);
  border: 1px solid rgba(0,229,255,0.12);
  border-radius: var(--radius);
  padding: 22px 16px;
  cursor: pointer;
  transition: all 0.25s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  color: var(--text);
}
.mode-card:hover {
  background: var(--surface2);
  border-color: var(--accent);
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}
.mode-card--special {
  grid-column: 1 / -1;
  flex-direction: row;
  justify-content: center;
  gap: 14px;
  background: linear-gradient(135deg, rgba(0,229,255,0.08), rgba(255,107,53,0.08));
  border-color: rgba(255,107,53,0.3);
}
.mode-card--special:hover {
  border-color: var(--accent2);
  box-shadow: 0 8px 32px rgba(255,107,53,0.2);
}
.mode-icon { font-size: 2rem; }
.mode-name { font-weight: 700; font-size: 1rem; }
.mode-desc { font-size: 0.78rem; color: var(--text-dim); }

/* DIFFICULTY */
.difficulty-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}
.diff-label { color: var(--text-dim); font-size: 0.9rem; }
.diff-btn {
  padding: 8px 22px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.15);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.88rem;
  transition: all 0.2s;
}
.diff-btn.active,
.diff-btn:hover {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  font-weight: 700;
}

/* ===== QUIZ SCREEN ===== */
.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.btn-quit {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--text-dim);
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.82rem;
  transition: all 0.2s;
}
.btn-quit:hover { border-color: var(--red); color: var(--red); }

.progress-info { color: var(--text-dim); font-size: 0.9rem; }

.score-display {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
.score-label { font-size: 0.7rem; color: var(--text-dim); }
#score-value {
  font-family: 'Zen Dots', cursive;
  font-size: 1.4rem;
  color: var(--gold);
  line-height: 1;
}

/* TIMER */
.timer-bar-wrap {
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 6px;
}
.timer-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--green), var(--accent));
  border-radius: 999px;
  transition: width 1s linear, background-color 0.5s;
}
.timer-bar.warning { background: linear-gradient(90deg, var(--accent2), var(--red)); }
.timer-text {
  text-align: right;
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 24px;
}
#timer-count { font-weight: 700; color: var(--accent); }

/* QUIZ CONTENT */
.quiz-content { position: relative; }

.question-label {
  text-align: center;
  font-size: 0.82rem;
  color: var(--accent);
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-bottom: 12px;
  font-weight: 700;
}

.question-display {
  background: var(--surface);
  border: 1px solid rgba(0,229,255,0.12);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
  margin-bottom: 24px;
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.question-flag {
  font-size: clamp(4rem, 16vw, 7rem);
  line-height: 1;
  filter: drop-shadow(0 4px 16px rgba(0,0,0,0.5));
}
.question-text {
  font-size: clamp(1.3rem, 4vw, 2rem);
  font-weight: 900;
  letter-spacing: 1px;
}

/* OPTIONS */
.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.option-btn {
  background: var(--surface);
  border: 2px solid rgba(0,229,255,0.1);
  border-radius: var(--radius);
  padding: 16px 12px;
  cursor: pointer;
  color: var(--text);
  font-family: 'Noto Sans JP', sans-serif;
  font-size: clamp(0.82rem, 2.5vw, 1rem);
  font-weight: 700;
  transition: all 0.18s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  min-height: 70px;
  word-break: break-all;
}
.option-btn:hover:not(:disabled) {
  background: var(--surface2);
  border-color: var(--accent);
  transform: scale(1.02);
}
.option-btn.correct {
  background: rgba(0,230,118,0.15);
  border-color: var(--green);
  color: var(--green);
  animation: pulse-green 0.4s ease;
}
.option-btn.wrong {
  background: rgba(255,61,113,0.12);
  border-color: var(--red);
  color: var(--red);
}
.option-btn:disabled { cursor: default; }
@keyframes pulse-green {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.option-flag { font-size: 1.8rem; }

/* FEEDBACK OVERLAY */
.feedback-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10,14,26,0.92);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
  pointer-events: none;
}
.feedback-overlay.hidden { display: none; }
.feedback-icon { font-size: 4rem; animation: bounceIn 0.4s cubic-bezier(.36,.07,.19,.97); }
@keyframes bounceIn {
  0%   { transform: scale(0); }
  70%  { transform: scale(1.2); }
  100% { transform: scale(1); }
}
.feedback-text { font-size: 1.4rem; font-weight: 900; }
.feedback-text.correct { color: var(--green); }
.feedback-text.wrong   { color: var(--red); }
.feedback-answer { color: var(--text-dim); font-size: 0.9rem; margin-top: 4px; }

/* ===== RESULT SCREEN ===== */
.result-container {
  max-width: 480px;
  margin: 0 auto;
  padding: 32px 16px;
  text-align: center;
}
.result-rank {
  font-size: 5rem;
  margin-bottom: 8px;
  animation: float 3s ease-in-out infinite;
}
.result-title {
  font-family: 'Zen Dots', cursive;
  font-size: 1.6rem;
  color: var(--accent);
  margin-bottom: 20px;
}
.result-score-big {
  background: var(--surface);
  border: 1px solid rgba(255,215,0,0.2);
  border-radius: 20px;
  padding: 24px;
  margin-bottom: 24px;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
}
#result-score {
  font-family: 'Zen Dots', cursive;
  font-size: clamp(2.8rem, 10vw, 4rem);
  color: var(--gold);
}
.result-score-max {
  font-size: 1.2rem;
  color: var(--text-dim);
}

.result-stats {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 24px;
}
.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.stat-num {
  font-family: 'Zen Dots', cursive;
  font-size: 1.8rem;
  color: var(--accent);
}
.stat-label { font-size: 0.78rem; color: var(--text-dim); margin-top: 2px; }

.result-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.btn-primary, .btn-secondary {
  padding: 14px 36px;
  border-radius: 999px;
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #4fc3f7);
  border: none;
  color: var(--bg);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0,229,255,0.35);
}
.btn-secondary {
  background: transparent;
  border: 2px solid rgba(255,255,255,0.2);
  color: var(--text);
}
.btn-secondary:hover {
  border-color: var(--text);
  transform: translateY(-2px);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 520px) {
  .options-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .option-btn { padding: 12px 8px; font-size: 0.8rem; min-height: 64px; }
  .mode-grid { grid-template-columns: 1fr 1fr; }
  .ad-placeholder { height: 60px; font-size: 11px; }
}
@media (max-width: 380px) {
  .options-grid { grid-template-columns: 1fr; }
  .mode-grid { grid-template-columns: 1fr; }
  .mode-card--special { grid-column: 1; }
}
