:root {
  color-scheme: light;
  --paper: #f3f0e6;
  --paper-deep: #e8e3d5;
  --ink: #20221d;
  --muted: #6f7168;
  --line: #aaa99f;
  --green: #667457;
  --green-soft: #d9dfcc;
  --red: #985e54;
  --yellow: #e1c776;
  --header-h: 58px;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  scroll-behavior: smooth;
  background: var(--paper);
}

body {
  min-width: 300px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 1%, rgba(255,255,255,.7), transparent 28rem),
    repeating-linear-gradient(0deg, transparent, transparent 27px, rgba(32,34,29,.024) 28px),
    var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--green); outline-offset: 3px; }

.hud {
  position: sticky;
  z-index: 100;
  top: 0;
  height: var(--header-h);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 0 clamp(12px, 3vw, 36px);
  border-bottom: 1px solid var(--ink);
  background: rgba(243,240,230,.94);
  backdrop-filter: blur(10px);
  font-family: "Courier New", ui-monospace, monospace;
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .06em;
}

.brand { display: flex; align-items: center; gap: 9px; color: inherit; text-decoration: none; }
.brand-mark { display: grid; width: 31px; height: 31px; place-items: center; border: 1px solid; border-radius: 50%; font-size: .63rem; }
.hud-stats, .hud-actions { display: flex; align-items: center; gap: clamp(9px, 2.4vw, 24px); white-space: nowrap; }
.hud-actions { justify-content: flex-end; }
.hud-button, .icon-button, .close-button { border: 0; padding: 5px; color: inherit; background: none; cursor: pointer; font: inherit; }
.hud-button:hover { text-decoration: underline; text-underline-offset: 3px; }
.hud-button b { color: var(--green); }
.egg-shop-button { border: 1px solid var(--ink); padding: 7px 9px; }
.icon-button { width: 31px; height: 31px; border: 1px solid var(--ink); border-radius: 50%; letter-spacing: 1px; }

.park { position: relative; width: min(1120px, 100%); min-height: 100vh; margin: 0 auto; padding: 0 clamp(14px, 3vw, 42px); }
.entrance { position: relative; z-index: 2; min-height: 300px; padding-top: 72px; text-align: center; }
.entrance-art { position: relative; width: min(430px, 86vw); height: 136px; margin: 0 auto; padding: 20px 54px 0; }
.entrance-art::before { position: absolute; inset: 18px 34px auto; height: 78px; border: 2px solid var(--ink); background: var(--paper); content: ""; box-shadow: 4px 4px 0 var(--paper-deep); transform: rotate(-.4deg); }
.entrance h1 { position: relative; z-index: 1; margin: 10px 0 0; font: 700 clamp(1.6rem, 5vw, 2.6rem)/.86 "Courier New", monospace; letter-spacing: .12em; }
.post { position: absolute; z-index: 2; top: 15px; width: 5px; height: 125px; background: var(--ink); }
.post::after { position: absolute; bottom: 0; left: -10px; width: 25px; border-top: 3px solid var(--ink); content: ""; }
.post.left { left: 32px; transform: rotate(1deg); }
.post.right { right: 32px; transform: rotate(-1deg); }
.entrance p { margin: 2px 0; color: var(--muted); font: .72rem "Courier New", monospace; letter-spacing: .08em; }
.path-start { width: 1px; height: 88px; margin: 18px auto 0; border-left: 2px dashed var(--line); }

.notice { position: relative; z-index: 4; width: min(520px, 100%); min-height: 0; margin: -10px auto 62px; text-align: center; }
.guide-card { display: inline-flex; align-items: center; gap: 12px; padding: 11px 15px; border: 1px solid var(--ink); background: var(--paper); box-shadow: 3px 3px 0 var(--paper-deep); font: 700 .74rem "Courier New", monospace; letter-spacing: .03em; }
.guide-card::before { content: "→"; font-size: 1rem; }

.plots { position: relative; z-index: 2; display: flex; flex-direction: column; padding-bottom: 130px; }
.plot-wrap { position: relative; width: var(--plot-width); margin-top: var(--plot-gap); align-self: center; }
.plot-wrap::before { position: absolute; z-index: -1; top: -80px; left: var(--path-x, 50%); height: 80px; border-left: 2px dashed rgba(78,78,70,.28); content: ""; }

