/* ============================================
   MathQuest - ブロック採掘アドベンチャー風デザイン
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;700;800&family=DotGothic16&display=swap');

:root {
  /* 洞窟の奥から鉱石を掘り当てるイメージのパレット */
  --cave-950: #10241c;
  --cave-900: #163326;
  --cave-800: #1f4634;
  --cave-700: #2c5c44;
  --moss-500: #4f8f5b;
  --dirt-600: #8b5a2b;
  --dirt-700: #6e4520;
  --ore-gold: #f4c430;
  --ore-gold-dark: #c9971f;
  --diamond: #4fd7e0;
  --diamond-dark: #2ba7b0;
  --ruby: #e35d5d;
  --paper: #f4f1e8;
  --ink: #1a2620;
  --radius-block: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, var(--cave-950) 0%, var(--cave-900) 45%, var(--cave-800) 100%);
  color: var(--paper);
  font-family: 'Baloo 2', sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.pixel-font {
  font-family: 'DotGothic16', monospace;
  letter-spacing: 0.5px;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid var(--diamond);
  outline-offset: 2px;
}

/* ---------- レイアウト ---------- */
.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 16px 16px 32px;
  display: flex;
  flex-direction: column;
}

/* ---------- ヘッダー(HUD) ---------- */
.hud {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0,0,0,0.25);
  border: 3px solid var(--cave-700);
  border-radius: var(--radius-block);
  padding: 10px 14px;
  margin-bottom: 18px;
}

.hud__level {
  background: var(--ore-gold);
  color: var(--ink);
  font-family: 'DotGothic16', monospace;
  font-weight: 700;
  font-size: 13px;
  border-radius: 8px;
  padding: 6px 10px;
  white-space: nowrap;
}

.hud__xp-track {
  flex: 1;
  height: 14px;
  background: var(--cave-950);
  border-radius: 7px;
  overflow: hidden;
  border: 2px solid var(--cave-700);
}

.hud__xp-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--diamond-dark), var(--diamond));
  transition: width 0.5s ease;
}

.hud__streak {
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 800;
  font-size: 14px;
  color: var(--ore-gold);
  white-space: nowrap;
}

/* ---------- ブロックカード ---------- */
.block-card {
  background: var(--cave-800);
  border: 3px solid var(--cave-700);
  border-radius: var(--radius-block);
  box-shadow: 0 6px 0 rgba(0,0,0,0.35);
  padding: 20px;
}

/* ---------- タイトル画面 ---------- */
.title-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 22px;
}

.title-screen h1 {
  font-family: 'DotGothic16', monospace;
  font-size: 30px;
  line-height: 1.4;
  margin: 0;
  color: var(--ore-gold);
  text-shadow: 3px 3px 0 var(--cave-950);
}

.title-screen p {
  color: var(--paper);
  opacity: 0.85;
  margin: 0;
  font-size: 15px;
}

.pickaxe-icon {
  width: 84px;
  height: 84px;
}

/* ---------- 選択グリッド(学年・単元) ---------- */
.choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
}

.choice-block {
  background: var(--dirt-600);
  border: 3px solid var(--dirt-700);
  border-radius: var(--radius-block);
  color: var(--paper);
  padding: 18px 10px;
  font-weight: 700;
  font-size: 15px;
  box-shadow: 0 5px 0 rgba(0,0,0,0.35);
  transition: transform 0.08s ease;
}
.choice-block:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 rgba(0,0,0,0.35);
}
.choice-block.unit {
  background: var(--cave-700);
  border-color: var(--cave-950);
  grid-column: span 2;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 10px;
}

.start-btn {
  background: var(--moss-500);
  border: 3px solid #2f5b37;
  color: var(--paper);
  font-weight: 800;
  font-size: 17px;
  padding: 16px 40px;
  border-radius: var(--radius-block);
  box-shadow: 0 6px 0 #2f5b37;
}
.start-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #2f5b37; }

/* ---------- 出題画面 ---------- */
.quiz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 13px;
  opacity: 0.8;
}

