/* Korean Farm Game — mobile-first, dark farm aesthetic */
:root {
  --bg: #0e1512;
  --bg2: #141d18;
  --card: #18241e;
  --card2: #1e2c24;
  --line: #2a3a2f;
  --ink: #eef3ea;
  --muted: #9fb0a2;
  --green: #8fd694;
  --green-dk: #3f6b4f;
  --gold: #e8b64c;
  --red: #e06c5b;
  --blue: #7fb6d9;
  --radius: 14px;
  --topbar-h: 0px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Noto Sans KR", "Apple SD Gothic Neo", sans-serif;
  -webkit-text-size-adjust: 100%;
  padding-bottom: 76px; /* room for tab bar */
}

/* ---------- sticky top bars ---------- */
#topbars {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(14, 21, 18, 0.97);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.bar { padding: 8px 12px; }
#playerbar {
  display: flex;
  align-items: center;
  gap: 10px;
}
.lvl-badge {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--green-dk);
  color: #fff;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex: none;
}
.player-meta { flex: 1; min-width: 0; }
.player-name { font-weight: 700; font-size: 14px; }
.xpbar {
  height: 6px; background: #243128; border-radius: 3px; margin-top: 4px;
  overflow: hidden;
}
.xpbar > i { display: block; height: 100%; background: var(--green); border-radius: 3px; }
.coins {
  font-weight: 700; color: var(--gold); white-space: nowrap; font-size: 15px;
}
.day-chip {
  font-size: 12px; color: var(--muted); white-space: nowrap;
}
#skillbar {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding-top: 0;
}
.skill-chip {
  display: flex; flex-direction: column; align-items: center;
  background: none; border: none; color: var(--ink);
  font-size: 10px; padding: 4px 0; cursor: pointer;
  border-radius: 8px;
}
.skill-chip:active { background: var(--card2); }
.ring { position: relative; width: 34px; height: 34px; }
.ring svg { transform: rotate(-90deg); }
.ring .lvl {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
}
.skill-chip span:last-child { color: var(--muted); margin-top: 1px; }

/* ---------- tab bar ---------- */
#tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: rgba(20, 29, 24, 0.98);
  border-top: 1px solid var(--line);
  padding: 6px 2px calc(6px + env(safe-area-inset-bottom));
}
#tabbar button {
  background: none; border: none; color: var(--muted);
  font-size: 10px; padding: 4px 0;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  cursor: pointer;
}
#tabbar button .ticon { font-size: 17px; line-height: 1; }
#tabbar button.active { color: var(--green); font-weight: 700; }

