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

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 8% 5%, #ffe2b8 0 12%, transparent 31%),
    radial-gradient(circle at 92% 13%, #f8d4dc 0 14%, transparent 32%),
    radial-gradient(circle at 70% 92%, #d8efe4 0 16%, transparent 35%),
    linear-gradient(160deg, #fffaf5, #fff3ef 55%, #f4edff);
}

button { font: inherit; }

.app-shell {
  width: min(100%, 580px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(1rem, env(safe-area-inset-top)) 1rem max(1.25rem, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 3.4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 .3rem;
}

.title {
  margin: 0;
  color: #c9768c;
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: .07em;
}

.progress {
  min-width: 4.75rem;
  padding: .45rem .7rem;
  border-radius: 999px;
  background: #fffdf9;
  color: #a7627b;
  text-align: center;
  font-weight: 800;
  box-shadow: 0 3px 12px rgba(170, 105, 129, .16);
}

.study-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 0;
}

.flashcard {
  width: 100%;
  max-width: 430px;
  margin: 0 auto;
  padding: 0;
  border: 0;
  border-radius: 26px;
  background: transparent;
  cursor: pointer;
  perspective: 1100px;
  -webkit-tap-highlight-color: transparent;
}

.flashcard:focus-visible { outline: 4px solid #f0b34d; outline-offset: 5px; }

.card-inner {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 5 / 6;
  transform-style: preserve-3d;
  transition: transform .45s cubic-bezier(.2, .75, .3, 1);
}

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

.card-face {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  overflow: hidden;
  border: 4px solid #e7a6b5;
  border-radius: 26px;
  background: #fff;
  box-shadow: 0 13px 0 rgba(231, 166, 181, .22), 0 21px 35px rgba(143, 92, 109, .16);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.card-front {
  padding: 1.4rem 1.4rem .95rem;
  background: linear-gradient(145deg, #fff7dc, #fffdf8 55%, #f2edff);
}

.card-back {
  padding: .9rem .9rem .75rem;
  transform: rotateY(180deg);
}

.card-content {
  display: grid;
  min-width: 0;
  min-height: 0;
  place-items: center;
}

.card-art-content { padding: .15rem; }

.card-guidance {
  display: grid;
  gap: .2rem;
  width: 100%;
  padding-top: .7rem;
  color: #8b6b79;
  font-size: clamp(.78rem, 3.6vw, .98rem);
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
}

.card-back .card-guidance { color: #7e698d; }

.art-crop {
  position: relative;
  display: block;
  width: min(100%, 22rem);
  height: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 16px;
  background: #fff;
}

.art-crop img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  max-width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
}

.word {
  max-width: 100%;
  overflow-wrap: anywhere;
  color: #785366;
  font-family: "Trebuchet MS", "Arial Rounded MT Bold", sans-serif;
  font-size: clamp(2.7rem, 15vw, 5rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: .02em;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .7rem;
  margin-top: 1.4rem;
}

.control {
  min-height: 3.35rem;
  border: 0;
  border-radius: 16px;
  padding: .6rem .45rem;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.15;
  transition: transform .16s ease, box-shadow .16s ease;
  -webkit-tap-highlight-color: transparent;
}

.control:active { transform: translateY(2px); }
.control:focus-visible { outline: 4px solid #f0b34d; outline-offset: 3px; }

.secondary { background: #fff2ed; color: #985e74; box-shadow: 0 4px 0 #efc1cc; }
.shuffle { grid-column: 1 / -1; background: #a99bdd; color: #fff; box-shadow: 0 4px 0 #887ac5; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (min-height: 760px) {
  .flashcard { max-width: 470px; }
}

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