:root {
  color-scheme: light;
  --bg-top: #fef6df;
  --bg-bottom: #edf8ff;
  --surface: rgba(255, 255, 255, 0.84);
  --surface-strong: #ffffff;
  --surface-soft: #f7fbff;
  --ink: #18324a;
  --ink-muted: #5c7488;
  --primary: #2382d9;
  --primary-strong: #115ea8;
  --accent: #ffbf4d;
  --accent-soft: #ffe7ae;
  --border: rgba(27, 93, 145, 0.18);
  --shadow: 0 22px 50px rgba(48, 102, 147, 0.14);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 14px;
  --font-ui: "Avenir Next", "Hiragino Sans", "Yu Gothic", "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  font-family: var(--font-ui);
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 225, 146, 0.4), transparent 24rem),
    radial-gradient(circle at 85% 15%, rgba(125, 205, 255, 0.32), transparent 18rem),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.noscript-notice {
  padding: 1rem 1.25rem;
  background: #fff1f1;
  color: #9f2f2f;
  text-align: center;
  font-weight: 700;
}

.page-shell {
  width: min(100%, 72rem);
  margin: 0 auto;
  padding:
    max(1rem, env(safe-area-inset-top))
    max(1rem, env(safe-area-inset-right))
    max(1.25rem, env(safe-area-inset-bottom))
    max(1rem, env(safe-area-inset-left));
}

.hero {
  text-align: center;
  padding: 1.25rem 0 1rem;
}

.hero-kicker {
  margin: 0 0 0.5rem;
  letter-spacing: 0.2em;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--primary-strong);
}

.hero h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1.15;
}

.hero-copy {
  width: min(100%, 34rem);
  margin: 0.9rem auto 0;
  line-height: 1.7;
  color: var(--ink-muted);
}

.hero-note {
  width: min(100%, 38rem);
  margin: 1rem auto 0;
  padding: 0.85rem 1rem;
  border: 1px solid rgba(35, 130, 217, 0.12);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink-muted);
  line-height: 1.7;
}

.hero-note a {
  color: var(--primary-strong);
  font-weight: 800;
  text-decoration-thickness: 0.12em;
  text-underline-offset: 0.14em;
}

.hero-note a:hover,
.hero-note a:focus-visible {
  color: var(--primary);
}

.app-frame {
  display: grid;
  gap: 1rem;
}

.status-banner,
.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.status-banner {
  padding: 0.9rem 1.1rem;
  font-weight: 700;
}

.screen {
  padding: clamp(1rem, 3vw, 1.5rem);
}

.panel h2 {
  margin: 0;
  font-size: clamp(1.35rem, 3vw, 1.8rem);
}

.section-copy,
.error-message,
.course-range,
.card-hint {
  color: var(--ink-muted);
  line-height: 1.7;
}

.section-head,
.card-topbar,
.control-row,
.card-stage,
.nav-row {
  display: grid;
  gap: 1rem;
}

.section-head {
  margin-bottom: 1rem;
}

.course-intro {
  display: grid;
  gap: 1rem;
}

.summary-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.summary-pill {
  margin: 0;
  padding: 0.65rem 0.95rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(35, 130, 217, 0.15);
  font-weight: 700;
  color: var(--primary-strong);
}

.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 0.9rem;
}

.course-card {
  display: grid;
  gap: 0.55rem;
  width: 100%;
  min-height: 9.2rem;
  padding: 1.1rem;
  border: 1px solid rgba(35, 130, 217, 0.16);
  border-radius: 1.3rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(246, 252, 255, 0.92));
  box-shadow: 0 14px 28px rgba(53, 107, 149, 0.08);
  text-align: left;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.course-card:hover,
.course-card:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 18px 36px rgba(53, 107, 149, 0.14);
  border-color: rgba(35, 130, 217, 0.32);
}

.course-card-label {
  font-size: 1.1rem;
  font-weight: 800;
}

