:root {
  color-scheme: light;
  --ink: #172b43;
  --muted: #52657b;
  --line: #cbd7e5;
  --line-strong: #183c63;
  --paper: #ffffff;
  --page: #f4f7fb;
  --blue: #145b96;
  --blue-dark: #10436f;
  --blue-soft: #e9f3fb;
  --coral: #bd4d48;
  --coral-soft: #fff0ed;
  --shadow: 0 18px 50px rgba(23, 54, 86, 0.1);
  font-family: "Noto Sans JP", "Yu Gothic UI", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* { box-sizing: border-box; }

html { min-width: 320px; min-height: 100%; background: var(--page); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 3%, rgba(209, 230, 247, 0.7), transparent 26rem),
    radial-gradient(circle at 95% 14%, rgba(255, 226, 218, 0.52), transparent 23rem),
    var(--page);
}

button { font: inherit; }
button:focus-visible { outline: 4px solid #e39a38; outline-offset: 4px; }

.app-shell {
  width: min(100% - 32px, 820px);
  margin: 0 auto;
  padding: 26px 0 30px;
}

.site-header {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 64px;
}

.brand-mark { position: relative; width: 54px; height: 54px; flex: 0 0 54px; }
.brand-card {
  position: absolute;
  width: 39px;
  height: 48px;
  border: 2px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
}
.brand-card-back { top: 2px; left: 10px; transform: rotate(9deg); background: #dceaf5; }
.brand-card-front {
  top: 4px;
  left: 3px;
  display: grid;
  place-items: center;
  color: var(--blue-dark);
  font-size: 28px;
  font-weight: 900;
  box-shadow: 0 3px 8px rgba(20, 54, 82, .12);
}
.brand-copy { min-width: 0; }
.eyebrow { margin: 0 0 2px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .08em; }
.brand-copy h1 { margin: 0; font-size: clamp(21px, 4vw, 27px); line-height: 1.15; font-weight: 900; letter-spacing: .03em; }
.header-chip {
  margin-left: auto;
  padding: 8px 12px;
  border: 1px solid #c7d8e8;
  border-radius: 999px;
  color: #254d70;
  background: rgba(255,255,255,.75);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.intro { padding: 25px 0 19px; text-align: center; }
.intro h2 { margin: 0; font-size: clamp(20px, 4vw, 26px); font-weight: 900; letter-spacing: .02em; }
.intro p { margin: 8px 0 0; color: var(--muted); font-size: 14px; line-height: 1.7; }

.deck-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0 auto 18px;
  max-width: 490px;
}
.deck-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 68px;
  padding: 9px 14px;
  border: 2px solid #b8c8d9;
  border-radius: 15px;
  color: #294966;
  background: rgba(255,255,255,.92);
  cursor: pointer;
  transition: border-color .16s ease, background-color .16s ease, transform .16s ease;
}
.deck-button:hover { transform: translateY(-1px); border-color: var(--blue); }
.deck-button.chosen { border-color: var(--blue-dark); color: #fff; background: var(--blue-dark); box-shadow: 0 5px 14px rgba(16,67,111,.18); }
.deck-button-main { font-size: 35px; font-weight: 900; line-height: 1; }
.deck-button-label { font-size: 16px; font-weight: 900; }

.study-panel {
  padding: clamp(16px, 3vw, 26px);
  border: 1px solid #d7e1eb;
  border-radius: 25px;
  background: rgba(255,255,255,.94);
  box-shadow: var(--shadow);
}
.panel-topline { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.panel-kicker { margin: 0 0 3px; color: var(--muted); font-size: 11px; font-weight: 900; letter-spacing: .1em; }
.panel-topline h2 { margin: 0; font-size: 22px; font-weight: 900; }
.deck-description { margin: 5px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.counter {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  flex: 0 0 auto;
  min-width: 76px;
  padding: 8px 12px;
  border: 1px solid #d3e0ec;
  border-radius: 13px;
  background: #f5f9fd;
}
.counter-current { color: var(--blue-dark); font-size: 20px; font-weight: 900; font-variant-numeric: tabular-nums; }
.counter-caption { color: var(--muted); font-size: 10px; font-weight: 700; }
.progress-track { height: 8px; margin: 17px 0 18px; overflow: hidden; border-radius: 999px; background: #e4ebf2; }
.progress-fill { height: 100%; border-radius: inherit; background: #246c9f; transition: width .2s ease; }

.mode-row { display: flex; align-items: center; gap: 12px; }
.mode-heading { color: var(--muted); font-size: 12px; font-weight: 800; white-space: nowrap; }
.mode-buttons { display: inline-flex; padding: 4px; border: 1px solid #cbd9e6; border-radius: 999px; background: #f4f8fb; }
.mode-button {
  min-height: 36px;
  padding: 5px 15px;
  border: 0;
  border-radius: 999px;
  color: #38536c;
  background: transparent;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}
.mode-button.chosen { color: #fff; background: var(--blue-dark); }
.mode-current { margin-left: auto; color: var(--muted); font-size: 11px; font-weight: 700; }

.card-stage { display: flex; flex-direction: column; align-items: center; padding: 21px 0 15px; }
.card-hint { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 10px; color: var(--muted); font-size: 13px; font-weight: 800; }
.hint-dot { width: 8px; height: 8px; border-radius: 50%; background: #d17a38; }
.flashcard {
  display: block;
  width: min(100%, 450px);
  aspect-ratio: 1 / 1;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(27, 52, 77, .13);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.flashcard img { display: block; width: 100%; height: 100%; object-fit: contain; user-select: none; }
.flashcard.is-back {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 12px 17px 15px;
}
.flashcard.is-back img {
  flex: 1 1 auto;
  width: 100%;
  height: calc(100% - 58px);
  min-height: 0;
  object-fit: contain;
}
.card-word-label {
  display: block;
  flex: 0 0 auto;
  width: 100%;
  max-width: 100%;
  padding: 0 5px 2px;
  color: #17324d;
  font-size: clamp(24px, 4vw, 34px);
  font-weight: 900;
  line-height: 1.22;
  text-align: center;
  overflow-wrap: anywhere;
}
.flashcard:active { transform: scale(.995); }
.side-indicator { display: inline-flex; align-items: center; gap: 7px; margin-top: 11px; color: #35516b; font-size: 12px; font-weight: 900; }
.side-indicator-dot { width: 7px; height: 7px; border-radius: 50%; background: #2e7aa8; }
.flashcard.is-back + .side-indicator .side-indicator-dot { background: var(--coral); }

.navigation-row { display: grid; grid-template-columns: 1fr 1.25fr 1fr; gap: 10px; margin-top: 8px; }
.nav-button, .flip-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 54px;
  padding: 10px 12px;
  border: 2px solid transparent;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
  transition: background-color .16s ease, transform .16s ease;
}
.nav-button:active, .flip-button:active, .text-button:active { transform: translateY(1px); }
.nav-secondary { border-color: #c8d5e2; color: #254762; background: #f5f8fb; }
.nav-primary { color: #fff; background: var(--blue-dark); }
.flip-button { color: #fff; background: #b94d46; }
.nav-icon, .flip-icon { font-size: 20px; line-height: 1; }
.nav-button:disabled { cursor: not-allowed; opacity: .4; }
.utility-row { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px 24px; margin-top: 16px; }
.text-button { display: inline-flex; align-items: center; gap: 6px; padding: 7px 4px; border: 0; color: #3c5872; background: transparent; font-size: 12px; font-weight: 800; cursor: pointer; }
.text-button span { font-size: 17px; }

.site-footer { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 19px 3px 0; color: #5c6c7d; font-size: 11px; }
.site-footer p { margin: 0; font-weight: 800; }
.site-footer span { white-space: nowrap; }
.noscript-message { margin: 2rem auto; width: min(90%, 36rem); padding: 1rem; border: 2px solid #183c63; border-radius: 12px; background: #fff; color: #172b43; font-weight: 800; }

@media (max-width: 560px) {
  .app-shell { width: min(100% - 20px, 820px); padding-top: 14px; }
  .site-header { gap: 10px; }
  .brand-mark { width: 46px; height: 48px; flex-basis: 46px; transform: scale(.88); transform-origin: left center; }
  .header-chip { padding: 7px 9px; font-size: 10px; }
  .intro { padding: 19px 4px 15px; }
  .intro p { font-size: 12px; }
  .deck-switch { gap: 8px; margin-bottom: 12px; }
  .deck-button { min-height: 60px; gap: 7px; padding: 8px; }
  .deck-button-main { font-size: 30px; }
  .deck-button-label { font-size: 14px; }
  .study-panel { padding: 15px 12px; border-radius: 19px; }
  .panel-topline h2 { font-size: 19px; }
  .deck-description { max-width: 225px; font-size: 11px; }
  .counter { min-width: 68px; padding: 7px 9px; }
  .counter-current { font-size: 18px; }
  .mode-row { flex-wrap: wrap; gap: 7px 10px; }
  .mode-current { display: none; }
  .card-stage { padding-top: 17px; }
  .flashcard { border-radius: 13px; }
  .flashcard.is-back { padding: 9px 11px 12px; }
  .card-word-label { font-size: clamp(22px, 6vw, 29px); }
  .navigation-row { grid-template-columns: .9fr 1.1fr .9fr; gap: 6px; }
  .nav-button, .flip-button { min-height: 50px; gap: 5px; padding: 8px 5px; font-size: 12px; }
  .nav-icon, .flip-icon { font-size: 17px; }
  .site-footer { align-items: flex-start; flex-direction: column; gap: 4px; padding-top: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* Translation and pronunciation assistance */
.back-assistance {
  display: grid;
  grid-template-columns: minmax(0, .82fr) minmax(0, 1.45fr);
  gap: 12px;
  width: min(100%, 680px);
  margin-top: 15px;
  align-items: stretch;
}
.pronunciation-control,
.translation-panel {
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid #cbd9e7;
  border-radius: 15px;
  background: #f7faff;
}
.front-pronunciation {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: min(100%, 320px);
  margin-top: 12px;
  padding: 9px 14px;
  border: 1px solid #d3dfeb;
  border-radius: 13px;
  background: #f7faff;
}
.back-pronunciation {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}
.assist-heading {
  margin: 0 0 7px;
  color: #38536c;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .02em;
}
.assist-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 7px 13px;
  border: 1px solid #9db8d2;
  border-radius: 999px;
  color: #174c77;
  background: #fff;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}
.assist-toggle:hover { border-color: var(--blue); background: #eef6fd; }
.assist-toggle span { color: #b34a46; font-size: 15px; }
.pronunciation-output {
  margin: 0;
  padding: 7px 10px;
  border-radius: 9px;
  color: #172b43;
  background: #e8f1f9;
  font-family: "Noto Sans", "Noto Sans JP", sans-serif;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.translation-panel {
  border-color: #e4c9c3;
  background: #fff9f7;
}
.translation-heading-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.translation-subtitle {
  margin: -3px 0 0;
  color: #6c5b5a;
  font-size: 11px;
  font-weight: 700;
}
.language-picker {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 130px;
  color: #665453;
  font-size: 10px;
  font-weight: 900;
}
.language-picker select {
  max-width: 100%;
  min-height: 35px;
  padding: 5px 26px 5px 9px;
  border: 1px solid #d7b5af;
  border-radius: 9px;
  color: #563d3b;
  background: #fff;
  font: inherit;
  font-size: 11px;
  font-weight: 800;
}
.translation-sentence {
  margin: 13px 0 0;
  padding: 10px 12px;
  border-left: 4px solid #bd655e;
  border-radius: 8px;
  color: #4d3533;
  background: #ffefec;
  font-size: 14px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}
.translation-sentence strong { color: #6b302c; font-weight: 900; }
.translation-sentence .translated-word { font-size: 17px; }

@media (max-width: 620px) {
  .back-assistance { grid-template-columns: 1fr; gap: 9px; }
  .back-pronunciation { align-items: center; }
  .translation-heading-row { align-items: center; }
  .translation-panel, .pronunciation-control { padding: 12px; }
}

@media (max-width: 380px) {
  .translation-heading-row { align-items: stretch; flex-direction: column; }
  .language-picker { width: 100%; }
  .language-picker select { width: 100%; }
}
