@font-face { font-family: "Atkinson"; src: url(fonts/AtkinsonHyperlegible-Regular.ttf) format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Atkinson"; src: url(fonts/AtkinsonHyperlegible-Bold.ttf) format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Nunito"; src: url(fonts/Nunito-VariableFont_wght.ttf) format("truetype"); font-weight: 400 900; font-display: swap; }

:root {
  --cream: #fff8e8; --ink: #2a1d12; --ink2: #4a3826; --green: #2c6a2c; --green-d: #1f4f1f;
  --gold: #f5b82e; --sky: #bfe6ff; --card: #ffffff; --line: #5b4330;
  --ok-bg: #e2f5dc; --ok: #1d5e25; --warn-bg: #fff0d4; --warn: #8a4b06;
  --radius: 22px; --shadow: 0 6px 0 rgba(60,40,20,.18), 0 10px 24px rgba(60,40,20,.12);
}
* { box-sizing: border-box; }
html { font-size: 22px; -webkit-text-size-adjust: 100%; }
html.big { font-size: 27px; }
body {
  margin: 0; color: var(--ink); font-family: "Atkinson", "Segoe UI", system-ui, sans-serif; line-height: 1.5;
  background: linear-gradient(#fff3d1 0, var(--cream) 340px) fixed; min-height: 100vh;
}
h1, h2, h3, .display { font-family: "Nunito", "Atkinson", sans-serif; font-weight: 900; line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 2.2rem; } h2 { font-size: 1.45rem; } h3 { font-size: 1.15rem; }
p { margin: 0 0 .8rem; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 5px solid #1565c0; outline-offset: 3px; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 16px 18px 60px; }

/* top bar */
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 10px 18px; background: #fffdf6; border-bottom: 3px solid #f0dfb8; position: relative; z-index: 20; }
.topbar .farmname { font-family: "Nunito"; font-weight: 900; font-size: 1.05rem; margin-right: auto; display: flex; align-items: center; gap: 8px; }
.pill { display: inline-flex; align-items: center; gap: 6px; background: #fff; border: 3px solid #ecd9ae; border-radius: 999px; padding: 4px 14px; font-weight: 700; font-size: 1rem; min-height: 48px; }
.pill .e { font-size: 1.15em; }
.tbtn { min-height: 52px; padding: 6px 14px; border-radius: 16px; border: 3px solid var(--line); background: #fff; font-weight: 700; font-size: .95rem; }
.tbtn[aria-pressed="true"] { background: #fff1c2; }
.tbtn:hover { background: #fff6dc; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 68px; padding: 12px 28px; border-radius: 20px; border: 0; font-weight: 700; font-size: 1.1rem; box-shadow: var(--shadow); transition: transform .12s; text-decoration: none; }
.btn:active { transform: translateY(3px); }
.btn.primary { background: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green-d); }
.btn.sun { background: var(--gold); color: #2a1d12; }
.btn.sun:hover { background: #f0a800; }
.btn.plain { background: #fff; color: var(--ink); border: 3px solid var(--line); }
.btn.plain:hover { background: #fff6dc; }
.btnrow { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 14px; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 24px; margin: 16px 0; border: 3px solid #f0dfb8; }

/* title */
.title-hero { text-align: center; padding-top: 10px; }
.title-hero h1 { font-size: 2.6rem; color: #6b3d12; margin-top: 8px; letter-spacing: .5px; }
.title-hero .sub { font-size: 1.15rem; color: var(--ink2); max-width: 760px; margin: 0 auto 10px; }
.namebox { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; align-items: center; margin: 10px 0; }
.namebox input { font: inherit; font-size: 1.05rem; min-height: 60px; padding: 8px 16px; border-radius: 16px; border: 3px solid var(--line); width: min(420px, 90vw); }

/* farm map */
.farm { width: 100%; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); border: 3px solid #e8d3a4; background: var(--sky); position: relative; }
.farm svg { display: block; width: 100%; height: auto; }
.legend { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 8px 16px; margin: 12px 0 0; padding: 0; list-style: none; font-size: .95rem; }
.legend li { background: #fff; border-radius: 14px; padding: 8px 12px; border: 2px solid #ecd9ae; }
.legend b { font-family: "Nunito"; }

.missions { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-top: 10px; }
.mcard { text-align: left; display: flex; gap: 14px; align-items: center; min-height: 110px; padding: 14px 18px; border-radius: 20px; border: 3px solid var(--line); background: #fff; box-shadow: var(--shadow); }
.mcard:hover { background: #fffaf0; }
.mcard .big { font-size: 2.6rem; line-height: 1; }
.mcard .t { font-family: "Nunito"; font-weight: 900; font-size: 1.1rem; display: block; }
.mcard .s { font-size: .95rem; color: var(--ink2); display: block; }
.mcard.done { background: #f0f9ea; border-color: #2c6a2c; }
.mcard.next { border-color: #c27c00; background: #fff6d8; box-shadow: 0 0 0 5px #ffd76a, var(--shadow); }

/* step */
.stephead { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin: 6px 0 4px; }
.stephead h2 { margin: 0; }
.dots { display: flex; gap: 8px; }
.dots span { width: 22px; height: 22px; border-radius: 50%; background: #eadbb9; border: 2px solid #b39467; }
.dots span.on { background: var(--gold); border-color: #a06c00; }
.dots span.cur { background: #fff; border: 4px solid var(--green); }
.scene { display: flex; align-items: center; justify-content: center; min-height: 150px; font-size: 4.2rem; background: linear-gradient(#d8f0ff, #f3fbe9 70%, #e7d2a8 70%); border-radius: var(--radius); border: 3px solid #e8d3a4; letter-spacing: 8px; overflow: hidden; }
.scene .art { animation: bob 3s ease-in-out infinite; display: inline-block; }
.scenario { font-size: 1.1rem; margin-top: 16px; }
.ask { font-size: 1.5rem; margin: 14px 0 10px; color: #6b3d12; }
.choices { display: grid; gap: 14px; }
.choice { display: flex; align-items: center; gap: 16px; text-align: left; width: 100%; min-height: 76px; padding: 12px 18px; border-radius: 20px; border: 3px solid var(--line); background: #fff; font-size: 1.05rem; box-shadow: 0 4px 0 rgba(60,40,20,.18); transition: transform .1s, background .15s; }
.choice:hover:not(:disabled) { background: #fff6dc; transform: translateY(-2px); }
.choice .k { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 52px; height: 52px; border-radius: 50%; background: var(--gold); color: #2a1d12; font-family: "Nunito"; font-weight: 900; font-size: 1.25rem; border: 3px solid #a06c00; }
.choice.wrong { background: #f4efe6; color: #5a4a3a; border-style: dashed; text-decoration: line-through; text-decoration-thickness: 2px; }
.choice.wrong .k { background: #d9cdb8; border-color: #8f7d63; }
.choice.removed { opacity: .45; text-decoration: line-through; }
.choice.right { background: var(--ok-bg); border-color: var(--ok); border-width: 4px; }
.choice.right .k { background: #3c9a46; color: #fff; border-color: #1d5e25; }
.choice:disabled { cursor: default; }
.hintrow { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }

.feedback { margin-top: 18px; border-radius: var(--radius); padding: 20px 24px; font-size: 1.08rem; animation: pop .35s ease-out; }
.feedback.ok { background: var(--ok-bg); border: 4px solid var(--ok); }
.feedback.no { background: var(--warn-bg); border: 4px solid #c27c00; }
.feedback h3 { font-size: 1.35rem; color: var(--ok); }
.feedback.no h3 { color: var(--warn); }
.feedback .why { font-family: "Nunito"; font-weight: 900; color: #1d4f6b; margin: 10px 0 4px; font-size: 1.1rem; }
.feedback.no .why { color: var(--warn); }
.reward { display: inline-block; background: #fff; border-radius: 999px; padding: 2px 14px; border: 2px solid #9fcf8f; font-weight: 700; margin-left: 6px; font-size: .95rem; }

.outcome { margin-top: 14px; padding: 16px 20px; border-radius: 18px; font-size: 1.08rem; animation: pop .35s ease-out; }
.outcome.good { background: var(--ok-bg); border: 3px solid var(--ok); }
.outcome.bad { background: #fff3dc; border: 3px solid #c27c00; }
.eventbanner { display: flex; align-items: center; gap: 14px; background: #263b5e; color: #fff; padding: 14px 20px; border-radius: 18px; margin: 10px 0; font-family: "Nunito"; font-weight: 900; font-size: 1.3rem; }
.eventbanner .e { font-size: 2.2rem; animation: bob 1.6s ease-in-out infinite; }

/* celebration */
.celebrate { text-align: center; }
.celebrate .badge { font-size: 6rem; display: inline-block; animation: spinpop 1.2s ease-out, bob 3s 1.2s ease-in-out infinite; }
.celebrate h1 { color: #6b3d12; }
.starsrow { font-size: 2.6rem; letter-spacing: 6px; margin: 6px 0; }
.starsrow span { display: inline-block; animation: pop .5s ease-out both; }
.starsrow span:nth-child(2) { animation-delay: .25s; } .starsrow span:nth-child(3) { animation-delay: .5s; }
.badges { display: flex; flex-wrap: wrap; gap: 10px; }
.badgechip { background: #fff6d8; border: 3px solid #e3b23c; border-radius: 999px; padding: 6px 14px; font-weight: 700; font-size: .95rem; }

/* toast + confetti */
#toast { visibility: hidden; position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(140%); background: #263b5e; color: #fff; padding: 16px 26px; border-radius: 18px; font-size: 1.05rem; font-weight: 700; z-index: 50; transition: transform .35s; max-width: 92vw; text-align: center; box-shadow: var(--shadow); }
#toast.show { visibility: visible; transform: translateX(-50%) translateY(0); }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
#confetti i { position: absolute; top: -30px; width: 14px; height: 22px; border-radius: 3px; animation: fall 3.2s linear forwards; }
.sparkle { position: fixed; pointer-events: none; font-size: 2rem; z-index: 45; animation: sparkle 1.1s ease-out forwards; }

/* how to */
.howto li { margin-bottom: 12px; }
.keys kbd { display: inline-block; min-width: 44px; text-align: center; padding: 2px 10px; border: 3px solid var(--line); border-radius: 10px; background: #fff; font-family: "Nunito"; font-weight: 900; box-shadow: 0 3px 0 rgba(0,0,0,.2); }

/* animations */
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes pop { 0% { transform: scale(.85); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes spinpop { 0% { transform: scale(0) rotate(-180deg); } 70% { transform: scale(1.2) rotate(10deg); } 100% { transform: scale(1) rotate(0); } }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }
@keyframes sparkle { 0% { transform: scale(.3); opacity: 1; } 100% { transform: translateY(-80px) scale(1.4); opacity: 0; } }

/* SVG farm animations */
.sway { transform-box: fill-box; transform-origin: 50% 100%; animation: sway 3.5s ease-in-out infinite; }
@keyframes sway { 0%,100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }
.sunrays { transform-box: fill-box; transform-origin: center; animation: spin 40s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.cloud { animation: drift 60s linear infinite; }
.cloud.c2 { animation-duration: 85s; animation-delay: -30s; }
@keyframes drift { from { transform: translateX(-260px); } to { transform: translateX(1100px); } }
.flow { stroke-dasharray: 18 22; animation: flow 2.2s linear infinite; }
@keyframes flow { to { stroke-dashoffset: -80; } }
.worm { animation: wiggle 2.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes wiggle { 0%,100% { transform: translateX(0) scaleX(1); } 50% { transform: translateX(14px) scaleX(.85); } }
.cow { animation: graze 6s ease-in-out infinite; transform-box: fill-box; transform-origin: center bottom; }
@keyframes graze { 0%,100% { transform: translateX(0); } 50% { transform: translateX(-26px); } }
.bee { animation: buzz 7s ease-in-out infinite; }
@keyframes buzz { 0% { transform: translate(0,0); } 25% { transform: translate(60px,-30px); } 50% { transform: translate(120px,10px); } 75% { transform: translate(50px,30px); } 100% { transform: translate(0,0); } }
.bob { animation: bob 2.6s ease-in-out infinite; transform-box: fill-box; }
.shimmer { animation: shimmer 3s ease-in-out infinite; }
@keyframes shimmer { 0%,100% { opacity: .55; } 50% { opacity: .9; } }

/* weather events */
.rain line { stroke: #2f6fb0; stroke-width: 4; stroke-linecap: round; animation: rain .7s linear infinite; }
@keyframes rain { from { transform: translateY(-80px); } to { transform: translateY(520px); } }
.floodwater { animation: flood 3s ease-out forwards; transform-box: fill-box; transform-origin: center; }
@keyframes flood { from { transform: scaleX(.6) scaleY(.3); opacity: .3; } to { transform: scale(1); opacity: .85; } }
.frost { animation: frost 3s ease-out forwards; }
@keyframes frost { from { opacity: 0; } to { opacity: .85; } }
.coldflow { stroke-dasharray: 14 18; animation: flow 1.8s linear infinite; }
.heat { animation: shimmer 1.6s ease-in-out infinite; }
.windline { stroke: #ffffff; stroke-width: 6; stroke-linecap: round; opacity: .9; animation: wind 1.4s linear infinite; }
@keyframes wind { from { transform: translateX(-300px); } to { transform: translateX(1200px); } }
.crawl { animation: crawl 4s ease-in-out infinite alternate; }
@keyframes crawl { from { transform: translateX(-20px); } to { transform: translateX(30px); } }
.fox { animation: fox 4s ease-out forwards; }
@keyframes fox { from { transform: translate(460px, 232px); } to { transform: translate(0, 0); } }
.dry { filter: saturate(.35) sepia(.5); transition: filter 2s; }
.pulse { animation: pulse 1.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.15); } }
.erosion { stroke-dasharray: 10 10; animation: flow 1.2s linear infinite; }

@media (max-width: 640px) {
  html { font-size: 20px; } html.big { font-size: 24px; }
  .wrap { padding: 10px 12px 50px; }
  .title-hero h1 { font-size: 2rem; }
  .topbar { padding: 8px 10px; gap: 8px; }
  .topbar .farmname { width: 100%; font-size: 1rem; }
  .pill { min-height: 44px; padding: 2px 10px; }
  .tbtn { min-height: 48px; padding: 4px 10px; font-size: .85rem; }
  .scene { font-size: 3.2rem; min-height: 120px; }
  .choice { padding: 10px 12px; gap: 12px; }
  .choice .k { width: 46px; height: 46px; }
  .btn { width: 100%; }
  .card { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

.stepfarm { max-width: 860px; margin: 0 auto; }
[tabindex="-1"], .feedback, .ask, .eventbanner, #nextbtn, .choice { scroll-margin-top: 20px; scroll-margin-bottom: 30px; }
@media (max-width: 640px) {
  .topbar { position: static; }
  .topbar .farmname { display: none; }
  .tbtn { flex: 1 1 40%; }
  .zlabel { font-size: 46px; stroke-width: 12; }
  .legend { grid-template-columns: 1fr; font-size: .9rem; }
  [tabindex="-1"], .feedback, .ask, .eventbanner, #nextbtn, .choice { scroll-margin-top: 12px; }
}

/* topbar labels */
.long { display: inline; }
.guide { display: flex; gap: 14px; align-items: flex-start; background: #fff7d6; border: 3px solid #e3b23c; border-radius: 20px; padding: 12px 18px; margin: 16px 0 0; font-size: 1.02rem; }
.guide .face { font-size: 2.2rem; line-height: 1; }
.legendbox { margin-top: 10px; }
.legendbox summary { cursor: pointer; font-weight: 700; min-height: 52px; display: flex; align-items: center; padding: 6px 14px; background: #fff; border: 3px solid var(--line); border-radius: 16px; list-style: none; }
.legendbox summary::-webkit-details-marker { display: none; }
.storystep { color: var(--ink2); font-size: .95rem; margin: 8px 0 0; }
.story .scene { min-height: 190px; font-size: 5rem; }
.larder h2 { margin-bottom: 8px; }
h2.cat { margin-top: 26px; color: #6b3d12; }
.shopgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.shopcard, .tradecard { display: flex; gap: 14px; background: #fff; border: 3px solid #e8d3a4; border-radius: 20px; padding: 14px 16px; box-shadow: var(--shadow); }
.shopcard .big, .tradecard .big { font-size: 3rem; line-height: 1; flex: 0 0 auto; }
.shopcard .info, .tradecard .info { flex: 1 1 auto; min-width: 0; }
.shopcard h3, .tradecard h3 { margin: 0 0 4px; }
.shopcard p, .tradecard p { margin: 0 0 6px; font-size: .95rem; }
.shopcard .yield { color: var(--ok); }
.shopcard .upkeep, .tradecard .upkeep { color: var(--ink2); }
.buybtn, .tradebtn { width: 100%; min-height: 64px; margin-top: 6px; font-size: 1rem; padding: 8px 14px; }
.btn:disabled { opacity: .7; cursor: not-allowed; box-shadow: none; }
.tradecard .swap { font-size: 1.02rem; }
@media (max-width: 640px) {
  .tbtn { flex: 1 1 28%; padding: 4px 6px; }
  .long { display: none; }
  .shopgrid { grid-template-columns: 1fr; }
  .shopcard .big, .tradecard .big { font-size: 2.4rem; }
}

.shead { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.shead .big { font-size: 2.6rem; line-height: 1; }
.shead h3 { margin: 0; }
.buybtn, .tradebtn { white-space: nowrap; }
