:root {
  --bg: #0a0908;
  --bg-2: #16110d;
  --bg-3: #1e1712;
  --ember: #8a1f11;
  --ember-bright: #c9482a;
  --bone: #cbb994;
  --bone-dim: #6e6250;
  --good: #7a8f5c;
  --bad: #a33b2b;
}

* { box-sizing: border-box; }

html, body {
  min-height: 100%;
  margin: 0;
}

body {
  background: radial-gradient(ellipse at center, var(--bg-2) 0%, var(--bg) 70%);
  background-attachment: fixed;
  color: var(--bone);
  font-family: "Cinzel", serif;
  position: relative;
  min-height: 100vh;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    repeating-linear-gradient(0deg, rgba(255,255,255,0.015) 0px, transparent 1px, transparent 3px),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.01) 0px, transparent 1px, transparent 3px);
  pointer-events: none;
  z-index: 0;
}

h1, h2, h3 {
  font-family: "UnifrakturCook", serif;
  color: var(--bone);
  margin: 0;
}

a { color: var(--ember-bright); }

/* ---------- Gate (Login/Register) ---------- */

#gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
}

#gate .frame {
  position: relative;
  padding: 4rem 3.5rem;
  text-align: center;
  max-width: 420px;
  width: 100%;
}

#gate .frame::before,
#gate .frame::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 1px;
  height: 50px;
  background: linear-gradient(var(--bone-dim), transparent);
}
#gate .frame::before { top: -10px; }
#gate .frame::after { bottom: -10px; transform: translateX(-50%) rotate(180deg); }

.sigil {
  font-size: 1.4rem;
  color: var(--ember-bright);
  margin: 0.4rem 0;
  letter-spacing: 0.5em;
}

#gate h1 {
  font-size: clamp(2.8rem, 10vw, 5rem);
  letter-spacing: 0.03em;
  text-shadow: 0 0 18px rgba(201,72,42,0.55), 0 0 40px rgba(138,31,17,0.35);
}

.tagline {
  font-family: "Cinzel", serif;
  font-size: 0.7rem;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--bone-dim);
  margin: 1.2rem 0 2.2rem;
}

.gate-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin-top: 1.5rem;
}

.gate-form input {
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--bone-dim);
  color: var(--bone);
  padding: 0.7rem 0.9rem;
  font-family: "Cinzel", serif;
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  outline: none;
  border-radius: 2px;
}
.gate-form input:focus { border-color: var(--ember-bright); }
.gate-form input::placeholder { color: var(--bone-dim); }

.gate-actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

button, .btn {
  background: rgba(138,31,17,0.25);
  border: 1px solid var(--ember);
  color: var(--bone);
  padding: 0.6rem 1.1rem;
  font-family: "Cinzel", serif;
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 2px;
  transition: background 0.15s, border-color 0.15s;
}
button:hover, .btn:hover { background: rgba(201,72,42,0.35); border-color: var(--ember-bright); }
button:disabled { opacity: 0.35; cursor: not-allowed; }
button.ghost { background: transparent; border-color: var(--bone-dim); color: var(--bone-dim); }
button.ghost:hover { color: var(--bone); border-color: var(--bone); }
button.small { padding: 0.35rem 0.7rem; font-size: 0.62rem; }

.gate-switch {
  margin-top: 1.6rem;
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  color: var(--bone-dim);
  cursor: pointer;
  text-transform: uppercase;
}
.gate-switch:hover { color: var(--bone); }

.gate-error {
  color: var(--bad);
  font-size: 0.72rem;
  min-height: 1em;
  letter-spacing: 0.05em;
}

/* ---------- Game shell ---------- */

#game {
  display: none;
  position: relative;
  z-index: 1;
  max-width: 980px;
  margin: 0 auto;
  padding: 1.2rem 1rem 4rem;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--bone-dim);
  padding-bottom: 0.8rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.game-header h1 {
  font-size: 1.8rem;
  letter-spacing: 0.03em;
}

