:root {
  --bg1: #f5fbff;
  --bg2: #fff8ef;
  --panel: #ffffff;
  --text: #22304a;
  --muted: #6b7890;
  --primary: #4e7cff;
  --primary-dark: #335fd8;
  --correct: #24b26b;
  --wrong: #ef5c5c;
  --border: #dbe5f4;
  --shadow: 0 10px 24px rgba(54, 84, 125, 0.12);
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
  background: linear-gradient(180deg, var(--bg1), var(--bg2));
  color: var(--text);
}

body {
  min-height: 100vh;
}

button {
  font: inherit;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 16px;
}

.app-header {
  text-align: center;
  margin: 8px 0 16px;
}

.app-header h1 {
  margin: 0;
  font-size: 1.9rem;
  color: var(--primary-dark);
}

.subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
  animation: fadeIn 0.25s ease;
}

.panel {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(219, 229, 244, 0.9);
}

.setting-block + .setting-block {
  margin-top: 18px;
}

.setting-block h3,
.board-block h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.choice-grid {
  display: grid;
  gap: 10px;
}

.subject-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.subject-grid .choice-btn:last-child {
  grid-column: span 2;
}

.level-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.choice-grid.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.choice-btn {
  min-height: 54px;
  background: #f3f7ff;
  color: var(--text);
  border-radius: 16px;
  border: 2px solid transparent;
  font-weight: 700;
  transition: transform 0.15s ease, background 0.15s ease, border 0.15s ease;
  padding: 8px 10px;
}

.choice-btn:active {
  transform: scale(0.98);
}

.choice-btn.selected {
  background: #e8f0ff;
  border-color: var(--primary);
  color: var(--primary-dark);
}

.mode-grid {
  display: grid;
  gap: 12px;
}

.big-action-btn {
  min-height: 88px;
  border-radius: 18px;
  color: white;
  font-size: 1.12rem;
  font-weight: 800;
  text-align: center;
  padding: 14px;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12);
  transition: transform 0.15s ease, filter 0.15s ease;
}

.big-action-btn span {
  display: block;
  margin-top: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  opacity: 0.95;
}

.big-action-btn:active {
  transform: scale(0.98);
}

.quiz-color {
  background: linear-gradient(135deg, #7b93ff, #5f7cff);
}

.folder-color {
  background: linear-gradient(135deg, #ff9e7a, #ff7d61);
}

.note-box {
  margin-top: 18px;
  background: #fff8d8;
  border: 1px solid #f4e0a0;
  border-radius: 16px;
  padding: 12px 14px;
  color: #6a5a1f;
  font-size: 0.92rem;
  line-height: 1.7;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--primary);
  color: white;
  font-weight: 700;
  font-size: 0.9rem;
}

.badge.soft {
  background: #e9f0ff;
  color: var(--primary-dark);
}

.small-btn,
.primary-btn,
.secondary-btn {
  min-height: 46px;
  border-radius: 14px;
  padding: 0 16px;
  font-weight: 700;
}

.small-btn {
  background: #eef3fb;
  color: var(--text);
}

.primary-btn {
  width: 100%;
  background: var(--primary);
  color: white;
  margin-top: 14px;
}

.secondary-btn {
  width: 100%;
  background: #fff0d6;
  color: #8d5f00;
  margin-top: 10px;
}

.primary-btn:active,
.secondary-btn:active,
.small-btn:active {
  transform: scale(0.98);
}

.progress-text {
  font-size: 1rem;
  font-weight: 800;
  color: var(--primary-dark);
  margin-bottom: 12px;
}

.question-box {
  background: #f6f9ff;
  border: 2px solid #e2ebff;
  border-radius: 18px;
  padding: 18px;
  font-size: 1.18rem;
  font-weight: 800;
  line-height: 1.65;
  text-align: center;
}

.choices-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.quiz-choice {
  min-height: 56px;
  background: white;
  border-radius: 16px;
  border: 2px solid var(--border);
  color: var(--text);
  font-weight: 800;
  padding: 12px 14px;
  text-align: left;
}

.quiz-choice.correct {
  background: #e9fff3;
  border-color: var(--correct);
  color: #11623a;
}

.quiz-choice.wrong {
  background: #fff0f0;
  border-color: var(--wrong);
  color: #933737;
}

.quiz-choice:disabled {
  opacity: 1;
}

.feedback {
  margin-top: 14px;
  border-radius: 16px;
  padding: 14px;
  line-height: 1.6;
  font-weight: 700;
}

.feedback.info {
  background: #eef6ff;
  color: #225289;
}

.feedback.correct {
  background: #eafbf1;
  color: #15633a;
}

.feedback.wrong {
  background: #fff2f2;
  color: #8f3c3c;
}

.streak-box {
  margin-top: 12px;
  background: #fff7d6;
  color: #7a6110;
  border-radius: 14px;
  padding: 10px 12px;
  font-weight: 800;
  text-align: center;
}

.instruction {
  margin: 4px 0 10px;
  color: var(--muted);
  font-size: 0.94rem;
}

.board-block + .board-block {
  margin-top: 18px;
}

.cards-area {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  min-height: 86px;
  padding: 10px;
  background: #f8fbff;
  border: 2px dashed #cfe0ff;
  border-radius: 18px;
}

.card-item {
  min-height: 52px;
  min-width: 86px;
  padding: 12px 14px;
  background: white;
  border: 2px solid #d7e2f3;
  border-radius: 16px;
  box-shadow: 0 6px 12px rgba(96, 124, 168, 0.08);
  font-weight: 800;
  color: var(--text);
  user-select: none;
  touch-action: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.card-item.selected {
  border-color: #ff8c66;
  background: #fff4ee;
  transform: scale(1.03);
}

.card-item.placed {
  background: #f4fff8;
  border-color: #9fe2bc;
  min-width: auto;
  padding: 10px 12px;
  box-shadow: none;
}

.cards-empty {
  color: var(--muted);
  font-weight: 700;
  padding: 10px 4px;
}

.folders-area {
  display: grid;
  gap: 12px;
}

.folder-drop {
  background: #fffdf7;
  border: 2px solid #ffd9b8;
  border-radius: 20px;
  padding: 12px;
  min-height: 112px;
  transition: transform 0.12s ease, border 0.12s ease, background 0.12s ease;
}

.folder-drop.hover {
  border-color: #ff8c66;
  background: #fff3eb;
  transform: scale(1.01);
}

.folder-title {
  font-weight: 900;
  color: #b85d23;
  margin-bottom: 10px;
}

.folder-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.folder-placeholder {
  color: #b39a86;
  font-size: 0.92rem;
  font-weight: 700;
}

.drag-ghost {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.92;
  transform: translate(-50%, -50%) scale(1.04);
  box-shadow: 0 14px 26px rgba(48, 70, 109, 0.18);
}

.result-summary {
  font-size: 1.45rem;
  font-weight: 900;
  color: var(--primary-dark);
  text-align: center;
  margin: 12px 0 10px;
}

.result-message {
  text-align: center;
  font-size: 1.08rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.result-extra {
  background: #f7faff;
  border: 1px solid #e0eaf9;
  border-radius: 16px;
  padding: 12px;
  color: var(--text);
  line-height: 1.7;
  white-space: pre-line;
}

.result-actions {
  margin-top: 16px;
}

.hidden {
  display: none !important;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 640px) {
  .mode-grid {
    grid-template-columns: 1fr 1fr;
  }

  .folders-area {
    grid-template-columns: 1fr 1fr;
  }
}
