:root {
  color-scheme: light;
  font-family: "Hiragino Sans", "Yu Gothic", Meiryo, sans-serif;
  color: #163c35;
  background: #173d37;
  --paper: #fff9eb;
  --ink: #173d37;
  --rust: #a13736;
  --yellow: #ffdc80;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible + span, h2:focus-visible {
  outline: 3px solid #237b9d;
  outline-offset: 4px;
}

main { width: min(100% - 2rem, 63rem); margin: auto; padding: 2rem 0 3rem; }
.masthead {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  isolation: isolate;
  overflow: hidden;
  padding: 1.5rem clamp(1.2rem, 4vw, 3rem);
  background: #a13736;
  color: var(--paper);
  border-radius: 1.6rem 1.6rem 0 0;
}
.masthead::after {
  position: absolute;
  z-index: -1;
  inset: 0;
  content: "";
  background: repeating-linear-gradient(135deg, transparent 0 25px, #ffffff12 25px 26px);
}
.title p { margin: 0; color: var(--yellow); font-size: 1rem; font-weight: 800; letter-spacing: .13em; }
h1 { margin: .25rem 0 0; font-family: "Yu Mincho", "Hiragino Mincho ProN", serif; font-size: clamp(2.4rem, 7vw, 4rem); line-height: 1.12; }
h1 span { display: block; margin-top: .35rem; font: 700 .85rem/1.4 sans-serif; letter-spacing: .12em; }
.blossom { font-size: clamp(3.2rem, 11vw, 7.25rem); color: #ffb0a0; margin-right: 4%; line-height: .9; transform: rotate(-14deg); }
#game, #loading, noscript { background: var(--paper); border-radius: 0 0 1.6rem 1.6rem; }
#loading, noscript { margin: 0; padding: 1.5rem; }
.settings {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .8rem 1.5rem;
  padding: .75rem clamp(.85rem, 4vw, 2.5rem) 1rem;
  border-bottom: 1px solid #e6d8b8;
  background: #f4e8cc;
}
fieldset { margin: 0; padding: 0; border: 0; display: flex; gap: .4rem; }
legend { padding: 0; margin-bottom: .3rem; font-size: .85rem; font-weight: 800; }
label { cursor: pointer; position: relative; }
label input { position: absolute; opacity: 0; }
label span {
  display: grid;
  place-items: center;
  padding: .35rem .8rem;
  min-height: 2.65rem;
  border-radius: 2rem;
  border: 1px solid #bba985;
  font-weight: 750;
  font-size: .92rem;
  background: #fffaf0;
}
label input:checked + span { background: var(--ink); border-color: var(--ink); color: white; }
.play, .summary { padding: 1rem clamp(.65rem, 4vw, 2.5rem) 1.4rem; }
.progress-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .55rem; font-weight: 800; }
.progress-dots { display: flex; gap: clamp(.16rem, .7vw, .4rem); }
.progress-dots i { width: clamp(.42rem, 1.3vw, .75rem); aspect-ratio: 1; border-radius: 50%; background: #ddcfad; }
.progress-dots .active { background: var(--rust); }
.progress-dots .done { background: #3d7363; }
.stars { color: #835105; }
.listen { text-align: center; margin: 1.2rem 0; }
.listen h2 { margin: 0 0 .75rem; font-size: clamp(1rem, 3vw, 1.3rem); }
#listen, .action {
  border: 0;
  border-radius: 2rem;
  padding: .7rem 1.3rem;
  min-height: 2.85rem;
  color: white;
  background: var(--rust);
  box-shadow: 0 4px 0 #6f2022;
  font-weight: 800;
}
#listen span { color: var(--yellow); padding-right: .25rem; }
.text-button {
  display: block;
  margin: .55rem auto 0;
  width: fit-content;
  min-height: 2rem;
  background: none;
  border: 0;
  text-decoration: underline;
  color: var(--ink);
}
#prompt { margin: .3rem 0; font-weight: 800; }
#audio-status { margin: .2rem 0 0; color: #873132; }
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(.4rem, 2vw, 1.1rem); }
.card {
  display: grid;
  grid-template-rows: auto minmax(clamp(10.5rem, 23vw, 14rem), 1fr) 1.25rem;
  justify-items: center;
  align-items: center;
  gap: .55rem;
  padding: clamp(.3rem, 1.2vw, .75rem);
  background: #fffef6;
  color: var(--ink);
  border: 4px double #8eaa93;
  border-radius: .65rem;
  box-shadow: 0 .28rem 0 #c6b48f;
}
.card:not([aria-disabled="true"]):hover { border-color: #a13736; background: #fff1d2; }
.card-art {
  display: block;
  width: min(100%, 10rem);
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: .35rem;
  background: #f4e8cc;
}
.card-text {
  writing-mode: vertical-rl;
  white-space: nowrap;
  font: 700 clamp(.94rem, 3.2vw, 1.55rem)/1.5 "Yu Mincho", "Hiragino Mincho ProN", "Noto Serif CJK JP", serif;
  letter-spacing: .045em;
}
.card-text span { display: block; }
.card[aria-disabled="true"] { cursor: default; }
.card.wrong { border-color: #87433a; background: #f6e3dd; }
.card.correct { border-color: #267050; background: #e6f4d9; }
.card-mark { color: #8f3b30; font-size: .95rem; font-weight: 800; }
.correct .card-mark { color: #205b42; }
.response { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: .45rem 1rem; padding-top: 1rem; min-height: 4rem; }
#feedback { margin: 0; font-weight: 800; }
.summary { text-align: center; min-height: 22rem; padding-top: 2rem; }
.summary > span { font-size: 4rem; color: var(--rust); }
.summary h2 { margin: 0; }
.summary p { margin: 1rem 0 1.5rem; }
@media (max-width: 430px) {
  main { width: calc(100% - 1rem); padding: .5rem 0 1rem; }
  .settings { gap: .55rem; }
  .progress-row { font-size: .85rem; }
}
@media (prefers-reduced-motion: no-preference) {
  .card.correct { animation: pop .24s ease-out; }
  @keyframes pop { 50% { transform: translateY(-.35rem); } }
}
