/* Little Airfield UI: warm, rounded, readable over the map. Landscape phone first (about 844 x 390). */
:root {
  --ink: #2c2a24; --ink2: #5a5446; --paper: #fffaf0; --card: rgba(255, 250, 240, .96); --line: #e7dcc4;
  --sun: #f2b705; --sun-ink: #4a3500; --sky: #2f80ed; --ok: #1fa971; --bad: #d8443b;
  --sl: env(safe-area-inset-left, 0px); --sr: env(safe-area-inset-right, 0px); --sb: env(safe-area-inset-bottom, 0px); --st: env(safe-area-inset-top, 0px);
  --font: ui-rounded, "SF Pro Rounded", -apple-system, "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #b9e08e; color: var(--ink); font: 15px/1.35 var(--font); -webkit-user-select: none; user-select: none; overscroll-behavior: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
button:disabled { opacity: .45; cursor: default; }
html { touch-action: manipulation; -webkit-text-size-adjust: 100%; }
.compass { width: 44px; height: 44px; flex: none; filter: drop-shadow(0 2px 3px rgba(0,0,0,.18)); pointer-events: none; }
.compass svg { width: 100%; height: 100%; display: block; }
#world { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* ---- HUD ---- */
.hud { position: fixed; top: calc(6px + var(--st)); left: calc(8px + var(--sl)); right: calc(8px + var(--sr)); display: flex; justify-content: space-between; gap: 8px; pointer-events: none; z-index: 5; }
.hud-left, .hud-right { display: flex; gap: 6px; align-items: center; pointer-events: auto; }
.pill { display: inline-flex; align-items: center; gap: 5px; height: 32px; padding: 0 11px 0 7px; border-radius: 16px; background: var(--card); box-shadow: 0 2px 0 rgba(0,0,0,.12), 0 4px 12px rgba(0,0,0,.12); font-weight: 800; font-size: 15px; white-space: nowrap; }
.pill svg { width: 20px; height: 20px; flex: none; }
.repbar { width: 46px; height: 6px; border-radius: 3px; background: #ead9b1; overflow: hidden; }
.repbar i { display: block; height: 100%; width: 0; background: var(--sun); transition: width .4s; }
.wind { gap: 6px; }
.wind svg { width: 18px; height: 18px; color: var(--sky); transition: transform .3s; }
.wind em { font-style: normal; font-size: 12px; font-weight: 800; padding: 2px 7px; border-radius: 9px; }
.wind em.good { background: #dff3e7; color: var(--ok); }
.wind em.bad { background: #fff1c9; color: #9a6a00; }
.round { width: 34px; height: 34px; border-radius: 17px; background: var(--card); display: grid; place-items: center; box-shadow: 0 2px 0 rgba(0,0,0,.12), 0 4px 12px rgba(0,0,0,.12); }
.round svg { width: 20px; height: 20px; }

/* ---- pattern strip (left) ---- */
.pattern { position: fixed; top: calc(46px + var(--st)); left: calc(8px + var(--sl)); width: 196px; display: flex; flex-direction: column; gap: 6px; z-index: 4; max-height: calc(100% - 46px - 96px); overflow-y: auto; scrollbar-width: none; }
.pcard { grid-template-columns: minmax(0, 1fr) auto;  background: var(--card); border-radius: 12px; padding: 5px 6px 5px 9px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 6px; box-shadow: 0 2px 0 rgba(0,0,0,.1), 0 4px 10px rgba(0,0,0,.1); border-left: 5px solid var(--c, #2f80ed); animation: slideIn .35s ease-out; }
.pcard b { font-size: 13px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.pcard small { color: var(--ink2); font-size: 11px; grid-column: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcard .land { grid-row: 1 / span 2; grid-column: 2; background: var(--sun); color: var(--sun-ink); font-weight: 900; font-size: 13.5px; padding: 7px 11px; border-radius: 10px; box-shadow: 0 2px 0 #c48a00; }
.pcard .land:active { transform: translateY(2px); box-shadow: none; }
.pcard .tag { grid-row: 1 / span 2; grid-column: 2; font-size: 11.5px; font-weight: 800; color: var(--ok); background: #dff3e7; padding: 5px 7px; border-radius: 8px; }
.pattern .empty { background: rgba(255,250,240,.75); border-radius: 12px; padding: 8px 10px; font-size: 12.5px; color: var(--ink2); }
@keyframes slideIn { from { transform: translateX(-30px); opacity: 0; } }

/* ---- Gus ---- */
.gus { position: fixed; left: calc(8px + var(--sl)); bottom: calc(8px + var(--sb)); display: flex; align-items: flex-end; gap: 8px; z-index: 6; max-width: min(430px, 55vw); }
.gus-face { width: 52px; height: 52px; border-radius: 26px; background: #fff; box-shadow: 0 2px 0 rgba(0,0,0,.15), 0 4px 12px rgba(0,0,0,.15); position: relative; flex: none; }
.gus-face svg { width: 100%; height: 100%; }
.badge { position: absolute; top: -3px; right: -3px; width: 20px; height: 20px; border-radius: 10px; background: var(--bad); color: #fff; font: 900 13px/20px var(--font); text-align: center; font-style: normal; animation: pop 1s ease-in-out infinite alternate; }
@keyframes pop { to { transform: scale(1.18); } }
.gus-say { background: var(--card); border-radius: 14px 14px 14px 4px; padding: 9px 11px; box-shadow: 0 2px 0 rgba(0,0,0,.1), 0 4px 12px rgba(0,0,0,.12); }
.gus-say p { margin: 0 0 5px; font-size: 13.5px; }
.gus-row { display: flex; align-items: center; gap: 8px; }
.gus-row span { font-size: 12px; font-weight: 800; color: var(--ink2); flex: 1; }
.gus.hidden .gus-say { display: none; }
.gus-say { cursor: pointer; }
.gus:not(.open) .gus-say p, .gus:not(.open) #gusHide { display: none; }
.gus:not(.open) .gus-say { padding: 7px 11px; flex: none; }

/* ---- dock (right) ---- */
.dock { position: fixed; right: calc(8px + var(--sr)); bottom: calc(8px + var(--sb)); display: flex; gap: 8px; z-index: 6; }
.dock-btn { position: relative; width: 64px; height: 58px; border-radius: 16px; background: var(--card); display: grid; place-items: center; align-content: center; gap: 1px; box-shadow: 0 3px 0 rgba(0,0,0,.14), 0 4px 12px rgba(0,0,0,.14); font-size: 11.5px; font-weight: 800; }
.dock-btn svg { width: 26px; height: 26px; }
.dock-btn.build { background: #ffe9a8; }
.dock-btn:active { transform: translateY(2px); }

/* ---- generic ---- */
.btn { background: var(--sun); color: var(--sun-ink); font-weight: 900; border-radius: 12px; padding: 10px 16px; box-shadow: 0 3px 0 #c48a00; }
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 #c48a00; }
.btn.small { padding: 7px 12px; font-size: 13.5px; border-radius: 10px; }
.btn.ghost { background: #efe6d2; box-shadow: 0 3px 0 #d3c6a6; color: var(--ink); }
.btn.blue { background: var(--sky); color: #fff; box-shadow: 0 3px 0 #1f5fb8; }
.link { font-size: 12px; font-weight: 700; color: var(--ink2); text-decoration: underline; }
.card { position: fixed; z-index: 7; background: var(--card); border-radius: 16px; box-shadow: 0 4px 0 rgba(0,0,0,.12), 0 10px 30px rgba(0,0,0,.2); padding: 12px 14px; }
.plane-card, .building-card { left: 50%; bottom: calc(8px + var(--sb)); transform: translateX(-50%); width: min(360px, calc(100% - 420px)); min-width: 260px; }
.card h3 { margin: 0; font-size: 16px; }
.card .sub { color: var(--ink2); font-size: 12.5px; margin: 1px 0 8px; }
.card .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.card .x { position: absolute; top: 6px; right: 8px; font-size: 22px; line-height: 1; color: var(--ink2); width: 30px; height: 30px; }
.need { display: inline-flex; align-items: center; gap: 6px; }
.need.done { opacity: .55; }

/* ---- placement bar ---- */
.placebar { position: fixed; top: calc(46px + var(--st)); left: 50%; transform: translateX(-50%); z-index: 8; background: var(--card); border-radius: 14px; padding: 8px 10px 8px 14px; display: flex; gap: 8px; align-items: center; box-shadow: 0 4px 16px rgba(0,0,0,.2); font-weight: 800; font-size: 13.5px; }
.placebar .why { color: var(--bad); font-weight: 700; }
.placebar small { display: block; font-weight: 600; font-size: 11.5px; opacity: .65; }

/* ---- build sheet (right side panel) ---- */
.sheet { position: fixed; top: calc(6px + var(--st)); right: calc(8px + var(--sr)); bottom: calc(8px + var(--sb)); width: min(380px, 48vw); background: var(--paper); border-radius: 18px; z-index: 9; box-shadow: 0 10px 40px rgba(0,0,0,.3); display: flex; flex-direction: column; overflow: hidden; animation: sheetIn .25s ease-out; }
@keyframes sheetIn { from { transform: translateX(40px); opacity: 0; } }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px 8px 16px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { margin: 0; font-size: 18px; }
.sheet-head .x { margin-left: auto; font-size: 24px; width: 32px; height: 32px; color: var(--ink2); }
.tabs { display: flex; background: #efe6d2; border-radius: 10px; padding: 3px; }
.tab { padding: 5px 10px; border-radius: 8px; font-weight: 800; font-size: 13px; color: var(--ink2); }
.tab.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.1); }
.sheet-body { overflow-y: auto; padding: 8px 10px 12px; display: grid; gap: 8px; -webkit-overflow-scrolling: touch; }
.bitem { display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 13px; padding: 8px 10px; text-align: left; }
.bitem .ic { width: 44px; height: 44px; border-radius: 10px; background: #eef6e4; display: grid; place-items: center; font-weight: 900; color: #5a7d34; font-size: 13px; }
.bitem b { font-size: 14.5px; display: block; }
.bitem small { color: var(--ink2); font-size: 12px; display: block; }
.bitem .lock { color: var(--bad); font-weight: 700; }
.bitem .cost { font-weight: 900; font-size: 14px; white-space: nowrap; }
.bitem.locked { opacity: .62; }

/* ---- modal ---- */
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(20, 30, 20, .45); display: grid; place-items: center; padding: 10px calc(10px + var(--sr)) 10px calc(10px + var(--sl)); }
.modal-box { background: var(--paper); border-radius: 20px; padding: 16px 18px; width: min(560px, 100%); max-height: calc(100vh - 20px); overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.35); animation: pop2 .22s ease-out; }
@keyframes pop2 { from { transform: scale(.94); opacity: 0; } }
.modal-box h2 { margin: 0 0 4px; font-size: 19px; }
.modal-box .quote { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px; margin: 8px 0 10px; font-size: 14.5px; }
.parts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.part { background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: 10px 6px; font-weight: 800; font-size: 13.5px; }
.part.wrong { border-color: #f3b4ae; background: #fff1ef; color: var(--bad); }
.part.right { border-color: #9edab9; background: #e6f7ee; color: var(--ok); }
.result { margin-top: 10px; font-weight: 700; min-height: 1.4em; }
.jlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 8px; }
.jitem { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; }
.jitem b { display: block; font-size: 13.5px; }
.jitem small { color: var(--ink2); font-size: 11.5px; display: block; }
.jitem.unseen { opacity: .5; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; flex-wrap: wrap; }

/* ---- floaters + toast ---- */
#floaters { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.floater { position: absolute; font-weight: 900; font-size: 15px; color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.35), 0 0 6px rgba(0,0,0,.25); animation: rise 1.4s ease-out forwards; white-space: nowrap; transform: translateX(-50%); }
.floater.coin { color: #ffe066; }
.floater.find { color: #fff3a8; font-size: 15px; background: rgba(90,60,140,.82); padding: 4px 10px; border-radius: 10px; text-shadow: none; animation-duration: 2.6s; }
.floater.heart { color: #ff8fab; font-size: 17px; }
.order { background: #fff; border-radius: 14px; padding: 10px 12px; box-shadow: 0 1px 0 rgba(0,0,0,.08); display: grid; gap: 7px; }
.order .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.order .top > span { display: grid; }
.order b { font-size: 15px; }
.order .from { font-size: 12px; color: var(--ink2); font-weight: 600; }
.order .bar { height: 9px; border-radius: 5px; background: #eee3cf; overflow: hidden; }
.order .bar i { display: block; height: 100%; background: linear-gradient(90deg, #7fd056, #5dbb4a); border-radius: 5px; transition: width .4s; }
.order .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12.5px; font-weight: 800; color: var(--ink2); }
.order .reward { color: #9a6a00; text-align: right; }
.order.done { box-shadow: 0 0 0 2.5px #7fd056 inset; }
.order.wait { color: var(--ink2); font-weight: 700; text-align: center; background: #fbf6ec; }
.jtabs { margin: 4px 0 10px; }
.hearts { color: #ff6f91; letter-spacing: 1px; font-size: 14px; }
.hearts .off { color: #eadcc6; }
.story { margin: 4px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--ink2); }
.story li { margin: 2px 0; }
.curios { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; margin-top: 8px; }
.curio { background: #fff; border-radius: 12px; padding: 8px 10px; display: grid; gap: 2px; }
.curio small { color: var(--ink2); font-size: 12px; }
.curio.unseen { opacity: .5; }
.floater.why { color: #fff; background: rgba(58,42,31,.86); padding: 4px 10px; border-radius: 10px; font-size: 13px; font-weight: 700; text-shadow: none; animation-duration: 2.2s; max-width: 80vw; white-space: normal; text-align: center; }
.burst { position: absolute; width: 0; height: 0; pointer-events: none; }
.burst b { position: absolute; left: -18px; top: -18px; width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--c); animation: ring .5s ease-out forwards; }
.burst i { position: absolute; left: -4px; top: -4px; width: 8px; height: 8px; border-radius: 50%; background: var(--c); animation: spark .6s cubic-bezier(.2,.7,.3,1) forwards; }
@keyframes ring { from { transform: scale(.5); opacity: 1; } to { transform: scale(1.9); opacity: 0; } }
@keyframes spark { to { transform: translate(var(--dx), var(--dy)) scale(.3); opacity: 0; } }
.fly { position: absolute; left: 0; top: 0; width: 16px; height: 16px; pointer-events: none; will-change: transform; }
.fly.coin { border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff0a8, #f2b705 55%, #c48a00); box-shadow: inset 0 0 0 1.5px #c48a00, 0 1px 2px rgba(0,0,0,.25); }
.fly.star { width: 20px; height: 20px; background: #ffd23f; clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); }
.pill.bump { animation: bump .22s ease-out; }
@keyframes bump { 50% { transform: scale(1.12); } }
.wind.shift { animation: glow 1.8s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 4px rgba(242,183,5,.55), 0 4px 12px rgba(0,0,0,.12); } }
.floater.rep { color: #fff; }
@keyframes rise { to { transform: translate(-50%, -46px); opacity: 0; } }
.toast { position: fixed; left: 50%; top: calc(48px + var(--st)); transform: translate(-50%, -10px); background: rgba(44,42,36,.92); color: #fff; padding: 8px 14px; border-radius: 12px; font-weight: 700; font-size: 13.5px; opacity: 0; transition: opacity .2s, transform .2s; z-index: 30; pointer-events: none; max-width: 70vw; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- portrait (phone held upright): same game, stacked layout ---- */
@media (orientation: portrait) {
  .hud { flex-wrap: wrap; row-gap: 6px; }
  .hud-left { flex: 1 1 auto; flex-wrap: nowrap; }
  .hud-right { margin-left: auto; }
  .repbar { display: none; }
  .pill { padding: 0 9px 0 6px; font-size: 14px; }
  /* waiting planes: a strip that scrolls sideways under the HUD */
  .pattern { top: calc(84px + var(--st)); left: 0; right: 0; width: auto; flex-direction: row; overflow-x: auto; overflow-y: hidden; max-height: none; padding: 0 8px 4px; scroll-snap-type: x mandatory; }
  .pcard { flex: 0 0 auto; width: 186px; scroll-snap-align: start; }
  .pattern .empty { flex: 0 0 auto; }
  /* Gus and the cards stack above the dock */
  .gus { left: calc(8px + var(--sl)); right: calc(8px + var(--sr)); bottom: calc(76px + var(--sb)); max-width: none; }
  .gus-say { flex: 1; }
  .plane-card, .building-card { left: 8px; right: 8px; transform: none; width: auto; min-width: 0; bottom: calc(76px + var(--sb)); }
  .dock { left: calc(8px + var(--sl)); right: calc(8px + var(--sr)); justify-content: flex-end; }
  /* build menu slides up from the bottom */
  .sheet { top: auto; left: 0; right: 0; bottom: 0; width: auto; height: 62vh; border-radius: 18px 18px 0 0; padding-bottom: var(--sb); animation-name: sheetUp; }
  .placebar { top: auto; bottom: calc(76px + var(--sb)); width: calc(100% - 16px); justify-content: space-between; }
  .parts { grid-template-columns: repeat(2, 1fr); }
  .toast { top: calc(150px + var(--st)); }
}
@keyframes sheetUp { from { transform: translateY(40px); opacity: 0; } }

/* small landscape phones (iPhone SE: 667 x 375) */
@media (max-height: 380px) {
  .pattern { width: 150px; }
  .gus { max-width: 46vw; }
  .gus-say p { font-size: 12.5px; }
  .dock-btn { width: 56px; height: 52px; }
}
