/* Husky Farm Tycoon — UI chrome. The world itself is canvas-drawn (see render.js).
   Class vocabulary used by ui.js:
   layout:  .topbar .sidebar .bottombar .toasts #modal-root
   chips:   .chip .chip-ico .chip-val .chip-label
   buttons: .btn .btn-primary .btn-ghost .btn-sm .btn-danger .btn[disabled] .tab .tab.active
   cards:   .panel .panel-head .panel-body .section .card .card.sel .card-row .muted .price .lock
   bars:    .bar .bar-fill (use --v: 0..1 and data attrs / inline width)
   misc:    .row .col .spacer .tag .badge .stat .statline .help
*/

:root {
  --ink: #0c1626;
  --ink-2: #122036;
  --panel: rgba(16, 27, 46, 0.92);
  --panel-2: rgba(23, 38, 64, 0.92);
  --line: rgba(125, 170, 230, 0.18);
  --text: #eaf2ff;
  --text-dim: #9fb3d4;
  --brand: #5cc6ff;       /* ice blue */
  --brand-2: #2b8fd6;
  --gold: #ffcf5c;        /* coins / money */
  --good: #6ee7a8;
  --warn: #ffd166;
  --bad: #ff6b6b;
  --rad: 12px;
  --rad-sm: 8px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.38);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 50% -10%, #16335e 0%, #0a1730 55%, #060e1f 100%);
  overflow: hidden;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ---- stage / canvas ---- */
#stage {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 64px 360px 76px 16px;   /* leave room for topbar / sidebar / bottombar */
}
#game {
  image-rendering: -webkit-optimize-contrast;
  max-width: 100%; max-height: 100%;
  border-radius: 14px;
  box-shadow: var(--shadow), 0 0 0 1px rgba(120, 170, 240, 0.12) inset;
  background: #cfe5f5;
}

