:root {
  --ink: #1d211f;
  --muted: #69706c;
  --cream: #fffaf0;
  --paper: #fffdf8;
  --yellow: #f6c453;
  --yellow-dark: #dca835;
  --sage: #9eae83;
  --sage-dark: #657157;
  --line: rgba(29, 33, 31, .13);
  --shadow: 0 24px 70px rgba(55, 48, 31, .13);
  --radius: 28px;
  --dog-accent: #f6c453;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--cream); }

body {
  min-width: 300px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 12%, rgba(246, 196, 83, .14), transparent 24rem),
    radial-gradient(circle at 92% 75%, rgba(158, 174, 131, .13), transparent 25rem),
    var(--cream);
  font-family: Inter, ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button, input { font: inherit; }
button { color: inherit; }

.hidden { display: none !important; }

.ambient {
  position: fixed;
  z-index: -1;
  border: 1px solid rgba(29, 33, 31, .06);
  border-radius: 50%;
  pointer-events: none;
}

.ambient--one { width: 340px; height: 340px; top: -230px; left: 12%; }
.ambient--two { width: 470px; height: 470px; right: -320px; bottom: -170px; }

.app-shell {
  width: min(1180px, calc(100% - 44px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.topbar {
  min-height: 86px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  z-index: 10;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
  font-size: 22px;
  font-weight: 850;
  letter-spacing: -.6px;
}

.brand__mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: var(--yellow);
  border-radius: 14px;
  transform: rotate(-3deg);
}

.brand__mark svg { width: 34px; fill: var(--ink); }

.player-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px 7px 13px;
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, .72);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  backdrop-filter: blur(10px);
}

.player-chip__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--sage); }
.player-chip__separator { width: 1px; height: 20px; background: var(--line); }
.bone-balance { display: inline-flex; align-items: center; gap: 5px; color: #9a701c; }
.bone-balance svg { width: 22px; fill: var(--yellow-dark); }
.bone-balance strong { min-width: 12px; font-variant-numeric: tabular-nums; }

.icon-button, .round-button, .modal-close {
  padding: 0;
  border: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.icon-button { width: 29px; height: 29px; background: rgba(29, 33, 31, .07); border-radius: 50%; }
.icon-button svg { width: 15px; fill: currentColor; }

.screen { display: none; min-height: 620px; animation: reveal .4s ease both; }
.screen--active { display: grid; }

@keyframes reveal { from { opacity: 0; transform: translateY(7px); } }

.auth-screen, .menu-screen {
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, .82fr);
  align-items: center;
  gap: clamp(40px, 8vw, 110px);
  padding: 40px 4% 74px;
}

.eyebrow {
  margin: 0 0 15px;
  color: var(--sage-dark);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .16em;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 23px; font-size: clamp(47px, 5.6vw, 76px); line-height: .99; letter-spacing: -.065em; }
h1 em { color: var(--yellow-dark); font-style: normal; }
h2 { margin-bottom: 12px; font-size: clamp(32px, 4vw, 44px); line-height: 1; letter-spacing: -.045em; }

.lead { max-width: 560px; margin-bottom: 0; color: var(--muted); font-size: 18px; line-height: 1.65; }

.card {
  background: rgba(255, 253, 248, .9);
  border: 1px solid rgba(29, 33, 31, .09);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.auth-card { padding: 24px 32px 28px; }
.dog-portrait { height: 185px; margin: -38px auto 9px; }
.dog-portrait svg { display: none; }
.dog-portrait__image { width: 100%; height: 100%; display: block; object-fit: contain; filter: drop-shadow(0 12px 9px rgba(29,33,31,.12)); }
.portrait-shadow { fill: rgba(29, 33, 31, .11); }
.portrait-body, .portrait-head, .portrait-leg { fill: #1d201f; }
.portrait-tail { fill: none; stroke: #1d201f; stroke-width: 12; stroke-linecap: round; }
.portrait-ear { fill: #101211; }
.portrait-muzzle { fill: #292d2b; }
.portrait-eye { fill: var(--yellow); }
.portrait-tag, .portrait-collar, .menu-tag { fill: var(--dog-accent); }
.menu-collar { stroke: var(--dog-accent); }
.portrait-glint { fill: white; }
.portrait-nose { fill: #090a0a; }

label { display: block; margin: 0 0 9px; font-size: 14px; font-weight: 750; }
.input-wrap { position: relative; }

input {
  width: 100%;
  height: 55px;
  padding: 0 48px 0 17px;
  border: 1.5px solid rgba(29, 33, 31, .17);
  outline: 0;
  color: var(--ink);
  background: #fff;
  border-radius: 15px;
  transition: border .2s, box-shadow .2s;
}

input:focus { border-color: var(--yellow-dark); box-shadow: 0 0 0 4px rgba(246, 196, 83, .18); }
input[aria-invalid="true"] { border-color: #c95b50; }
.input-icon { position: absolute; top: 50%; right: 17px; transform: translateY(-52%); font-size: 23px; }
.form-hint, .form-error { min-height: 17px; margin: 7px 0 0; font-size: 11px; }
.form-hint { color: var(--muted); }
.form-error { color: #ad4038; font-weight: 650; }
.privacy-note { margin: 15px 0 0; text-align: center; color: var(--muted); font-size: 11px; }

.button {
  min-height: 52px;
  padding: 0 24px;
  border: 1px solid transparent;
  border-radius: 15px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 9px;
  font-weight: 820;
  cursor: pointer;
  transition: transform .18s, box-shadow .18s, background .18s;
}

.button:hover { transform: translateY(-2px); }
.button:active { transform: translateY(0) scale(.98); }
.button svg { width: 19px; fill: currentColor; }
.button--primary { background: var(--yellow); color: var(--ink); box-shadow: 0 10px 22px rgba(220, 168, 53, .22); }
.button--primary:hover { background: #f8ca60; box-shadow: 0 13px 26px rgba(220, 168, 53, .29); }
.button--secondary { border-color: var(--line); background: rgba(255, 255, 255, .64); }
.button--secondary:hover { background: #fff; }
.button--wide { width: 100%; margin-top: 16px; }

.menu-screen { grid-template-columns: minmax(390px, .8fr) minmax(0, 1.2fr); position: relative; }
.menu-copy { position: relative; z-index: 2; }
.menu-screen h1 { font-size: clamp(48px, 5vw, 70px); }
.menu-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }
.control-tips { display: flex; gap: 24px; margin-top: 30px; color: var(--muted); font-size: 12px; }
.control-tips > div { display: flex; align-items: center; gap: 8px; }
kbd { padding: 4px 9px; border: 1px solid var(--line); border-bottom-width: 3px; background: #fff; border-radius: 7px; color: var(--ink); font: 650 11px inherit; }
.tap-icon { font-size: 24px; color: var(--ink); }

.menu-visual { min-height: 480px; position: relative; overflow: hidden; border-radius: 52% 48% 45% 55% / 51% 43% 57% 49%; background: #f5eddb; }
.sun { position: absolute; width: 108px; height: 108px; top: 55px; right: 75px; border-radius: 50%; background: var(--yellow); }
.cloud { position: absolute; width: 90px; height: 23px; border-radius: 50px; background: rgba(255,255,255,.72); }
.cloud::before, .cloud::after { content: ""; position: absolute; bottom: 0; border-radius: 50%; background: inherit; }
.cloud::before { width: 39px; height: 39px; left: 14px; }
.cloud::after { width: 29px; height: 29px; right: 12px; }
.cloud--one { top: 90px; left: 75px; }
.cloud--two { top: 180px; right: 38px; transform: scale(.72); }
.hill { position: absolute; bottom: 56px; border-radius: 50% 50% 0 0; transform-origin: bottom; }
.hill--back { width: 470px; height: 220px; left: -80px; background: #c7cfad; transform: rotate(7deg); }
.hill--front { width: 540px; height: 180px; right: -165px; background: var(--sage); transform: rotate(-5deg); }
.menu-dog { width: min(480px, 85%); position: absolute; z-index: 2; left: 50%; bottom: 66px; transform: translateX(-50%); animation: dogBreathe 2.8s ease-in-out infinite; }
.menu-dog svg { display: none; }
.menu-dog__image { width: 100%; max-height: 285px; display: block; object-fit: contain; filter: drop-shadow(0 14px 10px rgba(22,25,24,.17)); }
.grass-line { position: absolute; z-index: 3; left: 0; right: 0; bottom: 54px; height: 4px; background: var(--sage-dark); }
@keyframes dogBreathe { 50% { transform: translateX(-50%) translateY(-5px) rotate(-.5deg); } }

.menu-cookie-decoration {
  width: 62px;
  height: 62px;
  position: absolute;
  z-index: 5;
  right: -5px;
  bottom: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(217,154,85,.13);
  pointer-events: none;
  animation: menuCookieOrbit 3.2s ease-in-out infinite;
}
.menu-cookie-decoration svg { width: 48px; overflow: visible; animation: menuCookieSpin 3.6s linear infinite; filter: drop-shadow(0 7px 7px rgba(108,67,31,.22)); }
.menu-cookie-base { fill: #d99a55; stroke: #a96831; stroke-width: 2; }
.menu-cookie-chip { fill: #62402c; }
.menu-cookie-shine { fill: none; stroke: rgba(255,244,210,.65); stroke-width: 3; stroke-linecap: round; }
@keyframes menuCookieSpin { to { transform: rotate(360deg); } }
@keyframes menuCookieOrbit { 50% { transform: translateY(-9px) scale(1.05); } }

.game-screen { place-items: center; padding: 20px 0 50px; }
.game-card { width: 100%; }
.game-hud { width: min(950px, 94%); margin: 0 auto 14px; display: flex; align-items: center; gap: 36px; }
.hud-item { display: flex; flex-direction: column; }
.hud-item span { color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.hud-item strong { font-variant-numeric: tabular-nums; font-size: 24px; letter-spacing: .09em; }
.hud-item--best { margin-right: auto; }
.hud-bones { height: 43px; padding: 0 14px; display: flex; align-items: center; gap: 7px; border: 1px solid rgba(220,168,53,.25); border-radius: 999px; background: rgba(246,196,83,.16); color: #8f681b; }
.hud-bones svg { width: 24px; fill: var(--yellow-dark); }
.hud-bones strong { font-size: 16px; font-variant-numeric: tabular-nums; }
.hud-bones--pulse { animation: bonePulse .32s ease; }
@keyframes bonePulse { 50% { transform: scale(1.12); background: rgba(246,196,83,.42); } }
.round-button { width: 43px; height: 43px; border: 1px solid var(--line); background: rgba(255,255,255,.78); border-radius: 50%; }
.round-button svg { width: 18px; fill: currentColor; }

.canvas-wrap {
  width: 100%;
  height: min(57vw, 560px);
  min-height: 330px;
  max-height: 560px;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(29,33,31,.09);
  border-radius: 30px;
  background: #f8f1df;
  box-shadow: var(--shadow);
  touch-action: none;
  user-select: none;
  cursor: pointer;
}

#gameCanvas { width: 100%; height: 100%; display: block; }
.countdown { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink); font-size: clamp(70px, 12vw, 130px); font-weight: 900; text-shadow: 0 4px 0 rgba(255,255,255,.55); }
.jump-prompt { position: absolute; left: 50%; bottom: 28px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; color: rgba(29,33,31,.66); font-size: 12px; font-weight: 700; pointer-events: none; animation: promptBounce 1.3s ease-in-out infinite; }
.prompt-arrow { margin-top: 2px; font-size: 20px; }
@keyframes promptBounce { 50% { transform: translateX(-50%) translateY(-6px); } }
.game-help { margin: 17px 0 0; text-align: center; color: var(--muted); font-size: 12px; }

.overlay {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: none;
  place-items: center;
  padding: 20px;
  background: rgba(24, 27, 25, .43);
  backdrop-filter: blur(10px);
}
.overlay--active { display: grid; animation: fadeIn .2s ease both; }
@keyframes fadeIn { from { opacity: 0; } }

.modal { width: min(420px, 100%); padding: 30px; position: relative; text-align: center; animation: modalIn .3s cubic-bezier(.2,.8,.2,1) both; }
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(.97); } }
.modal-icon { width: 60px; height: 60px; margin: -60px auto 22px; display: grid; place-items: center; border: 5px solid var(--paper); border-radius: 50%; background: var(--yellow); font-size: 23px; font-weight: 900; }
.modal-icon--sad { background: #d98968; color: #fff; font-size: 34px; }
.modal .eyebrow { margin-bottom: 9px; }
.text-button { margin: 16px auto 0; padding: 4px; border: 0; background: none; color: var(--muted); font-size: 13px; font-weight: 700; cursor: pointer; text-decoration: underline; text-underline-offset: 4px; }
.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 24px 0 4px; }
.result-grid .result-bones { grid-column: 1 / -1; background: rgba(246,196,83,.19); }
.result-bones strong { color: #976d18; }
.mini-bone { display: inline-block !important; margin-right: 3px; color: var(--yellow-dark) !important; font-size: 14px !important; transform: rotate(45deg); }
.result-grid div { padding: 15px; border-radius: 16px; background: #f5f0e5; }
.result-grid span { display: block; color: var(--muted); font-size: 10px; font-weight: 750; text-transform: uppercase; }
.result-grid strong { display: block; margin-top: 3px; font-size: 25px; }
.new-record { width: max-content; margin: 0 auto; padding: 6px 11px; border-radius: 99px; background: rgba(246,196,83,.25); color: #9a701c; font-size: 12px; font-weight: 850; }

.leaderboard-card { width: min(520px, 100%); padding: 35px 28px 24px; }
.modal-close { width: 36px; height: 36px; position: absolute; top: 16px; right: 16px; border-radius: 50%; background: rgba(29,33,31,.07); font-size: 25px; line-height: 1; }
.leaderboard-head { display: flex; justify-content: space-between; padding: 15px 14px 8px; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.leaderboard-list { max-height: min(48vh, 380px); margin: 0; padding: 0; overflow-y: auto; list-style: none; text-align: left; }
.leaderboard-list li { min-height: 49px; margin-bottom: 5px; padding: 7px 14px; display: grid; grid-template-columns: 28px 34px 1fr auto; align-items: center; gap: 8px; border-radius: 13px; background: rgba(29,33,31,.035); font-size: 13px; }
.leaderboard-list li.current { background: rgba(246,196,83,.21); }
.rank { color: var(--muted); font-weight: 800; }
.avatar { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: var(--sage); color: white; font-size: 12px; font-weight: 850; text-transform: uppercase; }
.leader-name { overflow: hidden; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.leader-score { font-weight: 850; font-variant-numeric: tabular-nums; }
.leaderboard-note, .empty-leaderboard { margin: 15px 0 0; color: var(--muted); font-size: 11px; }

.shop-card { width: min(610px, 100%); padding: 35px 28px 25px; }
.shop-wallet { width: max-content; margin: 18px auto 20px; padding: 9px 14px; display: flex; align-items: center; gap: 7px; border-radius: 999px; background: rgba(246,196,83,.18); color: #8f681b; font-size: 13px; }
.shop-wallet svg { width: 23px; fill: var(--yellow-dark); }
.shop-wallet strong { font-size: 17px; font-variant-numeric: tabular-nums; }
.shop-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; text-align: left; }
.shop-item { padding: 15px; border: 1px solid var(--line); border-radius: 17px; background: rgba(255,255,255,.56); }
.shop-item--selected { border-color: var(--yellow-dark); box-shadow: inset 0 0 0 1px var(--yellow-dark); background: rgba(246,196,83,.1); }
.shop-item__top { display: grid; grid-template-columns: 1fr; gap: 8px; margin-bottom: 13px; }
.collar-preview { width: 100%; height: 125px; position: relative; display: grid; place-items: center; overflow: hidden; border-radius: 13px; background: linear-gradient(180deg, #fffdf8, #f2ede3); }
.collar-preview img { width: 88%; height: 112px; display: block; object-fit: contain; filter: drop-shadow(0 7px 5px rgba(29,33,31,.12)); }
.collar-preview__band { width: 29px; height: 15px; position: absolute; left: 64%; top: 42%; border: 5px solid var(--preview-color); border-radius: 48%; transform: rotate(12deg); box-shadow: inset 0 0 0 1px rgba(255,255,255,.28), 0 1px 1px rgba(29,33,31,.24); }
.collar-preview__charm { position: absolute; left: calc(64% + 18px); top: calc(42% + 20px); color: var(--preview-color); font-size: 18px; font-weight: 900; line-height: 1; text-shadow: 0 1px 0 #fff, 0 2px 2px rgba(29,33,31,.3); }
.shop-item h3 { margin: 0 0 2px; font-size: 14px; }
.shop-item p { margin: 0; color: var(--muted); font-size: 10px; }
.shop-buy { width: 100%; min-height: 36px; padding: 0 10px; border: 0; border-radius: 10px; background: var(--ink); color: white; font-size: 11px; font-weight: 800; cursor: pointer; }
.shop-buy:disabled { background: rgba(29,33,31,.1); color: var(--muted); cursor: default; }
.shop-buy--equip { background: var(--yellow); color: var(--ink); }
.shop-message { min-height: 17px; margin: 13px 0 0; color: #9a701c; font-size: 11px; font-weight: 750; }

.footer { min-height: 55px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; }

@media (max-width: 820px) {
  .app-shell { width: min(100% - 28px, 680px); }
  .topbar { min-height: 72px; }
  .auth-screen, .menu-screen { grid-template-columns: 1fr; gap: 38px; padding: 38px 4px 55px; text-align: center; }
  .auth-copy .lead, .menu-copy .lead { margin-left: auto; margin-right: auto; }
  .auth-card { width: min(430px, 100%); margin: 0 auto; text-align: left; }
  .dog-portrait { height: 165px; }
  .menu-visual { min-height: 390px; order: -1; }
  .menu-actions, .control-tips { justify-content: center; }
  .canvas-wrap { height: min(72vw, 500px); }
}

@media (max-width: 520px) {
  .app-shell { width: calc(100% - 20px); }
  .brand { font-size: 19px; }
  .brand__mark { width: 39px; height: 39px; }
  .player-chip { font-size: 12px; }
  h1 { font-size: clamp(41px, 13.5vw, 60px); }
  .lead { font-size: 15px; line-height: 1.55; }
  .auth-screen { padding-top: 24px; }
  .auth-card { padding: 20px 20px 24px; }
  .dog-portrait { height: 142px; margin-top: -25px; }
  .menu-screen { padding-top: 18px; }
  .menu-visual { min-height: 300px; border-radius: 28px; }
  .sun { width: 78px; height: 78px; top: 35px; right: 40px; }
  .menu-dog { bottom: 35px; width: 92%; }
  .hill { bottom: 29px; }
  .grass-line { bottom: 29px; }
  .menu-actions { flex-direction: column; }
  .menu-actions .button { width: 100%; }
  .menu-cookie-decoration { width: 49px; height: 49px; right: 3px; bottom: 8px; }
  .menu-cookie-decoration svg { width: 38px; }
  .control-tips { gap: 14px; }
  .game-screen { padding-top: 5px; }
  .game-hud { gap: 18px; }
  .hud-item strong { font-size: 19px; }
  .hud-bones { height: 39px; padding: 0 10px; }
  .hud-bones svg { width: 20px; }
  .canvas-wrap { height: calc(100dvh - 205px); min-height: 365px; max-height: 630px; border-radius: 22px; }
  .game-help { display: none; }
  .modal { padding: 27px 20px 22px; }
  .shop-grid { grid-template-columns: 1fr; max-height: 48vh; overflow-y: auto; }
  .footer { flex-direction: column; justify-content: center; padding: 14px 0; }
}

@media (max-height: 690px) and (min-width: 821px) {
  .screen { min-height: 500px; }
  .auth-screen, .menu-screen { padding-top: 15px; padding-bottom: 30px; }
  .dog-portrait { height: 140px; }
  .menu-visual { min-height: 420px; }
}

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