:root {
  color-scheme: light;
  --ink: #24342f;
  --muted: #66756e;
  --paper: #fffdf7;
  --line: #d8dfd8;
  --sky: #dff3ff;
  --grass: #72b77c;
  --road: #e7ddd0;
  --coral: #e96f5f;
  --yellow: #f6c94c;
  --teal: #2c8f87;
  --blue: #397db4;
  --shadow: 0 14px 34px rgba(37, 63, 52, 0.14);
  font-family: "Pretendard", "Noto Sans KR", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { min-width: 0; min-height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background: #eff7f1;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

button, input, textarea { font: inherit; }
button { color: inherit; }
button:focus-visible, a:focus-visible, summary:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(57, 125, 180, 0.45);
  outline-offset: 3px;
}

[hidden] { display: none !important; }
.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; }

.app-shell {
  width: min(1080px, 100%);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom));
}

.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 54px; margin-bottom: 10px; }
.brand-link { display: inline-flex; align-items: center; gap: 9px; color: inherit; text-decoration: none; }
.brand-link strong, .brand-link small { display: block; }
.brand-link strong { font-size: 14px; }
.brand-link small { margin-top: 1px; color: var(--muted); font-size: 9px; }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; border: 2px solid var(--ink); border-radius: 50%; background: var(--yellow); font-size: 12px; font-weight: 900; }

.icon-button, .pause-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--paper);
  cursor: pointer;
}
.icon-button:disabled { opacity: 0.42; cursor: default; }

.screen { min-height: calc(100svh - 88px); }
.screen.is-active { display: block; }
.paper-panel { border: 1px solid var(--line); border-radius: 8px; background: var(--paper); box-shadow: var(--shadow); }
.eyebrow { margin: 0 0 10px; color: var(--coral); font-size: 12px; font-weight: 900; text-transform: uppercase; }

.boot-screen, .countdown-screen, .paused-screen { display: grid; place-items: center; }
.boot-panel, .countdown-card, .pause-card { width: min(520px, 100%); padding: 34px 24px; text-align: center; }
.boot-panel h1, .pause-card h1 { margin: 12px 0; font-size: clamp(25px, 7vw, 38px); }
.loading-paw { display: inline-grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--yellow); animation: paw-bob 0.8s ease-in-out infinite alternate; }

