:root {
  --bg: #deeeff; --ink: #2b2333; --card: #fffdf9; --red: #d93a3a; --red-d: #a82a33;
  --green: #2f9e5a; --gold: #f4c542; --muted: #6d6478;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { overflow-x: clip; }
body {
  margin: 0; min-height: 100dvh; background: var(--bg); color: var(--ink);
  font: 500 16px/1.45 Nunito, system-ui, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
main { position: relative; z-index: 1; max-width: 460px; margin: 0 auto; padding: 16px; }
h1, h2, h3, .tabs, .coins { font-family: 'Pixelify Sans', system-ui, sans-serif; }
h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.15rem; margin: 1.2em 0 .5em; }
.pix { image-rendering: pixelated; }
.muted { color: var(--muted); font-size: .9rem; }
.error { color: var(--red-d); font-weight: 700; min-height: 1.2em; }
.ok { color: var(--green); font-weight: 800; }
[hidden] { display: none !important; }

/* chunky pixel buttons */
button, input {
  font: inherit; color: inherit; border: 3px solid var(--ink); border-radius: 10px;
  background: var(--card); padding: .6em .9em;
}
button { font-weight: 800; cursor: pointer; box-shadow: 0 4px 0 var(--ink); transition: transform .05s; touch-action: manipulation; }
button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
button:disabled { opacity: .45; cursor: default; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
form { display: flex; gap: 8px; }
form input { flex: 1; min-width: 0; }
form button { background: var(--red); color: #fff; }

.bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.coins { background: var(--card); border: 3px solid var(--ink); border-radius: 999px; padding: .15em .7em; font-size: 1.1rem; }

/* adoption */
#adopt { text-align: center; }
.adopt-dog { width: min(100%, 384px); margin: 12px auto; display: block; animation: bob 1.2s steps(2) infinite; }

/* empty doghouse (before the dog moves in) */
.house { width: min(100%, 384px); display: block; margin: 8px auto 16px; }
.story .card { margin: 0; font-size: 1.05rem; }

/* scene */
.scene { position: relative; overflow: hidden; padding-top: 52px; margin: 0 -16px; }
.dog { position: relative; width: min(100%, 384px); aspect-ratio: 3 / 2; margin: 0 auto; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.layers { position: absolute; inset: 0; animation: bob 1.2s steps(2) infinite; }
.layers img { position: absolute; inset: 0; width: 100%; height: 100%; }
.layers.hop { animation: hop .45s ease-out; }
@keyframes bob { 50% { transform: translateY(-1.5%); } }
@keyframes hop { 40% { transform: translateY(-12%); } }

.bubble {
  position: absolute; top: 4px; left: 50%; transform: translate(-50%, 6px); margin: 0; z-index: 3;
  background: var(--card); border: 3px solid var(--ink); border-radius: 12px; padding: .3em .8em;
  font-weight: 800; white-space: nowrap; max-width: 92%; overflow: hidden; text-overflow: ellipsis;
  opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none;
}
.bubble.show { opacity: 1; transform: translate(-50%, 0); }

.heart { position: absolute; top: 45%; color: var(--red); font-size: 1.6rem; z-index: 2; pointer-events: none; animation: float 1.3s ease-out both; }
@keyframes float { from { opacity: 1; transform: translateY(0) scale(.6); } to { opacity: 0; transform: translateY(-110px) scale(1.2); } }

.present { position: absolute; right: 4%; bottom: 2%; width: 20%; max-width: 80px; z-index: 2; cursor: pointer; animation: wiggle 1.4s infinite; }
.present.open { animation: unwrap .9s forwards; }
@keyframes wiggle { 0%, 70%, 100% { transform: rotate(0); } 75% { transform: rotate(-8deg); } 85% { transform: rotate(8deg); } }
@keyframes unwrap { 50% { transform: scale(1.3) rotate(-6deg); } 100% { transform: scale(2); opacity: 0; } }

/* fetch: ball flies off, dog runs after it and comes back carrying it */
.thrown { position: absolute; width: 36px; left: 70%; top: 55%; opacity: 0; pointer-events: none; z-index: 2; }
.thrown.fly { animation: throw 1s ease-out forwards; }
@keyframes throw { 0% { opacity: 1; transform: translate(0, 0) rotate(0); } 40% { transform: translate(30vw, -90px) rotate(360deg); } 100% { opacity: 1; transform: translate(80vw, 20px) rotate(900deg); } }
.dog.fetch { animation: fetch 2.8s ease-in-out; }
@keyframes fetch {
  0% { transform: translateX(0) scaleX(1); }
  35% { transform: translateX(110vw) scaleX(1); }
  45% { transform: translateX(110vw) scaleX(-1); }
  90% { transform: translateX(0) scaleX(-1); }
  100% { transform: translateX(0) scaleX(1); }
}
.mouthball { position: absolute; left: 70%; top: 46%; width: 12.5%; opacity: 0; }
.dog.fetch .mouthball { animation: carry 2.8s; }
@keyframes carry { 0%, 44% { opacity: 0; } 45%, 95% { opacity: 1; } 100% { opacity: 0; } }

/* action buttons */
.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.actions button { padding: .6em .2em; font-size: .9rem; position: relative; }
.badge { position: absolute; top: -7px; right: -5px; width: 16px; height: 16px; border-radius: 50%; background: var(--red); border: 2px solid var(--ink); }

/* treats */
.treats { display: flex; flex-wrap: wrap; gap: 8px; }
.treats button, .treats span { padding: 4px; border-radius: 10px; position: relative; }
.treats span { background: var(--card); border: 3px solid var(--ink); }
.treat { width: 52px; height: 52px; display: block; }
.collection .treat { width: 40px; height: 40px; }
.collection small { position: absolute; right: 2px; bottom: 0; font-weight: 800; font-size: .7rem; }
.collection .locked img { filter: grayscale(1) brightness(1.6); opacity: .35; }

/* dialog */
dialog {
  width: min(420px, calc(100% - 32px)); max-height: 85dvh; border: 3px solid var(--ink); border-radius: 16px;
  background: var(--card); color: var(--ink); padding: 20px; box-shadow: 0 6px 0 var(--ink);
}
dialog::backdrop { background: rgb(43 35 51 / .45); }
dialog h2 { margin-top: 0; }
dialog .close { float: right; padding: .1em .5em; box-shadow: 0 2px 0 var(--ink); background: var(--card); color: var(--ink); }
dialog form { display: block; }
.note { white-space: pre-line; font-size: 1.05rem; }
details { border-top: 2px dashed #d8cfe0; padding: .4em 0; }
summary { cursor: pointer; font-weight: 800; }
.options { display: grid; gap: 8px; }
.options button { text-align: left; }
.muted .treat { width: 28px; height: 28px; display: inline-block; vertical-align: middle; }
.reward { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 1.1rem; }
.reward .treat { width: 78px; height: 78px; }
#next-q { width: 100%; background: var(--green); color: #fff; }
.shop { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.shop li { display: flex; align-items: center; gap: 10px; }
.shop .icon { width: 72px; height: 56px; background: var(--bg); border-radius: 8px; flex: none; display: grid; place-items: center; }
.shop .icon img { max-width: 64px; max-height: 48px; width: auto; height: 100%; object-fit: contain; }
.shop span { flex: 1; font-weight: 700; }

/* Termine */
.card { background: var(--card); border: 3px solid var(--ink); border-radius: 14px; padding: 16px; box-shadow: 0 4px 0 var(--ink); }
.card h2 { margin-top: 0; }
.slots { display: grid; gap: 8px; }
.slots .chosen { background: var(--green); color: #fff; }

/* tab bar */
.tabs {
  position: fixed; z-index: 5; left: 0; right: 0; bottom: 0; display: flex; gap: 8px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 3px solid var(--ink);
}
.tabs button { flex: 1; font-weight: 700; }
body:has(.tabs[hidden]) { padding-bottom: 16px; }
.tabs .active { background: var(--red); color: #fff; }

.fatal { text-align: center; padding: 40px 16px; font-weight: 700; }

/* snow */
#snow { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
#snow i { position: absolute; top: -10px; width: 6px; height: 6px; background: #fff; border-radius: 1px; animation: fall linear infinite; }
@keyframes fall { to { transform: translateY(105dvh) translateX(30px); } }

@media (prefers-reduced-motion: reduce) {
  #snow, .layers, .adopt-dog, .present { animation: none !important; }
}