.game-header .sub {
  font-size: 0.65rem;
  color: var(--bone-dim);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.char-vitals {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.tabs {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 1.2rem;
  border-bottom: 1px solid rgba(110,98,80,0.3);
  padding-bottom: 0.6rem;
}

.tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--bone-dim);
  padding: 0.4rem 0.8rem;
}
.tab-btn.active { color: var(--ember-bright); border-color: var(--ember); background: rgba(138,31,17,0.15); }

.panel { display: none; }
.panel.active { display: block; }

.card {
  background: rgba(22,17,13,0.7);
  border: 1px solid rgba(110,98,80,0.35);
  border-radius: 3px;
  padding: 1rem 1.1rem;
  margin-bottom: 0.9rem;
}

.card h2 { font-size: 1.1rem; margin-bottom: 0.6rem; }
.card h3 { font-size: 0.9rem; color: var(--bone-dim); margin-bottom: 0.5rem; text-transform: uppercase; letter-spacing: 0.1em; font-family: "Cinzel", serif; }

.bar-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.7rem;
  margin: 0.3rem 0;
}
.bar-label { width: 4.2rem; color: var(--bone-dim); text-transform: uppercase; letter-spacing: 0.08em; }
.bar-track {
  flex: 1;
  height: 8px;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(110,98,80,0.4);
  border-radius: 2px;
  overflow: hidden;
}
.bar-fill { height: 100%; background: var(--good); transition: width 0.3s; }
.bar-fill.warn { background: #b8863c; }
.bar-fill.crit { background: var(--bad); }
.bar-val { width: 2.6rem; text-align: right; color: var(--bone-dim); }

.badge {
  display: inline-block;
  font-size: 0.6rem;
  padding: 0.15rem 0.5rem;
  border-radius: 2px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-left: 0.4rem;
}
.badge.crit { background: rgba(163,59,43,0.3); color: #e08a76; border: 1px solid var(--bad); }
.badge.info { background: rgba(110,98,80,0.2); color: var(--bone-dim); border: 1px solid var(--bone-dim); }

.pet-card, .item-row, .recipe-row, .station-row, .wound-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(110,98,80,0.15);
}
.pet-card:last-child, .item-row:last-child, .recipe-row:last-child, .station-row:last-child, .wound-row:last-child { border-bottom: none; }

.icon { font-size: 1.4rem; width: 1.8rem; text-align: center; flex-shrink: 0; }

.grow { flex: 1; min-width: 0; }
.name { font-size: 0.85rem; }
.meta { font-size: 0.65rem; color: var(--bone-dim); }

.pet-vitals { flex: 1; display: flex; flex-direction: column; gap: 0.15rem; min-width: 120px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

.row-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.sub-tabs { display: flex; gap: 0.4rem; margin-bottom: 0.7rem; }

.empty-hint { color: var(--bone-dim); font-size: 0.75rem; font-style: italic; padding: 0.5rem 0; }

.event-row { font-size: 0.72rem; padding: 0.3rem 0; border-bottom: 1px solid rgba(110,98,80,0.12); color: var(--bone-dim); }
.event-row .t { color: var(--bone); }
.event-row.success .t { color: var(--good); }
.event-row.warning .t { color: #c99a4a; }
.event-row.danger .t { color: var(--bad); }

.encounter-text { font-size: 0.9rem; line-height: 1.5; margin-bottom: 1rem; }
.encounter-options { display: flex; flex-direction: column; gap: 0.5rem; }
.encounter-options button { text-align: left; }
.combat-bar { margin: 0.8rem 0; }

.toast-stack {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.toast {
  background: var(--bg-3);
  border: 1px solid var(--ember);
  color: var(--bone);
  padding: 0.6rem 0.9rem;
  font-size: 0.75rem;
  border-radius: 2px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  animation: toast-in 0.25s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

select {
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--bone-dim);
  color: var(--bone);
  padding: 0.4rem 0.6rem;
  font-family: "Cinzel", serif;
  font-size: 0.72rem;
  border-radius: 2px;
}
