/* Bundled OFL fonts (library/fonts): a stylized display face for titles/buttons, a rounded UI face for the rest. */
@font-face { font-family: 'Display'; src: url('assets/fonts/lilita-one-latin-400-normal.woff2') format('woff2'); font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Display'; src: url('assets/fonts/lilita-one-latin-ext-400-normal.woff2') format('woff2'); font-display: swap; unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'UI'; font-weight: 700 900; src: url('assets/fonts/nunito-latin-800-normal.woff2') format('woff2'); font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'UI'; font-weight: 700 900; src: url('assets/fonts/nunito-latin-ext-800-normal.woff2') format('woff2'); font-display: swap; unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

/* Palette: soft storybook pastels over the 3D valley (cream panels, petal pink, leaf green, sky blue) */
:root {
  --accent: #ff7fa8; --accent-dark: #c4436d; --leaf: #6cc65a; --leaf-dark: #3f8f35; --sky: #6fc3f2; --gold: #ffc94a;
  --ink: #2c2340; --panel: rgba(255, 250, 242, .94); --panel-dim: rgba(255, 250, 242, .78); --line: rgba(60, 40, 80, .12);
  --text: #3a2c4f; --dim: #7a6c8c;
  --u: clamp(11px, 2.1vmin, 18px); /* base UI unit: legible at 800x450, not huge at 1920x1080 */
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  margin: 0; width: 100vw; height: 100vh; overflow: hidden; background: #bfe6ff; color: var(--text);
  font: 800 16px/1.25 "UI", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  touch-action: none; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none;
  user-select: none; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none;
}
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#vignette { position: fixed; inset: 0; pointer-events: none; z-index: 1; background: radial-gradient(ellipse at 50% 45%, rgba(0, 0, 0, 0) 55%, rgba(40, 20, 70, .28) 100%); }
#flash { position: fixed; inset: 0; z-index: 2; pointer-events: none; background: #fffbe6; animation: flash .45s ease-out forwards; }
@keyframes flash { from { opacity: .85; } to { opacity: 0; } }
svg { width: 1.2em; height: 1.2em; flex: none; fill: currentColor; }
.petal-ico { color: var(--accent); }

button {
  font: inherit; font-size: calc(var(--u) * 1.1); cursor: pointer; border: 0; border-radius: 14px; padding: .55em 1.2em; color: var(--text);
  background: #fff; box-shadow: 0 4px 0 rgba(60, 40, 80, .18); display: inline-flex; align-items: center; justify-content: center; gap: .45em;
}
button:hover { filter: brightness(1.05); }
button:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(60, 40, 80, .18); }
button.big {
  font-family: 'Display', 'UI', sans-serif; font-weight: 400; letter-spacing: .03em; font-size: calc(var(--u) * 2);
  background: linear-gradient(180deg, #ffa3c2, #ff6f9c); color: #fff; box-shadow: 0 5px 0 var(--accent-dark); padding: .4em 1.6em;
  text-shadow: 0 2px 0 rgba(150, 30, 70, .35);
}
button.reward { background: linear-gradient(180deg, #8fe07c, #56b947); color: #fff; box-shadow: 0 4px 0 var(--leaf-dark); text-shadow: 0 1px 0 rgba(0, 60, 0, .3); }
button.subtle { background: rgba(60, 40, 80, .07); box-shadow: none; font-size: var(--u); }
button.icon { width: calc(var(--u) * 2.8); height: calc(var(--u) * 2.8); padding: 0; border-radius: 50%; background: var(--panel); }

/* ---------------- HUD */
#hud { position: fixed; top: max(10px, env(safe-area-inset-top)); left: 12px; right: 12px; display: flex; align-items: flex-start; gap: 10px; z-index: 10; pointer-events: none; font-size: var(--u); }
#hud button { pointer-events: auto; }
.hud-left { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.pill { display: flex; align-items: center; gap: .4em; padding: .3em .9em; border-radius: 999px; background: var(--panel); box-shadow: 0 3px 10px rgba(60, 40, 80, .15); }
.big-pill { font-size: calc(var(--u) * 1.9); font-family: 'Display', 'UI', sans-serif; font-weight: 400; letter-spacing: .02em; }
.big-pill svg { width: 1.1em; height: 1.1em; }
.big-pill.bump { animation: bump .25s ease-out; }
@keyframes bump { 40% { transform: scale(1.08); } }
.small-pill { font-size: calc(var(--u) * .95); color: var(--leaf-dark); }
.hud-mid { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.season-chip { display: flex; align-items: center; gap: .4em; padding: .25em .9em; border-radius: 999px; background: var(--panel); box-shadow: 0 3px 10px rgba(60, 40, 80, .15); font-size: calc(var(--u) * 1.05); }
.season-chip svg { color: var(--accent); }
.season-chip small { color: var(--dim); font-size: .85em; }
.goal { display: flex; flex-direction: column; align-items: center; gap: 2px; width: min(340px, 36vw); padding: .3em .7em .35em; border-radius: 12px; background: var(--panel-dim); }
.goal-bar { width: 100%; height: .6em; border-radius: 1em; background: rgba(60, 40, 80, .12); overflow: hidden; }
.goal-bar i { display: block; height: 100%; width: 0; border-radius: 1em; background: linear-gradient(90deg, #8fe07c, #ff8fb4); transition: width .3s; }
.goal small { font-size: calc(var(--u) * .82); color: var(--text); white-space: nowrap; }
.season-btn { pointer-events: auto; font-family: 'Display', 'UI', sans-serif; font-weight: 400; letter-spacing: .03em; font-size: calc(var(--u) * 1.2);
  background: linear-gradient(180deg, #ffe17a, #ffbf3a); color: #5a3a00; box-shadow: 0 4px 0 #c08a10; animation: glow 1.2s ease-in-out infinite alternate; }
@keyframes glow { to { transform: scale(1.05); filter: brightness(1.1); } }
.hud-right { display: flex; gap: 8px; }

/* ---------------- upgrade dock: always visible while playing, affordable cards glow */
#dock { position: fixed; z-index: 10; left: 50%; bottom: max(10px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; gap: 6px;
  padding: 6px; border-radius: 18px; background: var(--panel-dim); box-shadow: 0 6px 20px rgba(60, 40, 80, .2); font-size: var(--u); max-width: calc(100vw - 24px); }
.up { position: relative; display: flex; flex-direction: column; align-items: center; gap: 1px; width: calc(var(--u) * 6.1); padding: .4em .2em .35em; border-radius: 12px;
  background: #fff; box-shadow: 0 3px 0 rgba(60, 40, 80, .15); font-size: calc(var(--u) * .78); line-height: 1.1; }
.up svg { width: 1.9em; height: 1.9em; color: var(--sky); }
.up .nm { font-size: .95em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.up .lv { position: absolute; top: 3px; right: 5px; font-size: .8em; color: var(--dim); }
.up .cost { display: flex; align-items: center; gap: .15em; font-size: 1.05em; color: var(--accent-dark); }
.up .cost svg { width: 1em; height: 1em; color: var(--accent); }
.up.ok { background: linear-gradient(180deg, #fff, #ffeef4); box-shadow: 0 3px 0 var(--accent), 0 0 0 2px var(--accent); }
.up.ok svg { animation: wiggle 1.4s ease-in-out infinite; }
@keyframes wiggle { 50% { transform: rotate(-8deg) scale(1.08); } }
.up.no { opacity: .62; }
.up.max .cost { color: var(--leaf-dark); }
.up.locked { opacity: .45; }
.up.hl { outline: 3px solid var(--gold); outline-offset: 2px; }

#zonePrompt { position: fixed; z-index: 11; left: 50%; bottom: calc(max(10px, env(safe-area-inset-bottom)) + var(--u) * 6.4); transform: translateX(-50%); display: flex; align-items: center; gap: .7em;
  padding: .45em .5em .45em 1em; border-radius: 16px; background: var(--panel); box-shadow: 0 6px 20px rgba(60, 40, 80, .2); font-size: var(--u); white-space: nowrap; }
#zonePrompt button { font-size: var(--u); background: linear-gradient(180deg, #8fe07c, #56b947); color: #fff; box-shadow: 0 3px 0 var(--leaf-dark); }
#zonePrompt button[disabled] { background: #ddd; color: #888; box-shadow: none; cursor: default; }
#arrow { position: fixed; z-index: 9; width: calc(var(--u) * 3); height: calc(var(--u) * 3); margin: calc(var(--u) * -1.5) 0 0 calc(var(--u) * -1.5); color: var(--gold); pointer-events: none;
  filter: drop-shadow(0 2px 2px rgba(60, 40, 0, .5)); }
#arrow svg { width: 100%; height: 100%; animation: nudge .8s ease-in-out infinite alternate; }
@keyframes nudge { to { transform: translateY(-14%); } }

#pops { position: fixed; inset: 0; pointer-events: none; z-index: 8; }
#pops div { position: absolute; transform: translate(-50%, -50%); font: 400 calc(var(--u) * 1.3) 'Display', 'UI', sans-serif; color: #fff; letter-spacing: .02em;
  -webkit-text-stroke: 1.5px #c4436d; text-shadow: 0 2px 0 #c4436d; white-space: nowrap; }
#pops div.gold { color: #fff3b0; -webkit-text-stroke-color: #a8690b; text-shadow: 0 2px 0 #a8690b; font-size: calc(var(--u) * 1.7); }
#banner { position: fixed; z-index: 12; left: 50%; top: 30%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; pointer-events: none; text-align: center;
  animation: bannerIn .5s cubic-bezier(.2, 1.4, .4, 1); }
#banner b { font: 400 calc(var(--u) * 3) 'Display', 'UI', sans-serif; color: #fff; -webkit-text-stroke: 2px #c4436d; text-shadow: 0 4px 0 #c4436d, 0 8px 20px rgba(60, 20, 60, .3); white-space: nowrap; }
#banner small { margin-top: .3em; font-size: calc(var(--u) * 1.15); padding: .2em .8em; border-radius: 999px; background: var(--panel); }
@keyframes bannerIn { from { transform: translateX(-50%) scale(.6); opacity: 0; } }

#thunder { position: fixed; z-index: 10; right: 14px; bottom: calc(max(10px, env(safe-area-inset-bottom)) + var(--u) * 6.6); display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: var(--u); }
#btnThunder { position: relative; width: calc(var(--u) * 4.4); height: calc(var(--u) * 4.4); padding: 0; border-radius: 50%; overflow: hidden;
  background: linear-gradient(180deg, #ffe17a, #ffb52e); color: #5a3a00; box-shadow: 0 4px 0 #c08a10; }
#btnThunder svg { width: 55%; height: 55%; position: relative; z-index: 1; }
#btnThunder i { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: rgba(60, 40, 80, .45); }
#btnThunder.cool { filter: saturate(.4); }
.key { display: inline-grid; place-items: center; min-width: 1.8em; height: 1.7em; padding: 0 .4em; border-radius: 6px; background: #fff; color: var(--text); box-shadow: 0 2px 0 rgba(60, 40, 80, .3); font-size: .85em; }
body.touch .keyhint { display: none; }

#coach { position: fixed; z-index: 13; left: 50%; top: calc(var(--u) * 7.2); transform: translateX(-50%); display: flex; align-items: center; gap: .7em; padding: .5em .6em .5em 1em;
  border-radius: 16px; background: var(--panel); box-shadow: 0 6px 20px rgba(60, 40, 80, .22); font-size: calc(var(--u) * 1.1); max-width: calc(100vw - 24px); animation: bannerIn .4s ease-out; }
#coach .coach-keys { display: flex; gap: 3px; align-items: center; }
#coach .coach-keys:empty { display: none; }
#coach .skip { font-size: calc(var(--u) * .8); padding: .35em .7em; background: rgba(60, 40, 80, .07); box-shadow: none; }
#hand { position: fixed; z-index: 14; width: calc(var(--u) * 3.4); height: calc(var(--u) * 3.4); pointer-events: none; margin: 0 0 0 calc(var(--u) * -.8);
  background: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cpath fill='%23fff' stroke='%233a2c4f' stroke-width='3' stroke-linejoin='round' d='M24 30V9a5 5 0 0 1 10 0v15l13 3c4 1 6 4 5 8l-3 15c-1 5-5 8-10 8H31c-3 0-6-2-8-4L12 41c-2-3-1-6 2-7 2-1 5 0 7 2l3 4z'/%3E%3C/svg%3E");
  animation: tap 1s ease-in-out infinite; }
@keyframes tap { 50% { transform: translate(0, 18%) scale(.92); } }

#joystick { position: fixed; z-index: 15; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%; background: rgba(255, 255, 255, .25); border: 2px solid rgba(255, 255, 255, .6); pointer-events: none; }
#joystick .knob { position: absolute; left: 35px; top: 35px; width: 50px; height: 50px; border-radius: 50%; background: rgba(255, 255, 255, .85); box-shadow: 0 2px 6px rgba(60, 40, 80, .3); }

/* ---------------- screens: every screen sits on an opaque card */
.screen { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: 16px; font-size: var(--u); background: rgba(60, 40, 80, .28); }
#menu { justify-content: flex-start; padding-left: max(16px, 6vw); background: linear-gradient(90deg, rgba(60, 40, 80, .28), rgba(60, 40, 80, 0) 55%); }
.card { background: var(--panel); border-radius: 24px; padding: calc(var(--u) * 1.5) calc(var(--u) * 1.8); display: flex; flex-direction: column; align-items: flex-start;
  gap: calc(var(--u) * .8); max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 20px 60px rgba(60, 40, 80, .3); }
.card.center { align-items: center; text-align: center; }
.card h1, #loading h1 { margin: 0; font: 400 calc(var(--u) * 5)/1 'Display', 'UI', sans-serif; letter-spacing: .02em; color: #ff8fb4;
  -webkit-text-stroke: 2px #b5375f; text-shadow: 0 6px 0 #b5375f, 0 12px 24px rgba(181, 55, 95, .25); }
.card h2 { margin: 0; font: 400 calc(var(--u) * 2.6)/1.05 'Display', 'UI', sans-serif; letter-spacing: .02em; color: var(--accent-dark); }
.tagline, .sub { margin: 0; color: var(--dim); font-size: calc(var(--u) * 1.1); max-width: 22em; }
.menu-card { width: min(27em, 44vw); }
.menu-card .big { width: 100%; }
.menu-stats { display: flex; flex-wrap: wrap; gap: .4em .9em; color: var(--text); }
.menu-stats span { display: flex; align-items: center; gap: .3em; }
.menu-stats svg { color: var(--accent); }
.menu-stats:empty { display: none; }
.row { display: flex; gap: .6em; flex-wrap: wrap; }
.controls { display: flex; flex-wrap: wrap; gap: .5em 1em; color: var(--dim); font-size: calc(var(--u) * .95); }
.controls span { display: flex; align-items: center; gap: .3em; }
.final { margin: 0; display: flex; align-items: center; gap: .3em; font: 400 calc(var(--u) * 3.4) 'Display', 'UI', sans-serif; color: var(--accent-dark); }
.seed-gain { display: flex; align-items: center; gap: .3em; font: 400 calc(var(--u) * 3) 'Display', 'UI', sans-serif; color: var(--leaf-dark); }
.seed-gain small { font: 800 calc(var(--u) * 1.1) 'UI', sans-serif; color: var(--dim); }
.seed-gain svg { color: #b07a3a; }
.season-card { max-width: min(30em, 90vw); }
.settings { width: min(26em, 92vw); }
.slider { display: grid; grid-template-columns: 6em 1fr 2.5em; align-items: center; gap: .8em; width: 100%; }
.slider input { width: 100%; accent-color: var(--accent); }
.setrow { display: flex; align-items: center; gap: .8em; width: 100%; }
.seg { display: flex; gap: 3px; padding: 3px; border-radius: 12px; background: rgba(60, 40, 80, .08); flex: 1; }
.seg button { flex: 1; font-size: calc(var(--u) * .9); padding: .45em .5em; border-radius: 9px; background: transparent; box-shadow: none; color: var(--dim); }
.seg button.on { background: #fff; color: var(--text); box-shadow: inset 0 0 0 2px var(--accent); }
.legal { margin: 0; color: var(--dim); font-size: calc(var(--u) * .78); line-height: 1.35; text-align: left; }

#loading { position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column; gap: 24px; align-items: center; justify-content: center; background: linear-gradient(180deg, #bfe6ff, #ffe3ec); }
#loading .bar { width: min(60vw, 360px); height: 12px; border-radius: 12px; background: rgba(60, 40, 80, .12); overflow: hidden; }
#loading i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #8fe07c, #ff8fb4); transition: width .15s; }
#toast { position: fixed; z-index: 40; left: 50%; top: calc(var(--u) * 6.4); transform: translateX(-50%); padding: .6em 1.1em; border-radius: 12px; background: var(--panel); font-size: var(--u); box-shadow: 0 6px 20px rgba(60, 40, 80, .2); }

body.cover #hud, body.cover #dock, body.cover #vignette, body.cover #thunder { display: none !important; }

/* short landscape screens (phones): tighter cards and dock */
@media (max-height: 500px) {
  .card { padding: calc(var(--u) * .9) calc(var(--u) * 1.2); gap: calc(var(--u) * .5); border-radius: 18px; }
  .card h1 { font-size: calc(var(--u) * 3.8); }
  .card h2 { font-size: calc(var(--u) * 2.1); }
  button.big { font-size: calc(var(--u) * 1.6); }
  .up { width: calc(var(--u) * 5.4); }
  #coach { top: calc(var(--u) * 6.2); }
}
/* portrait phones: menu card at the bottom, dock wraps into two rows */
@media (max-aspect-ratio: 1/1) {
  #menu { justify-content: center; align-items: flex-end; padding: 12px; background: linear-gradient(0deg, rgba(60, 40, 80, .3), rgba(60, 40, 80, 0) 60%); }
  .menu-card { width: 100%; align-items: center; text-align: center; }
  #dock { flex-wrap: wrap; justify-content: center; width: calc(100vw - 16px); }
  .up { width: calc((100vw - 64px) / 4); }
  .goal { width: 60vw; }
  #hud { flex-wrap: wrap; }
  .hud-mid { order: 3; flex-basis: 100%; }
  #zonePrompt { bottom: calc(var(--u) * 12.5); }
  #thunder { bottom: calc(var(--u) * 13); }
}

/* coach extras: key separators and tip icons */
#coach .or { margin: 0 .25em; color: var(--dim); }
#coach .tip-ico { width: 1.7em; height: 1.7em; color: var(--sky); }
#coach .tip-ico.gold { color: #e0a800; }
#zonePrompt .key { margin-left: .2em; font-size: .8em; color: var(--text); }