.course-card-range {
  color: var(--ink-muted);
}

.course-card-count {
  align-self: end;
  justify-self: start;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: var(--accent-soft);
  font-weight: 700;
}

.course-meta {
  display: grid;
  gap: 0.35rem;
  align-content: start;
}

.course-meta h2 {
  font-size: clamp(1.25rem, 3vw, 1.65rem);
}

.control-row {
  align-items: stretch;
}

.direction-toggle {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.course-size-toggle {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.button {
  min-height: 3.25rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease, border-color 0.18s ease;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.button:hover:enabled,
.button:focus-visible {
  transform: translateY(-1px);
}

.button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.button-primary {
  color: #ffffff;
  background: linear-gradient(180deg, var(--primary), var(--primary-strong));
  box-shadow: 0 14px 24px rgba(35, 130, 217, 0.22);
}

.button-secondary {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(24, 50, 74, 0.1);
  box-shadow: 0 10px 22px rgba(53, 107, 149, 0.08);
}

.direction-button {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.76);
  border-color: rgba(17, 94, 168, 0.08);
}

.course-size-button {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.76);
  border-color: rgba(17, 94, 168, 0.08);
}

.course-size-button.is-active,
.direction-button.is-active {
  color: #ffffff;
  background: linear-gradient(180deg, #4da6ed, var(--primary));
  box-shadow: 0 14px 24px rgba(35, 130, 217, 0.2);
}

.card-stage {
  justify-items: center;
}

.card-meta {
  width: min(100%, 38rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.card-counter {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
}

.flashcard {
  width: min(100%, 38rem);
  height: clamp(22rem, 60vh, 31rem);
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  perspective: 1500px;
  touch-action: manipulation;
}

.flashcard-core {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.44s cubic-bezier(0.22, 0.7, 0.2, 1);
}

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

.flashcard-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: clamp(1rem, 4vw, 1.5rem);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(35, 130, 217, 0.12);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(244, 250, 255, 0.96));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.7),
    0 26px 44px rgba(53, 107, 149, 0.13);
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.flashcard-back {
  transform: rotateY(180deg);
  background:
    linear-gradient(180deg, rgba(255, 251, 237, 0.98), rgba(248, 251, 255, 0.95));
}

.flashcard-label {
  display: inline-flex;
  align-self: flex-start;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: rgba(17, 94, 168, 0.08);
  color: var(--primary-strong);
  font-size: 0.9rem;
  font-weight: 800;
}

.flashcard-body {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: auto;
  padding: 0.25rem;
  touch-action: pan-y pinch-zoom;
}

.flashcard-value {
  width: 100%;
  margin: auto 0;
  overflow-wrap: anywhere;
}

.flashcard-value[data-kind="word"] {
  align-self: center;
  font-size: clamp(2rem, 8vw, 3.7rem);
  font-weight: 800;
  line-height: 1.15;
  text-align: center;
  letter-spacing: 0.03em;
}

.flashcard-value[data-kind="meaning"] {
  font-size: clamp(1rem, 4.1vw, 1.45rem);
  font-weight: 700;
  line-height: 1.8;
  white-space: pre-wrap;
  text-align: left;
}

.card-hint {
  margin: 0;
  text-align: center;
}

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

.button:focus-visible,
.flashcard:focus-visible,
.course-card:focus-visible {
  outline: 3px solid rgba(255, 191, 77, 0.9);
  outline-offset: 3px;
}

.is-hidden {
  display: none !important;
}

@media (min-width: 48rem) {
  .section-head,
  .card-topbar,
  .control-row {
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .card-topbar {
    align-items: start;
  }
}

@media (max-width: 40rem) {
  .page-shell {
    padding-top: max(0.75rem, env(safe-area-inset-top));
  }

  .flashcard {
    height: clamp(21rem, 57vh, 28rem);
  }

  .card-meta {
    width: 100%;
  }
}
