:root {
  --bg: #0e0d10;
  --bg-card: #1a181d;
  --bg-card-2: #221f26;
  --border: #322d36;
  --text: #ece7e0;
  --text-dim: #a89f9f;
  --gold: #d4a942;
  --red: #b1332b;
  --green: #4c8c4a;
  --blue: #3f6fa8;
  --purple: #7a4fa0;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  overscroll-behavior-y: contain;
}
.hidden { display: none !important; }
button { font-family: inherit; }
input { font-family: inherit; }

/* ---------- Auth screen ---------- */
.screen { min-height: 100%; }
.auth-wrap {
  max-width: 420px; margin: 0 auto; padding: 48px 20px 20px;
  display: flex; flex-direction: column; align-items: stretch;
}
.logo {
  text-align: center; font-size: 26px; letter-spacing: 1px; margin-bottom: 24px; color: var(--gold);
}
.logo span { display: block; font-size: 14px; color: var(--text-dim); letter-spacing: 4px; }
.auth-tabs { display: flex; margin-bottom: 16px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.auth-tab {
  flex: 1; padding: 12px; background: var(--bg-card); color: var(--text-dim); border: none; font-size: 15px;
}
.auth-tab.active { background: var(--gold); color: #16130c; font-weight: 600; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form input {
  padding: 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-card);
  color: var(--text); font-size: 16px;
}
.auth-error { color: var(--red); min-height: 18px; font-size: 14px; margin: 0; }
.auth-hint { color: var(--text-dim); font-size: 13px; text-align: center; margin-top: 20px; line-height: 1.5; }

.btn {
  padding: 14px; border-radius: 10px; border: none; font-size: 16px; font-weight: 600; cursor: pointer;
}
.btn-primary { background: var(--gold); color: #16130c; }
.btn-secondary { background: var(--bg-card-2); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--red); color: white; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; }

/* ---------- Game shell ---------- */
#game-shell { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
#topbar { background: var(--bg-card); border-bottom: 1px solid var(--border); padding: 8px 12px; flex-shrink: 0; }
.topbar-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.player-id strong { font-size: 16px; }
.player-id span { display: block; font-size: 12px; color: var(--gold); }
.player-money { text-align: right; font-size: 13px; }
.bars { display: flex; flex-direction: column; gap: 3px; }
.bar-row { display: flex; align-items: center; gap: 6px; font-size: 11px; }
.bar-label { width: 16px; text-align: center; }
.bar { flex: 1; height: 8px; background: #000; border-radius: 4px; overflow: hidden; border: 1px solid var(--border); }
.bar-fill { height: 100%; width: 0%; transition: width .3s; }
.bar-fill.health { background: var(--red); }
.bar-fill.energy { background: #e0b23a; }
.bar-fill.nerve { background: var(--purple); }
.bar-fill.happy { background: var(--green); }
.bar-fill.xp { background: var(--blue); }
.bar-text { width: 68px; text-align: right; color: var(--text-dim); flex-shrink: 0; }
.status-banner {
  margin-top: 6px; padding: 6px 10px; border-radius: 8px; background: var(--red); color: #fff;
  font-size: 12px; text-align: center;
}

#content { flex: 1; overflow-y: auto; padding: 12px; padding-bottom: 24px; }

#bottomnav {
  display: flex; overflow-x: auto; background: var(--bg-card); border-top: 1px solid var(--border);
  flex-shrink: 0; padding: 4px 0; scrollbar-width: none;
}
#bottomnav::-webkit-scrollbar { display: none; }
.nav-btn {
  flex: 0 0 auto; min-width: 64px; background: none; border: none; color: var(--text-dim);
  font-size: 10px; padding: 8px 6px; display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.nav-btn span { font-size: 18px; }
.nav-btn.active { color: var(--gold); }

/* ---------- Cards / lists ---------- */
.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px; margin-bottom: 10px;
}
.card h2 { margin: 0 0 10px; font-size: 16px; color: var(--gold); }
.card h3 { margin: 0 0 6px; font-size: 14px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.row + .row { margin-top: 8px; }
.list-item {
  display: flex; justify-content: space-between; align-items: center; padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.muted { color: var(--text-dim); font-size: 12px; }
.pill {
  display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; background: var(--bg-card-2);
  border: 1px solid var(--border);
}
.pill.locked { color: var(--red); }
.pill.ok { color: var(--green); }
.section-title { font-size: 13px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; margin: 16px 0 6px; }
.section-title:first-child { margin-top: 0; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.small-input {
  padding: 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-card-2);
  color: var(--text); font-size: 15px; width: 100%;
}

/* Chat */
#chat-log { display: flex; flex-direction: column; gap: 6px; height: 50vh; overflow-y: auto; margin-bottom: 10px; }
.chat-msg { font-size: 13px; }
.chat-msg .who { color: var(--gold); font-weight: 600; }
.chat-input-row { display: flex; gap: 8px; }
.chat-input-row input { flex: 1; }

/* Toasts */
#toast-container { position: fixed; top: 10px; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; z-index: 999; pointer-events: none; }
.toast {
  background: var(--bg-card-2); border: 1px solid var(--gold); color: var(--text); padding: 10px 16px;
  border-radius: 10px; font-size: 13px; max-width: 90%; box-shadow: 0 4px 12px rgba(0,0,0,.4);
}
.toast.error { border-color: var(--red); }

@media (min-width: 700px) {
  #content { max-width: 640px; margin: 0 auto; width: 100%; }
  .topbar-row, .bars { max-width: 640px; margin: 0 auto; }
}
