:root {
  color-scheme: light;
  --ink: #20322b;
  --muted: #68766d;
  --paper: #fffaf0;
  --cream: #f5e7c8;
  --green: #2f795b;
  --green-dark: #20523e;
  --orange: #e36f3d;
  --yellow: #f5c65b;
  --red: #ce5146;
  --line: #263d33;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background: #d9cca9;
  color: var(--ink);
  font-family: Inter, ui-rounded, "Arial Rounded MT Bold", system-ui, sans-serif;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
button { color: inherit; font: inherit; }
button:focus-visible { outline: 3px solid #f2a93b; outline-offset: 2px; }
button:disabled { opacity: .38; cursor: not-allowed; }
[hidden] { display: none !important; }

.app { height: 100vh; height: 100svh; display: grid; grid-template-rows: 64px minmax(0, 1fr); }
.topbar {
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 7px clamp(10px, 3vw, 26px);
  border-bottom: 2px solid #2d4539;
  background: rgba(255, 250, 240, .94);
  box-shadow: 0 4px 0 #20322b14;
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; font-weight: 1000; letter-spacing: -.06em; white-space: nowrap; }
.brand img { width: 39px; height: 39px; }
.brand b { color: var(--orange); }
.stats { display: flex; gap: clamp(16px, 6vw, 58px); }
.stats div { display: grid; justify-items: center; }
.stats small, .eyebrow, .modal header small, .request-copy small { color: var(--muted); font-size: .56rem; font-weight: 950; letter-spacing: .17em; }
.stats strong { font-size: clamp(.78rem, 2.6vw, 1rem); font-variant-numeric: tabular-nums; }
.top-actions { justify-self: end; display: flex; gap: 6px; }
.icon-button, .close-button {
  border: 1.5px solid #385144;
  border-radius: 11px;
  background: #fffaf0;
  box-shadow: 0 2px 0 #385144;
  font-size: .72rem;
  font-weight: 900;
  cursor: pointer;
}
.icon-button { min-width: 58px; padding: 8px 10px; }
.icon-button i { display: inline-grid; place-items: center; min-width: 18px; height: 18px; margin-left: 3px; border-radius: 99px; background: var(--orange); color: white; font-size: .6rem; font-style: normal; }

.stage { position: relative; min-height: 0; width: 100%; max-width: 1500px; margin: 0 auto; overflow: hidden; isolation: isolate; background: #bdcf91; touch-action: none; }
#game { width: 100%; height: 100%; display: block; outline: none; touch-action: none; }

.request-stack {
  position: absolute;
  z-index: 9;
  top: 12px;
  right: 12px;
  width: min(390px, calc(100% - 24px));
  display: block;
}
.request-card {
  position: relative;
  min-height: 72px;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  padding: 7px 8px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 250, 240, .97);
  box-shadow: 0 3px 0 #20322b2b, 0 9px 20px #273a2626;
  animation: card-in 200ms ease-out;
}
@keyframes card-in { from { opacity: 0; translate: 12px 0; } }
.request-art { width: 45px; height: 45px; display: grid; place-items: center; border-radius: 11px; background: #ead9b5; }
.request-art img { width: 40px; height: 33px; object-fit: contain; }
.request-copy { min-width: 0; display: grid; gap: 1px; }
.request-copy strong { line-height: 1.05; }
.request-copy span { overflow: hidden; color: var(--muted); font-size: .69rem; text-overflow: ellipsis; white-space: nowrap; }
.request-pay { color: var(--green); font-size: .86rem; }
.request-buttons { display: flex; gap: 5px; }
.request-buttons button, .action-bar button, .dog-actions button, .shop-item button, .big-button {
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  box-shadow: 0 2px 0 var(--line);
  font-weight: 950;
  cursor: pointer;
}
.request-buttons { grid-column: 2 / -1; justify-content: end; }
.request-buttons button { padding: 5px 9px; font-size: .6rem; text-transform: uppercase; }
button.primary { background: var(--green); color: white; }

.jobs { position: absolute; z-index: 5; top: 12px; left: 10px; width: min(220px, 31vw); display: grid; gap: 6px; pointer-events: none; }
.job-chip { padding: 7px 9px; border: 1.5px solid #294237; border-radius: 10px; background: rgba(255,250,240,.9); box-shadow: 0 2px 0 #29423722; cursor: pointer; pointer-events: auto; }
.job-chip strong, .job-chip span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-chip strong { font-size: .7rem; }
.job-chip span { margin-top: 2px; color: var(--muted); font-size: .55rem; font-weight: 800; }
.job-chip i { display: block; height: 4px; margin-top: 5px; overflow: hidden; border-radius: 9px; background: #d8d0bc; }
.job-chip i b { display: block; height: 100%; background: var(--green); }

.hint, .toast {
  position: absolute;
  z-index: 7;
  left: 50%;
  translate: -50% 8px;
  padding: 8px 13px;
  border: 1.5px solid #344a40;
  border-radius: 99px;
  background: rgba(255,250,240,.93);
  font-size: .66rem;
  font-weight: 900;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: 180ms ease;
}
.hint { top: 14px; }
.toast { top: 18%; color: white; background: rgba(32,50,43,.93); }
.hint.show, .toast.show { opacity: 1; translate: -50% 0; }

.action-bar { position: absolute; z-index: 8; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); translate: -50% 0; display: flex; gap: 7px; align-items: end; }
.action-bar button { min-height: 45px; padding: 10px 15px; font-size: .7rem; text-transform: uppercase; white-space: nowrap; }
.action-bar .action-main { min-width: 128px; background: var(--green); color: white; }
.action-bar .whistle-action { background: var(--yellow); }

.joystick { display: none; position: absolute; z-index: 7; left: 22px; bottom: max(18px, env(safe-area-inset-bottom)); width: 112px; height: 112px; border: 2px solid #31493d66; border-radius: 50%; background: #fffaf055; box-shadow: inset 0 0 0 10px #fffaf01f; touch-action: none; }
.joystick div { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; translate: -50% -50%; border: 2px solid #31493d; border-radius: 50%; background: #fffaf0cc; box-shadow: 0 3px 0 #31493d44; }

.overlay, .modal-backdrop { position: absolute; inset: 0; z-index: 30; display: grid; place-items: center; padding: 20px; background: rgba(37, 55, 45, .58); backdrop-filter: blur(5px); }
.intro-card, .modal { width: min(520px, 100%); max-height: min(690px, calc(100% - 20px)); overflow: auto; border: 2px solid var(--line); border-radius: 24px; background: var(--paper); box-shadow: 0 8px 0 #20322b33, 0 25px 60px #18291f66; }
.intro-card { padding: clamp(22px, 6vw, 42px); text-align: center; }
.intro-card > img { width: 78px; height: 78px; }
.intro-card h1 { margin: 7px 0 10px; font-size: clamp(2rem, 9vw, 4.2rem); line-height: .88; letter-spacing: -.075em; }
.intro-card > p:not(.eyebrow) { margin: 0 auto; max-width: 430px; color: var(--muted); font-size: .9rem; line-height: 1.5; }
.control-note { display: flex; justify-content: center; gap: 13px; flex-wrap: wrap; margin: 20px 0; color: var(--muted); font-size: .65rem; font-weight: 800; }
kbd { padding: 3px 5px; border: 1px solid #6d786f; border-radius: 4px; background: white; box-shadow: 0 2px 0 #c8c1ae; font: inherit; }
.big-button { padding: 13px 24px; background: var(--green); color: white; font-size: .9rem; }

.modal { padding: 15px; }
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 12px; }
.modal h2 { margin: 1px 0 0; font-size: 1.55rem; letter-spacing: -.04em; }
.close-button { width: 36px; height: 36px; font-size: 1.35rem; }
.modal-list { display: grid; gap: 8px; }
.empty-note { padding: 30px 12px; color: var(--muted); text-align: center; }
.dog-card, .shop-item { border: 1.5px solid #52635966; border-radius: 13px; background: white; }
.dog-card { display: grid; grid-template-columns: 54px 1fr; gap: 9px; padding: 9px; }
.dog-card > img { width: 50px; height: 43px; align-self: center; }
.dog-card header { display: flex; padding: 0; }
.dog-card header strong { font-size: .84rem; }
.dog-card header span { color: var(--muted); font-size: .65rem; }
.dog-meta { color: var(--muted); font-size: .62rem; font-weight: 750; }
.dog-meter { height: 7px; margin: 6px 0 4px; overflow: hidden; border-radius: 9px; background: #ded9ca; }
.dog-meter i { display: block; height: 100%; background: var(--green); }
.dog-card.warning .dog-meter i { background: #e2a532; }
.dog-card.danger .dog-meter i { background: var(--red); }
.dog-actions { grid-column: 1 / -1; display: flex; gap: 5px; justify-content: end; }
.dog-actions button { padding: 6px 9px; font-size: .58rem; text-transform: uppercase; }
.shop-item { display: grid; grid-template-columns: 1fr auto; gap: 5px 12px; align-items: center; padding: 12px; }
.shop-item strong { font-size: .82rem; }
.shop-item p { grid-column: 1; margin: 0; color: var(--muted); font-size: .65rem; }
.shop-item button { grid-column: 2; grid-row: 1 / 3; min-width: 72px; padding: 9px; background: var(--yellow); font-size: .66rem; }
.shop-item.owned { opacity: .55; }
.requests-list .request-card { animation: none; }

@media (pointer: coarse), (max-width: 760px) {
  .app { grid-template-rows: 58px minmax(0, 1fr); }
  .topbar { grid-template-columns: auto 1fr auto; gap: 7px; padding: 6px 8px; }
  .brand > span { display: none; }
  .brand img { width: 38px; height: 38px; }
  .stats { justify-self: center; gap: 20px; }
  .icon-button { min-width: auto; padding: 7px 8px; font-size: .65rem; }
  .joystick { display: block; }
  .action-bar { left: auto; right: 12px; translate: 0; flex-direction: column-reverse; align-items: stretch; }
  .action-bar button { min-width: 108px; }
  .request-stack { top: 8px; left: 8px; right: 8px; width: auto; }
  .request-stack .request-card { width: 100%; }
  .jobs { top: 112px; left: 7px; width: 42vw; }
  .job-chip { padding: 6px 7px; }
  .request-card { grid-template-columns: 42px 1fr auto; gap: 6px; padding: 6px 7px; }
  .request-art { width: 40px; height: 40px; }
  .request-art img { width: 36px; height: 30px; }
  .request-copy span { font-size: .6rem; }
  .request-card > b { font-size: .78rem; }
  .request-buttons button { padding: 6px 9px; }
  .hint { top: auto; bottom: 143px; }
}

@media (max-height: 520px) and (pointer: coarse) {
  .joystick { width: 88px; height: 88px; }
  .joystick div { width: 42px; height: 42px; }
  .jobs { top: 104px; }
  .job-chip:nth-child(n+3) { display: none; }
  .intro-card { padding: 18px; }
  .intro-card > img { width: 48px; height: 48px; }
  .intro-card h1 { font-size: 2.25rem; }
  .control-note { margin: 10px 0; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