.home-layout { display: grid; gap: 12px; }
.home-copy, .home-visual { padding: clamp(22px, 6vw, 42px); }
.home-copy h1 { margin: 0; font-size: clamp(42px, 13vw, 74px); line-height: 0.98; letter-spacing: 0; }
.lead { margin: 20px 0; color: #42544c; font-size: clamp(16px, 4vw, 20px); line-height: 1.65; }
.record-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0 0 22px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.record-strip div { min-width: 0; padding: 11px 6px; text-align: center; }
.record-strip div + div { border-left: 1px solid var(--line); }
.record-strip dt { color: var(--muted); font-size: 11px; }
.record-strip dd { margin: 4px 0 0; font-size: 14px; font-weight: 900; }

.primary-button, .secondary-button, .text-button {
  min-height: 48px;
  border-radius: 8px;
  padding: 11px 18px;
  font-weight: 900;
  cursor: pointer;
}
.primary-button { border: 2px solid var(--ink); background: var(--coral); color: white; box-shadow: 4px 4px 0 var(--ink); }
.secondary-button { border: 1px solid var(--ink); background: white; }
.text-button { border: 0; background: transparent; text-decoration: underline; }
.start-button { width: 100%; min-height: 58px; font-size: 20px; }
.key-hint { margin: 15px 0 0; color: var(--muted); text-align: center; font-size: 12px; }
kbd { border: 1px solid #aeb8b1; border-bottom-width: 3px; border-radius: 5px; background: white; padding: 2px 7px; font: 700 11px/1.5 system-ui, sans-serif; }

.home-visual { position: relative; min-height: 310px; overflow: hidden; background: var(--sky); }
.home-visual::after { position: absolute; right: -10%; bottom: -42px; left: -10%; height: 125px; border-radius: 50% 50% 0 0; background: var(--grass); content: ""; }
.sun { position: absolute; top: 28px; right: 30px; width: 56px; height: 56px; border: 5px solid var(--paper); border-radius: 50%; background: var(--yellow); }
.home-dog { position: absolute; z-index: 2; right: 50%; bottom: 24px; width: clamp(210px, 55vw, 270px); transform: translateX(50%); transform-origin: 50% 100%; }
.home-dog img, .result-dog img, .walker img, .debug-dog-preview img {
  display: block;
  width: 100%;
  height: auto;
  transform: scale(var(--dog-state-scale, 1));
  transform-origin: 50% 100%;
}
.dog-fallback { display: none; font-size: 88px; }
.is-image-fallback img { display: none; }
.is-image-fallback .dog-fallback { display: block; }
.leash { position: absolute; right: -48px; bottom: 42px; width: 82px; height: 28px; border: 7px solid var(--coral); border-left: 0; border-radius: 0 30px 30px 0; transform: rotate(-13deg); }
.speech-bubble { position: absolute; z-index: 3; top: 42px; left: 24px; margin: 0; border: 2px solid var(--ink); border-radius: 8px; background: white; padding: 10px 14px; font-weight: 900; }

.settings-panel, .how-to { margin-top: 12px; padding: 20px; }
.settings-panel h2 { margin: 0 0 12px; font-size: 18px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; min-height: 44px; gap: 16px; border-top: 1px solid var(--line); cursor: pointer; }
.toggle-row input { width: 22px; height: 22px; accent-color: var(--teal); }
.slider-row { display: grid; gap: 8px; border-top: 1px solid var(--line); padding: 10px 0; }
.slider-row span { display: flex; justify-content: space-between; gap: 12px; }
.slider-row input { width: 100%; accent-color: var(--teal); }
.how-to summary { min-height: 36px; font-weight: 900; cursor: pointer; }
.how-to ol { margin: 10px 0 0; padding-left: 22px; line-height: 1.8; }

.countdown-card strong { display: block; margin: 10px 0; color: var(--coral); font-size: clamp(72px, 25vw, 160px); line-height: 1; }
.countdown-card p, .countdown-card span { margin: 0; color: var(--muted); font-weight: 800; }

.play-screen { position: relative; }
.hud { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) 44px; gap: 6px; padding: 10px; }
.hud-stat { min-width: 0; border-right: 1px solid var(--line); padding: 2px 6px; }
.hud-stat span { display: block; color: var(--muted); font-size: 10px; }
.hud-stat strong { display: block; margin-top: 3px; white-space: nowrap; font-size: clamp(13px, 3.4vw, 18px); }
.hud-stat strong span { display: inline; color: inherit; font-size: inherit; }
.pause-button { width: 40px; height: 40px; }
.happiness { grid-column: 1 / -1; }
.happiness-label { display: flex; justify-content: space-between; margin-bottom: 4px; font-size: 11px; }
.meter { height: 10px; border: 1px solid #9daa9f; border-radius: 5px; overflow: hidden; background: #edf0ed; }
.meter span { display: block; width: 0%; height: 100%; background: var(--yellow); transition: width 180ms ease; }
.zoomies-banner { margin: 8px auto; border: 2px solid var(--ink); border-radius: 8px; background: var(--yellow); padding: 7px 12px; text-align: center; }
.zoomies-banner strong, .zoomies-banner span { display: block; }
.zoomies-banner span { margin-top: 2px; font-size: 11px; }

.walk-scene { --sunset-opacity: 0; position: relative; min-height: clamp(280px, 48svh, 450px); margin-top: 10px; border: 2px solid var(--ink); border-radius: 8px; overflow: hidden; background: var(--sky); box-shadow: var(--shadow); }
.walk-scene::before { position: absolute; z-index: 1; inset: 0 0 41%; pointer-events: none; background: #f5a087; opacity: var(--sunset-opacity); content: ""; }
.sky-decor span { position: absolute; width: 70px; height: 22px; border-radius: 50%; background: white; opacity: 0.9; }
.sky-decor span:nth-child(1) { top: 35px; left: 8%; }
.sky-decor span:nth-child(2) { top: 70px; right: 12%; width: 90px; }
.sky-decor span:nth-child(3) { top: 25px; right: 42%; width: 50px; }
.houses { position: absolute; right: 0; bottom: 40%; left: 0; display: flex; align-items: end; gap: 4px; padding: 0 4%; }
.houses i { flex: 1; height: 94px; border: 2px solid #49665b; background: #f3b38e; box-shadow: inset 0 -25px #fff1cc; }
.houses i:nth-child(2) { height: 118px; background: #f5d36d; }
.houses i:nth-child(3) { height: 82px; background: #92c6cc; }
.houses i:nth-child(4) { height: 106px; background: #ef9da8; }
.tree-line { position: absolute; right: 0; bottom: 33%; left: 0; display: flex; justify-content: space-around; }
.tree-line i { width: 34px; height: 48px; border: 5px solid #52725b; border-radius: 50% 50% 40% 40%; background: var(--grass); }
.sidewalk { position: absolute; right: 0; bottom: 0; left: 0; height: 41%; border-top: 6px solid white; background: var(--road); }
.sidewalk::after { position: absolute; right: 0; top: 62%; left: 0; border-top: 3px dashed rgba(80, 89, 80, 0.3); content: ""; }
.timing-track { position: absolute; z-index: 2; inset: 0; pointer-events: none; }
.target-zone { position: absolute; top: 4%; bottom: 4%; left: 23%; width: 76px; border: 3px solid var(--coral); border-radius: 8px; background: rgba(255, 255, 255, 0.5); }
.timing-target__fallback { position: absolute; right: 0; bottom: 5px; left: 0; color: #a33e35; font-size: 24px; line-height: 1; text-align: center; }
.walker { position: absolute; z-index: 4; bottom: 10%; left: 2%; width: clamp(155px, 30vw, 225px); aspect-ratio: 1; transform-origin: 50% 100%; }
.walker img { width: 100%; height: 100%; object-fit: contain; object-position: center bottom; }
.event-object { position: absolute; z-index: 3; bottom: 17%; left: 0; width: clamp(60px, 15vw, 92px); height: clamp(60px, 15vw, 92px); will-change: transform; }
.event-object img { display: block; width: 100%; height: 100%; object-fit: contain; }
.event-fallback { display: none; place-items: center; width: 100%; height: 100%; border: 2px solid var(--ink); border-radius: 8px; background: white; font-size: 11px; font-weight: 900; text-align: center; }
.event-object.is-image-fallback img { display: none; }
.event-object.is-image-fallback .event-fallback { display: grid; }
.feedback { position: absolute; z-index: 7; top: 14px; right: 0; left: 0; min-height: 48px; pointer-events: none; text-align: center; font-size: clamp(28px, 9vw, 54px); font-weight: 1000; text-shadow: 0 3px white; }
.feedback.is-perfect { color: var(--coral); }
.feedback.is-good { color: var(--blue); }
.feedback.is-miss { color: #725d78; }

.action-area { display: grid; place-items: center; gap: 5px; padding: 8px 0 0; text-align: center; }
.action-area p { margin: 0; color: var(--muted); font-size: 11px; }
.paw-button { position: relative; width: 82px; height: 82px; border: 3px solid var(--ink); border-radius: 50%; background: var(--coral); color: white; cursor: pointer; box-shadow: 0 7px 0 #873b34; touch-action: manipulation; user-select: none; }
.paw-button > span { display: block; margin: 15px auto 0; font-size: 31px; line-height: 0.7; }
.paw-button > i { display: block; font-size: 12px; font-style: normal; letter-spacing: 4px; transform: translateY(-29px); }
.paw-button:active { transform: translateY(5px); box-shadow: 0 2px 0 #873b34; }

.dog-state--idle { animation: dog-idle 2.4s ease-in-out infinite; }
.dog-state--walk { animation: dog-walk 0.42s ease-in-out infinite alternate; }
.dog-state--jump-success, .dog-state--hop-success { animation: dog-jump 0.45s ease-out; }
.dog-state--stop-success { animation: dog-stop 0.42s ease-out; }
.dog-state--sniff-success { animation: dog-sniff 0.46s ease-out; }
.dog-state--catch-success { animation: dog-perfect 0.42s ease-out; }
.dog-state--calm-success { animation: dog-good 0.45s ease-out; }
.dog-state--splash-fail { animation: dog-splash 0.42s ease-out; }
.dog-state--bump-fail, .dog-state--drop-fail { animation: dog-miss 0.42s ease-out; }
.dog-state--startled-fail, .dog-state--chase-fail { animation: dog-surprised 0.46s ease-out; }
.dog-state--pass-fail { animation: dog-pass 0.46s ease-out; }
.dog-state--zoomies { animation: dog-zoomies 0.23s ease-in-out infinite alternate; }
.walk-scene.is-zoomies .houses, .walk-scene.is-zoomies .tree-line { animation: background-rush 0.55s linear infinite; }
.walk-scene.is-last-ten { box-shadow: 0 0 0 4px rgba(233, 111, 95, 0.2), var(--shadow); }
.dog-state--result-happy { animation: dog-result-happy 2.2s ease-in-out infinite; }
.dog-state--result-tired { animation: dog-result-tired 2.8s ease-in-out infinite; filter: saturate(0.84); }
.walk-event[data-event-state="armed"] { filter: drop-shadow(0 0 8px rgba(246, 201, 76, 0.55)); }
.walk-event[data-event-state="resolved"], .walk-event[data-event-state="expired"] { opacity: 0.72; }
.walk-event[data-event-state="resolved"].is-visual-replaced,
.walk-event[data-event-state="expired"].is-visual-replaced { opacity: 0; }
.paw-particles span { position: absolute; z-index: 6; width: 10px; height: 10px; border-radius: 50%; background: var(--yellow); animation: particle-pop 0.75s ease-out forwards; }

.pause-card p { color: var(--muted); line-height: 1.7; }
.pause-card .primary-button, .pause-card .text-button { width: 100%; margin-top: 10px; }
.result-layout { display: grid; gap: 12px; }
.result-lead, .result-stats { padding: clamp(22px, 6vw, 38px); }
.result-lead { text-align: center; }
.result-dog { width: clamp(170px, 44vw, 220px); margin: 0 auto 10px; transform-origin: 50% 100%; }
.result-lead h1 { margin: 6px 0; font-size: clamp(42px, 14vw, 72px); }
.final-score { display: block; color: var(--coral); font-size: clamp(30px, 9vw, 48px); }
.result-stats dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; }
.result-stats div { display: flex; justify-content: space-between; gap: 8px; min-width: 0; border-bottom: 1px solid var(--line); padding: 12px 6px; }
.result-stats dt { color: var(--muted); font-size: 12px; }
.result-stats dd { margin: 0; font-weight: 900; }
.result-actions { display: grid; gap: 9px; margin-top: 12px; }

.debug-panel { margin-top: 10px; padding: 10px 12px; background: rgba(255, 253, 247, 0.96); font: 11px/1.45 ui-monospace, SFMono-Regular, Consolas, monospace; }
.debug-panel strong { display: block; margin-bottom: 5px; color: var(--coral); }
.debug-zoomies-controls { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.debug-zoomies-controls button { min-height: 34px; border: 1px solid var(--line); border-radius: 6px; background: white; padding: 5px 9px; color: var(--ink); font: inherit; }
.debug-panel pre { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.debug-asset-gallery { display: grid; grid-template-columns: minmax(0, 150px) 1fr; gap: 8px 12px; align-items: center; margin-top: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
.debug-asset-controls { display: grid; grid-column: 1 / -1; grid-template-columns: auto minmax(0, 1fr) auto; gap: 6px; }
.debug-asset-controls button, .debug-asset-controls select { min-width: 0; min-height: 34px; border: 1px solid var(--line); border-radius: 6px; background: white; padding: 5px 8px; color: var(--ink); font: inherit; }
.debug-dog-preview { width: 140px; min-height: 140px; transform-origin: 50% 100%; }
.debug-asset-gallery p { margin: 0; overflow-wrap: anywhere; }

.modal { position: fixed; z-index: 30; inset: 0; display: grid; place-items: center; background: rgba(28, 42, 36, 0.62); padding: 18px; }
.modal-card { width: min(560px, 100%); padding: 22px; }
.modal-card h2 { margin: 0 0 12px; }
.modal-card textarea { width: 100%; min-height: 180px; resize: vertical; border: 1px solid var(--line); border-radius: 8px; padding: 13px; background: white; color: var(--ink); line-height: 1.65; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

@media (min-width: 760px) {
  .app-shell { padding-right: 24px; padding-left: 24px; }
  .home-layout, .result-layout { grid-template-columns: 1.08fr 0.92fr; }
  .home-visual { min-height: 560px; }
  .record-strip dt { font-size: 12px; }
  .record-strip dd { font-size: 17px; }
  .result-actions { grid-template-columns: 1.3fr 1fr auto; }
  .walk-scene { min-height: 490px; }
  .action-area { margin-top: -102px; position: relative; z-index: 9; pointer-events: none; }
  .action-area .paw-button { pointer-events: auto; }
  .action-area p { color: #43554d; }
}

@media (max-width: 420px) {
  .app-shell { padding-right: 10px; padding-left: 10px; }
  .brand-link small { display: none; }
  .home-copy, .home-visual, .result-lead, .result-stats { padding: 20px 16px; }
  .record-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .record-strip div:nth-child(3) { border-top: 1px solid var(--line); border-left: 0; }
  .record-strip div:nth-child(4) { border-top: 1px solid var(--line); }
  .record-strip dd { font-size: 12px; }
  .walk-scene { min-height: 300px; }
  .target-zone { left: 21%; width: 64px; }
  .walker { left: 1%; width: 155px; }
  .debug-asset-gallery { grid-template-columns: 1fr; }
  .debug-dog-preview { margin: 0 auto; }
}

@media (max-height: 700px) and (orientation: landscape) {
  body[data-state="PLAYING"] .app-shell { min-height: 0; padding-top: 6px; padding-bottom: 6px; }
  body[data-state="PLAYING"] .topbar { display: none; }
  body[data-state="PLAYING"] .screen { min-height: 0; }
  .walk-scene { min-height: 230px; margin-top: 6px; }
  .action-area { position: absolute; right: 14px; bottom: 10px; z-index: 9; }
  .action-area p { display: none; }
}

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

body.reduce-motion *, body.reduce-motion *::before, body.reduce-motion *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }

@keyframes paw-bob { to { transform: translateY(-8px) rotate(7deg); } }
@keyframes dog-idle { 50% { transform: translateY(-3px) scaleY(1.015); } }
@keyframes dog-walk { from { transform: translateY(0) rotate(-1deg); } to { transform: translateY(-5px) rotate(1deg); } }
@keyframes dog-jump { 50% { transform: translateY(-38px) rotate(-5deg); } }
@keyframes dog-stop { 50% { transform: scaleX(0.92) translateX(-5px); } }
@keyframes dog-sniff { 50% { transform: rotate(8deg) translate(8px, 7px); } }
@keyframes dog-splash { 25% { transform: translateY(-9px) rotate(-6deg); } 75% { transform: translateY(2px) rotate(6deg); } }
@keyframes dog-surprised { 50% { transform: translateY(-20px) scale(1.05); } }
@keyframes dog-pass { 50% { transform: translateX(10px); opacity: 0.72; } }
@keyframes dog-perfect { 50% { transform: scale(1.13) rotate(5deg); } }
@keyframes dog-good { 50% { transform: translateY(-15px); } }
@keyframes dog-miss { 25% { transform: translateX(-8px) rotate(-4deg); } 75% { transform: translateX(8px) rotate(4deg); } }
@keyframes dog-zoomies { to { transform: translate(10px, -6px) rotate(3deg); } }
@keyframes dog-result-happy { 50% { transform: translateY(-4px) rotate(2deg); filter: drop-shadow(0 0 8px rgba(246, 201, 76, 0.45)); } }
@keyframes dog-result-tired { 50% { transform: translateY(3px) rotate(-2deg); } }
@keyframes background-rush { to { transform: translateX(-46px); } }
@keyframes particle-pop { from { opacity: 1; transform: translate(0, 0) scale(1); } to { opacity: 0; transform: translate(var(--particle-x), var(--particle-y)) scale(0.2); } }