/* ---------- content ---------- */
#tabcontent { padding: 12px 12px 20px; max-width: 720px; margin: 0 auto; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.card h2 { margin: 0 0 4px; font-size: 18px; }
.card h3 { margin: 12px 0 6px; font-size: 15px; color: var(--green); }
.card p.hint { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.row { display: flex; align-items: center; gap: 8px; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.btn {
  background: var(--card2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 14px;
  cursor: pointer;
}
.btn.primary { background: var(--green-dk); border-color: var(--green-dk); color: #fff; font-weight: 700; }
.btn.gold { background: #6b5426; border-color: #6b5426; color: #fff; }
.btn.danger { background: #5b2b25; border-color: #5b2b25; color: #fff; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.sm { padding: 6px 10px; font-size: 12px; }

/* plots */
.plot-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 560px) { .plot-grid { grid-template-columns: repeat(4, 1fr); } }
.plot {
  background: var(--card2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  text-align: center;
  min-height: 96px;
  display: flex; flex-direction: column; justify-content: center; gap: 6px;
}
.plot .crop-name { font-weight: 700; font-size: 14px; }
.plot .timer { font-size: 12px; color: var(--gold); }
.plot.ready { border-color: var(--green); }
.plot .ko { color: var(--muted); font-size: 12px; }

/* seed picker */
.seed-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.seed-chip {
  border: 1px solid var(--line);
  background: var(--card2);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
}
.seed-chip.sel { border-color: var(--green); background: var(--green-dk); color: #fff; }
.seed-chip .n { opacity: 0.75; font-size: 11px; }

/* lists */
.item-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 4px;
  border-bottom: 1px solid var(--line);
}
.item-row:last-child { border-bottom: none; }
.item-row .nm { font-weight: 600; font-size: 14px; }
.item-row .ko { color: var(--muted); font-size: 12px; }
.item-row .qty { margin-left: auto; color: var(--muted); font-size: 13px; }
.price { color: var(--gold); font-weight: 700; font-size: 13px; white-space: nowrap; }
.price.up::after { content: " ▲"; color: var(--green); font-size: 10px; }
.price.down::after { content: " ▼"; color: var(--red); font-size: 10px; }

/* sub-tabs (Market sections, Kitchen views) */
.subtabs { display: flex; gap: 6px; margin-bottom: 10px; }
.subtabs .btn.sm.sel { background: var(--green-dk); border-color: var(--green-dk); color: #fff; }

/* market event banner */
.event-banner {
  background: linear-gradient(135deg, #233026, #1a241d);
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 12px;
}
.event-banner .ev-name { font-weight: 800; color: var(--gold); }
.event-banner .ev-desc { font-size: 13px; color: var(--muted); margin: 4px 0; }
.event-banner .ev-meta { font-size: 12px; display: flex; gap: 12px; }
.idx-up { color: var(--green); } .idx-down { color: var(--red); }

/* bank */
.bank-bal { font-size: 28px; font-weight: 800; color: var(--gold); }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.stat { background: var(--card2); border-radius: 10px; padding: 8px 10px; }
.stat .k { font-size: 11px; color: var(--muted); }
.stat .v { font-size: 16px; font-weight: 700; }
.inline-form { display: flex; gap: 8px; margin-top: 8px; }
.inline-form input {
  flex: 1; background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; color: var(--ink); padding: 9px 12px; font-size: 14px;
}

/* quests */
.quest { padding: 10px 4px; border-bottom: 1px solid var(--line); }
.quest:last-child { border: none; }
.quest .qname { font-weight: 700; }
.quest .qdesc { font-size: 13px; color: var(--muted); }
.quest .qprog { font-size: 12px; color: var(--gold); }

/* auth pages */
.auth-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 26px 22px;
}
.game-logo { margin: 0; font-size: 24px; text-align: center; }
.tagline { text-align: center; color: var(--muted); font-size: 13px; margin: 6px 0 18px; }
.auth-card h2 { font-size: 17px; margin: 0 0 12px; }
.auth-card label { display: block; font-size: 13px; margin-bottom: 10px; color: var(--muted); }
.auth-card input {
  display: block; width: 100%; margin-top: 4px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  color: var(--ink); padding: 10px 12px; font-size: 15px;
}
.auth-card .btn { width: 100%; margin-top: 6px; }
.error {
  background: #3a1f1b; border: 1px solid var(--red); color: #f2b8ac;
  border-radius: 10px; padding: 9px 12px; font-size: 13px;
}
.switch, .lang { text-align: center; font-size: 13px; margin-top: 12px; }
.switch a, .lang a { color: var(--green); }

/* modal + toast */
#modal-root:empty { display: none; }
.modal-veil {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 18px; width: 100%; max-width: 380px;
}
.modal h3 { margin: 0 0 8px; }
#toast-root {
  position: fixed; bottom: 84px; left: 0; right: 0; z-index: 120;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  pointer-events: none;
}
.toast {
  background: #243128; border: 1px solid var(--green-dk); color: var(--ink);
  border-radius: 999px; padding: 8px 16px; font-size: 13px;
  animation: toastin 0.2s ease-out;
}
@keyframes toastin { from { transform: translateY(8px); opacity: 0; } }

.top-links { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.top-links a { color: var(--muted); font-size: 12px; text-decoration: none; }
.locked-note { font-size: 12px; color: var(--muted); font-style: italic; }
