/* BexFarm — gaya. Gelap, hangat, ala papan kayu + kuningan. */
:root {
  --bg: #0e1210;
  --bg2: #141b17;
  --panel: #1a231d;
  --panel2: #212c24;
  --line: #2f3d33;
  --line2: #3d4f42;
  --text: #e8f0e6;
  --dim: #96a99a;
  --gold: #f0c05a;
  --gem: #7ad7f0;
  --bex: #9d84ff;
  --good: #62d993;
  --warn: #f0a24a;
  --bad: #ef6a6a;
  --wood: #4a3324;
  --r: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background:
    radial-gradient(1200px 600px at 15% -10%, #1b2a20 0%, transparent 60%),
    radial-gradient(900px 500px at 110% 10%, #1a2140 0%, transparent 55%),
    var(--bg);
  color: var(--text);
  font: 14px/1.45 ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
  height: 100%;
  overflow: hidden;
}
.app { height: 100%; margin: 0; padding: 0; }

/* ---------- hud di dalam kanvas ---------- */
.logo {
  font-size: 24px; font-weight: 800; letter-spacing: .5px;
  background: linear-gradient(92deg, var(--gold), #ffe9a8 45%, var(--good));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hud { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.top-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 999px;
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  border: 1px solid var(--line2); font-variant-numeric: tabular-nums; font-weight: 600; font-size: 13px;
}
.chip svg { width: 14px; height: 14px; display: block; }
.chip.time { color: #d8e8d2; font-weight: 500; }
.chip.weather { color: #cfe3ff; }
.chip.bex { border-color: #52457f; color: #d6ccff; background: linear-gradient(180deg, #2a2440, #1d1a2c); }
.chip.boom { border-color: #6b5320; background: linear-gradient(180deg, #3a2c12, #241b0d); color: var(--gold); animation: pulse 1.6s infinite; }
.chip.energy { color: #cfe3d6; font-weight: 500; }
.chip.energy i { display: inline-block; width: 34px; height: 5px; margin: 0 5px; border-radius: 3px; background: #0d120e; border: 1px solid var(--line); overflow: hidden; vertical-align: middle; }
.chip.energy i b { display: block; height: 100%; background: var(--good); }
.chip.energy.low { color: #ffc0b4; border-color: #6b2f28; }
.chip.energy.low i b { background: var(--bad); }
.chip.lvl { color: #cfe0f0; font-weight: 500; }
.chip.lvl i { display: inline-block; width: 34px; height: 5px; margin: 0 5px; border-radius: 3px; background: #0d120e; border: 1px solid var(--line); overflow: hidden; vertical-align: middle; }
.chip.lvl i b { display: block; height: 100%; background: #6fb3e0; }
@keyframes pulse { 50% { box-shadow: 0 0 0 3px rgba(240, 192, 90, .18); } }

.badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge { font-size: 11px; font-weight: 700; letter-spacing: .3px; text-transform: uppercase; padding: 3px 9px; border-radius: 6px; }
.badge.good { background: rgba(98, 217, 147, .14); color: var(--good); border: 1px solid rgba(98, 217, 147, .3); }
.badge.warn { background: rgba(240, 162, 74, .14); color: var(--warn); border: 1px solid rgba(240, 162, 74, .3); }

/* ---------- layout: game mengisi layar ---------- */
.layout { display: block; height: 100%; }
.stage { height: 100%; background: #0d120f; border: 0; border-radius: 0; padding: 0; box-shadow: none; }
.canvas-wrap { position: relative; height: 100%; }
.scene { position: relative; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
#farm-canvas {
  display: block; width: 100%; height: 100%;
  position: relative; z-index: 1;
  image-rendering: pixelated; background: #2b3b2a;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .35);
  cursor: pointer;
}
/* satu-satunya renderer dunia: WebGL di kanvas belakang, kanvas 2D jadi lapisan UI transparan */
#farm-gl {
  position: absolute; inset: 0; z-index: 0;
  display: none; width: 100%; height: 100%;
  image-rendering: auto; background: #0d120f;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .35);
  cursor: pointer;
}
#farm-canvas.gl3d { background: transparent; box-shadow: none; }
.overlays {
  position: absolute; inset: 0; z-index: 3; min-height: 0; padding: 10px;
  display: flex; flex-direction: column; gap: 7px; pointer-events: none;
}
.hud-stack { display: flex; flex-direction: column; gap: 7px; pointer-events: auto; }
.hud-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 7px;
  padding: 6px 8px; border-radius: 12px;
  background: rgba(9, 14, 10, .74); border: 1px solid rgba(61, 79, 66, .55);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .35);
}
.hud-row .logo { font-size: 17px; white-space: nowrap; }
.overlay-body { flex: 1 1 auto; min-height: 0; display: flex; justify-content: flex-end; pointer-events: none; }
.dock {
  pointer-events: auto; display: flex; flex-direction: column; gap: 5px; padding: 6px 8px;
  border-radius: 12px; background: rgba(9, 14, 10, .8); border: 1px solid rgba(61, 79, 66, .55);
  box-shadow: 0 -4px 14px rgba(0, 0, 0, .3);
}
.dock .toolbar { margin-top: 0; gap: 5px; }
.dock .tool { padding: 4px 9px; font-size: 12px; }
.dock .tool-hint { padding-top: 1px; font-size: 11px; }
.dock .inventory { min-height: 34px; padding: 5px 8px; border-radius: 10px; background: rgba(19, 26, 21, .7); }
.tip {
  position: absolute; z-index: 7; pointer-events: none; opacity: 0; transition: opacity .12s;
  background: rgba(10, 16, 12, .94); border: 1px solid var(--line2); color: #e8f0e6;
  padding: 5px 9px; border-radius: 8px; font-size: 12px; white-space: nowrap; max-width: 92%;
  transform: translateX(-10%);
}
.tip.on { opacity: 1; }
.offline {
  position: absolute; z-index: 6; inset: auto 12px 12px 12px; display: none; gap: 8px; align-items: center; justify-content: space-between;
  background: rgba(12, 20, 15, .93); border: 1px solid var(--line2); border-radius: 12px; padding: 10px 12px;
}
.offline.on { display: flex; }
.offline .sub { display: block; color: var(--dim); font-weight: 400; }

/* ---------- toolbar ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }
.tool {
  padding: 7px 11px; border-radius: 9px; cursor: pointer; font-size: 13px; font-weight: 600;
  background: linear-gradient(180deg, var(--panel2), var(--panel)); color: var(--text);
  border: 1px solid var(--line2); transition: transform .08s, border-color .12s;
}
.tool:hover { transform: translateY(-1px); border-color: #55705c; }
.tool.on { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(240, 192, 90, .2) inset; background: linear-gradient(180deg, #35301c, #24210f); }
.tool.seed { display: inline-flex; align-items: center; gap: 6px; }
.tool.seed .dot { width: 9px; height: 9px; border-radius: 3px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .4); }
.tool.seed.dim { opacity: .38; }
.tool-sep { width: 1px; height: 22px; background: var(--line2); margin: 0 4px; }
.tool.ring-open { border-style: dashed; color: var(--gold); letter-spacing: .2px; }
.tool.ring-open:hover { border-style: solid; border-color: var(--gold); }
.tool-hint { flex: 1 1 100%; color: var(--dim); font-size: 12px; padding-top: 4px; }

kbd { background: #0e1512; border: 1px solid var(--line2); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; font-size: 10px; }

/* ---------- tab + panel di dalam kanvas ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.tab { padding: 5px 11px; font-size: 11.5px; font-weight: 700; letter-spacing: .2px; cursor: pointer;
  color: var(--dim); border: 1px solid var(--line2); border-radius: 999px;
  background: rgba(12, 18, 13, .86); box-shadow: 0 2px 8px rgba(0,0,0,.35); }
.tab:hover { color: var(--text); border-color: #55705c; }
.tab.on { color: #241d10; border-color: #8a6a20; background: linear-gradient(180deg, #ffd77a, #e9b64e); }

.menu {
  position: relative; flex: 0 0 auto; width: min(336px, 48%); max-width: 100%; min-height: 0; max-height: 100%;
  display: flex; flex-direction: column; pointer-events: auto;
  background: rgba(11, 16, 12, .95); border: 1px solid var(--line2); border-radius: 12px;
  box-shadow: var(--shadow); overflow: hidden;
}
.menu.closed { display: none; }
.menu-x { flex: 0 0 auto; padding: 7px; font-size: 11.5px; font-weight: 700; cursor: pointer;
  color: var(--dim); background: #10160f; border: 0; border-top: 1px solid var(--line); }
.menu-x:hover { color: var(--text); }
.panel { flex: 1 1 auto; min-height: 0; padding: 12px; overflow: auto; }
@media (max-width: 980px) {
  .hud-row { padding: 5px 6px; gap: 5px; }
  .hud-row .logo { font-size: 15px; }
  .chip { padding: 3px 8px; font-size: 12px; }
  .btn.sm { padding: 4px 7px; font-size: 11.5px; }
  .top-actions kbd { display: none; }
}
@media (max-width: 760px) {
  .menu { flex: 1 1 auto; width: auto; }
}
.panel h3 { margin: 0 0 10px; font-size: 15px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.panel h4 { margin: 16px 0 8px; font-size: 13px; color: #cfe0c8; text-transform: uppercase; letter-spacing: .6px; }
.sub { color: var(--dim); font-weight: 400; font-size: 11.5px; }
.log-mini { color: var(--dim); font-size: 11.5px; margin-top: 10px; }
.empty { color: var(--dim); padding: 14px; text-align: center; border: 1px dashed var(--line2); border-radius: 10px; }

/* ---------- buttons ---------- */
.btn {
  padding: 8px 12px; border-radius: 9px; cursor: pointer; font-weight: 700; font-size: 13px;
  background: linear-gradient(180deg, var(--panel2), var(--panel)); color: var(--text); border: 1px solid var(--line2);
  transition: transform .08s, filter .12s;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.12); }
.btn:disabled { opacity: .42; cursor: not-allowed; }
.btn.sm { padding: 5px 9px; font-size: 12px; }
.btn.primary { background: linear-gradient(180deg, #f0c05a, #cf9a2c); color: #2b2208; border-color: #f7d684; }
.btn.danger { background: linear-gradient(180deg, #4a2020, #2f1616); color: #ffc9c9; border-color: #6d3232; margin-top: 14px; }
.view-toggle.on { border-color: var(--good); color: var(--good); }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; padding: 5px 8px; }
.icon-btn svg { display: block; fill: none; stroke: currentColor; stroke-width: 1.25; }
.icon-btn.on { border-color: var(--gold); color: var(--gold); box-shadow: 0 0 0 2px rgba(240, 192, 90, .18) inset; }

/* ---------- cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 10px; }
.card { background: linear-gradient(180deg, var(--panel2), #182019); border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 7px; }
.card.ok { border-color: rgba(98, 217, 147, .45); box-shadow: 0 0 0 1px rgba(98, 217, 147, .12) inset; }
.card.busy { border-color: rgba(240, 192, 90, .4); }
.card-h { font-weight: 700; font-size: 13px; display: flex; align-items: center; gap: 7px; justify-content: space-between; }
.card-h svg { width: 16px; height: 16px; }
.card-b { font-size: 12px; color: #c6d6c2; }
.pill { font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 999px; background: #26332a; color: var(--dim); }
.pill.red { background: rgba(239, 106, 106, .16); color: var(--bad); }
.rew { display: flex; gap: 5px; flex-wrap: wrap; }
.rew .chip { padding: 3px 8px; font-size: 12px; }
.bar { height: 7px; border-radius: 5px; background: #0d120e; overflow: hidden; border: 1px solid var(--line); margin: 5px 0; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, #f0c05a, #62d993); }

/* ---------- tabel ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl th { text-align: left; color: var(--dim); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .4px; padding: 5px 6px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 6px; border-bottom: 1px solid #222c24; }
.tbl tr:hover td { background: rgba(255, 255, 255, .025); }
.price { color: var(--gold); font-weight: 700; font-variant-numeric: tabular-nums; }
.trend { font-size: 11px; font-weight: 700; }
.trend.up { color: var(--good); } .trend.down { color: var(--bad); } .trend.flat { color: var(--dim); }
.rowbtn { text-align: right; white-space: nowrap; }
.rowbtn button { padding: 3px 7px; margin-left: 3px; border-radius: 6px; font-size: 11px; cursor: pointer; background: #223024; color: var(--text); border: 1px solid var(--line2); }
.rowbtn button:hover { border-color: var(--gold); }
.meter { display: inline-block; width: 46px; height: 7px; border-radius: 4px; background: #0d120e; border: 1px solid var(--line); overflow: hidden; vertical-align: middle; }
.meter > i { display: block; height: 100%; }
.meter.g > i { background: var(--good); } .meter.y > i { background: var(--warn); } .meter.r > i { background: var(--bad); }
.meter.big { display: block; width: 100%; height: 12px; }

/* ---------- rumah / istirahat ---------- */
.rest-card { padding: 11px 12px; border: 1px solid var(--line); border-radius: 12px; background: linear-gradient(180deg, #241d16, #17140f); display: grid; gap: 8px; margin-bottom: 10px; }
.rest-top { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; }
.rest-top span { color: var(--gold); font-weight: 700; }
.pen-zones { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; }
.pen-zones h4 { width: 100%; margin: 0 0 2px; }
.pz { padding: 4px 9px; border-radius: 999px; border: 1px solid var(--line); background: #151b16; color: var(--dim); font-size: 12px; }
.pz.on { color: #e9f2e6; border-color: #3d5a3f; background: #1b2519; }

/* ---------- resep / toko ---------- */
.recipes { display: grid; gap: 8px; }
.recipe { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; padding: 9px 10px; border: 1px solid var(--line); border-radius: 11px; background: #182019; }
.recipe.can { border-color: rgba(98, 217, 147, .35); }
.recipe b { font-size: 13px; }
.recipe .sub { grid-column: 1; }
.recipe .ing { color: #7f937f; }
.recipe .btn { grid-row: 1 / span 3; grid-column: 2; }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 9px; }
.shop-item { display: flex; flex-direction: column; gap: 5px; padding: 10px; border: 1px solid var(--line); border-radius: 11px; background: linear-gradient(180deg, var(--panel2), #171f18); }
.shop-item b { font-size: 13px; }
.shop-item.max { opacity: .55; }
.lvl { color: var(--gem); font-weight: 600; font-size: 11px; }

/* ---------- dompet ---------- */
.wallet-hero { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; background: linear-gradient(140deg, #241f3c, #161428); border: 1px solid #453a70; }
.wallet-hero svg { width: 34px; height: 34px; }
.big { font-size: 26px; font-weight: 800; color: #d9cfff; font-variant-numeric: tabular-nums; }
.stat-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.notice { margin: 12px 0; padding: 9px 11px; border-radius: 10px; background: rgba(240, 162, 74, .1); border: 1px solid rgba(240, 162, 74, .35); color: #ffd9ac; font-size: 12px; }
.notice code { background: #1a211a; padding: 1px 5px; border-radius: 4px; }
.wd { display: flex; gap: 8px; }
.wd input { flex: 1; min-width: 0; padding: 9px 10px; border-radius: 9px; border: 1px solid var(--line2); background: #10150f; color: var(--text); font-family: ui-monospace, monospace; font-size: 12px; }
.wd input:focus { outline: none; border-color: var(--bex); }

/* ---------- info ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.stat { padding: 8px 10px; border-radius: 10px; background: #182019; border: 1px solid var(--line); }
.stat span { display: block; color: var(--dim); font-size: 11px; }
.stat b { font-size: 15px; }
.how { margin: 0; padding-left: 18px; color: #c9d9c5; font-size: 12.5px; }
.how li { margin-bottom: 5px; }
.keys { display: flex; gap: 12px; flex-wrap: wrap; color: var(--dim); font-size: 11px; align-items: center; margin: 2px 0 10px; }
.sw { display: inline-block; width: 16px; height: 6px; border-radius: 3px; margin-right: 5px; vertical-align: middle; }
.sw.water { background: #4fc3f7; } .sw.fert { background: #7bd88f; } .sw.ready { background: #ffd34d; } .sw.pest { background: #ff5c8a; width: 8px; height: 8px; border-radius: 50%; }

/* ---------- suara ---------- */
.snd { display: flex; align-items: center; gap: 8px; margin: 5px 0; color: var(--dim); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; }
.snd span { flex: 0 0 42px; }
.snd input { flex: 1 1 auto; height: 4px; margin: 0; accent-color: var(--gold); cursor: pointer; }
.chip.mood { display: inline-block; margin-top: 7px; color: #d9c9a0; font-size: 11px; }
.btn.off { opacity: .5; }
.log { max-height: 200px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; padding: 8px; background: #12180f; }
.log .li { font-size: 11.5px; color: var(--dim); padding: 2px 0; border-bottom: 1px dotted #202a20; }

/* ---------- inventaris ---------- */
.inventory { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; padding: 7px 9px; border: 1px solid var(--line); border-radius: var(--r); background: #131a15; min-height: 40px; }
.inv-title { color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; margin-right: 4px; }
.inv-empty { color: #5f7263; font-size: 12px; }
.inv-item { display: inline-flex; gap: 6px; align-items: baseline; padding: 4px 9px; border-radius: 8px; cursor: pointer;
  background: #1c261d; border: 1px solid var(--line2); color: var(--text); font-size: 12px; }
.inv-item:hover { border-color: var(--gold); }
.inv-item .qt { color: var(--gold); font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- toast ---------- */
.toasts { position: fixed; left: 14px; top: 112px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: min(340px, 46vw); }
.toast { padding: 9px 13px; border-radius: 10px; font-size: 12.5px; font-weight: 600; box-shadow: var(--shadow);
  background: #1d271f; border: 1px solid var(--line2); animation: slidein .18s ease-out; }
.toast.good { background: #14301f; border-color: #2c6b45; color: #a8f0c6; }
.toast.warn { background: #33260f; border-color: #6e5321; color: #ffd9a1; }
.toast.info { background: #16222c; border-color: #2d4d63; color: #b9e0ff; }
.toast.out { opacity: 0; transform: translateY(6px); transition: opacity .3s, transform .3s; }
/* denah besar menempati band yang sama dengan kolom toast: yang masih hidup diredam, bukan ditimpa */
.toasts.dim { opacity: 0; pointer-events: none; transition: opacity .16s; }
@keyframes slidein { from { opacity: 0; transform: translateY(8px); } }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
