/* Cozy Farm Days: the in-game HUD (top bar, quest tracker, toolbar, info panel) and the content of the farm dialogs
   (shipping bin, mailbox, day summary, new farm). Menus, dialogs, splash and loading come from the Game Shell
   (css/shell.css), coloured by data/theme.json; the second half of this file adapts the shell to the light farm theme. */
:root {
  --ink: #3d2a1c;          /* outlines, dark text */
  --panel: rgba(61, 42, 28, .9);
  --paper: #fff6e3;        /* text on dark */
  --muted: #e2cfae;
  --btn: #f6e7c8;          /* light buttons */
  --accent: #ffc94a;       /* selected / primary */
  --good: #8fd46e;
  --bad: #ff8a70;
  --radius: 12px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--gs-bg, #4a6b2a); color: var(--paper);
  font: 14px/1.35 var(--gs-font-body, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif); -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
#game { position: fixed; inset: 0; touch-action: none; }
#game canvas { display: block; touch-action: none; }
[hidden] { display: none !important; }
button { font: inherit; color: var(--ink); background: var(--btn); border: 0; border-radius: 9px; padding: 6px 12px; cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); font-weight: 700; }
button.danger { background: #e0573f; color: #fff; font-weight: 700; }
button.link { background: none; color: var(--muted); text-decoration: underline; padding: 4px; }
button.big { padding: 12px 22px; font-size: 17px; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; flex: 0 0 auto; }
svg .f { fill: currentColor; stroke: none; }
.icon { width: 40px; height: 40px; padding: 0; display: inline-grid; place-items: center; position: relative; }
.icon.small { width: 28px; height: 28px; font-size: 18px; }
.icon.big { width: 52px; height: 52px; background: var(--panel); border-radius: 14px; display: flex; align-items: center; justify-content: center; }
.icon.big img { width: 40px; height: 40px; object-fit: contain; display: block; flex: 0 0 auto; }
.dot { position: absolute; top: 4px; right: 4px; width: 12px; height: 12px; border-radius: 50%; background: #ff5a3c; box-shadow: 0 0 0 2px var(--panel); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { transform: scale(1.3); } }

/* day / night + rain overlays (above the canvas, below the HUD) */
#night { position: fixed; inset: 0; pointer-events: none; opacity: 0; z-index: 1; }
#rain { position: fixed; inset: -40px; pointer-events: none; z-index: 2; opacity: .45;
  background-image: repeating-linear-gradient(105deg, transparent 0 22px, rgba(200, 225, 255, .55) 22px 23.5px, transparent 23.5px 60px);
  background-size: 120px 120px; animation: rain .45s linear infinite; }
@keyframes rain { to { background-position: -32px 120px; } }

/* top bar */
#top { position: fixed; left: 8px; right: 8px; top: 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; pointer-events: none; z-index: 5; }
#top > * { pointer-events: auto; }
#day, #coins, #water { background: var(--panel); padding: 7px 12px; border-radius: var(--radius); font-weight: 700; white-space: nowrap; display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
#day svg { color: var(--accent); }
#day span { color: var(--muted); font-weight: 600; min-width: 42px; }
#coins { color: var(--accent); } #coins img { width: 22px; height: 22px; }
#water { color: #9fd3ff; } #water.low { color: var(--bad); animation: glow 1s infinite; }
.grow { flex: 1; pointer-events: none !important; }
#speed { display: flex; background: var(--panel); border-radius: var(--radius); padding: 4px; gap: 4px; }
#speed .sp { padding: 4px 8px; background: transparent; color: var(--paper); display: inline-flex; align-items: center; gap: 2px; }
#speed .sp svg { width: 16px; height: 16px; }
#speed .sp.on { background: var(--accent); color: var(--ink); }
#btn-menu { width: 46px; height: 46px; }
#btn-sleep { display: flex; align-items: center; gap: 6px; font-weight: 700; padding: 7px 12px; background: var(--panel); color: var(--paper); }
#btn-sleep.glow { background: var(--accent); color: var(--ink); animation: glow 1.4s infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 4px rgba(255, 201, 74, .45); } }

/* quest tracker */
#quest { position: fixed; left: 8px; top: 62px; width: 250px; background: var(--panel); border-radius: 14px; padding: 8px 10px; z-index: 4; cursor: pointer; }
#quest.done { box-shadow: 0 0 0 2px var(--accent); }
.qt { display: flex; align-items: center; gap: 6px; font-size: 15px; margin-bottom: 2px; } .qt svg { color: var(--good); }
.qg { display: grid; grid-template-columns: 1fr 70px 42px; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin: 3px 0; }
.qg i { display: block; height: 6px; background: rgba(255,255,255,.15); border-radius: 4px; overflow: hidden; }
.qg i b { display: block; height: 100%; background: var(--accent); }
.qg small { text-align: right; font-variant-numeric: tabular-nums; }
.claim { margin-top: 4px; color: var(--accent); font-weight: 700; font-size: 12px; }

/* toolbar */
#toolbar { position: fixed; left: 50%; bottom: calc(8px + var(--safe-b)); transform: translateX(-50%); background: var(--panel); padding: 6px; border-radius: 16px; max-width: calc(100vw - 16px); z-index: 5; }
#tools { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: thin; align-items: center; }
.tool { width: 58px; height: 62px; padding: 2px; display: grid; grid-template-rows: 1fr auto; place-items: center; flex: 0 0 auto; background: #f6e7c8; position: relative; }
.tool img { max-width: 50px; max-height: 40px; object-fit: contain; pointer-events: none; }
.tool .ic svg { width: 28px; height: 28px; }
.tool small { font-weight: 700; font-size: 11px; white-space: nowrap; }
.tool.on { background: var(--accent); box-shadow: inset 0 0 0 2px var(--ink); }
.tool .n { position: absolute; top: 2px; right: 3px; font-style: normal; font-weight: 800; font-size: 11px; background: var(--ink); color: var(--paper); border-radius: 8px; padding: 0 5px; }
.tool.poor small, .tool.poor .n { color: #c0432c; } .tool.poor .n { color: #ffb3a3; }
.tool .lk { display: none; position: absolute; inset: 0; place-items: center; background: rgba(61,42,28,.55); border-radius: 9px; color: var(--paper); }
.tool.locked .lk { display: grid; }
.sep { width: 2px; align-self: stretch; background: rgba(255,255,255,.15); flex: 0 0 auto; }
#hint { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(86px + var(--safe-b)); background: var(--panel); padding: 6px 12px; border-radius: 10px; max-width: calc(100vw - 32px); color: var(--muted); font-size: 13px; text-align: center; z-index: 4; pointer-events: none; }

/* info panel */
#panel { position: fixed; right: 8px; top: 70px; width: 290px; max-width: calc(100vw - 16px); background: var(--panel); border-radius: 14px; padding: 10px 12px; z-index: 6; }
.ph { display: flex; justify-content: space-between; align-items: center; font-size: 16px; }
#panel-status { color: var(--accent); margin: 4px 0 6px; font-weight: 600; }
.bad { color: var(--bad); }
#panel-body p { margin: 4px 0; color: var(--muted); font-size: 13px; }
#panel-body p.bad { color: var(--bad); }
.row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.row label { color: var(--muted); font-size: 12px; min-width: 40px; }
.row em { color: var(--muted); font-size: 12px; }
.chip { display: inline-flex; align-items: center; gap: 3px; background: rgba(255,255,255,.12); border-radius: 8px; padding: 1px 7px 1px 2px; font-weight: 700; vertical-align: middle; }
.chip img { width: 24px; height: 24px; }
.chip.new { background: var(--accent); color: var(--ink); padding: 3px 8px; }
#panel-acts { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
#panel-acts .act { font-size: 13px; font-weight: 700; }

/* ---------- farm dialogs (inside the shell's cream panel) ---------- */
.farm-d .gs-body, .day-d .gs-body, .help-d .gs-body, .nf-d .gs-body { color: var(--gs-fg); }
.tabs { display: flex; gap: 6px; margin: 0 0 10px; }
.tabs button { flex: 1; padding: 8px 10px; border: 2px solid var(--gs-line); border-radius: 10px; background: var(--gs-card); color: var(--gs-muted); font: 800 calc(16px * var(--gs-text)) var(--gs-font-display); }
.tabs button.on { background: var(--gs-good); border-color: var(--gs-good); color: #fff; }
.mlist { display: grid; gap: 6px; }
.mrow { display: flex; align-items: center; gap: 8px; background: var(--gs-card); border: 2px solid var(--gs-line); border-radius: 12px; padding: 5px 8px; }
.mrow img { width: 40px; height: 40px; flex: none; }
.mrow > div { flex: 1; display: grid; min-width: 0; }
.mrow b { font-size: calc(16px * var(--gs-text)); }
.mrow small { color: var(--gs-muted); font-size: calc(13px * var(--gs-text)); }
.mrow .gs-btn { min-width: 0; min-height: 44px; padding: 0 8px; font-size: calc(14px * var(--gs-text)); letter-spacing: 0; }
.mrow.locked { opacity: .55; }
.coins-line { display: flex; align-items: center; justify-content: flex-end; gap: 4px; margin-top: 8px; }
.coins-line img { width: 24px; height: 24px; } .coins-line b { color: var(--gs-accent); font-size: 18px; }
.farm-d .chip, .day-d .chip, .gs-panel .chip { background: var(--gs-card); border: 1px solid var(--gs-line); color: var(--gs-fg); }
.farm-d .chip.new { background: var(--gs-good); border-color: var(--gs-good); color: #fff; }
.farm-d .row label { color: var(--gs-muted); }
.qcard { background: var(--gs-card); border: 2px solid var(--gs-line); border-radius: 14px; padding: 10px 12px; margin-bottom: 4px; }
.qcard.done { border-color: var(--gs-good); box-shadow: 0 0 0 3px rgba(106, 154, 50, .25); }
.qcard .gs-label { margin: 0 0 4px; }
.qcard h3 { margin: 2px 0 4px; font: 700 calc(21px * var(--gs-text)) var(--gs-font-display); }
.qcard p { margin: 2px 0 8px; color: var(--gs-muted); }
.qcard .qg { grid-template-columns: 1fr 110px 46px; font-size: calc(14px * var(--gs-text)); color: var(--gs-fg); }
.qcard .qg i, .farm-d .qg i { background: #e6d6b4; } .qcard .qg i b { background: var(--gs-good); }
.qcard .gs-btn { margin-top: 8px; }
.tips { margin: 6px 0 0; padding-left: 20px; color: var(--gs-fg); font-size: calc(16px * var(--gs-text)); }
.tips li { margin: 6px 0; }
.gs-p.small { font-size: calc(13px * var(--gs-text)); }
.gs-p.center, .center { text-align: center; }
/* day summary */
.dstats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0 10px; }
.dstat { display: flex; align-items: center; gap: 8px; background: var(--gs-card); border: 2px solid var(--gs-line); border-radius: 12px; padding: 6px 10px; min-width: 0; }
.dstat img { width: 38px; height: 38px; flex: none; }
.dstat span { min-width: 0; }
.dstat i { display: block; font: normal 700 calc(13px * var(--gs-text)) var(--gs-font-body); color: var(--gs-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dstat b { display: block; font: 800 calc(21px * var(--gs-text)) / 1.1 var(--gs-font-body); }
.dstat.hi b { color: var(--gs-accent); }
.dnotes { margin: 4px 0 0; padding-left: 20px; color: var(--gs-muted); font-size: calc(15px * var(--gs-text)); }
.dnotes li { margin: 3px 0; } .dnotes li.bad { color: var(--gs-danger); } .dnotes li.good { color: var(--gs-good); font-weight: 700; }
.dnotes svg { width: 18px; height: 18px; }
/* new farm */
.newfarm { display: grid; gap: 12px; }
.nf-field { display: grid; gap: 4px; font: 700 calc(14px * var(--gs-text)) var(--gs-font-body); color: var(--gs-muted); }
.nf-field input { padding: 9px 12px; border: 2px solid #c9b28a; border-radius: 10px; background: #fffaf0; color: var(--gs-fg); font: 700 calc(18px * var(--gs-text)) var(--gs-font-body); user-select: text; -webkit-user-select: text; }
.nf-field input:focus { outline: none; border-color: var(--gs-good); }
.nf-field small { font-weight: 400; }
.nf-pace { display: flex; } .nf-pace button { flex: 1; }
/* menu side card */
.lc-name { margin: 0 0 6px; font: 700 calc(24px * var(--gs-text)) var(--gs-font-display); color: var(--gs-fg); }
.gs-side .kv { display: flex; gap: 14px; margin-bottom: 6px; font: 800 calc(16px * var(--gs-text)) var(--gs-font-body); flex-wrap: wrap; }
.gs-side .kv span { display: inline-flex; align-items: center; gap: 4px; }
.gs-side .kv img { width: 24px; height: 24px; }
.pbar { height: 10px; border-radius: 99px; background: #e6d6b4; overflow: hidden; margin: 6px 0 4px; box-shadow: inset 0 1px 2px rgba(58, 46, 31, .25); }
.pbar i { display: block; height: 100%; background: linear-gradient(#86b84a, var(--gs-good)); border-radius: 99px; }
body.no-fx #rain { animation: none; }

/* ---------- Game Shell on the light farm theme (shell.css defaults are dark) ---------- */
.gs-banner { aspect-ratio: 955 / 254; padding-top: 0; padding-bottom: 2.5%; width: min(440px, 88%); }
.gs-banner span { color: var(--gs-ink); font-weight: 700; letter-spacing: 1.5px;
  text-shadow: 2px 2px 0 var(--gs-fg), -2px 2px 0 var(--gs-fg), 2px -2px 0 var(--gs-fg), -2px -2px 0 var(--gs-fg), 0 3px 0 var(--gs-fg), 0 -3px 0 var(--gs-fg), 3px 0 0 var(--gs-fg), -3px 0 0 var(--gs-fg), 0 5px 0 var(--gs-fg); }
.gs-btn { font-weight: 700; letter-spacing: .5px; color: var(--gs-ink); text-shadow: 0 2px 0 #6b2c0e; border-width: 18px 22px; border-image-width: 18px 22px; }
.gs-btn small { color: #ffe2c2; text-shadow: 0 1px 0 #6b2c0e; }
.gs-btn:hover, .gs-btn:focus-visible { filter: drop-shadow(0 0 8px rgba(255, 190, 90, .6)); }
.gs-btn.gs-sec { color: var(--gs-fg); text-shadow: 0 1px 0 rgba(255, 245, 220, .7); }
.gs-btn.gs-sec small { color: var(--gs-muted); text-shadow: none; }
.gs-btn.gs-danger { color: var(--gs-danger); text-shadow: 0 1px 0 rgba(255, 245, 220, .7); }
.gs-panel { --gs-pw: 40px; }
.gs-panel-sm { --gs-pw: 30px; }
.gs-dialog .gs-title, .gs-res-head h2, .gs-pause-info b, .gs-slot-n, .gs-level-n { color: var(--gs-fg); }
.gs-res-head h2 { font-weight: 700; }
.gs-stat { background: var(--gs-card); border: 2px solid var(--gs-line); border-radius: 12px; }
.gs-stat b { color: var(--gs-fg); font-weight: 800; }
.gs-badge { border-color: var(--gs-line); background: var(--gs-card); }
.gs-badge.gs-best { background: rgba(181, 83, 31, .12); border: 2px solid var(--gs-accent); }
.gs-results.gs-won::before { background: radial-gradient(ellipse at 50% 35%, rgba(255, 230, 150, .35), transparent 60%); }
.gs-seg { border: 2px solid #c9b28a; border-radius: 10px; background: var(--gs-card); }
.gs-seg button { background: transparent; color: var(--gs-muted); }
.gs-seg button + button { border-left: 1px solid #dcc9a4; }
.gs-seg button.gs-on { background: var(--gs-good); color: #fff; }
.gs-select { border: 2px solid #c9b28a; border-radius: 10px; background: var(--gs-card); color: var(--gs-fg); }
.gs-slot { background: var(--gs-card); border: 2px solid var(--gs-line); border-radius: 12px; }
.gs-slot-n { background: var(--gs-panel); }
.gs-slot.gs-empty { border-style: dashed; background: rgba(244, 232, 204, .55); }
.gs-slot.gs-empty .gs-slot-n { border-color: #c9b28a; }
.gs-toast { background: rgba(58, 46, 31, .92); border-color: #6b5538; color: #fff6e2; }
.gs-toast.gs-bad { background: var(--gs-danger); border-color: #8d2f24; }
.gs-saved { background: var(--gs-panel); border: 2px solid #c9a46a; color: var(--gs-good); }
.gs-tut-box { background: var(--gs-panel); border: 3px solid var(--gs-accent); }
.gs-tut-box p { color: var(--gs-fg); }
.gs-tut-hole { box-shadow: 0 0 0 9999px rgba(30, 40, 15, .6); border-width: 3px; border-radius: 12px; }
/* splash, loading, menu on green instead of near-black */
.gs-studio { color: #fff6e2; text-shadow: 0 3px 0 rgba(30, 40, 10, .35); }
.gs-studio b { color: #ffb469; }
.gs-splash { background: radial-gradient(ellipse at 50% 45%, #5d8436, var(--gs-bg) 60%, var(--gs-bg2)); }
.gs-line { background: linear-gradient(90deg, transparent, #9cbb6c, transparent); height: 2px; }
.gs-madewith { color: #cfe0b0; } .gs-madewith b { color: #fff6e2; } .gs-skip { color: #a9c287; }
.gs-keyart::after { background: linear-gradient(0deg, rgba(58, 46, 31, .78) 0, rgba(58, 46, 31, .15) 24%, transparent 46%); }
.gs-loading .gs-logo { width: min(560px, 82vw); height: min(190px, 30vh); filter: drop-shadow(0 6px 10px rgba(40, 30, 10, .45)); }
.gs-lrow { color: #fff6e2; text-shadow: 0 1px 3px rgba(0, 0, 0, .6); }
.gs-tip { width: auto; max-width: min(760px, 92vw); padding: 7px 18px; border-radius: 99px; background: rgba(251, 244, 226, .93); color: var(--gs-fg); box-shadow: 0 2px 8px rgba(0, 0, 0, .25); }
.gs-menu-shade { background: linear-gradient(90deg, rgba(58, 85, 32, .92) 0%, rgba(74, 107, 42, .7) 30%, rgba(74, 107, 42, 0) 54%), linear-gradient(0deg, rgba(58, 85, 32, .55), transparent 22%); }
.gs-menu .gs-logo { width: min(400px, 34vw); height: min(150px, 22vh); top: 3vh; filter: drop-shadow(0 6px 10px rgba(40, 30, 10, .45)); }
.gs-menu-col { top: calc(5vh + min(150px, 22vh)); }
@media (max-height: 520px) and (orientation: landscape) { .gs-menu .gs-logo { height: 26vh; width: 30vw; } .gs-menu-col { top: 31vh; } }
.gs-foot { color: #d9e6c2; }
@media (max-width: 760px) and (orientation: portrait) {
  .gs-menu-shade { background: linear-gradient(0deg, rgba(58, 85, 32, .97) 0%, rgba(58, 85, 32, .9) 42%, rgba(74, 107, 42, .1) 66%, rgba(74, 107, 42, 0) 80%, rgba(58, 85, 32, .55) 100%); }
  .gs-menu .gs-logo { left: 16px; right: 16px; width: auto; height: 17vh; top: 7vh; }
  .gs-menu-col { top: auto; bottom: 8vh; }
  .dstats { grid-template-columns: repeat(2, 1fr); }
  .qcard .qg { grid-template-columns: 1fr 70px 40px; }
  .mrow { flex-wrap: wrap; } .mrow > div { flex: 1 1 60%; }
}

/* phones */
@media (max-width: 760px) {
  #top { gap: 5px; }
  #day, #coins, #water { padding: 5px 8px; font-size: 13px; }
  #day span { min-width: 36px; }
  #speed .sp svg { display: none; }
  #speed .sp[data-s="0"] svg { display: inline; }
  #speed .sp { padding: 4px 6px; font-size: 12px; }
  #btn-sleep span { display: none; }
  .icon.big { width: 44px; height: 44px; } .icon.big img { width: 34px; height: 34px; }
  .tool { width: 50px; height: 56px; }
  .tool img { max-width: 42px; max-height: 32px; }
  #toolbar { left: 8px; right: 8px; transform: none; max-width: none; }
  #hint { bottom: calc(78px + var(--safe-b)); font-size: 12px; }
  #quest { top: auto; bottom: calc(78px + var(--safe-b)); width: auto; right: 8px; padding: 6px 10px; }
  #quest .qg { grid-template-columns: 1fr 60px 40px; }
  #hud:has(#hint:not([hidden])) #quest, #hud:has(#panel:not([hidden])) #quest { display: none; }
  #panel { left: 8px; right: 8px; width: auto; top: auto; bottom: calc(78px + var(--safe-b)); }
}
@media (max-height: 480px) and (orientation: landscape) {
  .tool { width: 46px; height: 48px; } .tool img { max-height: 28px; }
  #panel { top: 56px; bottom: auto; max-height: calc(100vh - 130px); overflow-y: auto; }
  #quest { display: none; }
}
