/* =========================================================================
 * I Wanna Ascend — UI theme (jade / ink cultivation)
 * ========================================================================= */
:root {
  --bg: #0f1714;
  --bg-2: #14201b;
  --panel: #1b2a23;
  --panel-2: #22362c;
  --line: #2f4739;
  --ink: #e8f3ec;
  --ink-dim: #9fb6a8;
  --jade: #3fd29b;
  --jade-2: #2bbd88;
  --gold: #e8c468;
  --red: #ff6b6b;
  --blue: #6bb6ff;
  --shadow: 0 6px 18px rgba(0,0,0,.35);
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }
html { touch-action: manipulation; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #1c2e25 0%, var(--bg) 60%);
  color: var(--ink);
  min-height: 100vh;
  min-height: 100dvh;
  overscroll-behavior-y: none;
}

#app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 14px 96px;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px; box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { font-size: 28px; color: var(--jade); }
.brand-text strong { display: block; font-size: 17px; letter-spacing: .3px; }
.brand-text small { color: var(--ink-dim); font-size: 11px; }
.stats { display: flex; gap: 14px; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; min-width: 72px; }
.stat-label { font-size: 10px; color: var(--ink-dim); text-transform: uppercase; letter-spacing: .5px; }
.stat-val { font-size: 15px; font-weight: 700; }
.stat.currency .stat-val { color: var(--jade); }
.stat.currency.jade .stat-val { color: var(--gold); }

