/* ==========================================================================
   漢字フラッシュ style.css
   子ども向け・大きく見やすい・レスポンシブ・画像依存ゼロ(絵文字アイコン)
   ========================================================================== */

:root {
  --bg: #fff8ec;
  --text: #333333;
  --card-bg: #ffffff;
  --shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  --radius: 20px;
  --accent: #ff9f43;
  --accent-dark: #e8871f;
  --gray-btn: #d9d9d9;
  --gray-text: #9a9a9a;

  /* 学年別アクセント色 */
  --grade1: #ff6b6b;
  --grade2: #ff9f43;
  --grade3: #ffd93d;
  --grade4: #6bcB77;
  --grade5: #4dc9ff;
  --grade6: #a37bff;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Kaku Gothic ProN",
    "Yu Gothic", "Meiryo", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

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

.screen {
  display: none;
  min-height: 100vh;
  flex-direction: column;
}

.screen.active {
  display: flex;
}

/* ============ 学年選択画面 ============ */

#screen-select {
  align-items: center;
  padding: 32px 16px 48px;
  text-align: center;
}

.select-header h1 {
  font-size: clamp(28px, 6vw, 44px);
  margin: 0 0 8px;
  color: var(--accent-dark);
}

.select-header .subtitle {
  font-size: clamp(14px, 3vw, 18px);
  color: var(--gray-text);
  margin: 0 0 24px;
}

.continue-hint {
  font-size: 14px;
  color: var(--gray-text);
  margin-top: 8px;
}

.grade-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(140px, 1fr));
  gap: 16px;
  width: 100%;
  max-width: 560px;
}

@media (min-width: 700px) {
  .grade-buttons {
    grid-template-columns: repeat(3, minmax(140px, 1fr));
  }
}

.grade-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 110px;
  padding: 16px 10px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: #fff;
  font-weight: bold;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.grade-btn:active {
  transform: scale(0.96);
}

.grade-btn .grade-name {
  font-size: clamp(18px, 4vw, 24px);
}

.grade-btn .grade-count {
  font-size: clamp(12px, 2.6vw, 15px);
  opacity: 0.9;
}

.grade-btn.grade-1 { background: var(--grade1); }
.grade-btn.grade-2 { background: var(--grade2); }
.grade-btn.grade-3 { background: var(--grade3); color: #5c4b00; }
.grade-btn.grade-4 { background: var(--grade4); }
.grade-btn.grade-5 { background: var(--grade5); }
.grade-btn.grade-6 { background: var(--grade6); }

/* ============ フラッシュ画面 ============ */

#screen-flash {
  height: 100vh;
  height: 100dvh;
}

.flash-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  background: var(--card-bg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  flex-wrap: wrap;
}

.icon-btn {
  min-height: 44px;
  min-width: 44px;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 15px;
  background: #f0f0f0;
}

.icon-btn:active {
  background: #e0e0e0;
}

.icon-btn[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
}

.grade-label {
  font-weight: bold;
  font-size: clamp(14px, 3vw, 18px);
  flex: 1;
  text-align: center;
}

.progress-label {
  font-size: clamp(13px, 2.8vw, 16px);
  color: var(--gray-text);
  min-width: 64px;
  text-align: center;
}

.card-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  overflow-y: auto;
  touch-action: pan-y;
}

.kanji-card {
  width: 100%;
  max-width: 720px;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  user-select: none;
}

.kanji-display {
  font-size: clamp(120px, 42vmin, 320px);
  line-height: 1;
  font-weight: 500;
  color: var(--text);
  text-align: center;
}

.finish-message {
  font-size: clamp(16px, 3.6vw, 22px);
  color: var(--accent-dark);
  font-weight: bold;
  text-align: center;
}

.answer-area {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-top: 2px dashed #eee;
  padding-top: 16px;
}

.answer-row {
  display: flex;
  gap: 10px;
  align-items: baseline;
  font-size: clamp(14px, 3.4vw, 18px);
}

.answer-label {
  flex: 0 0 72px;
  color: var(--accent-dark);
  font-weight: bold;
  font-size: 0.85em;
}

.answer-value {
  flex: 1;
  word-break: break-word;
}

.speak-btn {
  align-self: center;
  margin-top: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  padding: 10px 20px;
}

.speak-btn:active {
  background: var(--accent-dark);
}

.flash-bottombar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  background: var(--card-bg);
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
}

.nav-btn {
  flex: 1;
  min-height: 52px;
  border-radius: 14px;
  background: #f0f0f0;
  font-size: clamp(14px, 3.4vw, 18px);
  font-weight: bold;
}

.nav-btn:active {
  background: #e0e0e0;
}

.nav-btn:disabled {
  color: var(--gray-text);
  background: #f5f5f5;
  opacity: 0.6;
  cursor: default;
}

.answer-btn {
  flex: 1.4;
  min-height: 52px;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  font-size: clamp(15px, 3.6vw, 20px);
  font-weight: bold;
}

.answer-btn:active {
  background: var(--accent-dark);
}

.answer-btn[aria-pressed="true"] {
  background: var(--accent-dark);
}

/* ============ デバッグバッジ ============ */

.debug-badge {
  position: fixed;
  right: 10px;
  bottom: 10px;
  max-width: 45vw;
  max-height: 40vh;
  overflow: auto;
  background: rgba(0, 0, 0, 0.85);
  color: #0f0;
  font-family: monospace;
  font-size: 11px;
  padding: 8px 10px;
  border-radius: 8px;
  z-index: 9999;
  white-space: pre-wrap;
}

.debug-badge.debug-error {
  color: #ff6b6b;
}

/* ============ スマホ横 / 小画面調整 ============ */

@media (max-width: 380px) {
  .answer-label {
    flex-basis: 60px;
  }
}
