:root {
  --cream: #f4edd9;
  --paper: #fbf7ea;
  --ink: #26362a;
  --muted: #687061;
  --leaf: #536d3d;
  --leaf-dark: #365139;
  --red: #a64132;
  --gold: #d6a44b;
  --line: rgba(50, 65, 45, 0.18);
  --design-width: 1440;
  --design-height: 900;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }

body {
  color: var(--ink);
  background: #d9d3bf;
  font-family: "Gill Sans", "Trebuchet MS", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; }

#viewport {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 25% 15%, rgba(255,255,255,.65), transparent 33%),
    #ded7c3;
}

#app-shell {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1440px;
  height: 900px;
  display: grid;
  grid-template-columns: 950px 490px;
  transform-origin: center;
  overflow: hidden;
  background: var(--cream);
  box-shadow: 0 30px 80px rgba(52, 50, 38, .22);
}

.orchard {
  position: relative;
  overflow: hidden;
  background: #cde4e5;
  isolation: isolate;
}

.orchard::before,
.orchard::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.orchard::before {
  inset: 0;
  z-index: 20;
  opacity: .17;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.75' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.35'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

.orchard::after {
  inset: 0;
  z-index: 4;
  background: linear-gradient(0deg, rgba(249, 245, 221, .28), transparent 34%);
}

.brand-lockup {
  position: absolute;
  z-index: 10;
  left: 36px;
  bottom: 34px;
  width: 320px;
  padding: 20px 22px 18px;
  border: 1px solid rgba(255, 252, 229, .48);
  border-radius: 4px 22px 22px 22px;
  background: rgba(247, 242, 216, .74);
  box-shadow: 0 14px 36px rgba(61, 75, 45, .13);
  backdrop-filter: blur(5px);
  pointer-events: none;
}

.eyebrow {
  display: block;
  margin-bottom: 8px;
  color: var(--red);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
}

.brand-lockup h1,
.empty-state h2,
.error-state h2,
.detail-title,
.story-quote {
  font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
}

.brand-lockup h1 {
  margin: 0;
  font-size: 45px;
  line-height: .94;
  letter-spacing: -.045em;
}

.brand-lockup p { margin: 14px 0 0; color: #59634f; font-size: 13px; line-height: 1.45; }

.orchard-art,
.orchard-layer { position: absolute; inset: 0; width: 100%; height: 100%; }
.orchard-art { z-index: 0; pointer-events: none; }
.orchard-layer { object-fit: cover; object-position: center; }
.orchard-background { z-index: 0; }
.orchard-midground { z-index: 1; }
.orchard-foreground { z-index: 2; }

.apple-layer { position: absolute; z-index: 12; inset: 0; pointer-events: none; }

.tree-apple {
  position: absolute;
  left: 0;
  top: 0;
  width: 60px;
  height: 64px;
  border: 0;
  padding: 0;
  pointer-events: auto;
  cursor: grab;
  touch-action: none;
  background: transparent;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 5px 4px rgba(43, 44, 29, .24));
  transition: filter .2s ease;
}

.tree-apple img { width: 100%; height: 100%; object-fit: contain; transform-origin: 52% 7%; pointer-events: none; }

.tree-apple:hover,
.tree-apple:focus-visible { filter: drop-shadow(0 9px 5px rgba(43,44,29,.32)) brightness(1.06); outline: none; }
.tree-apple:hover img,
.tree-apple:focus-visible img { animation: apple-wiggle 1s ease-in-out; }
.tree-apple.is-dragging { z-index: 80; cursor: grabbing; filter: drop-shadow(0 14px 8px rgba(43,44,29,.32)); }
.tree-apple.is-dragging img { animation: none; }
.tree-apple.is-collected { pointer-events: none; opacity: 0; }

@keyframes apple-wiggle {
  0%, 100% { transform: rotate(0); }
  18% { transform: rotate(-4deg); }
  38% { transform: rotate(3deg); }
  58% { transform: rotate(-2deg); }
  78% { transform: rotate(1deg); }
}

.basket {
  position: absolute;
  z-index: 35;
  right: 38px;
  bottom: 28px;
  width: 172px;
  height: 178px;
  padding: 0;
  border: 0;
  color: var(--ink);
  cursor: pointer;
  background: transparent;
  transition: transform .24s ease;
}

.basket:hover { transform: translateY(-4px) rotate(-1deg); }
.basket:focus-visible { outline: 3px solid rgba(166, 65, 50, .58); outline-offset: 4px; border-radius: 20px; }
.basket.is-target { transform: scale(1.09); }
.basket-image { width: 160px; height: 156px; object-fit: contain; filter: drop-shadow(0 8px 5px rgba(55,45,28,.22)); }
.basket-count {
  position: absolute;
  z-index: 2;
  right: 2px;
  top: 34px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: #fffaf0;
  background: var(--red);
  border: 3px solid var(--cream);
  font-size: 13px;
  font-weight: 700;
}

.inventory-drawer {
  position: absolute;
  z-index: 34;
  right: 87px;
  bottom: 172px;
  width: 76px;
  max-height: 470px;
  padding: 10px 11px 12px;
  overflow: hidden;
  color: var(--ink);
  background: rgba(251, 247, 234, .96);
  border: 1px solid rgba(76,81,52,.2);
  border-radius: 20px 20px 12px 12px;
  box-shadow: 0 16px 34px rgba(50,52,36,.18);
  opacity: 0;
  transform: translateY(22px) scaleY(.86);
  transform-origin: 50% 100%;
  pointer-events: none;
  transition: transform .38s cubic-bezier(.22,.8,.25,1), opacity .24s ease;
}

.inventory-drawer.is-open { opacity: 1; transform: translateY(0) scaleY(1); pointer-events: auto; }
.drawer-heading { display: grid; justify-items: center; gap: 2px; padding: 0 0 8px; border-bottom: 1px solid var(--line); }
.drawer-heading span { font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif; font-size: 10px; font-weight: 700; }
.drawer-heading strong { color: var(--red); font-size: 9px; }
.inventory-list {
  width: 52px;
  max-height: 378px;
  padding: 9px 0 3px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #a99e78 transparent;
}
.inventory-empty { margin: 12px 0 4px; color: var(--muted); font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif; font-size: 10px; line-height: 1.25; text-align: center; }
.inventory-item {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  margin-bottom: 7px;
  padding: 4px;
  color: var(--ink);
  border: 1px solid rgba(57,74,46,.15);
  border-radius: 16px;
  background: rgba(255,252,239,.72);
  cursor: pointer;
  transition: transform .18s ease, background .18s ease, border-color .18s ease;
}
.inventory-item:hover, .inventory-item.is-active { transform: translateY(-2px); border-color: rgba(166,65,50,.42); background: #fffdf5; }
.inventory-item:focus-visible { outline: 2px solid var(--red); outline-offset: -2px; }
.inventory-thumb { width: 43px; height: 43px; object-fit: contain; filter: drop-shadow(0 3px 2px rgba(55,45,28,.18)); }
.inventory-copy { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.detail-panel {
  position: relative;
  z-index: 40;
  grid-column: 2;
  height: 900px;
  padding: 34px;
  overflow: hidden;
  background:
    linear-gradient(rgba(255,255,255,.42), rgba(255,255,255,.42)),
    repeating-linear-gradient(0deg, transparent 0 27px, rgba(102,104,75,.035) 28px),
    var(--paper);
  border-left: 1px solid rgba(63,68,45,.16);
}

.panel-state { height: 100%; }
.loading-state { display: grid; grid-template-rows: 88px 230px 180px 1fr; gap: 17px; }
.skeleton { border-radius: 18px; background: linear-gradient(90deg, #e9e2cf 20%, #f6f0df 45%, #e9e2cf 70%); background-size: 250% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -250% 0; } }

.empty-state, .error-state { display: flex; flex-direction: column; justify-content: center; align-items: flex-start; padding: 48px 30px; }
.empty-emblem { width: 115px; margin-bottom: 30px; transform: rotate(-5deg); }
.empty-emblem svg { fill: none; stroke: #8e9b6b; stroke-width: 3; overflow: visible; }
.empty-state h2, .error-state h2 { margin: 4px 0 16px; max-width: 330px; font-size: 38px; line-height: 1.02; letter-spacing: -.035em; }
.empty-state p, .error-state p { max-width: 330px; color: var(--muted); font-size: 15px; line-height: 1.65; }
.gesture-cue { display: flex; align-items: center; gap: 11px; margin-top: 28px; color: var(--red); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.gesture-cue span { width: 42px; height: 1px; background: var(--red); position: relative; }
.gesture-cue span::after { content: ""; position: absolute; right: 0; top: -3px; width: 6px; height: 6px; border-right: 1px solid; border-bottom: 1px solid; transform: rotate(-45deg); }

.apple-details { height: 100%; display: grid; grid-template-rows: auto 192px 1fr 245px; gap: 14px; }
.detail-header { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.detail-kicker { display: flex; justify-content: space-between; color: var(--red); font-size: 10px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; }
.detail-title { margin: 7px 0 0; font-size: 34px; line-height: .98; letter-spacing: -.035em; }
.portrait-card { display: grid; grid-template-columns: 45% 1fr; gap: 18px; padding: 15px; border: 1px solid var(--line); border-radius: 19px; background: rgba(255,255,255,.42); }
.apple-portrait { position: relative; display: grid; place-items: center; overflow: hidden; border-radius: 14px; background: #e3dfba; }
.apple-portrait::after { content: ""; position: absolute; inset: auto 7% 9% 7%; height: 15px; border-radius: 50%; background: rgba(53,56,35,.17); filter: blur(5px); }
.apple-portrait img { position: relative; z-index: 2; width: 118px; height: 118px; object-fit: contain; filter: drop-shadow(0 10px 6px rgba(53,45,31,.2)); }
.tag-stack { display: flex; flex-direction: column; justify-content: center; gap: 8px; }
.tag { width: fit-content; padding: 7px 10px; border: 1px solid rgba(71,79,48,.18); border-radius: 99px; color: #4f5947; background: rgba(255,253,243,.68); font-size: 11px; font-weight: 600; }
.facts-card { min-height: 0; padding: 17px 18px; overflow: hidden; border-radius: 18px; color: #f9f4df; background: #42573e; }
.story-quote { margin: 0 0 11px; color: #e9d99d; font-size: 17px; line-height: 1.3; }
.facts-card p { margin: 0; color: rgba(255,255,255,.76); font-size: 11.5px; line-height: 1.47; }
.taste-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 12px; }
.taste-grid div { padding-top: 9px; border-top: 1px solid rgba(255,255,255,.18); }
.taste-grid span { display: block; color: #d7c98e; font-size: 8px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.taste-grid strong { display: block; margin-top: 3px; color: #fffaf0; font-size: 10px; line-height: 1.25; }
.map-card { position: relative; display: grid; grid-template-columns: 56% 1fr; align-items: center; overflow: hidden; padding: 14px 17px; border: 1px solid var(--line); border-radius: 18px; background: #ece5ce; }
.uk-map { width: 100%; height: 210px; overflow: visible; }
.county-highlight { color: var(--red); fill: currentColor; stroke: #fff8e7; stroke-width: 1.5; paint-order: stroke; animation: map-pulse 2s ease-in-out infinite; }
@keyframes map-pulse { 50% { opacity: .58; } }
.map-copy .eyebrow { font-size: 9px; }
.map-copy h3 { margin: 5px 0 8px; font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif; font-size: 22px; line-height: 1.05; }
.map-copy p { margin: 0; color: var(--muted); font-size: 10.5px; line-height: 1.45; }

@media (max-width: 760px) {
  html, body {
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
  }

  body { background: var(--paper); }

  #viewport {
    position: relative;
    inset: auto;
    min-height: 100svh;
    overflow: visible;
    background: var(--paper);
  }

  #app-shell {
    position: relative;
    left: auto;
    top: auto;
    width: 100%;
    height: auto;
    display: block;
    overflow: visible;
    transform: none !important;
    box-shadow: none;
  }

  .orchard {
    width: 100%;
    height: auto;
    aspect-ratio: 19 / 18;
  }

  .brand-lockup {
    left: 12px;
    bottom: 12px;
    width: min(58vw, 250px);
    padding: 11px 13px 12px;
    border-radius: 3px 15px 15px 15px;
    backdrop-filter: blur(3px);
  }

  .brand-lockup .eyebrow {
    margin-bottom: 5px;
    font-size: 7px;
    letter-spacing: .15em;
  }

  .brand-lockup h1 {
    font-size: clamp(25px, 7.7vw, 36px);
    line-height: .91;
  }

  .brand-lockup p {
    margin-top: 7px;
    font-size: clamp(8px, 2.35vw, 11px);
    line-height: 1.3;
  }

  .tree-apple {
    width: clamp(36px, 9vw, 52px);
    height: clamp(39px, 9.6vw, 56px);
    -webkit-tap-highlight-color: transparent;
  }

  .basket {
    right: 8px;
    bottom: 5px;
    width: 104px;
    height: 112px;
  }

  .basket-image {
    width: 100px;
    height: 106px;
  }

  .basket-count {
    right: 0;
    top: 22px;
    width: 25px;
    height: 25px;
    border-width: 2px;
    font-size: 11px;
  }

  .inventory-drawer {
    right: 23px;
    bottom: 105px;
    max-height: min(64vw, 390px);
  }

  .inventory-list { max-height: min(52vw, 310px); }

  .detail-panel {
    width: 100%;
    height: auto;
    min-height: 100svh;
    padding: 25px 18px 42px;
    overflow: visible;
    border-top: 1px solid rgba(63,68,45,.16);
    border-left: 0;
  }

  .panel-state { min-height: 72svh; }
  .loading-state { grid-template-rows: 78px 240px 230px 300px; }
  .empty-state, .error-state { min-height: 72svh; padding: 42px 18px; }

  .apple-details {
    height: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
  }

  .detail-title { font-size: clamp(34px, 10vw, 46px); }

  .portrait-card {
    grid-template-columns: 1fr;
    gap: 13px;
    padding: 14px;
  }

  .apple-portrait { min-height: 225px; }
  .apple-portrait img { width: 170px; height: 170px; }

  .tag-stack {
    flex-direction: row;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .facts-card {
    overflow: visible;
    padding: 21px 19px;
  }

  .story-quote { font-size: 20px; }
  .facts-card p { font-size: 13.5px; line-height: 1.6; }

  .taste-grid {
    grid-template-columns: 1fr;
    gap: 11px;
    margin-top: 18px;
  }

  .taste-grid span { font-size: 9px; }
  .taste-grid strong { font-size: 12px; }

  .map-card {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 20px;
  }

  .uk-map {
    width: min(100%, 250px);
    height: 285px;
    margin: 0 auto;
  }

  .map-copy {
    padding: 3px 8px 8px;
    text-align: center;
  }

  .map-copy h3 { font-size: 26px; }
  .map-copy p { font-size: 12px; }
}

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