:root {
  font-family: "Trebuchet MS", Arial, sans-serif;
  color: #24454d;
  background: #f7f7ee;
}
* { box-sizing: border-box; }
body { margin: 0; background: radial-gradient(circle at 12% 8%, #fff7da, transparent 32%), #f7f7ee; }
button, input { font: inherit; }
button { cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }
.hidden { display: none !important; }

.screen { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.welcome { width: min(560px, 100%); text-align: center; background: #fff; border: 3px solid #e9e6d8; border-radius: 34px; padding: 28px; box-shadow: 0 12px 0 #e4e5d9; }
.app-mark { width: 82px; height: 82px; border-radius: 20px; }
h1 { font-size: clamp(32px, 5vw, 48px); line-height: 1.1; margin: 16px 0 8px; }
p { font-size: 18px; line-height: 1.45; }
.eyebrow { margin: 14px 0 0; color: #e38b44; font-weight: 900; font-size: 14px; letter-spacing: .13em; }
.home-intro { margin: 12px 0 24px; font-size: 21px; }
.primary, .secondary { border: 0; border-radius: 18px; min-height: 60px; padding: 12px 22px; font-size: 21px; font-weight: 800; width: 100%; margin-top: 14px; }
.primary { background: #197b88; color: white; box-shadow: 0 6px 0 #0e5965; }
.secondary { background: #e8f1ee; color: #185763; box-shadow: 0 6px 0 #c9dbd7; }
.primary:active, .secondary:active, .deck:active, .play:active { transform: translateY(3px); box-shadow: 0 2px 0 #9aa; }
.deck { display: flex; align-items: center; gap: 18px; width: 100%; min-height: 98px; margin-top: 16px; padding: 14px 20px; border: 0; border-radius: 25px; text-align: left; color: #21444b; box-shadow: 0 6px 0 #d7d9ce; }
.deck-challenge { background: #ffdda1; }
.deck-starter { background: #c7ece2; }
.deck-symbol { flex: none; display: grid; place-items: center; width: 62px; height: 62px; border-radius: 19px; background: #ffffffb8; color: #e98732; font-size: 38px; }
.deck-starter .deck-symbol { color: #318c83; }
.deck strong { display: block; font-size: clamp(23px, 4vw, 29px); }
.deck small { display: block; margin-top: 3px; font-size: 16px; color: #547075; }
.login-card label { display: block; text-align: left; font-weight: 800; margin-top: 22px; }
.login-card input { display: block; width: 100%; min-height: 58px; border: 2px solid #b7d1d3; border-radius: 14px; padding: 12px; margin-top: 8px; font-size: 22px; }
.error { color: #a32323; min-height: 1.5em; }
.quiet { color: #5d7379; font-size: 16px; }

#study { height: 100vh; height: 100dvh; max-width: 1100px; margin: auto; display: flex; flex-direction: column; padding: clamp(8px, 1.5vw, 16px); gap: 10px; }
.study-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 70px; }
.play { flex: none; display: flex; align-items: center; justify-content: center; gap: 8px; min-width: 124px; height: 64px; border: 0; border-radius: 22px; background: #197b88; color: #fff; box-shadow: 0 5px 0 #0c5964; font-size: 24px; font-weight: 900; }
.play .speaker { font-size: 29px; }
.play.playing { animation: listening 1.1s ease-in-out infinite; }
.prompt { flex: 1; text-align: center; line-height: 1.2; }
#study-status { font-size: clamp(22px, 3vw, 32px); font-weight: 900; }
.prompt-hint { color: #698185; font-size: 16px; margin-top: 3px; }
.top-right { display: flex; align-items: center; gap: 9px; }
.trophy-count { display: flex; align-items: center; gap: 4px; min-width: 67px; justify-content: center; padding: 8px; border-radius: 18px; background: #fff0c5; font-size: 23px; font-weight: 900; color: #a2631b; }
.gear { flex: none; width: 54px; height: 54px; border: 0; border-radius: 16px; background: #e3ece9; color: #657b7c; font-size: 26px; user-select: none; -webkit-user-select: none; }
.reward-track { display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 47px; border-radius: 18px; background: #fff; border: 2px solid #eee9d8; padding: 6px 14px; }
.reward-track-title { font-size: 16px; font-weight: 900; color: #96601f; white-space: nowrap; }
.reward-dots { display: flex; justify-content: center; gap: clamp(5px, 1vw, 10px); }
.reward-dot { width: clamp(15px, 2.5vw, 21px); height: clamp(15px, 2.5vw, 21px); border-radius: 50%; background: #e9e4d7; border: 2px solid #ded8c9; transition: transform .25s, background .25s; }
.reward-dot.filled { background: #f5bd4c; border-color: #e7a830; transform: scale(1.08); }
.reward-label { min-width: 52px; font-size: 17px; font-weight: 900; color: #8b672e; white-space: nowrap; }
.pictures { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); gap: clamp(8px, 1.5vw, 15px); }
.picture { border: 5px solid #d6e7e3; border-radius: 27px; background: #fff; box-shadow: 0 5px 0 #e3e7dc; overflow: hidden; position: relative; padding: 7px; }
.picture img { position: absolute; inset: 8px; width: calc(100% - 16px); height: calc(100% - 16px); object-fit: contain; }
.picture:focus-visible { outline: 5px solid #e8913d; outline-offset: 2px; }
.picture.correct { border-color: #42aa7b; background: #edfaee; box-shadow: 0 5px 0 #b5dcc3; }
.picture.wrong { border-color: #e99e57; background: #fff1df; box-shadow: 0 5px 0 #e9cfac; }
.picture.correct::after { content: "✓"; position: absolute; right: 12px; top: 8px; display: grid; place-items: center; width: 54px; height: 54px; border-radius: 50%; background: #3ba777; color: white; font-size: 38px; font-weight: 900; box-shadow: 0 3px 0 #25825a; }
.feedback { min-height: 45px; display: grid; place-items: center; text-align: center; font-size: clamp(18px, 2.6vw, 26px); font-weight: 900; }
.done-mark { width: 80px; height: 80px; display: grid; place-items: center; margin: auto; border-radius: 50%; background: #ffdf94; color: #b67623; font-size: 56px; }

.reward-overlay, .overlay { position: fixed; inset: 0; display: grid; place-items: center; padding: 18px; }
.reward-overlay { z-index: 20; background: #205f69b8; }
.reward-card { position: relative; width: min(540px, 100%); max-height: calc(100dvh - 60px); overflow: auto; padding: 25px 24px 30px; text-align: center; background: radial-gradient(ellipse at 50% 30%, #fff0bd, #fffaf0 65%); border: 5px solid #ffd276; border-radius: 38px; box-shadow: 0 14px 0 #c59047, 0 25px 50px #163d4866; animation: trophy-pop .45s cubic-bezier(.2,1.4,.5,1) both; }
.reward-card img { display: block; width: clamp(190px, 40vw, 320px); max-width: 100%; height: auto; margin: 0 auto; transform-origin: 50% 85%; animation: trophy-lift 1s .15s ease-out both; }
.reward-card h2 { margin: 2px 0 6px; font-size: clamp(31px, 5vw, 43px); color: #2c5960; }
.reward-card p { margin: 4px 0; font-weight: 800; }
.reward-kicker { letter-spacing: .15em; color: #df8a35; font-size: 17px; }
#reward-tally { margin-top: 14px; padding: 6px 16px; display: inline-block; border-radius: 20px; background: #fff0c5; color: #9d6426; font-size: 21px; font-weight: 900; }
.reward-spark { position: absolute; color: #d39321; font-size: 52px; animation: sparkle 1.1s ease-in-out 2 alternate; }
.reward-spark-a { left: 23px; top: 55px; }
.reward-spark-b { right: 24px; top: 82px; animation-delay: .35s; }
.overlay { z-index: 30; background: #173b4bc9; }
.parent-box { width: min(460px, 100%); background: white; border-radius: 25px; padding: 24px; text-align: center; }
.parent-box h2 { margin: 4px; font-size: 28px; }
.parent-box a { color: #175f6c; }
.sound-option { display: flex; gap: 12px; align-items: center; justify-content: center; min-height: 48px; font-size: 20px; }
.sound-option input { width: 24px; height: 24px; accent-color: #197b88; }

@keyframes trophy-pop { from { opacity: 0; transform: scale(.65); } to { opacity: 1; transform: scale(1); } }
@keyframes sparkle { to { transform: scale(1.2) rotate(18deg); } }
@keyframes trophy-lift { 0% { transform: translateY(16px) scale(.8); } 45% { transform: translateY(-8px) scale(1.06) rotate(-4deg); } 70% { transform: rotate(3deg); } 100% { transform: none; } }
@keyframes listening { 50% { box-shadow: 0 5px 0 #0c5964, 0 0 0 9px #85c9c94d; } }

@media (max-width: 650px) {
  #study { gap: 7px; }
  .study-top { min-height: 62px; }
  .play { min-width: 70px; width: 70px; height: 58px; }
  .play-label { display: none; }
  .prompt-hint { font-size: 13px; }
  .trophy-count { min-width: 52px; font-size: 19px; }
  .gear { width: 48px; height: 48px; }
  .reward-track-title { font-size: 0; }
  .reward-track-title span { font-size: 20px; }
  .reward-track { gap: 8px; }
  .reward-dot { width: 14px; height: 14px; }
  .reward-label { min-width: 44px; font-size: 14px; }
}
@media (max-height: 650px) {
  #study { gap: 6px; padding: 8px; }
  .study-top { min-height: 54px; }
  .play { height: 48px; min-width: 90px; font-size: 20px; }
  .play .speaker { font-size: 23px; }
  .gear { height: 45px; width: 45px; }
  .trophy-count { font-size: 19px; padding: 4px; }
  #study-status { font-size: 22px; }
  .prompt-hint { display: none; }
  .reward-track { min-height: 34px; padding: 3px 10px; }
  .reward-track-title { font-size: 14px; }
  .reward-dot { width: 14px; height: 14px; }
  .reward-label { font-size: 14px; }
  .picture { border-radius: 18px; }
  .feedback { min-height: 30px; font-size: 18px; }
  .reward-card { padding: 12px; }
  .reward-card img { width: min(240px, 37dvh); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
