:root {
  color-scheme: light;
  --bg: #fff7e8;
  --surface: #ffffff;
  --ink: #1f2933;
  --muted: #718096;
  --line: #e8edf3;
  --orange: #ff9f1c;
  --orange-dark: #f57c00;
  --green: #58cc02;
  --green-dark: #3fa900;
  --blue: #1cb0f6;
  --red: #ff4b4b;
  --shadow: 0 18px 42px rgba(31, 41, 51, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: "Arial", "Hiragino Sans", "Yu Gothic", sans-serif;
  letter-spacing: 0;
  background: linear-gradient(180deg, #fffaf0 0%, #fff7e8 52%, #effbe7 100%);
}

button {
  font: inherit;
}

.app-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px max(22px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--orange-dark);
  font-size: 0.78rem;
  font-weight: 800;
}

h1 {
  margin: 0;
  font-size: 1.78rem;
  line-height: 1.05;
}

.streak-badge {
  display: grid;
  place-items: center;
  min-width: 70px;
  height: 70px;
  border: 3px solid #ffd18a;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 8px 0 #ffd18a;
  font-weight: 900;
}

.streak-badge span {
  font-size: 1.2rem;
  line-height: 1;
}

.streak-badge small {
  color: var(--muted);
  font-size: 0.68rem;
}

.summary-panel {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.summary-panel > div {
  min-width: 0;
  padding: 12px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  text-align: center;
}

.summary-number {
  display: block;
  font-size: 1.35rem;
  font-weight: 900;
}

.summary-number.weak {
  color: var(--red);
}

.summary-label {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.primary-button,
.secondary-button,
.ghost-button,
.wrong-button,
.correct-button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.14s ease, filter 0.14s ease;
  touch-action: manipulation;
}

.primary-button:active,
.secondary-button:active,
.ghost-button:active,
.wrong-button:active,
.correct-button:active,
.card:active {
  transform: translateY(2px);
}

.primary-button {
  color: #fff;
  background: var(--green);
  box-shadow: 0 6px 0 var(--green-dark);
}

.secondary-button {
  color: #fff;
  background: var(--orange);
  box-shadow: 0 6px 0 var(--orange-dark);
}

.ghost-button {
  grid-column: 1 / -1;
  color: #45515f;
  border: 2px solid #d7e2eb;
  background: #fff;
  box-shadow: 0 4px 0 #d7e2eb;
}

.button-icon {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin-right: 4px;
}

.lesson-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
  margin-bottom: 16px;
}

.lesson-chip {
  min-width: 0;
  padding: 8px 4px;
  border: 1px solid #f3d8ab;
  border-radius: 8px;
  background: #fff;
  color: #5f6875;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 900;
}

.lesson-chip span {
  display: block;
  margin-top: 2px;
  color: var(--orange-dark);
  font-size: 0.86rem;
}

.study-area {
  padding: 16px;
  border: 1px solid rgba(88, 204, 2, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.session-head {
  display: grid;
  grid-template-columns: 1fr 86px;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.session-head p {
  margin: 0 0 2px;
  color: var(--green-dark);
  font-size: 0.78rem;
  font-weight: 900;
}

.session-head strong {
  font-size: 1rem;
}

.mini-meter {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf3;
}

.mini-meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--blue));
  transition: width 0.22s ease;
}

.card {
  position: relative;
  display: block;
  width: 100%;
  min-height: 310px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  perspective: 1200px;
  cursor: pointer;
  touch-action: manipulation;
}

.card-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 26px 22px;
  border: 3px solid #252f3b;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 0 #252f3b;
  backface-visibility: hidden;
  transform-style: preserve-3d;
  transition: transform 0.34s ease;
}

.card-back {
  border-color: var(--green-dark);
  box-shadow: 0 8px 0 var(--green-dark);
  transform: rotateY(180deg);
}

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

.card.is-flipped .card-back {
  transform: rotateY(360deg);
}

.lesson-pill {
  position: absolute;
  top: 18px;
  left: 18px;
  padding: 7px 10px;
  border-radius: 999px;
  background: #fff0d1;
  color: var(--orange-dark);
  font-size: 0.76rem;
  font-weight: 900;
}

.card-kicker {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.term,
.meaning {
  display: block;
  max-width: 100%;
  text-align: center;
  line-height: 1.22;
  text-wrap: balance;
  overflow-wrap: break-word;
}

.term {
  font-size: 2.08rem;
  font-weight: 900;
}

.meaning {
  font-size: 1.62rem;
  font-weight: 900;
}

.pos-badge {
  min-width: 48px;
  padding: 7px 12px;
  border-radius: 999px;
  background: #e8f8df;
  color: var(--green-dark);
  font-size: 1rem;
  font-weight: 900;
}

.tap-hint {
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 800;
}

.answer-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.wrong-button {
  color: #fff;
  background: var(--red);
  box-shadow: 0 6px 0 #cf3030;
}

.correct-button {
  color: #fff;
  background: var(--green);
  box-shadow: 0 6px 0 var(--green-dark);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: max(18px, env(safe-area-inset-bottom));
  left: 18px;
  width: min(420px, calc(100% - 36px));
  margin: 0 auto;
  padding: 13px 15px;
  border-radius: 8px;
  background: #252f3b;
  color: #fff;
  text-align: center;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 380px) {
  .app-shell {
    padding-right: 12px;
    padding-left: 12px;
  }

  .term {
    font-size: 1.78rem;
  }

  .meaning {
    font-size: 1.38rem;
  }

  .card {
    min-height: 292px;
  }
}
