:root {
  --yellow: #ffd83d;
  --yellow-soft: #fff4a8;
  --ink: #202124;
  --black: #171717;
  --red: #e64a3d;
  --blue: #2d6cdf;
  --cream: #fffdf1;
  --line: rgba(23, 23, 23, 0.14);
  --shadow: 0 18px 50px rgba(33, 31, 14, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at top right, rgba(230, 74, 61, 0.22), transparent 28rem),
    linear-gradient(145deg, var(--yellow) 0%, #fff07a 42%, #fff9d7 100%);
  color: var(--ink);
  font-family: "Inter", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 2px 16px;
}

.eyebrow {
  margin: 0 0 6px;
  color: #3b3516;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  color: var(--black);
  font-size: clamp(28px, 7vw, 50px);
  line-height: 1.05;
  letter-spacing: 0;
}

.bolt-badge {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border: 4px solid var(--black);
  border-radius: 50%;
  background: var(--red);
  color: white;
  font-size: 28px;
  box-shadow: 5px 5px 0 var(--black);
}

.stats,
.tabs,
.panel,
.quiz-card {
  border: 3px solid var(--black);
  box-shadow: 6px 6px 0 var(--black);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  overflow: hidden;
  background: var(--cream);
  border-radius: 8px;
}

.stats div {
  padding: 14px 8px;
  text-align: center;
}

.stats div + div {
  border-left: 2px solid var(--line);
}

.stats span {
  display: block;
  font-size: 22px;
  font-weight: 900;
}

.stats small {
  color: #5b5330;
  font-size: 12px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 18px;
  padding: 6px;
  border-radius: 999px;
  background: var(--black);
}

.tab {
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: white;
  font-weight: 900;
}

.tab.is-active {
  background: var(--yellow);
  color: var(--black);
}

.panel {
  display: none;
  margin-top: 18px;
  border-radius: 12px;
  background: rgba(255, 253, 241, 0.9);
  padding: 18px;
}

.panel.is-active {
  display: block;
}

.card-wrap {
  perspective: 1200px;
}

.flashcard {
  position: relative;
  display: block;
  width: 100%;
  min-height: 390px;
  border: 0;
  background: transparent;
  transform-style: preserve-3d;
  transition: transform 220ms ease;
}

.flashcard.is-flipped {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  min-height: 390px;
  padding: 26px;
  border: 4px solid var(--black);
  border-radius: 18px;
  backface-visibility: hidden;
  box-shadow: var(--shadow);
  text-align: left;
}

.card-front {
  background: linear-gradient(160deg, #fffdf1, var(--yellow-soft));
}

.card-back {
  background: linear-gradient(160deg, #fff, #eaf2ff);
  transform: rotateY(180deg);
}

.tag {
  align-self: flex-start;
  border: 2px solid var(--black);
  border-radius: 999px;
  background: var(--yellow);
  padding: 6px 12px;
  color: var(--black);
  font-size: 13px;
  font-weight: 900;
}

.prompt,
.answer {
  color: var(--black);
  font-family: "Yu Gothic", "Hiragino Sans", "Meiryo", "Microsoft YaHei", sans-serif;
  font-size: clamp(48px, 13vw, 92px);
  line-height: 1.05;
  word-break: keep-all;
}

.hint,
.kana-line,
.meaning,
.note,
.watch {
  font-size: clamp(16px, 3.8vw, 21px);
  line-height: 1.55;
}

.hint,
.kana-line {
  color: #5f5424;
  font-weight: 800;
}

.meaning {
  color: var(--blue);
  font-weight: 900;
}

.note,
.watch {
  border-left: 5px solid var(--yellow);
  padding-left: 12px;
}

.watch {
  border-left-color: var(--red);
}

.actions,
.secondary-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.actions button,
.secondary-actions button,
.option,
.search-row input {
  border: 3px solid var(--black);
  border-radius: 8px;
}

.primary-btn,
.icon-btn,
.secondary-actions button,
.option {
  min-height: 48px;
  background: white;
  color: var(--black);
  font-weight: 900;
  box-shadow: 4px 4px 0 var(--black);
}

.primary-btn {
  flex: 1;
  background: var(--red);
  color: white;
}

.icon-btn {
  width: 64px;
  background: var(--yellow);
  font-size: 22px;
}

.icon-btn.wide {
  width: auto;
  flex: 1;
}

.secondary-actions {
  flex-wrap: wrap;
}

.secondary-actions button {
  flex: 1 1 120px;
  background: #fffdf1;
  padding: 0 12px;
}

.quiz-card {
  border-radius: 16px;
  background: #fff;
  padding: 18px;
}

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

.quiz-card h2 {
  margin: 24px 0;
  font-size: clamp(42px, 12vw, 84px);
  line-height: 1.08;
}

.options {
  display: grid;
  gap: 12px;
}

.option {
  width: 100%;
  padding: 14px;
  text-align: left;
  background: var(--cream);
}

.option.is-correct {
  background: #d7ffd8;
}

.option.is-wrong {
  background: #ffd8d3;
}

.feedback,
.result {
  min-height: 34px;
  margin-top: 14px;
  color: #3c3515;
  font-weight: 800;
  line-height: 1.5;
}

.search-row input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  background: #fff;
}

.word-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.word-item {
  border: 2px solid var(--black);
  border-radius: 10px;
  background: #fff;
  padding: 14px;
}

.word-item strong {
  display: block;
  margin-bottom: 4px;
  font-size: 22px;
}

.word-item p {
  margin: 5px 0 0;
  color: #403a22;
  line-height: 1.55;
}

@media (min-width: 760px) {
  .app-shell {
    padding-top: 32px;
  }

  .panel {
    padding: 24px;
  }

  .options {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 430px) {
  .flashcard,
  .card-face {
    min-height: 430px;
  }

  .actions {
    position: sticky;
    bottom: 10px;
    z-index: 2;
    padding: 8px;
    border: 3px solid var(--black);
    border-radius: 12px;
    background: rgba(255, 216, 61, 0.94);
  }
}