/* ---------- stamina ---------- */
.stamina-wrap { margin: 12px 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }
.stamina-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-dim); margin-bottom: 6px; }
.stamina-track { height: 14px; background: #0c1410; border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.stamina-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--jade-2), var(--jade)); transition: width .25s ease; }

/* ---------- content / panels ---------- */
.content { margin-top: 6px; }
.panel {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px;
}
.panel h2 { margin: 0 0 4px; font-size: 18px; }
.panel .sub { color: var(--ink-dim); font-size: 12px; margin-bottom: 12px; }
.grid { display: grid; gap: 12px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
/* phone (narrow): collapse dense grids to one column */
@media (max-width: 479px) {
  .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; }
}
/* tablet / large-phone landscape: 2-up for the 3-col grids */
@media (min-width: 480px) and (max-width: 899px) {
  .grid.cols-3 { grid-template-columns: repeat(2, 1fr); }
}
/* desktop: full 3-up */
@media (min-width: 900px) {
  .grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- buttons ---------- */
button { font-family: inherit; cursor: pointer; }
.btn {
  border: 1px solid var(--jade-2); background: linear-gradient(180deg, var(--jade), var(--jade-2));
  color: #08130d; font-weight: 700; border-radius: 12px; padding: 12px 16px; font-size: 15px;
  box-shadow: 0 4px 12px rgba(63,210,155,.25); transition: transform .08s ease, filter .15s ease;
}
.btn:active { transform: scale(.97); }
.btn:disabled { filter: grayscale(.7) brightness(.7); cursor: not-allowed; box-shadow: none; }
.btn.ghost { background: transparent; color: var(--jade); }
.btn.gold { border-color: var(--gold); background: linear-gradient(180deg, #f2d589, var(--gold)); color: #2a2207; box-shadow: 0 4px 12px rgba(232,196,104,.25); }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn.danger { border-color: var(--red); background: transparent; color: var(--red); }

/* big meditate button */
.meditate-btn {
  width: 100%; padding: 26px; font-size: 22px; border-radius: 18px;
  background: radial-gradient(circle at 50% 30%, #47e0a6, #1f9c6e);
  color: #06140d; font-weight: 800; letter-spacing: .5px;
  border: 2px solid #7df0c2; box-shadow: 0 8px 26px rgba(63,210,155,.35);
}
.meditate-btn:active { transform: scale(.98); }

.muted { color: var(--ink-dim); }
.pill-tag { display: inline-block; font-size: 10px; padding: 2px 8px; border-radius: 99px; background: #0d1712; border: 1px solid var(--line); color: var(--ink-dim); margin-left: 6px; }
.tag-bound { color: var(--red); border-color: #5a2b2b; }
.tag-tradable { color: var(--jade); }

/* progress / bars */
.bar { height: 10px; background: #0c1410; border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), #f6e3a0); }

/* lists / cards */
.card {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
}
.card h3 { margin: 0 0 6px; font-size: 15px; }
.card .row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card .meta { font-size: 12px; color: var(--ink-dim); }
.card .actions { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.locked { opacity: .55; }
.locked .card { border-style: dashed; }

/* inventory grid */
.inv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.inv-cell { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px; text-align: center; }
.inv-cell .ic { font-size: 26px; }
.inv-cell .nm { font-size: 12px; margin-top: 4px; }
.inv-cell .ct { font-size: 12px; color: var(--jade); font-weight: 700; }

/* market */
.listing { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.listing:last-child { border-bottom: none; }
.price-ss { color: var(--jade); font-weight: 700; }
.price-jade { color: var(--gold); font-weight: 700; }

/* settings */
.kv { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.kv:last-child { border-bottom: none; }

/* ---------- phone (<600px) top bar + touch tuning ---------- */
@media (max-width: 599px) {
  #app { padding: 10px 10px 92px; }
  .topbar { padding: 10px 12px; gap: 8px; }
  .brand { flex: 1 1 auto; }
  .brand-text small { display: none; }
  .brand-mark { font-size: 24px; }
  .brand-text strong { font-size: 15px; }
  .stats { flex: 1 1 100%; order: 3; justify-content: space-between; gap: 4px; }
  .stat { min-width: 0; flex: 1; align-items: center; }
  .stat-label { font-size: 9px; letter-spacing: .3px; }
  .stat-val { font-size: 14px; }
  /* cards: full-width touch-friendly action buttons */
  .card .actions { gap: 8px; }
  .card .actions .btn { flex: 1 1 auto; }
  .meditate-btn { padding: 22px; font-size: 19px; }
  .btn { padding: 13px 16px; }
  .nav-btn { padding: 8px 2px; }
}
/* very small phones */
@media (max-width: 359px) {
  .stat-label { font-size: 8px; }
  .stat-val { font-size: 12px; }
  .meditate-btn { font-size: 17px; padding: 20px; }
}

/* ---------- nav ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around; gap: 2px;
  background: linear-gradient(180deg, #16241d, #0e1713);
  border-top: 1px solid var(--line); padding: 6px 4px calc(env(safe-area-inset-bottom, 0px));
}
.nav-btn {
  flex: 1; background: transparent; border: none; color: var(--ink-dim);
  font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 2px; border-radius: 10px;
}
.nav-btn span { font-size: 18px; }
.nav-btn.active { color: var(--jade); background: #0f1b15; }

/* tablet (600–899): floating pill bar, roomier touch targets */
@media (min-width: 600px) and (max-width: 899px) {
  #app { padding: 14px 18px 104px; max-width: 820px; }
  .nav {
    left: 50%; right: auto; transform: translateX(-50%);
    bottom: calc(12px + env(safe-area-inset-bottom, 0px)); width: min(620px, calc(100vw - 28px));
    border: 1px solid var(--line); border-radius: 18px;
    box-shadow: var(--shadow); padding: 6px 8px; gap: 4px;
  }
  .nav-btn { font-size: 12px; min-height: 52px; }
  .nav-btn span { font-size: 20px; }
}

/* desktop / web (>=900): left side rail */
@media (min-width: 900px) {
  #app { padding: 22px 26px 26px 212px; max-width: 1240px; }
  .nav {
    position: fixed; left: 18px; top: 18px; bottom: 18px; width: 176px;
    flex-direction: column; justify-content: flex-start; gap: 6px;
    background: linear-gradient(180deg, var(--panel), var(--bg-2));
    border: 1px solid var(--line); border-radius: var(--radius); padding: 12px;
    box-shadow: var(--shadow);
  }
  .nav-btn { flex: none; flex-direction: row; justify-content: flex-start; gap: 12px; font-size: 14px; padding: 13px 14px; min-height: auto; }
  .nav-btn span { font-size: 18px; }
  .meditate-btn { max-width: 520px; margin: 0 auto; display: block; }
  .panel { padding: 20px; }
  .toast { bottom: 24px; }
}

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 84px;
  transform: translateX(-50%) translateY(20px);
  background: #0c1712; border: 1px solid var(--jade-2); color: var(--ink);
  padding: 10px 16px; border-radius: 12px; font-size: 13px; opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease; z-index: 50; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: var(--red); color: #ffd9d9; }

/* utility */
.hidden { display: none !important; }
.flx { display: flex; gap: 10px; align-items: center; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.mt { margin-top: 12px; }