.question-box {
  font-size: 20px;
  line-height: 1.6;
  font-weight: 700;
  text-align: center;
  padding: 20px 8px;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 14px;
}

.choice-answer-btn {
  background: var(--cave-700);
  border: 3px solid var(--cave-950);
  color: var(--paper);
  border-radius: var(--radius-block);
  padding: 18px 8px;
  font-size: 18px;
  font-weight: 800;
  box-shadow: 0 5px 0 rgba(0,0,0,0.35);
}
.choice-answer-btn:active { transform: translateY(3px); }
.choice-answer-btn.correct { background: var(--moss-500); border-color: #2f5b37; }
.choice-answer-btn.wrong { background: var(--ruby); border-color: #a13a3a; }
.choice-answer-btn:disabled { opacity: 0.55; }

/* ---------- フィードバック ---------- */
.feedback {
  margin-top: 16px;
  border-radius: var(--radius-block);
  padding: 16px;
  animation: pop 0.25s ease;
}
.feedback.correct { background: rgba(79,143,91,0.25); border: 2px solid var(--moss-500); }
.feedback.wrong { background: rgba(227,93,93,0.18); border: 2px solid var(--ruby); }
.feedback h3 { margin: 0 0 8px; font-size: 16px; }
.feedback p { margin: 0; font-size: 14px; line-height: 1.6; opacity: 0.95; }

@keyframes pop {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.next-btn {
  margin-top: 14px;
  width: 100%;
  background: var(--ore-gold);
  color: var(--ink);
  font-weight: 800;
  font-size: 16px;
  padding: 14px;
  border-radius: var(--radius-block);
  box-shadow: 0 5px 0 var(--ore-gold-dark);
}
.next-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ore-gold-dark); }

.back-link {
  display: inline-block;
  margin-top: 18px;
  color: var(--paper);
  opacity: 0.6;
  font-size: 13px;
  text-decoration: underline;
  background: none;
}

/* ---------- ロード中 ---------- */
.loading {
  text-align: center;
  padding: 40px 0;
  opacity: 0.8;
}

.spinner-block {
  width: 28px;
  height: 28px;
  background: var(--ore-gold);
  margin: 0 auto 12px;
  animation: spin-block 1s infinite steps(4);
}
@keyframes spin-block {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.error-box {
  background: rgba(227,93,93,0.15);
  border: 2px solid var(--ruby);
  border-radius: var(--radius-block);
  padding: 14px;
  font-size: 14px;
  text-align: center;
}

/* ---------- 保護者ダッシュボード ---------- */
.admin-body {
  background: var(--paper);
  color: var(--ink);
  font-family: 'Baloo 2', sans-serif;
  margin: 0;
  min-height: 100vh;
}
.admin-wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 18px 60px;
}
.admin-wrap h1 {
  font-family: 'DotGothic16', monospace;
  color: var(--cave-900);
  font-size: 22px;
}
.admin-card {
  background: #fff;
  border: 2px solid #ddd6c5;
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 18px;
}
.stat-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.stat-pill {
  background: var(--cave-900);
  color: var(--paper);
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 700;
  font-size: 14px;
}
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid #eee2cb; }
th { color: #6b6350; font-weight: 700; }
.badge-ok { color: #2f7a3d; font-weight: 700; }
.badge-ng { color: #b3413a; font-weight: 700; }

.admin-form label { display: block; font-size: 13px; font-weight: 700; margin: 10px 0 4px; }
.admin-form input, .admin-form select, .admin-form textarea {
  width: 100%; padding: 10px; border-radius: 8px; border: 1.5px solid #ddd6c5; font-family: inherit; font-size: 14px;
}
.admin-form button {
  margin-top: 14px;
  background: var(--moss-500);
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 700;
}

.login-wrap {
  max-width: 360px;
  margin: 80px auto;
  padding: 0 20px;
  text-align: center;
}
.login-wrap input {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  border: 1.5px solid #ddd6c5;
  font-size: 15px;
  margin: 14px 0;
}
.login-wrap button {
  width: 100%;
  background: var(--cave-900);
  color: #fff;
  padding: 12px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 15px;
}
