/* ===== Treat Trek — styles ===== */
:root {
  --orange: #F26B1D; --orange-dark: #C94F0E; --teal: #1BA9B5; --teal-dark: #128A94;
  --yellow: #FFD23F; --pink: #FF6FA5; --green: #58C36B; --cream: #FFF7E6; --ink: #2B2A33;
  --sky-top: #7CC9FF; --sky-bot: #D9F1FF; --card: #FFFFFF; --shadow: 0 8px 0 rgba(0,0,0,.12), 0 14px 28px rgba(0,0,0,.14);
  --font: 'Fredoka', 'Nunito', 'Arial Rounded MT Bold', 'Helvetica Rounded', system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body { font-family: var(--font); color: var(--ink); background: linear-gradient(var(--sky-top), var(--sky-bot)); overflow: hidden; user-select: none; }
button { font-family: inherit; cursor: pointer; border: 0; }
#app { position: relative; width: 100%; height: 100%; }
.screen { position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; padding: 16px; opacity: 0; transition: opacity .35s; }
.screen.active { display: flex; opacity: 1; }
h2 { font-size: clamp(28px, 5vw, 46px); margin: 0 0 18px; color: #fff; text-shadow: 0 3px 0 rgba(0,0,0,.18); }

/* Buttons */
.btn { background: var(--teal); color: #fff; font-weight: 700; font-size: 22px; padding: 14px 28px; border-radius: 999px; box-shadow: 0 6px 0 var(--teal-dark), 0 10px 20px rgba(0,0,0,.18); transition: transform .08s, box-shadow .08s; }
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--teal-dark), 0 4px 10px rgba(0,0,0,.18); }
.btn-orange { background: var(--orange); box-shadow: 0 6px 0 var(--orange-dark), 0 10px 20px rgba(0,0,0,.18); }
.btn-orange:active { box-shadow: 0 2px 0 var(--orange-dark); }
.btn-big { font-size: clamp(26px, 4vw, 38px); padding: 18px 56px; }
.btn-ghost { background: rgba(255,255,255,.85); color: var(--ink); box-shadow: 0 5px 0 rgba(0,0,0,.15); }
.btn-round { width: 60px; height: 60px; padding: 0; font-size: 28px; display: inline-flex; align-items: center; justify-content: center; background: rgba(255,255,255,.9); box-shadow: 0 5px 0 rgba(0,0,0,.14); }
.btn-round.off { opacity: .55; filter: grayscale(1); }
.btn-small { font-size: 17px; padding: 10px 18px; }
.btn-back { position: absolute; top: 16px; left: 16px; }
.btn-pulse { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }

/* ===== Title ===== */
#screen-title { padding: 0; }
.title-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center bottom; }
.title-content { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 14px; margin-top: -8vh; }
.logo { width: min(78vw, 640px); filter: drop-shadow(0 10px 18px rgba(0,0,0,.25)); animation: bob 3s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-10px) rotate(1deg); } }
.tagline { margin: -6px 0 6px; font-size: clamp(20px, 3vw, 30px); font-weight: 600; color: #fff; background: rgba(27,169,181,.9); padding: 6px 22px; border-radius: 999px; box-shadow: 0 4px 0 rgba(0,0,0,.15); }
.title-links { display: flex; gap: 14px; margin-top: 8px; }
.sun { position: absolute; z-index: 1; top: 4vh; right: 5vw; width: 12vw; max-width: 130px; aspect-ratio: 1; border-radius: 50%; background: var(--yellow); box-shadow: 0 0 60px 20px rgba(255,210,63,.55); animation: spin 30s linear infinite; }
.credit { position: absolute; bottom: 10px; right: 14px; z-index: 2; font-size: 13px; color: rgba(255,255,255,.85); text-shadow: 0 1px 2px rgba(0,0,0,.4); }

/* ===== Pet select ===== */
.pet-cards { display: flex; gap: 26px; flex-wrap: wrap; justify-content: center; }
.pet-card { background: var(--card); border-radius: 28px; padding: 22px 26px 18px; width: min(40vw, 300px); display: flex; flex-direction: column; align-items: center; gap: 6px; box-shadow: var(--shadow); transition: transform .15s; border: 5px solid transparent; }
.pet-card:hover { transform: translateY(-6px) rotate(-1deg); }
.pet-card:active { transform: scale(.97); }
.pet-card img { width: 100%; height: 190px; object-fit: contain; }
.pet-card .pet-name { font-size: 34px; font-weight: 700; color: var(--orange); }
.pet-card[data-pet="cat"] .pet-name { color: var(--teal); }
.pet-card .pet-goal { font-size: 18px; color: #666; }
.pet-card .pet-goal img { width: 34px; height: 34px; vertical-align: middle; display: inline; }

/* ===== Mode select ===== */
.mode-cards { display: flex; gap: 22px; flex-wrap: wrap; justify-content: center; }
.mode-card { background: var(--card); border-radius: 26px; padding: 20px 24px; width: min(42vw, 320px); box-shadow: var(--shadow); text-align: left; border: 5px solid transparent; transition: transform .15s; }
.mode-card:hover { transform: translateY(-5px); }
.mode-card.selected { border-color: var(--yellow); }
.mode-card .mode-emoji { font-size: 44px; }
.mode-card .mode-title { font-size: 26px; font-weight: 700; margin: 4px 0; }
.mode-card .mode-desc { font-size: 16px; color: #666; }
.story-list { display: none; margin-top: 18px; max-height: 34vh; overflow-y: auto; width: min(92vw, 700px); background: rgba(255,255,255,.6); border-radius: 22px; padding: 12px; gap: 8px; flex-direction: column; }
.story-list.open { display: flex; }
.story-item { background: #fff; border-radius: 16px; padding: 12px 16px; text-align: left; display: flex; align-items: center; gap: 12px; font-size: 18px; box-shadow: 0 3px 0 rgba(0,0,0,.08); }
.story-item:hover { background: var(--cream); }
.story-item .s-title { font-weight: 700; flex: 1; }
.story-item .s-meta { font-size: 14px; color: #777; }
.story-item img { width: 36px; height: 36px; object-fit: contain; }

/* ===== Play ===== */
#screen-play { padding: 0; justify-content: flex-start; }
.hud { width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 14px; z-index: 5; }
.hud .btn-round { width: 48px; height: 48px; font-size: 22px; }
.trail { flex: 1; position: relative; height: 26px; background: rgba(255,255,255,.65); border-radius: 999px; box-shadow: inset 0 3px 6px rgba(0,0,0,.12); }
.trail .fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: linear-gradient(90deg, var(--yellow), var(--orange)); border-radius: 999px; transition: width .4s ease; }
.trail .mark { position: absolute; top: 50%; transform: translate(-50%, -50%); font-size: 20px; line-height: 1; }
.trail .mark img { width: 30px; height: 30px; object-fit: contain; }
.trail .mark.pet { transition: left .4s ease; z-index: 2; }
.trail .mark.pet img { width: 40px; height: 40px; }
.hud .counter { font-weight: 700; font-size: 18px; background: rgba(255,255,255,.85); padding: 6px 14px; border-radius: 999px; min-width: 76px; text-align: center; }

.scene { position: relative; width: 100%; flex: 1; min-height: 240px; overflow: hidden; background: url('../assets/img/bg-meadow.jpg') center bottom / cover no-repeat; }
.scene::after { content: ''; position: absolute; inset: auto 0 0 0; height: 20%; background: linear-gradient(transparent, rgba(0,0,0,.06)); pointer-events: none; }
.cloud { position: absolute; top: 8%; width: 140px; height: 50px; background: #fff; border-radius: 50px; opacity: .9; animation: drift linear infinite; }
.cloud::before, .cloud::after { content: ''; position: absolute; background: #fff; border-radius: 50%; }
.cloud::before { width: 60px; height: 60px; left: 22px; top: -28px; }
.cloud::after { width: 44px; height: 44px; left: 66px; top: -18px; }
@keyframes drift { from { transform: translateX(110vw); } to { transform: translateX(-200px); } }
.sprite { position: absolute; bottom: 6%; object-fit: contain; pointer-events: none; }
.sprite.home { left: 2%; height: 42%; z-index: 1; }
.sprite.treat { right: 4%; height: 18%; bottom: 10%; z-index: 1; animation: hover 1.8s ease-in-out infinite; transition: transform .6s ease, opacity .5s; filter: drop-shadow(0 0 14px rgba(255,210,63,.9)); }
.sprite.treat.gone { opacity: 0; transform: scale(.2); }
@keyframes hover { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
.pet-wrap { position: absolute; bottom: 5%; left: 10%; height: 34%; aspect-ratio: 1.2; z-index: 3; transition: left .55s cubic-bezier(.4,.1,.3,1); transform-origin: bottom center; }
.pet-wrap.flip .pet { transform: scaleX(-1); }
.pet-wrap .pet { width: 100%; height: 100%; object-fit: contain; object-position: bottom; }
.pet-wrap.walking .pet { animation: walk .28s ease-in-out 2; }
.pet-wrap.idle .pet { animation: breathe 2.4s ease-in-out infinite; }
.pet-wrap.flip.walking .pet { animation-name: walkflip; }
.pet-wrap.flip.idle .pet { animation-name: breatheflip; }
.pet-wrap.cheer .pet { animation: cheer .5s ease-in-out 3; }
@keyframes walk { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-4%); } }
@keyframes walkflip { 0%,100% { transform: scaleX(-1) translateY(0); } 50% { transform: scaleX(-1) translateY(-4%); } }
@keyframes breathe { 0%,100% { transform: scaleY(1); } 50% { transform: scaleY(1.025); } }
@keyframes breatheflip { 0%,100% { transform: scaleX(-1) scaleY(1); } 50% { transform: scaleX(-1) scaleY(1.025); } }
@keyframes cheer { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-18%) rotate(-6deg); } }
.carry { position: absolute; top: -14%; left: 50%; width: 44%; transform: translateX(-50%) rotate(-12deg); display: none; filter: drop-shadow(0 4px 6px rgba(0,0,0,.25)); }
.pet-wrap.carrying .carry { display: block; animation: hover 1.6s ease-in-out infinite; }
.paw-layer { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.paw { position: absolute; bottom: 4%; font-size: 22px; opacity: .55; transform: translateX(-50%) rotate(90deg); animation: pawfade 6s linear forwards; }
.paw.flip { transform: translateX(-50%) rotate(-90deg); }
@keyframes pawfade { 0% { opacity: .6; } 80% { opacity: .35; } 100% { opacity: 0; } }
.banner { position: absolute; left: 50%; top: 16%; transform: translate(-50%, -30px) scale(.8); background: #fff; color: var(--orange); font-weight: 700; font-size: clamp(24px, 4vw, 40px); padding: 14px 34px; border-radius: 999px; box-shadow: var(--shadow); opacity: 0; transition: all .35s cubic-bezier(.2,1.4,.4,1); z-index: 6; white-space: nowrap; }
.banner.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.hint { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); background: rgba(255,255,255,.9); border-radius: 999px; padding: 6px 16px; font-size: 16px; opacity: 0; transition: opacity .3s; z-index: 6; }
.hint.show { opacity: 1; }

/* Reader panel */
.reader { width: 100%; background: var(--cream); border-top: 6px solid var(--yellow); padding: 14px 16px 16px; display: flex; flex-direction: column; align-items: center; gap: 10px; z-index: 5; box-shadow: 0 -10px 30px rgba(0,0,0,.08); }
.word-card { background: #fff; border-radius: 26px; padding: 16px 30px; min-width: min(90vw, 420px); max-width: 96vw; text-align: center; box-shadow: 0 6px 0 rgba(0,0,0,.08); font-weight: 600; line-height: 1.35; }
.word-card.word-mode { font-size: clamp(48px, 9vw, 96px); letter-spacing: .02em; }
.word-card.story-mode { font-size: clamp(24px, 3.6vw, 40px); }
.word-card .w { display: inline-block; padding: 0 .12em; border-radius: 10px; transition: all .2s; }
.word-card .w.read { color: var(--green); }
.word-card .w.cur { background: var(--yellow); color: var(--ink); animation: wiggle 1.2s ease-in-out infinite; }
.word-card .w.focus { text-decoration: underline; text-decoration-color: var(--teal); text-decoration-thickness: 3px; text-underline-offset: 4px; }
.word-card.pop { animation: pop .35s ease; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes wiggle { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-2deg); } 75% { transform: rotate(2deg); } }
.story-title { font-size: 15px; color: #888; font-weight: 600; margin-bottom: -4px; }
.reader-controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: center; }
.mic-pill { display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 999px; padding: 8px 18px; font-weight: 600; box-shadow: 0 4px 0 rgba(0,0,0,.08); min-width: 150px; }
.mic-pill .bars { display: inline-flex; gap: 3px; align-items: flex-end; height: 20px; }
.mic-pill .bars i { width: 4px; height: 6px; background: var(--teal); border-radius: 2px; }
.mic-pill.on .bars i { animation: bar .7s ease-in-out infinite; }
.mic-pill.on .bars i:nth-child(2) { animation-delay: .12s; } .mic-pill.on .bars i:nth-child(3) { animation-delay: .24s; } .mic-pill.on .bars i:nth-child(4) { animation-delay: .36s; }
@keyframes bar { 0%,100% { height: 6px; } 50% { height: 20px; } }
.mic-pill.warn { background: #FFE9C7; }
.mic-pill.off { opacity: .6; }
.heard { font-size: 14px; color: #999; min-height: 18px; }
.float-text { position: fixed; transform: translate(-50%, -50%); font-weight: 700; font-size: 32px; color: var(--orange); text-shadow: 0 2px 0 #fff; pointer-events: none; animation: floatup 1.2s ease-out forwards; z-index: 50; }
.float-text.good { color: var(--green); }
@keyframes floatup { 0% { opacity: 1; transform: translate(-50%, -50%) scale(.7); } 30% { transform: translate(-50%, -80%) scale(1.15); } 100% { opacity: 0; transform: translate(-50%, -160%) scale(1); } }

/* ===== Done ===== */
.done-card { background: #fff; border-radius: 30px; padding: 24px 32px; text-align: center; box-shadow: var(--shadow); max-width: 92vw; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.done-card img.win { height: 220px; object-fit: contain; animation: bob 2.5s ease-in-out infinite; }
.done-card h2 { color: var(--orange); text-shadow: none; margin-bottom: 0; }
.stats { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
.stat { background: var(--cream); border-radius: 18px; padding: 10px 18px; min-width: 110px; }
.stat b { display: block; font-size: 30px; color: var(--teal); }
.stat span { font-size: 14px; color: #777; }
.done-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

/* ===== Modal / settings ===== */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: none; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal.open { display: flex; }
.modal-card { background: #fff; border-radius: 26px; padding: 22px 26px; width: min(94vw, 520px); max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow); }
.modal-card h3 { margin: 0 0 12px; font-size: 26px; color: var(--teal); }
.field { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid #f0e8d8; font-size: 17px; }
.field label { font-weight: 600; }
.field select, .field input[type=number] { font-family: inherit; font-size: 17px; padding: 8px 10px; border-radius: 12px; border: 2px solid #e8dcc4; background: var(--cream); }
.field input[type=range] { width: 160px; }
.field .toggle { display: inline-flex; gap: 6px; }
.field .toggle button { padding: 8px 14px; border-radius: 999px; background: #eee; font-weight: 600; }
.field .toggle button.on { background: var(--teal); color: #fff; }
.modal textarea { width: 100%; min-height: 80px; font-family: inherit; font-size: 15px; border-radius: 12px; border: 2px solid #e8dcc4; padding: 8px; background: var(--cream); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }
.note { font-size: 13px; color: #888; margin: 6px 0 0; }
#fx-canvas { position: fixed; inset: 0; pointer-events: none; z-index: 90; }

@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 640px) {
  .pet-card { width: 44vw; padding: 14px; } .pet-card img { height: 120px; } .pet-card .pet-name { font-size: 26px; }
  .mode-card { width: 90vw; }
  .hud .counter { display: none; }
  .btn-small { font-size: 15px; padding: 9px 14px; }
}
@media (max-height: 560px) { .reader { padding: 8px 12px; } .word-card { padding: 8px 20px; } .heard { display: none; } }

/* Title screen pets composed from the game sprites (keeps the art consistent) */
.title-pet { position: absolute; bottom: 4%; z-index: 2; height: 24%; object-fit: contain; pointer-events: none; }
.title-dog { left: 8%; animation: bob 2.6s ease-in-out infinite; }
.title-cat { right: 8%; animation: bob 3.1s ease-in-out infinite reverse; }
.title-home { position: absolute; left: 50%; bottom: 3%; transform: translateX(-50%); height: 22%; z-index: 1; object-fit: contain; pointer-events: none; }
@media (max-width: 640px) { .title-pet { height: 16%; } .title-home { display: none; } }
#screen-title .title-links { position: fixed; top: 16px; right: 16px; margin: 0; z-index: 3; }