/* ---- top bar ---- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 56px; z-index: 30;
  display: flex; align-items: center; gap: 8px; padding: 0 12px;
  background: var(--panel); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar .title { font-weight: 800; letter-spacing: 0.2px; margin-right: 6px; white-space: nowrap; }
.topbar .title .pawn { color: var(--brand); }
.spacer { flex: 1 1 auto; }

.chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--panel-2); border: 1px solid var(--line);
  padding: 6px 10px; border-radius: 999px; font-size: 13px; line-height: 1;
}
.chip-ico { font-size: 15px; }
.chip-val { font-weight: 700; }
.chip-label { color: var(--text-dim); font-size: 11px; }
.chip.money .chip-val { color: var(--gold); }

/* ---- buttons ---- */
.btn {
  font: inherit; color: var(--text); cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line);
  padding: 8px 14px; border-radius: var(--rad-sm); font-weight: 600;
  transition: transform .06s ease, background .12s ease, border-color .12s ease, opacity .12s;
}
.btn:hover { background: #1c3052; border-color: rgba(125,170,230,.36); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(180deg, var(--brand), var(--brand-2)); border-color: transparent; color: #06243b; font-weight: 800; }
.btn-primary:hover { filter: brightness(1.06); background: linear-gradient(180deg, var(--brand), var(--brand-2)); }
.btn-ghost { background: transparent; }
.btn-danger { color: #ffd9d9; border-color: rgba(255,107,107,.45); }
.btn-danger:hover { background: rgba(255,107,107,.16); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn[disabled], .btn.disabled { opacity: .4; cursor: not-allowed; transform: none; }

.icon-btn { width: 34px; height: 34px; display: inline-grid; place-items: center; padding: 0; border-radius: 9px; }

/* ---- bottom tabs ---- */
.bottombar {
  position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 30;
  display: flex; gap: 6px; padding: 6px; border-radius: 14px;
  background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.tab {
  font: inherit; color: var(--text-dim); cursor: pointer; background: transparent; border: 0;
  padding: 9px 16px; border-radius: 10px; font-weight: 700; display: flex; align-items: center; gap: 7px;
}
.tab .ico { font-size: 16px; }
.tab:hover { color: var(--text); background: var(--panel-2); }
.tab.active { color: #06243b; background: var(--brand); }

/* ---- sidebar panel ---- */
.sidebar {
  position: fixed; top: 64px; right: 12px; bottom: 76px; width: 336px; z-index: 25;
  display: flex; flex-direction: column;
}
.panel {
  display: flex; flex-direction: column; height: 100%;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--rad);
  box-shadow: var(--shadow); overflow: hidden;
}
.panel-head { padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.panel-head h2 { margin: 0; font-size: 15px; }
.panel-head .sub { color: var(--text-dim); font-size: 12px; }
.panel-body { padding: 10px 12px; overflow-y: auto; overflow-x: hidden; flex: 1 1 auto; }
.panel-body::-webkit-scrollbar { width: 9px; }
.panel-body::-webkit-scrollbar-thumb { background: rgba(125,170,230,.25); border-radius: 9px; }

.section { margin: 6px 0 14px; }
.section > .section-title { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--text-dim); margin: 0 0 7px; }

/* ---- cards (buildings, dogs, missions, breeds) ---- */
.card {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--rad-sm);
  padding: 10px; margin-bottom: 8px; cursor: pointer; transition: border-color .12s, background .12s, transform .06s;
}
.card:hover { border-color: rgba(125,170,230,.4); background: #1a2c4c; }
.card.sel { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand) inset; }
.card.locked { opacity: .55; cursor: not-allowed; }
.card-row { display: flex; align-items: center; gap: 10px; }
.card .name { font-weight: 700; }
.card .desc, .muted { color: var(--text-dim); font-size: 12px; }
.card .swatch { width: 30px; height: 30px; border-radius: 8px; flex: 0 0 auto; display: grid; place-items: center; font-size: 18px; background: #0e1c33; }
.price { color: var(--gold); font-weight: 800; }
.price.cant { color: var(--bad); }
.lock { color: var(--warn); font-size: 12px; }

.row { display: flex; align-items: center; gap: 8px; }
.col { display: flex; flex-direction: column; gap: 6px; }
.tag { font-size: 11px; padding: 2px 7px; border-radius: 999px; background: #0e1c33; color: var(--text-dim); border: 1px solid var(--line); }
.badge { font-size: 10px; font-weight: 800; padding: 2px 6px; border-radius: 6px; background: var(--brand); color: #06243b; }

/* ---- stat bars ---- */
.statline { display: grid; grid-template-columns: 64px 1fr 30px; gap: 6px; align-items: center; font-size: 11px; margin: 3px 0; }
.statline .lbl { color: var(--text-dim); }
.statline .num { text-align: right; font-variant-numeric: tabular-nums; }
.bar { height: 7px; border-radius: 999px; background: #0c1a30; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand-2), var(--brand)); width: 0%; transition: width .25s ease; }
.bar-fill.hunger { background: linear-gradient(90deg, #d98a3a, var(--warn)); }
.bar-fill.energy { background: linear-gradient(90deg, #3aa0d9, #7fe0ff); }
.bar-fill.happy  { background: linear-gradient(90deg, #34a76a, var(--good)); }
.bar-fill.prog   { background: linear-gradient(90deg, #8a6cff, #c0b0ff); }

/* ---- toasts ---- */
.toasts { position: fixed; top: 64px; right: 360px; z-index: 40; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast {
  background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--brand);
  padding: 9px 13px; border-radius: 10px; box-shadow: var(--shadow); font-size: 13px; max-width: 320px;
  animation: toastIn .25s ease;
}
.toast.good { border-left-color: var(--good); }
.toast.warn { border-left-color: var(--warn); }
.toast.bad  { border-left-color: var(--bad); }
@keyframes toastIn { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }

/* ---- modal ---- */
#modal-root:empty { display: none; }
.modal-scrim { position: fixed; inset: 0; z-index: 50; background: rgba(4,9,18,.6); display: grid; place-items: center; padding: 20px; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); max-width: 440px; width: 100%; overflow: hidden; }
.modal-head { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.modal-body { padding: 16px; }
.modal-foot { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
.input { font: inherit; color: var(--text); background: #0c1a30; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }

/* ---- start screen + boot ---- */
.start { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: radial-gradient(900px 600px at 50% 30%, #14315c, #060e1f); }
.start.gone { display: none; }
.start-card { text-align: center; padding: 34px 40px; }
.start-emoji { font-size: 56px; }
.start-card h1 { font-size: 40px; margin: 8px 0 4px; letter-spacing: .5px; }
.start-tag { color: var(--text-dim); margin: 0 0 22px; font-size: 16px; }
.start-buttons { display: flex; gap: 12px; justify-content: center; }
.start-buttons .btn { padding: 12px 26px; font-size: 16px; }
.start-hint { color: var(--text-dim); font-size: 12px; margin-top: 22px; }

.boot { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; background: #060e1f; transition: opacity .4s; }
.boot.gone { opacity: 0; pointer-events: none; }
.boot-dog { font-size: 52px; animation: bob 1.1s ease-in-out infinite; }
.boot-text { color: var(--text-dim); margin-top: 10px; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

.help { color: var(--text-dim); font-size: 12px; line-height: 1.5; }
.empty { color: var(--text-dim); text-align: center; padding: 28px 10px; font-size: 13px; }

/* ---- responsive: narrower screens drop the sidebar under a toggle handled by ui.js ---- */
@media (max-width: 920px) {
  #stage { padding: 60px 12px 150px; }
  .sidebar { top: auto; bottom: 70px; right: 8px; left: 8px; width: auto; height: 44vh; }
  .toasts { right: 12px; }
}
