/* =========================================================
   Juragan Ternak — gaya antarmuka
   Tema: peternakan modern yang cerah (hijau rumput, kuning jerami, biru langit)
   ========================================================= */
:root {
  --grass: #3f8f3a;
  --grass-d: #2c6b28;
  --grass-l: #e7f4e1;
  --hay: #f6b93b;
  --hay-l: #fff4d6;
  --sky: #4aa3df;
  --sky-l: #e5f3fc;
  --barn: #c0392b;
  --soil: #7a5230;
  --ink: #23301f;
  --ink-2: #55624f;
  --muted: #8a9785;
  --line: #dde6d6;
  --card: #ffffff;
  --bg: #f4f8ef;
  --good: #2e9e4f;
  --bad: #d64545;
  --warn: #e8930c;
  --info: #3b82c4;
  --radius: 14px;
  --shadow: 0 6px 22px rgba(35, 60, 25, .12);
  --font: "Nunito", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --topbar-h: 58px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow-x: hidden; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.45; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.2; }
a { color: var(--grass-d); }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.hint { color: var(--ink-2); font-size: .86em; }
.good { color: var(--good); } .bad { color: var(--bad); } .warn { color: var(--warn); }
.noscript { padding: 2em; text-align: center; background: var(--hay-l); }

/* ---------- Tombol ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4em; border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: .55em 1em; border-radius: 10px; cursor: pointer; font-weight: 700; transition: transform .08s, box-shadow .15s, background .15s; white-space: nowrap; }
.btn:hover { box-shadow: 0 2px 10px rgba(0,0,0,.08); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.btn-primary { background: linear-gradient(180deg, #4fae48, var(--grass)); border-color: var(--grass-d); color: #fff; }
.btn-hay { background: linear-gradient(180deg, #ffcf5a, var(--hay)); border-color: #d99a1f; color: #3b2a05; }
.btn-danger { background: #fff; border-color: #f0b7b7; color: var(--bad); }
.btn-sm { padding: .35em .7em; font-size: .88em; border-radius: 8px; }
.btn-lg { padding: .8em 1.3em; font-size: 1.05em; width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: .4em; }
.icon-btn { width: 40px; height: 40px; border-radius: 10px; border: 1px solid rgba(0,0,0,.08); background: rgba(255,255,255,.92); cursor: pointer; font-size: 18px; font-weight: 800; box-shadow: var(--shadow); }
.icon-btn.off { opacity: .5; }

/* ---------- Form ---------- */
label { display: block; font-weight: 700; font-size: .9em; margin-bottom: .7em; }
input[type=text], input:not([type]), input[type=number], input[type=color], select, textarea {
  display: block; width: 100%; margin-top: .3em; padding: .55em .7em; border: 1px solid var(--line); border-radius: 9px; background: #fff; font-weight: 600; }
input[type=color] { height: 42px; padding: 3px; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(63,143,58,.35); border-color: var(--grass); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .6em; }

/* ---------- Layar awal ---------- */
.start-screen { position: fixed; inset: 0; overflow: auto; z-index: 40; display: flex; align-items: flex-start; justify-content: center; padding: 4vh 16px; }
.start-bg { position: fixed; inset: 0; z-index: -1;
  background: radial-gradient(ellipse at 50% 120%, #7cc66f 0 35%, transparent 36%), linear-gradient(180deg, #8fd0f7 0%, #c9ecff 45%, #a8dc8c 46%, #77bd5f 100%); }
.start-card { width: min(1100px, 100%); background: rgba(255,255,255,.96); border-radius: 22px; box-shadow: 0 20px 60px rgba(30,70,20,.25); padding: 26px; }
.brand-big { display: flex; gap: 16px; align-items: center; margin-bottom: 18px; }
.brand-big h1 { font-size: 2.1em; color: var(--grass-d); margin: 0; letter-spacing: -.5px; }
.brand-big p { margin: .2em 0 0; color: var(--ink-2); }
.brand-ico { font-size: 54px; filter: drop-shadow(0 4px 6px rgba(0,0,0,.15)); }
.start-grid { display: grid; grid-template-columns: 1.1fr 1fr 1.1fr; gap: 18px; }
.start-section { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.start-section h2 { font-size: 1.1em; color: var(--grass-d); }
.difficulty { border: 0; padding: 0; margin: 0 0 1em; display: grid; gap: .4em; }
.difficulty legend { font-weight: 700; font-size: .9em; margin-bottom: .3em; }
.difficulty label { margin: 0; display: flex; gap: .6em; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: .5em .7em; cursor: pointer; font-weight: 400; }
.difficulty label:has(input:checked) { border-color: var(--grass); background: var(--grass-l); }
.difficulty span { display: flex; flex-direction: column; } .difficulty small { color: var(--ink-2); }
.saved-list { display: grid; gap: .5em; margin-bottom: 1em; max-height: 240px; overflow: auto; }
.saved-item { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: .6em .7em; display: flex; justify-content: space-between; align-items: center; gap: .5em; }
.saved-item small { color: var(--ink-2); display: block; }
.resume-form { display: flex; gap: .5em; align-items: flex-end; } .resume-form label { flex: 1; margin: 0; }
.last-player { background: var(--hay-l); border: 1px dashed #e2b14c; border-radius: 10px; padding: .6em .8em; margin-bottom: .8em; font-size: .92em; }
.last-player b { color: #7a4d00; }

/* ---------- Tata letak game ---------- */
.app { height: 100%; display: flex; flex-direction: column; }
.topbar { height: var(--topbar-h); flex: none; display: flex; align-items: center; gap: 12px; padding: 0 12px; background: linear-gradient(90deg, var(--grass-d), var(--grass)); color: #fff; box-shadow: 0 2px 12px rgba(0,0,0,.15); z-index: 5; }
.brand { display: flex; align-items: center; gap: 6px; font-size: 1.1em; white-space: nowrap; } .brand span { font-size: 1.4em; }
.stats { display: flex; gap: 6px; flex: 1; overflow-x: auto; scrollbar-width: none; } .stats::-webkit-scrollbar { display: none; }
.chip { background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.22); border-radius: 999px; padding: 4px 11px; white-space: nowrap; font-size: .87em; display: flex; gap: 5px; align-items: baseline; }
.chip b { font-size: 1.05em; } .chip small { opacity: .8; }
.chip.neg b { color: #ffd2d2; }
.top-actions { display: flex; gap: 6px; } .top-actions .btn { background: rgba(255,255,255,.95); }

.layout { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 440px; min-height: 0; }
.scene-wrap { position: relative; min-height: 0; background: #bfe6ff; overflow: hidden; }
.scene { position: absolute; inset: 0; touch-action: none; }
.scene canvas { display: block; width: 100%; height: 100%; }
.hover-label { position: absolute; pointer-events: none; transform: translate(-50%, -130%); background: rgba(35,48,31,.9); color: #fff; padding: 5px 10px; border-radius: 8px; font-size: .86em; font-weight: 700; white-space: nowrap; z-index: 3; }
.hover-label small { display: block; font-weight: 400; opacity: .85; }
.scene-tools { position: absolute; top: 12px; left: 12px; display: flex; flex-direction: column; gap: 6px; z-index: 2; }
.scene-hint { position: absolute; left: 12px; bottom: 12px; right: 190px; font-size: .78em; color: #24421f; background: rgba(255,255,255,.75); padding: 4px 9px; border-radius: 8px; width: max-content; max-width: calc(100% - 210px); }
.next-week { position: absolute; right: 14px; bottom: 14px; z-index: 2; font-size: 1.05em; padding: .8em 1.3em; box-shadow: 0 8px 24px rgba(30,90,20,.35); }
.next-week.pulse { animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(79,174,72,.6); } 50% { box-shadow: 0 0 0 12px rgba(79,174,72,0); } }
.scene-error { position: absolute; inset: 20% 10% auto; background: #fff; border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); text-align: center; z-index: 4; }
.weather-fx { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.weather-fx.rain { background-image: repeating-linear-gradient(105deg, rgba(255,255,255,.0) 0 14px, rgba(220,235,255,.35) 14px 15px); background-size: 120px 120px; animation: rain .5s linear infinite; }
.weather-fx.storm { background-image: repeating-linear-gradient(105deg, rgba(255,255,255,0) 0 8px, rgba(210,225,255,.45) 8px 9px); background-size: 80px 80px; animation: rain .3s linear infinite; background-color: rgba(30,40,70,.12); }
.weather-fx.dry { background: radial-gradient(ellipse at 80% 0%, rgba(255,190,90,.28), transparent 60%); }
@keyframes rain { to { background-position: -40px 120px; } }

/* ---------- Panel ---------- */
.panel { background: var(--card); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.panel-strip { padding: 10px 12px 6px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, #fbfdf8, #fff); }
.target-strip { font-size: .85em; }
.target-strip .row { display: flex; justify-content: space-between; gap: .5em; }
.news-ticker { margin-top: 6px; font-size: .84em; background: var(--sky-l); border-radius: 8px; padding: 5px 9px; min-height: 1.9em; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabs { display: grid; grid-template-columns: repeat(8, auto); border-bottom: 1px solid var(--line); background: #fafcf7; }
.tabs button { border: 0; background: none; padding: 7px 1px 6px; min-width: 0; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 1px; font-size: 18px; border-bottom: 3px solid transparent; position: relative; }
.tabs button span { font-size: 10px; font-weight: 700; color: var(--ink-2); letter-spacing: -.1px; white-space: nowrap; }
.tabs button.active { border-bottom-color: var(--grass); background: #fff; } .tabs button.active span { color: var(--grass-d); }
.tabs button.new::after { content: ""; position: absolute; top: 5px; right: 18%; width: 8px; height: 8px; border-radius: 50%; background: var(--hay); }
.tab-content { flex: 1; overflow-y: auto; padding: 12px; }
.tab-content h3 { font-size: 1.02em; color: var(--grass-d); margin: 14px 0 8px; display: flex; align-items: center; justify-content: space-between; gap: .5em; }
.tab-content h3:first-child { margin-top: 0; }

/* ---------- Kartu & indikator ---------- */
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 11px; }
.kpi .lbl { font-size: .76em; color: var(--ink-2); font-weight: 700; text-transform: uppercase; letter-spacing: .3px; }
.kpi .val { font-size: 1.15em; font-weight: 800; margin-top: 2px; }
.kpi .sub { font-size: .78em; color: var(--muted); }
.bar { height: 8px; background: #edf1ea; border-radius: 99px; overflow: hidden; margin-top: 5px; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--grass); transition: width .4s; }
.bar.h-warn > i { background: var(--warn); } .bar.h-bad > i { background: var(--bad); } .bar.blue > i { background: var(--sky); }
.list { display: grid; gap: 8px; }
.item { border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: #fff; }
.item-head { display: flex; justify-content: space-between; align-items: center; gap: .5em; }
.item-head b { font-size: .98em; }
.item .meta { font-size: .82em; color: var(--ink-2); margin: 4px 0 6px; }
.tag { display: inline-block; font-size: .72em; font-weight: 800; padding: 2px 7px; border-radius: 99px; background: var(--grass-l); color: var(--grass-d); vertical-align: middle; }
.tag.hay { background: var(--hay-l); color: #8a5a00; } .tag.red { background: #fde4e4; color: var(--bad); } .tag.blue { background: var(--sky-l); color: #22629a; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .86em; }
.tbl th, .tbl td { padding: 6px 5px; border-bottom: 1px solid var(--line); text-align: left; }
.tbl th { font-size: .78em; color: var(--ink-2); text-transform: uppercase; letter-spacing: .3px; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tr.me td { background: var(--hay-l); }
.notes { display: grid; gap: 6px; }
.note { font-size: .86em; padding: 7px 9px; border-radius: 9px; border-left: 4px solid var(--info); background: #f5f9fd; }
.note.good { border-color: var(--good); background: #eff9f1; color: var(--ink); } .note.bad { border-color: var(--bad); background: #fdf1f1; color: var(--ink); }
.note.warn { border-color: var(--warn); background: #fff7ea; color: var(--ink); }
.note small { color: var(--muted); font-weight: 700; margin-right: 4px; }
.fix-note { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.fix-note .btn { flex: none; }
.fix-highlight { animation: fixGlow 1.6s ease-out 2; border-radius: 12px; }
@keyframes fixGlow { 0% { box-shadow: 0 0 0 0 rgba(230,145,30,.75); } 70% { box-shadow: 0 0 0 10px rgba(230,145,30,0); } 100% { box-shadow: 0 0 0 0 rgba(230,145,30,0); } }
.chart-box { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.chart-box canvas { width: 100%; height: 190px; display: block; }
.legend { display: flex; gap: 10px; flex-wrap: wrap; font-size: .76em; color: var(--ink-2); padding: 2px 4px 0; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 4px 10px; cursor: pointer; font-size: .82em; font-weight: 700; }
.seg button.on { background: var(--grass); color: #fff; }
.empty { text-align: center; color: var(--muted); padding: 14px; border: 1px dashed var(--line); border-radius: 12px; font-size: .9em; }
.tip { background: var(--hay-l); border: 1px solid #f0d28a; border-radius: 12px; padding: 9px 30px 9px 11px; font-size: .86em; margin-bottom: 10px; position: relative; }
.tip b { color: #7a4d00; }
.tip .x { position: absolute; top: 4px; right: 8px; border: 0; background: none; cursor: pointer; font-size: 18px; color: #a07a2a; }
.inline-form { display: flex; gap: 6px; align-items: flex-end; flex-wrap: wrap; margin-top: 6px; }
.inline-form input, .inline-form select { width: auto; flex: 1; min-width: 80px; margin: 0; padding: .4em .55em; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; font-size: .88em; }
.kv span:nth-child(even) { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Modal, toast, tutorial ---------- */
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(20,35,15,.45); display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade .15s; }
.modal-card { background: #fff; width: min(560px, 100%); max-height: 90vh; overflow: auto; border-radius: 18px; padding: 20px; position: relative; box-shadow: 0 24px 60px rgba(0,0,0,.25); }
.modal-card.wide { width: min(820px, 100%); }
.modal-x { position: absolute; top: 10px; right: 12px; border: 0; background: none; font-size: 26px; cursor: pointer; color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.confirm-box { background: var(--bg); border-radius: 12px; padding: 10px 12px; margin-top: 10px; }
@keyframes fade { from { opacity: 0; } }
.toasts { position: fixed; top: calc(var(--topbar-h) + 10px); left: 50%; transform: translateX(-50%); z-index: 70; display: grid; gap: 6px; width: min(460px, 92vw); pointer-events: none; }
.toast { pointer-events: auto; background: #23301f; color: #fff; border-radius: 12px; padding: 10px 14px; font-size: .9em; box-shadow: 0 10px 30px rgba(0,0,0,.25); animation: slide .25s; border-left: 5px solid var(--grass); }
.toast.bad { border-left-color: #ff7a7a; } .toast.warn { border-left-color: var(--hay); }
@keyframes slide { from { transform: translateY(-10px); opacity: 0; } }
.loading { position: fixed; inset: 0; z-index: 80; background: rgba(255,255,255,.35); display: flex; align-items: center; justify-content: center; }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 5px solid var(--grass-l); border-top-color: var(--grass); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.tutorial { position: fixed; inset: 0; z-index: 65; }
.tut-spot { position: absolute; border-radius: 12px; box-shadow: 0 0 0 4px var(--hay), 0 0 0 9999px rgba(20,35,15,.5); transition: all .25s; pointer-events: none; }
.tut-card { position: absolute; width: min(360px, 92vw); background: #fff; border-radius: 16px; padding: 16px; box-shadow: 0 20px 50px rgba(0,0,0,.3); transition: top .25s, left .25s; }
.tut-step { font-size: .75em; font-weight: 800; color: var(--grass); text-transform: uppercase; }
.tut-actions { display: flex; justify-content: space-between; margin-top: 10px; }

.score-big { font-size: 2.6em; font-weight: 900; color: var(--grass-d); text-align: center; margin: .2em 0; }

/* ---------- Responsif ---------- */
@media (max-width: 1100px) { .layout { grid-template-columns: minmax(0, 1fr) 390px; } .start-grid { grid-template-columns: 1fr 1fr; } .start-lb { grid-column: span 2; } }
@media (max-width: 820px) {
  :root { --topbar-h: 52px; }
  .brand b, .top-actions .lbl { display: none; }
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: 44vh minmax(0, 1fr); }
  .tabs { display: flex; overflow-x: auto; scrollbar-width: none; } .tabs::-webkit-scrollbar { display: none; }
  .tabs button { flex: 0 0 auto; padding: 6px 9px 5px; }
  .panel { border-left: 0; border-top: 1px solid var(--line); }
  .scene-hint { display: none; }
  .next-week { right: 10px; bottom: 10px; padding: .6em 1em; font-size: .95em; }
  .tabs button span { font-size: 9px; }
  .start-grid { grid-template-columns: 1fr; } .start-lb { grid-column: auto; }
  .brand-big h1 { font-size: 1.6em; } .brand-ico { font-size: 40px; }
  .start-card { padding: 16px; }
  .icon-btn { width: 36px; height: 36px; font-size: 16px; }
}
@media (max-width: 420px) { .cards { grid-template-columns: 1fr 1fr; gap: 6px; } .card { padding: 8px; } .field-row { grid-template-columns: 1fr; } }