.plot {
  position: relative;
  min-height: var(--plot-height);
  border: 2px solid var(--ink);
  background: rgba(243,240,230,.88);
  box-shadow: 5px 5px 0 rgba(117,116,106,.12);
  isolation: isolate;
}
.plot::before, .plot::after { position: absolute; z-index: 5; pointer-events: none; content: ""; }
.plot[data-type="pen"]::before, .plot[data-type="chickens"]::before { inset: 8px; border: 1px dashed rgba(32,34,29,.42); }
.plot.broken { border-bottom-style: dashed; }
.plot.broken::after { right: 20%; bottom: -8px; width: 45px; height: 18px; border-top: 3px solid var(--red); transform: rotate(10deg); }
.plot.drop-valid { background: var(--green-soft); box-shadow: 0 0 0 5px rgba(102,116,87,.25); }
.plot.drop-invalid { opacity: .5; }
.plot.feeding-active { box-shadow: 0 0 0 5px rgba(102,116,87,.2), 5px 5px 0 rgba(117,116,106,.12); }
.plot.feeding-active .plot-body { cursor: crosshair; }

.plot-head { position: absolute; z-index: 8; top: -15px; left: 13px; display: flex; max-width: calc(100% - 26px); align-items: center; gap: 7px; padding: 4px 8px; border: 1px solid var(--ink); background: var(--paper); font: 700 .66rem "Courier New", monospace; letter-spacing: .06em; text-transform: uppercase; }
.plot-number { color: var(--muted); }
.plot-body { position: absolute; inset: 0; overflow: hidden; }
.plot-controls { position: absolute; z-index: 12; right: 9px; bottom: 9px; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; max-width: calc(100% - 18px); }
.mini-button, .primary-button, .line-button { min-height: 34px; border: 1px solid var(--ink); padding: 7px 10px; color: var(--ink); background: var(--paper); box-shadow: 2px 2px 0 rgba(32,34,29,.16); cursor: pointer; font: 700 .66rem "Courier New", monospace; letter-spacing: .03em; text-transform: uppercase; }
.mini-button:hover, .primary-button:hover, .line-button:hover { color: var(--paper); background: var(--ink); }
.mini-button[disabled] { cursor: not-allowed; opacity: .42; }
.mini-button.selected { color: var(--paper); background: var(--green); }
.primary-button { padding: 11px 15px; color: white; background: var(--green); }
.danger-button { color: var(--red); }

.empty-plot, .locked-plot { position: absolute; inset: 0; display: grid; place-content: center; gap: 13px; padding: 28px; text-align: center; }
.empty-plot p, .locked-plot p { margin: 0; color: var(--muted); font: .72rem/1.5 "Courier New", monospace; }
.type-choices { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; }
.lock-sign { display: inline-block; justify-self: center; padding: 7px 10px; border: 1px solid var(--ink); background: var(--paper-deep); font: 700 .7rem "Courier New", monospace; transform: rotate(-1.5deg); }

.pen-ground { position: absolute; inset: 0; background: radial-gradient(ellipse at 22% 80%, rgba(102,116,87,.09), transparent 20%), radial-gradient(ellipse at 75% 30%, rgba(102,116,87,.07), transparent 16%); }
.grass-tuft { position: absolute; width: 24px; height: 24px; opacity: .55; }
.trough { position: absolute; right: 13%; bottom: 15%; width: 52px; opacity: .65; }

.dinosaur { position: absolute; z-index: 6; left: 50%; top: 50%; width: var(--dino-width); height: var(--dino-height); cursor: grab; touch-action: pan-y; user-select: none; will-change: left, top; filter: drop-shadow(1px 2px 0 rgba(32,34,29,.12)); transition: filter .15s; }
.dinosaur svg { display: block; width: 100%; height: 100%; overflow: visible; pointer-events: none; transform: scaleX(var(--facing, 1)); transform-origin: center; }
.dinosaur:hover { z-index: 9; filter: drop-shadow(2px 4px 0 rgba(32,34,29,.18)); }
.dinosaur.dragging { position: fixed !important; z-index: 200; width: calc(var(--dino-width) * 1.08); cursor: grabbing; pointer-events: none; filter: drop-shadow(4px 7px 0 rgba(32,34,29,.2)); touch-action: none; }
.dinosaur.scuffle { animation: scuffle .55s steps(2) 3; }
.dinosaur.eating { animation: eat .45s ease-in-out 3; }
.dino-label { position: absolute; top: 100%; left: 50%; padding: 2px 4px; color: var(--ink); background: rgba(243,240,230,.8); font: 600 .55rem "Courier New", monospace; opacity: 0; pointer-events: none; transform: translateX(-50%); white-space: nowrap; transition: opacity .15s; }
.dinosaur:hover .dino-label { opacity: 1; }

