:root {
  --bg: #0f172a;
  --panel: #111827;
  --panel-2: #1f2937;
  --line: #334155;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --accent: #22d3ee;
  --accent-2: #38bdf8;
  --ok: #34d399;
  --bad: #fb7185;
  --warn: #fbbf24;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #020617 0%, #0f172a 100%);
  color: var(--text);
  min-height: 100vh;
}

.wrap {
  width: min(920px, calc(100% - 24px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.hero, .card, .modal-panel {
  background: rgba(17, 24, 39, 0.92);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}

.hero {
  padding: 24px;
  margin-bottom: 18px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 12px;
}

h1, h2, h3, p { margin: 0; }

.hero h1 {
  font-size: clamp(28px, 5vw, 42px);
  margin-bottom: 10px;
  line-height: 1.1;
}

.hero p {
  color: var(--muted);
  line-height: 1.7;
}

.tips {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.tip {
  background: rgba(31, 41, 55, 0.9);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
}

.tip strong {
  display: block;
  margin-bottom: 6px;
  font-size: 18px;
}

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

.card {
  padding: 20px;
}

.section-title {
  font-size: 18px;
  margin-bottom: 8px;
}

.section-sub {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
  margin-bottom: 16px;
}

.word-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.word-box {
  background: rgba(31, 41, 55, 0.9);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
}

.word-box h3 {
  font-size: 16px;
  margin-bottom: 10px;
}

.mini-list {
  display: grid;
  gap: 8px;
}

.mini-btn, .play-btn, .choice-btn, .primary-btn, .secondary-btn, .speed-btn, .sentence-control, .mini-icon-btn {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.95);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
  font: inherit;
}

.mini-btn:hover, .play-btn:hover, .choice-btn:hover, .primary-btn:hover, .secondary-btn:hover, .speed-btn:hover, .sentence-control:hover, .mini-icon-btn:hover {
  transform: translateY(-1px);
  border-color: var(--accent-2);
}

.mini-btn {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.mini-btn-right {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.mini-icon-btn {
  min-width: 42px;
  height: 42px;
  padding: 0 12px;
  border-radius: 12px;
  background: rgba(2, 6, 23, 0.95);
  font-weight: 700;
}

.quiz-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.badge-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  background: rgba(15, 23, 42, 0.95);
}

.quiz-type {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.question-title {
  font-size: clamp(24px, 4vw, 34px);
  margin-bottom: 8px;
}

.question-sub {
  color: var(--muted);
  line-height: 1.7;
  margin-bottom: 18px;
}

.speed-helper {
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.speed-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.speed-btn {
  padding: 10px 14px;
  font-weight: 700;
}

.speed-btn.active {
  border-color: rgba(34, 211, 238, 0.55);
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.2), rgba(56, 189, 248, 0.1));
  color: #f8fafc;
}

.play-area {
  display: grid;
  place-items: center;
  padding: 16px 0 20px;
}

.play-btn {
  width: 124px;
  height: 124px;
  border-radius: 999px;
  font-size: 18px;
  font-weight: 700;
  border-color: rgba(34, 211, 238, 0.4);
  background: radial-gradient(circle at 30% 30%, rgba(34, 211, 238, 0.25), rgba(15, 23, 42, 0.98));
}

.choice-grid {
  display: grid;
  gap: 12px;
}

.choice-grid.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.choice-btn {
  padding: 18px 16px;
  font-size: 18px;
  font-weight: 700;
  min-height: 72px;
}

.choice-btn.correct {
  border-color: rgba(52, 211, 153, 0.75);
  background: rgba(6, 78, 59, 0.45);
}

.choice-btn.wrong {
  border-color: rgba(251, 113, 133, 0.75);
  background: rgba(136, 19, 55, 0.35);
}

.status {
  min-height: 28px;
  margin-top: 14px;
  font-weight: 700;
}

.status.ok { color: var(--ok); }
.status.bad { color: var(--bad); }

.action-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.primary-btn, .secondary-btn {
  padding: 12px 16px;
  font-weight: 700;
}

.primary-btn {
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.2), rgba(56, 189, 248, 0.1));
  border-color: rgba(34, 211, 238, 0.45);
}

.secondary-btn {
  color: var(--muted);
}

.footer-note {
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.practice-card {
  margin-top: 18px;
  padding: 18px;
  border-radius: 20px;
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid rgba(51, 65, 85, 0.9);
}

.sentence-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.sentence-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.sentence-item {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 16px;
  background: rgba(2, 6, 23, 0.4);
}

.sentence-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sentence-text {
  font-size: 17px;
  line-height: 1.6;
}

.sentence-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.sentence-control {
  min-width: 42px;
  height: 42px;
  padding: 0 12px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.95);
  font-weight: 700;
}

.sentence-control.ipa-open {
  border-color: rgba(34, 211, 238, 0.55);
  color: #f8fafc;
}

.sentence-ipa {
  display: none;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(51, 65, 85, 0.8);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
  word-break: break-word;
}

.sentence-ipa.open {
  display: block;
}

.sentence-ja {
  margin-top: 6px;
  font-size: 13px;
  color: #cbd5f5;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 20;
}

.modal.open { display: flex; }

.modal-panel {
  width: min(560px, 100%);
  padding: 22px;
}

.modal-panel h3 {
  font-size: 24px;
  margin-bottom: 10px;
}

.modal-panel p {
  color: var(--muted);
  line-height: 1.7;
  margin-bottom: 16px;
}

.train-box {
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  margin-bottom: 16px;
}

.train-target {
  font-size: 34px;
  font-weight: 800;
  margin-bottom: 8px;
}

.train-progress {
  color: var(--warn);
  font-weight: 700;
  margin-bottom: 10px;
}

.train-meta {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

@media (max-width: 780px) {
  .grid { grid-template-columns: 1fr; }
  .tips, .word-columns, .choice-grid.cols-2 { grid-template-columns: 1fr; }
  .play-btn { width: 104px; height: 104px; }
  .sentence-top { align-items: flex-start; flex-direction: column; }
  .sentence-controls { width: 100%; justify-content: flex-end; }
}