:root {
  color-scheme: light;
  font-family: "Arial Rounded MT Bold", "Hiragino Maru Gothic ProN", "Yu Gothic", sans-serif;
  background: #fff3ce;
  color: #33215c;
}

* { box-sizing: border-box; }

body { margin: 0; min-width: 320px; }

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

.app-shell {
  min-height: 100svh;
  padding: max(20px, env(safe-area-inset-top)) 18px max(22px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 10% 7%, #fff 0 3px, transparent 4px),
    radial-gradient(circle at 90% 18%, #fff 0 2px, transparent 3px),
    linear-gradient(150deg, #fff3ce 0%, #ffd9a7 100%);
}

.app-header { text-align: center; }
.eyebrow { margin: 0; color: #8e3b88; font-size: .85rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
h1 { margin: 4px 0; font-size: clamp(1.55rem, 6vw, 2rem); }
.progress { display: inline-block; margin: 0; padding: 5px 13px; border-radius: 999px; background: #fff; color: #6b3e91; font-weight: 800; box-shadow: 0 2px 0 #e3b66b; }

.study-area { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: center; padding: 12px 0; }
.hint, .message { margin: 0 auto 10px; text-align: center; font-size: .95rem; font-weight: 700; }
.message { min-height: 1.4em; margin-top: 12px; margin-bottom: 0; color: #6b3e91; }

.flashcard {
  width: min(100%, 520px);
  aspect-ratio: 1 / 1.08;
  margin: 0 auto;
  padding: 0;
  border: 0;
  border-radius: 28px;
  background: transparent;
  cursor: pointer;
  perspective: 1000px;
  touch-action: manipulation;
}

.flashcard:focus-visible { outline: 5px solid #6d28d9; outline-offset: 4px; }
.card-inner { position: relative; display: block; width: 100%; height: 100%; transition: transform .48s ease; transform-style: preserve-3d; }
.flashcard.is-flipped .card-inner { transform: rotateY(180deg); }
.card-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 7px solid #33215c;
  border-radius: 28px;
  backface-visibility: hidden;
  box-shadow: 0 8px 0 rgba(101, 50, 104, .20);
}
.card-image-face { background: #fff; }
.card-image-face img { width: 100%; height: 100%; object-fit: contain; padding: 6px; }
.card-word-face { padding: 22px; background: #7c3aed; color: white; transform: rotateY(180deg); }
.word-label { font-size: clamp(1rem, 5vw, 1.3rem); font-weight: 700; opacity: .86; }
.word { max-width: 100%; overflow-wrap: anywhere; font-size: clamp(2.5rem, 14vw, 5.6rem); font-weight: 900; line-height: 1.1; text-align: center; text-shadow: 0 4px 0 #4c1d95; }
.tap-label { position: absolute; bottom: 16px; padding: 7px 12px; border-radius: 999px; background: rgba(255,255,255,.91); color: #45286d; font-size: .82rem; font-weight: 800; }
.card-word-face .tap-label { color: #45286d; }

.controls { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; width: min(100%, 520px); margin: auto auto 0; }
.control-button { min-height: 54px; border: 0; border-radius: 16px; padding: 10px 8px; color: #33215c; font-weight: 900; cursor: pointer; box-shadow: 0 4px 0 rgba(78, 42, 90, .25); }
.control-button:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(78, 42, 90, .25); }
.control-button:focus-visible { outline: 4px solid #6d28d9; outline-offset: 2px; }
.secondary { background: #fff; }
.speak { background: #fce34e; }
.shuffle { grid-column: 1 / -1; background: #ff9e3d; }

@media (min-width: 600px) {
  .app-shell { padding-bottom: max(30px, env(safe-area-inset-bottom)); }
  .study-area { max-height: 660px; }
}

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