.feed-position-hint { position: absolute; z-index: 18; top: 20px; left: 50%; padding: 5px 8px; border: 1px solid var(--green); color: var(--green); background: rgba(243,240,230,.92); font: 700 .62rem "Courier New", monospace; pointer-events: none; transform: translateX(-50%); white-space: nowrap; }
.pen-lure { position: absolute; z-index: 7; pointer-events: none; transform: translate(-50%, -50%); }
.food-lure { width: 38px; height: 42px; text-align: center; }
.food-lure img { display: block; width: 27px; height: 31px; margin: 0 auto; }
.food-lure span { display: block; padding: 1px 3px; color: var(--green); background: rgba(243,240,230,.82); font: 600 .52rem "Courier New", monospace; white-space: nowrap; }
.released-chicken { width: 39px; height: 31px; filter: drop-shadow(1px 2px 0 rgba(32,34,29,.12)); }
.released-chicken svg { width: 100%; height: 100%; transform: scaleX(var(--chicken-facing, 1)); transform-origin: center; }

.egg { position: absolute; z-index: 6; width: 37px; height: 46px; transform-origin: 50% 100%; animation: egg-wobble 2.4s ease-in-out infinite; }
.egg.cracking { animation-duration: .7s; }
.egg-time { position: absolute; top: 100%; left: 50%; padding-top: 3px; font: 700 .58rem "Courier New", monospace; transform: translateX(-50%); white-space: nowrap; }

