:root {
  --bg: #f4f7f6;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #40B29A;
  --primary-600: #348E7B;
  --primary-light: #E8F5F2;
  --ok: #2D9E85;
  --ng: #dc2626;
  --border: #e5e7eb;
  --accent: #f59e0b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.wrap {
  max-width: 800px;
  margin: 24px auto;
  padding: 16px;
  flex: 1;
  width: 100%;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
  margin-bottom: 16px;
}

h1 {
  font-size: clamp(24px, 4vw, 32px);
  margin: 0 0 12px;
  color: var(--primary-600);
  text-align: center;
}

p.lead {
  color: var(--muted);
  margin: 0 0 16px;
  text-align: center;
  font-size: 18px;
  line-height: 1.5;
}

.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .grid2 {
    grid-template-columns: 1fr 1fr;
  }
}

.row {
  display: flex;
  align-items: stretch;
  flex-wrap: wrap;
}

/* カテゴリ選択ボタン */
.category-btn {
  background: #fff;
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
  font-size: 18px;
  font-weight: bold;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80px;
}

@media (hover: hover) {
  .category-btn:hover {
    border-color: var(--primary-light);
  }
}

.category-btn:active {
  border-color: var(--primary-light);
}

.category-btn.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-600);
  box-shadow: 0 4px 8px rgba(64, 178, 154, 0.1);
}



/* クイズの選択肢ボタン */
.options-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
  margin-bottom: 24px;
}

@media (min-width: 640px) {
  .options-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.option-btn {
  background: #fff;
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
  font-size: clamp(20px, 4vw, 24px);
  font-weight: bold;
  color: var(--text);
}

@media (hover: hover) {
  .option-btn:hover:not(:disabled) {
    border-color: var(--primary);
    background: var(--primary-light);
  }
}

.option-btn:active:not(:disabled) {
  border-color: var(--primary);
  background: var(--primary-light);
}

.option-btn:disabled {
  opacity: 0.8;
  cursor: default;
}

.option-btn.correct {
  background: var(--ok);
  color: #fff;
  border-color: var(--ok);
  animation: pop 0.3s ease-out;
}

.option-btn.wrong {
  background: var(--ng) !important;
  color: #fff !important;
  border-color: var(--ng) !important;
  animation: shake 0.4s;
  opacity: 0.6;
}

/* 共通ボタン */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  appearance: none;
  border: none;
  border-radius: 12px;
  padding: 14px 24px;
  font-size: 20px;
  font-weight: bold;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  transition: all 0.2s;
  min-height: 56px;
  width: 100%;
  max-width: 300px;
}

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

.btn.outline {
  background: transparent;
  color: var(--primary-600);
  border: 2px solid var(--primary);
}

.btn.accent {
  background: var(--accent);
  color: #fff;
}

@media (hover: hover) {
  .btn.accent:hover:not(:disabled) {
    background: #d97706;
  }
}

.btn.accent:active:not(:disabled) {
  background: #d97706;
}

.btn.ghost {
  background: transparent;
  color: var(--muted);
  height: auto;
  padding: 8px;
  font-size: 16px;
  width: auto;
  font-weight: normal;
}

.center-btn {
  display: flex;
  justify-content: center;
  margin-top: 16px;
}

.problem {
  font-size: clamp(24px, 5vw, 36px);
  font-weight: 700;
  text-align: center;
  margin: 16px 0 24px;
  color: var(--primary-600);
  line-height: 1.4;
}

.score {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary-600);
  padding: 6px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 18px;
}

.sep {
  height: 1px;
  background: var(--border);
  margin: 24px 0;
}

.hide {
  display: none !important;
}

.bottom-controls {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: rgba(255, 255, 255, 0.95);
  padding: 16px 16px 24px 16px;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
  z-index: 100;
  backdrop-filter: blur(8px);
}

.bottom-controls.hide {
  display: none !important;
}

.disabled-level {
  opacity: 0.4;
  pointer-events: none;
  filter: grayscale(1);
}

.result {
  text-align: center;
  font-weight: 700;
  margin: 8px 0;
  font-size: 28px;
  min-height: 40px;
}

.result.ok {
  color: var(--ok);
}

.result.ng {
  color: var(--ng);
}

ruby rt {
  font-size: 0.5em;
  color: inherit;
}

/* レベル選択行：ルビ有無のベースライン統一 */
.level-select {
  line-height: 1.4;
}

.level-select label {
  white-space: nowrap;
}

footer {
  text-align: center;
  padding: 24px 16px;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--border);
  background: #fff;
  margin-top: auto;
}

/* ラジオボタンなどのフォーム要素 */
input[type="radio"] {
  transform: scale(1.5);
  margin-right: 6px;
  cursor: pointer;
}

/* アニメーション */
@keyframes pop {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.05);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  20%,
  60% {
    transform: translateX(-5px);
  }

  40%,
  80% {
    transform: translateX(5px);
  }
}