:root {
  --page-bg: #f5f1e8;
  --surface: #fffdf8;
  --surface-alt: #e8efe6;
  --text: #243128;
  --muted: #6f7c72;
  --accent: #2f6f4e;
  --accent-dark: #23563c;
  --border: #d7ddd6;
  --shadow: 0 18px 40px rgba(44, 58, 49, 0.12);
  --radius-lg: 24px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--page-bg);
  color: var(--text);
}

button,
select {
  font: inherit;
}

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

.app-shell {
  width: min(100%, 480px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 18px 32px;

  display: flex;
  flex-direction: column;
}

.app-header {
  margin-bottom: 24px;
}

.header-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.header-copy {
  flex: 1;
  min-width: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  margin: 0;

  font-size: clamp(1.1rem, 9vw, 2.1rem);
  line-height: 1;
  letter-spacing: -0.04em;
}

.subtitle {
  position: relative;
  margin: 18px 0 0;
}

.artifact-sprite {
  flex: 0 0 auto;

  width: clamp(115px, 30vw, 145px);
  aspect-ratio: 4 / 3;

  background-image: url("img/artifact_sprites.png");
  background-repeat: no-repeat;
  background-size: 300% 300%;

  image-rendering: pixelated;

  cursor: help;
}

.audio-info-button {
  margin-left: 3px;
  padding: 2px;

  border: 0;
  background: none;

  font-size: 0.9em;
  line-height: 1;

  cursor: pointer;
  opacity: 0.7;
}

.audio-info-button:hover {
  opacity: 1;
}

.audio-info-message {
  position: absolute;
  z-index: 10;
  top: calc(100% + 8px);
  left: 0;

  max-width: 280px;
  padding: 9px 12px;

  background: #2f3832;
  color: white;

  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);

  font-size: 0.78rem;
  line-height: 1.4;
}

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

.controls label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
}

select {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
}

.study-mode {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin-top: 6px;
  padding: 4px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.mode-option {
  position: relative;
  cursor: pointer;
}

.mode-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-option span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 6px 8px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
}

.mode-option input:checked + span {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 2px 8px rgba(44, 58, 49, 0.1);
}

.mode-option input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.flashcard-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 390px;
}

.flashcard {
  width: 100%;
  height: clamp(290px, 62vh, 390px);
  padding: 0;
  border: 0;
  background: transparent;
  perspective: 1200px;
  cursor: pointer;
}

.flashcard:focus-visible {
  outline: 3px solid rgba(47, 111, 78, 0.35);
  outline-offset: 5px;
  border-radius: var(--radius-lg);
}

.flashcard-inner {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  transition: transform 0.45s ease;
  transform-style: preserve-3d;
}

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

.flashcard-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 34px 26px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backface-visibility: hidden;
}

.flashcard-front {
  background: var(--surface);
}

.flashcard-back {
  background: var(--surface-alt);
  transform: rotateY(180deg);
}

.card-label {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.card-text {
  max-width: 100%;
  font-size: clamp(1.8rem, 8vw, 2.8rem);
  font-weight: 750;
  line-height: 1.08;
  letter-spacing: -0.035em;
  text-align: center;
  overflow-wrap: anywhere;
}

.card-pronunciation {
  margin-top: 14px;
  font-size: clamp(1rem, 4.5vw, 1.35rem);
  font-weight: 400;
  line-height: 1.4;
  text-align: center;
  opacity: 0.65;
}

.card-navigation {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
}

.nav-button {
  min-height: 48px;
  padding: 0 16px;
  border-radius: var(--radius-md);
  font-weight: 800;
  cursor: pointer;
}

.nav-button.secondary {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.nav-button.primary {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
}

.nav-button.primary:hover {
  background: var(--accent-dark);
}

.card-counter {
  min-width: 58px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
  text-align: center;
}

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

  .flashcard {
    height: 390px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .flashcard-inner {
    transition: none;
  }
}