.crop-field { position: absolute; inset: 0; overflow: hidden; cursor: pointer; background: repeating-linear-gradient(90deg, transparent 0 35px, rgba(32,34,29,.05) 36px 37px); }
.soil-line { position: absolute; right: 5%; left: 5%; height: 1px; background: rgba(32,34,29,.3); }
.crop-stem { position: absolute; bottom: 18%; width: 26px; transform: scale(var(--growth-scale)); transform-origin: 50% 100%; transition: transform .4s cubic-bezier(.2,.8,.3,1.3); }
.crop-ready .crop-stem { animation: crop-sway 2.5s ease-in-out infinite alternate; }
.crop-meter { position: absolute; z-index: 5; top: 18px; right: 14px; width: 70px; height: 5px; border: 1px solid var(--ink); background: var(--paper); }
.crop-meter span { display: block; width: var(--crop-progress); height: 100%; background: var(--green); transition: width .25s; }
.water-drop { position: absolute; z-index: 15; color: #71898b; font-size: 14px; pointer-events: none; animation: drop .8s ease-out forwards; }

.chicken { position: absolute; z-index: 5; width: 37px; height: 30px; animation: chicken-peck 1.7s ease-in-out infinite; transition: left 2.8s linear, top 2.8s linear; }
.chicken svg { width: 100%; height: 100%; }

.escaped-dino { position: absolute; z-index: 20; width: 130px; height: 75px; pointer-events: none; filter: drop-shadow(3px 4px 0 rgba(32,34,29,.15)); transform: translate(-50%, -50%); will-change: left, top; }
.escaped-dino svg { width: 100%; height: 100%; transform: scaleX(var(--escape-facing, 1)); }
.escaped-note { color: var(--red); }

.visitor-layer { position: absolute; z-index: 3; inset: 220px 0 100px; overflow: hidden; pointer-events: none; }
.visitor { position: absolute; top: 0; width: 18px; height: 25px; will-change: transform; }
.visitor svg { width: 100%; height: 100%; }
.visitor.panic { animation: panic .2s steps(2) infinite; }
.money-pop, .incident-pop { position: absolute; z-index: 30; color: var(--green); font: 700 .7rem "Courier New", monospace; pointer-events: none; animation: float-up 1.4s ease-out forwards; }
.incident-pop { color: var(--red); }

.park-footer { position: relative; z-index: 5; display: flex; justify-content: space-between; padding: 36px 0 48px; border-top: 1px solid var(--line); color: var(--muted); font: .65rem "Courier New", monospace; letter-spacing: .06em; }
.park-footer a { color: inherit; }

.scrim { position: fixed; z-index: 110; inset: 0; background: rgba(32,34,29,.24); backdrop-filter: blur(2px); }
.drawer { position: fixed; z-index: 120; top: var(--header-h); right: 0; bottom: 0; width: min(390px, 92vw); padding: 26px; overflow-y: auto; border-left: 1px solid var(--ink); background: var(--paper); box-shadow: -12px 0 40px rgba(32,34,29,.12); transform: translateX(102%); transition: transform .22s ease; }
.drawer.open { transform: translateX(0); }
.drawer-head { display: flex; align-items: start; justify-content: space-between; gap: 20px; margin-bottom: 22px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.drawer h2 { margin: 4px 0 0; font: 700 1.65rem "Courier New", monospace; text-transform: uppercase; }
.eyebrow { color: var(--muted); font: 700 .63rem "Courier New", monospace; letter-spacing: .12em; }
.close-button { font-size: 1.7rem; line-height: 1; }
.drawer-copy, .tiny-note { color: var(--muted); font-size: .83rem; line-height: 1.55; }
.tiny-note { margin-top: 24px; font-size: .7rem; }
.shop-list { display: grid; gap: 9px; margin-top: 24px; }
.shop-item { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; align-items: center; width: 100%; padding: 14px; border: 1px solid var(--ink); color: inherit; background: transparent; text-align: left; cursor: pointer; }
.shop-item:hover { background: var(--paper-deep); }
.shop-item:disabled { cursor: not-allowed; opacity: .45; }
.shop-name { font: 700 .78rem "Courier New", monospace; text-transform: uppercase; }
.shop-price { font: 700 .8rem "Courier New", monospace; }
.shop-desc { grid-column: 1 / -1; color: var(--muted); font-size: .72rem; }
.collection-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.collection-card { min-height: 118px; padding: 11px; border: 1px solid var(--line); text-align: center; }
.collection-card.unknown { opacity: .4; }
.collection-card .asset { height: 65px; display: grid; place-items: center; }
.collection-card svg { width: 100%; max-height: 60px; }
.collection-card strong { display: block; font: 700 .65rem "Courier New", monospace; text-transform: uppercase; }
.line-button { display: block; width: 100%; margin: 9px 0; text-align: center; text-decoration: none; }

.toast-region { position: fixed; z-index: 300; right: 18px; bottom: 18px; display: grid; gap: 8px; width: min(320px, calc(100vw - 36px)); pointer-events: none; }
.toast { padding: 11px 13px; border: 1px solid var(--ink); background: var(--paper); box-shadow: 3px 3px 0 rgba(32,34,29,.17); font: 700 .7rem/1.4 "Courier New", monospace; animation: toast-in .2s ease-out, toast-out .3s 3.3s forwards; }

.celebration { width: min(430px, calc(100vw - 32px)); border: 2px solid var(--ink); padding: 32px; color: var(--ink); background: var(--paper); box-shadow: 8px 8px 0 rgba(32,34,29,.18); text-align: center; }
.celebration::backdrop { background: rgba(32,34,29,.4); backdrop-filter: blur(3px); }
.celebration h2 { margin: 8px 0; font: 700 2rem "Courier New", monospace; text-transform: uppercase; }
.celebration p { color: var(--muted); line-height: 1.6; }

@keyframes egg-wobble { 0%,72%,100% { transform: rotate(0); } 78% { transform: rotate(-7deg); } 84% { transform: rotate(7deg); } 90% { transform: rotate(-3deg); } }
@keyframes crop-sway { to { transform: scale(var(--growth-scale)) rotate(2deg); } }
@keyframes chicken-peck { 0%,55%,100% { transform: rotate(0); } 65%,78% { transform: rotate(13deg) translateY(2px); } }
@keyframes eat { 50% { transform: translateY(4px) rotate(1deg); } }
@keyframes scuffle { 0% { translate: -4px 1px; } 50% { translate: 5px -2px; } 100% { translate: -2px 2px; } }
@keyframes drop { 0% { transform: translateY(-18px); opacity: 0; } 25% { opacity: 1; } 100% { transform: translateY(22px); opacity: 0; } }
@keyframes float-up { to { transform: translateY(-35px); opacity: 0; } }
@keyframes escape-wander { 0% { transform: translateX(-30px) scaleX(1); } 50% { transform: translate(35px,-20px) scaleX(1); } 51% { transform: translate(35px,-20px) scaleX(-1); } 100% { transform: translateX(-35px) scaleX(-1); } }
@keyframes panic { 50% { translate: 3px 0; } }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }
@keyframes toast-out { to { transform: translateX(20px); opacity: 0; } }

@media (max-width: 680px) {
  :root { --header-h: 54px; }
  .hud { grid-template-columns: auto 1fr auto; gap: 7px; padding: 0 9px; font-size: .66rem; letter-spacing: 0; }
  .brand > span:last-child { display: none; }
  .brand-mark { width: 28px; height: 28px; }
  .hud-stats { justify-content: center; gap: 9px; }
  .hud-actions { gap: 4px; }
  .hud-button { padding: 4px 2px; }
  .egg-shop-button { padding: 6px; }
  .park { padding: 0 12px; }
  .entrance { min-height: 250px; padding-top: 48px; }
  .entrance-art { height: 128px; }
  .plot-wrap { width: min(var(--plot-width), calc(100vw - 76px)); align-self: center; margin-left: 0; }
  .plot-wrap::before { left: 50%; }
  .collection-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dino-label { opacity: 1; }
  .park-footer { padding-right: 4px; padding-left: 4px; }
}

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