:root {
  --ink: #173b4f;
  --deep: #075a63;
  --leaf: #178c58;
  --lime: #bfea55;
  --maize: #ffd33f;
  --sky: #bfefff;
  --paper: #fffef8;
  --cream: #e8f9ff;
  --clay: #f47b52;
  --muted: #53707a;
  --line: #b9dce2;
  --danger: #ae3c32;
  --shadow: 0 10px 0 rgba(23, 59, 79, 0.14), 0 20px 50px rgba(14, 74, 82, 0.12);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body { margin: 0; min-height: 100%; background: var(--cream); color: var(--ink); font-family: "Arial Rounded MT Bold", "Trebuchet MS", "Segoe UI", sans-serif; font-size: 16px; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.46; }

.brand { display: inline-flex; align-items: center; gap: .55rem; color: inherit; font-weight: 900; letter-spacing: .08em; text-decoration: none; }
.eyebrow { margin: 0 0 .45rem; color: var(--leaf); font-size: .78rem; font-weight: 900; letter-spacing: .13em; text-transform: uppercase; }
.primary-button { width: 100%; border: 3px solid var(--ink); border-radius: 1.2rem; background: var(--maize); color: var(--ink); padding: 1rem 1.1rem; font-weight: 900; box-shadow: 0 7px 0 var(--ink); transition: transform .15s, box-shadow .15s; }
.primary-button:hover { transform: translateY(-2px); box-shadow: 0 9px 0 var(--deep); }
.primary-button:active { transform: translateY(4px); box-shadow: 0 3px 0 var(--deep); }
.flash { margin-bottom: 1rem; border-radius: .8rem; padding: .85rem 1rem; background: #edf7e7; color: var(--ink); font-weight: 700; }
.flash-error { background: #fae4df; color: var(--danger); }

.welcome-page { background: #11a9bc; }
.welcome-shell { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(22rem, .65fr); min-height: 100svh; }
.welcome-art { position: relative; display: flex; min-height: 100svh; flex-direction: column; justify-content: space-between; overflow: hidden; padding: clamp(1.5rem, 4vw, 4rem); background: linear-gradient(90deg, rgba(0,88,98,.82) 0%, rgba(0,88,98,.25) 62%, rgba(0,88,98,.04) 100%), url('/static/farm-colombia-kids.png') center/cover; color: white; }
.welcome-art::after { content: ""; position: absolute; inset: auto 0 0; height: 42%; background: linear-gradient(transparent, rgba(14,44,32,.55)); pointer-events: none; }
.welcome-art > * { position: relative; z-index: 1; }
.welcome-copy { max-width: 42rem; padding: 10vh 0; }
.welcome-copy .eyebrow { color: var(--lime); }
.welcome-copy h1 { max-width: 9ch; margin: 0; font-family: "Arial Rounded MT Bold", "Trebuchet MS", sans-serif; font-size: clamp(3.5rem, 7.2vw, 7.5rem); line-height: .9; letter-spacing: -.045em; text-shadow: 0 6px 0 rgba(7,90,99,.45); }
.welcome-copy p:last-child { max-width: 34rem; margin: 2rem 0 0; font-size: clamp(1.05rem, 1.6vw, 1.35rem); line-height: 1.55; }
.art-caption { display: flex; align-items: center; gap: .75rem; font-weight: 800; }
.art-caption span { font-size: 2rem; }
.auth-panel { display: grid; place-items: center; padding: clamp(1.2rem, 4vw, 3rem); background: var(--paper); }
.auth-card { width: min(100%, 27rem); }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; margin-bottom: 2rem; padding: .4rem; border: 2px solid var(--line); border-radius: 1.1rem; background: #e7f8fb; }
.auth-tab { border: 0; border-radius: .65rem; background: transparent; color: var(--muted); padding: .75rem; font-weight: 800; }
.auth-tab.active { background: var(--maize); color: var(--ink); box-shadow: 0 4px 0 #d49a14; }
.auth-form h2 { margin: 0 0 1.5rem; font-size: 2rem; }
.auth-form label { display: grid; gap: .45rem; margin: 0 0 1rem; font-weight: 800; }
.auth-form input { width: 100%; border: 3px solid var(--line); border-radius: 1rem; background: white; padding: .9rem; color: var(--ink); outline: none; }
.auth-form input:focus { border-color: var(--leaf); box-shadow: 0 0 0 3px rgba(44,112,72,.15); }
.auth-form .primary-button { margin-top: .5rem; }

.game-page { background: linear-gradient(180deg, #c9f2ff 0, #eefbe9 26rem); }
.game-header { position: sticky; top: 0; z-index: 20; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem; min-height: 4.3rem; border-bottom: 1px solid rgba(23,58,42,.1); background: rgba(255,253,245,.94); padding: .75rem clamp(1rem, 4vw, 3.5rem); backdrop-filter: blur(12px); }
.game-header form { justify-self: end; }
.player-name { color: var(--muted); }
.player-name strong { color: var(--ink); }
.link-button { border: 0; background: transparent; color: var(--leaf); font-weight: 800; }
.game-shell { width: min(100% - 2rem, 88rem); margin: 0 auto; padding: 1.2rem 0 4rem; }
.farm-hero { position: relative; min-height: clamp(18rem, 38vw, 29rem); overflow: hidden; border: 4px solid white; border-radius: 2rem; background: linear-gradient(180deg, rgba(7,90,99,.02), rgba(7,90,99,.48)), url('/static/farm-colombia-kids.png') center/cover; box-shadow: var(--shadow); }
.season-status { position: absolute; top: 1rem; left: 1rem; width: min(22rem, calc(100% - 2rem)); border: 3px solid var(--ink); border-radius: 1.25rem; background: rgba(255,254,248,.96); padding: .8rem 1rem; box-shadow: 0 6px 0 var(--ink); }
.month-label { display: block; margin-bottom: .45rem; font-weight: 900; }
.month-track { height: .55rem; overflow: hidden; border-radius: 1rem; background: #dce6d9; }
.month-track span { display: block; height: 100%; border-radius: inherit; background: var(--maize); }
.guide-bubble { position: absolute; right: 1rem; bottom: 1rem; display: flex; align-items: center; gap: .8rem; width: min(31rem, calc(100% - 2rem)); border: 3px solid var(--ink); border-radius: 1.4rem; background: var(--paper); padding: .9rem 1rem; box-shadow: 0 7px 0 var(--ink); }
.guide-avatar { display: grid; flex: 0 0 3.5rem; width: 3.5rem; height: 3.5rem; place-items: center; border: 3px solid #d48b3c; border-radius: 50%; background: #ffe6a9; font-size: 2.1rem; }
.guide-bubble strong { font-size: .83rem; color: var(--leaf); }
.guide-bubble p { margin: .15rem 0 0; line-height: 1.35; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .8rem; margin: 1rem 0; }
.stats article { display: grid; gap: .3rem; border: 3px solid var(--line); border-radius: 1.25rem; background: var(--paper); padding: 1rem; box-shadow: 0 5px 0 rgba(23,59,79,.13); }
.stats span, .stats small { color: var(--muted); font-size: .84rem; }
.stats strong { font-size: 1.45rem; }
.market-stat { border-color: #ead17a !important; background: #fff7d8 !important; }
.milk-stat { border-color: #8ed4e7 !important; background: #effbff !important; }
.egg-stat { border-color: #e6c16c !important; background: #fff9df !important; }
.route-stat { border-color: #aaa3dc !important; background: #f3f1ff !important; }
.game-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(19rem, .55fr); gap: 1rem; align-items: start; }
.farm-board, .actions-panel, .lesson-panel, .market-panel, .ledger, .final-panel { border: 3px solid var(--line); border-radius: 1.6rem; background: var(--paper); padding: clamp(1rem, 2.4vw, 1.5rem); box-shadow: 0 7px 0 rgba(23,59,79,.12); }
.section-heading h2, .actions-panel h2, .lesson-panel h2, .market-panel h2, .ledger h2 { margin: 0; font-size: 1.55rem; line-height: 1.2; }
.farm-spaces { display: grid; grid-template-columns: repeat(2, 1fr); gap: .8rem; margin-top: 1rem; }
.farm-space { display: flex; min-height: 7rem; align-items: center; gap: 1rem; border: 3px solid #a9d8b6; border-radius: 1.35rem; background: #e7f9df; padding: 1rem; }
.horse-space { background: #f7e5cd; }
.corn-space { background: #fff4c5; }
.duck-space { background: #ecf8ff; border-color: #a8d8e8; }
.dairy-space { background: #edf9ff; border-color: #93cfe0; }
.space-icon { font-size: 3.2rem; filter: drop-shadow(0 5px 4px rgba(14,44,32,.1)); }
.farm-space strong, .farm-space small { display: block; }
.farm-space small { margin-top: .3rem; color: var(--muted); line-height: 1.35; }
.action-list { display: grid; gap: .55rem; margin-top: 1rem; }
.action-list button { display: grid; width: 100%; grid-template-columns: 2.5rem 1fr; align-items: center; gap: .7rem; border: 3px solid var(--line); border-radius: 1.1rem; background: white; padding: .8rem; color: var(--ink); text-align: left; box-shadow: 0 4px 0 rgba(23,59,79,.12); }
.action-list button:not(:disabled):hover { border-color: var(--leaf); background: #f4f9f1; }
.action-list button > span:first-child { font-size: 1.8rem; text-align: center; }
.action-list strong, .action-list small { display: block; }
.action-list small { margin-top: .15rem; color: var(--muted); font-size: .77rem; }
.next-form { margin-top: 1rem; }
.learning-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1rem; }
.lesson-panel { border-color: #7854b8; background: #7854b8; color: white; box-shadow: 0 7px 0 #4f347f; }
.lesson-panel .eyebrow { color: var(--lime); }
.lesson-panel h2 { font-size: clamp(1.25rem, 2.4vw, 1.8rem); }
.market-panel { background: #fff4b8; border-color: #e6bb28; box-shadow: 0 7px 0 #d9a817; }
.market-panel p:last-child { margin-bottom: 0; color: #67551d; line-height: 1.5; }
.ledger { margin-top: 1rem; }
.ledger-list { margin-top: 1rem; }
.ledger-list div { display: flex; justify-content: space-between; gap: 1rem; border-top: 1px solid var(--line); padding: .72rem 0; }
.positive { color: var(--leaf); }
.negative { color: var(--danger); }
.final-panel { padding: clamp(2rem, 5vw, 4rem); text-align: center; }
.final-panel h1 { margin: .3rem 0 1rem; font-family: Georgia, serif; font-size: clamp(2.3rem, 5vw, 4.5rem); }
.final-panel .primary-button { max-width: 20rem; margin-top: 1rem; }

.dairy-panel, .logistics-panel { margin-top: 1rem; border: 3px solid #85c8d8; border-radius: 1.6rem; background: #f4fcff; padding: clamp(1rem, 2.4vw, 1.6rem); box-shadow: 0 7px 0 rgba(23,59,79,.12); }
.logistics-panel { border-color: #93c8a5; background: #f6fff7; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.panel-heading h2 { margin: 0; font-size: clamp(1.55rem, 3vw, 2.2rem); }
.status-pill { border-radius: 999px; background: #fff1c7; padding: .55rem .8rem; color: #6b5111; font-size: .78rem; font-weight: 900; }
.technology-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; margin-top: 1rem; }
.technology-card, .route-card { display: grid; gap: .7rem; border: 3px solid #b7dce4; border-radius: 1.2rem; background: white; padding: 1rem; }
.technology-card.selected, .route-card.selected { border-color: var(--leaf); box-shadow: inset 0 0 0 2px #c5ebd2; }
.technology-icon, .route-card > span { font-size: 2.4rem; }
.technology-card h3, .technology-card p, .route-card h3, .route-card p { margin: 0; }
.technology-card p, .route-card p { color: var(--muted); font-size: .86rem; line-height: 1.45; }
.technology-card dl, .route-card dl { display: grid; gap: .35rem; margin: 0; }
.technology-card dl div, .route-card dl div { display: flex; justify-content: space-between; gap: .5rem; border-top: 1px solid #d7e7ea; padding-top: .35rem; }
.technology-card dt, .route-card dt { color: var(--muted); font-size: .78rem; }
.technology-card dd, .route-card dd { margin: 0; font-size: .8rem; font-weight: 900; text-align: right; }
.technology-card button, .route-card button, .current-badge { display: block; width: 100%; border: 2px solid var(--deep); border-radius: .8rem; background: var(--maize); padding: .65rem; color: var(--ink); font-weight: 900; text-align: center; }
.current-badge { border-color: #a7d6b9; background: #def5e6; }
.logistics-flow { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin: 1rem 0; overflow-x: auto; border: 2px solid #b8ddc5; border-radius: 1rem; background: white; padding: .8rem; white-space: nowrap; }
.logistics-flow span { border-radius: .7rem; background: #e9f7ed; padding: .55rem .7rem; font-size: .83rem; font-weight: 900; }
.logistics-flow i { color: var(--leaf); font-style: normal; font-weight: 900; }
.route-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .8rem; }
.route-card { border-color: #b8ddc5; }
.logistics-note { margin: 1rem 0 0; border-radius: .9rem; background: #e2f6e8; padding: .8rem 1rem; line-height: 1.45; }

@media (max-width: 900px) {
  .welcome-shell { grid-template-columns: 1fr; }
  .welcome-art { min-height: 48svh; }
  .welcome-copy { padding: 5vh 0; }
  .auth-panel { min-height: 52svh; }
  .game-grid { grid-template-columns: 1fr; }
  .actions-panel { order: -1; }
  .action-list { grid-template-columns: repeat(2, 1fr); }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .technology-grid { grid-template-columns: 1fr; }
}

@media (max-width: 580px) {
  .game-header { grid-template-columns: 1fr auto; }
  .player-name { grid-column: 1 / -1; grid-row: 2; }
  .welcome-art { min-height: 43svh; }
  .welcome-copy h1 { font-size: 3.5rem; }
  .farm-hero { min-height: 23rem; }
  .stats, .farm-spaces, .learning-grid, .action-list, .route-grid { grid-template-columns: 1fr; }
  .panel-heading { align-items: flex-start; flex-direction: column; }
  .farm-space { min-height: auto; }
  .ledger-list div { align-items: start; flex-direction: column; gap: .25rem; }
}

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