/* Gothicscape — "Ember" theme: dense game HUD, near-black with an ember accent */

:root {
  --bg: #0f1012;
  --bg-rail: #15171a;
  --bg-top: #121417;
  --surface: #17191c;
  --surface-2: #141619;
  --surface-3: #1f2226;
  --line: #262a2f;
  --line-2: #2f3338;
  --line-soft: #1f2226;
  --track: #24272b;

  --text: #e7e3db;
  --text-strong: #f4efe6;
  --text-2: #b9b5ad;
  --text-3: #a29e96;
  --text-4: #8e8a82;
  --text-off: #6f6c66;
  --text-dead: #55524d;

  --ember: #e8793a;
  --ember-soft: #f0935a;
  --ember-light: #ffb489;
  --ember-ink: #1a0f08;
  --ember-bg: #24190f;
  --ember-bg-2: #2a1f14;
  --ember-line: #6b3a1f;
  --gold: #e8b33a;
  --good: #7fb08a;
  --bad: #e5645a;

  --font-display: "Grenze Gotisch", Georgia, serif;
  --font-ui: "Barlow Semi Condensed", "Segoe UI", system-ui, sans-serif;
  --radius: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  min-height: 100vh;
}

button { font-family: inherit; }

button:focus-visible {
  outline: 2px solid var(--ember-soft);
  outline-offset: 2px;
}

.ico {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.muted { color: var(--text-3); }
.faint { color: var(--text-off); }
.good { color: var(--good); }
.bad { color: var(--bad); }
.small { font-size: 14px; }

.eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-4);
}

.eyebrow--ember { color: var(--ember-soft); letter-spacing: 2px; }

.split {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

/* ---------- App shell ---------- */

.app {
  display: flex;
  min-height: 100vh;
}

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  width: 80px;
  flex-shrink: 0;
  background: var(--bg-rail);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  gap: 8px;
  z-index: 30;
}

.rail-brand {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 700;
  color: var(--ember);
  line-height: 1;
  margin-bottom: 18px;
}

.rail-btn {
  position: relative;
  width: 64px;
  height: 60px;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--text-3);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.rail-btn .ico { width: 22px; height: 22px; }
.rail-btn:hover { color: var(--text); background: #1c1e21; }
.rail-btn.active { background: #22201d; color: var(--ember-soft); }

.rail-badge {
  position: absolute;
  top: 6px;
  right: 8px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--ember);
  color: var(--ember-ink);
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
}

.rail-menu {
  position: relative;
  margin-top: auto;
}

.rail-icon {
  width: 44px;
  height: 44px;
  background: transparent;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.rail-icon:hover, .rail-icon[aria-expanded="true"] { color: var(--text); border-color: var(--text-off); }

.file-menu {
  position: absolute;
  left: 56px;
  bottom: 0;
  min-width: 190px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
}

.file-menu button {
  height: 40px;
  padding: 0 12px;
  background: transparent;
  border: 0;
  border-radius: 7px;
  color: var(--text);
  font-size: 15px;
  text-align: left;
  cursor: pointer;
}

.file-menu button:hover { background: var(--surface-3); }

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 60px;
  padding: 0 24px;
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 16px;
  background: var(--bg-top);
  border-bottom: 1px solid var(--line);
}

.tabs {
  display: flex;
  align-items: stretch;
  gap: 4px;
}

.tab {
  padding: 0 18px;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--text-3);
  font-size: 17px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tab:hover { color: var(--text); }

.tab.active {
  color: var(--text-strong);
  font-weight: 600;
  border-bottom-color: var(--ember);
}

.tab-badge {
  font-size: 13px;
  padding: 2px 7px;
  border-radius: 5px;
  background: #23262a;
  color: var(--text-2);
}

.tab.active .tab-badge { background: #3a2416; color: var(--ember-soft); }

.page-title {
  display: flex;
  align-items: center;
  font-family: var(--font-display);
  font-size: 28px;
  color: var(--text-strong);
}

.resources {
  display: flex;
  align-items: center;
  gap: 22px;
  font-size: 15px;
  color: var(--text-3);
  white-space: nowrap;
}

.res { display: flex; align-items: center; gap: 6px; }
.res strong { color: var(--text-strong); font-weight: 600; }
.ico--coin { width: 15px; height: 15px; stroke: var(--gold); stroke-width: 2; }
#topFoodWrap.starving strong { color: var(--bad); }

.saved {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--good);
  font-size: 13px;
}

.saved .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--good);
}

/* ---------- Activity bar ---------- */

.activity-bar {
  position: sticky;
  top: 61px;
  z-index: 15;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 24px;
  min-height: 44px;
  padding: 6px 24px;
  background: #111315;
  border-bottom: 1px solid var(--line);
}

.activity-idle {
  font-size: 14px;
  color: var(--text-4);
}

.activity-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 280px;
  max-width: 520px;
  padding: 4px 0;
  background: transparent;
  border: none;
  color: var(--text-2);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.activity-row .ico { width: 16px; height: 16px; color: var(--ember-soft); }
.activity-row:hover .activity-name { color: var(--text-strong); }
.activity-name { white-space: nowrap; }
.activity-time { width: 40px; text-align: right; color: var(--text-strong); }

/* ---------- Content & layout ---------- */

.content {
  padding: 20px 24px 32px;
}

.panel { display: none; }
.panel.active { display: block; }

.page-cols {
  display: flex;
  gap: 18px;
  align-items: flex-start;
}

.page-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.page-side {
  width: 288px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
}

.section-label { margin: 22px 0 10px; }
.section-label:first-child { margin-top: 0; }

/* ---------- Skill hero ---------- */

.hero-row {
  display: flex;
  gap: 18px;
}

.now-card {
  flex: 1;
  min-width: 0;
  min-height: 164px;
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
}

.now-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.now-titles { display: flex; flex-direction: column; gap: 4px; min-width: 0; }

.now-name {
  font-family: var(--font-display);
  font-size: 44px;
  font-weight: 500;
  line-height: 1;
  color: var(--text-strong);
}

.now-card.is-idle .now-name { color: var(--text-off); font-size: 34px; }
.now-card.is-idle .eyebrow--ember { color: var(--text-4); }

.now-foot { display: flex; flex-direction: column; gap: 8px; }

.now-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 22px;
  font-size: 15px;
  color: var(--text-3);
}

.now-stats strong { color: var(--text-strong); font-weight: 600; }

.level-card {
  width: 250px;
  flex-shrink: 0;
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.ring { width: 96px; height: 96px; flex-shrink: 0; }
.ring-track { fill: none; stroke: var(--track); stroke-width: 8; }
.ring-fill {
  fill: none;
  stroke: var(--ember);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 0 263.9;
  transition: stroke-dasharray 0.3s ease;
}
.ring-text { font-family: var(--font-ui); font-size: 28px; font-weight: 700; fill: var(--text-strong); }

.level-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.level-xp { font-size: 20px; font-weight: 600; }
.level-info .muted { font-size: 14px; }

/* ---------- Bars ---------- */

.bar {
  display: block;
  height: 6px;
  background: var(--track);
  border-radius: 3px;
  overflow: hidden;
}

.bar-fill {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--ember);
  border-radius: inherit;
  transition: width 0.1s linear;
}

.bar-fill--good { background: var(--good); }
.bar-fill--bad { background: var(--bad); }
.bar-fill--neutral { background: var(--text-2); }

.bar--lg { height: 14px; border-radius: 7px; }
.bar--mini { flex: 1; min-width: 80px; height: 8px; border-radius: 4px; }

/* ---------- Buttons ---------- */

.btn {
  height: 44px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.btn--primary {
  background: var(--ember);
  border: 0;
  color: var(--ember-ink);
  font-weight: 700;
}

.btn--primary:hover:not(:disabled) { background: #f28a4d; }

.btn--ghost {
  height: 40px;
  padding: 0 16px;
  background: transparent;
  border: 1px solid var(--ember-line);
  color: var(--ember-light);
  font-size: 15px;
}

.btn--ghost:hover:not(:disabled) { background: var(--ember-bg); border-color: var(--ember); }

.btn--stop {
  background: #2a1c14;
  border: 1px solid var(--ember-line);
  color: var(--ember-light);
}

.btn--stop:hover { background: #3a2518; }

.btn:disabled {
  background: transparent;
  border: 1px solid var(--line-2);
  color: var(--text-dead);
  cursor: not-allowed;
}

.btn-sm {
  height: 32px;
  width: 88px;
  padding: 0;
  border-radius: 8px;
  font-size: 14px;
  justify-self: end;
}

.link-btn {
  padding: 0;
  background: none;
  border: 0;
  color: var(--ember-soft);
  font-size: 14px;
  cursor: pointer;
  text-align: left;
}

.link-btn:hover:not(:disabled) { color: var(--ember-light); text-decoration: underline; }
.link-btn:disabled { color: var(--text-dead); cursor: not-allowed; }

.btn-pair { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.end { justify-self: end; }

/* ---------- Tables (grid rows) ---------- */

.table {
  background: var(--surface-2);
  border-color: var(--line);
  overflow: hidden;
}

.trow {
  display: grid;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  font-size: 16px;
  border-bottom: 1px solid var(--line-soft);
}

.trow:last-child { border-bottom: 0; }
#wcRows .trow:last-child, #flRows .trow:last-child, #axeRows .trow:last-child, #knifeRows .trow:last-child,
#shopRows .trow:last-child, #shopBowRows .trow:last-child { border-bottom: 0; }

.trow--head {
  min-height: 38px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-4);
  border-bottom: 1px solid var(--line);
}

.trow--wc   { grid-template-columns: minmax(110px, 2fr) repeat(6, minmax(44px, 0.85fr)) 96px; }
.trow--fl   { grid-template-columns: minmax(120px, 2fr) 0.6fr minmax(140px, 1.8fr) 0.7fr 0.7fr 0.7fr 0.7fr 0.7fr 96px; }
.trow--axe  { grid-template-columns: minmax(140px, 2fr) 1fr 1fr 120px; }
.trow--shop { grid-template-columns: minmax(120px, 2fr) 1fr 1fr 1fr 120px; }
.trow--bld  { grid-template-columns: minmax(170px, 1.6fr) 0.7fr minmax(140px, 1.3fr) minmax(160px, 1.8fr) minmax(150px, 1.6fr); }
.trow--tall { min-height: 76px; padding-top: 10px; padding-bottom: 10px; }

.trow .cell-name { font-weight: 600; color: var(--text-strong); display: flex; align-items: center; gap: 8px; }
.trow .cell-dim { color: var(--text-2); }

.trow.is-active { background: var(--ember-bg); }
.trow.is-active .cell-name { color: var(--ember-light); }
.trow.is-active .cell-name::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ember);
}

.trow.is-locked { color: var(--text-off); }
.trow.is-locked .cell-name { color: var(--text-off); font-weight: 500; }
.trow.is-locked .cell-dim { color: var(--text-off); }
.trow.is-locked .cell-req { color: #c98a62; }

.trow.is-short .cell-need { color: var(--bad); }

.lock-tag {
  justify-self: end;
  width: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text-off);
}

.lock-tag .ico { width: 13px; height: 13px; stroke-width: 2; }

.tag {
  justify-self: end;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 6px;
}

.tag--on { background: #3a2416; color: var(--ember-soft); }
.tag--own { color: var(--text-4); }

/* Buildings */

.bld-name {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 18px;
  font-weight: 600;
}

.bld-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ember-soft);
}

.bld-level { font-size: 18px; }

.stepper { display: flex; align-items: center; gap: 8px; }

.step {
  width: 34px;
  height: 34px;
  background: var(--surface-3);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
}

.step:hover:not(:disabled) { border-color: var(--ember-line); color: var(--ember-light); }
.step:disabled { background: transparent; border-color: #23262a; color: var(--text-dead); cursor: not-allowed; }
.step-val { width: 48px; text-align: center; font-size: 17px; }

.output {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 16px;
  font-size: 15px;
}

.output .warn { color: var(--ember-light); }

/* ---------- Side cards ---------- */

.side-card {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.side-card .split { font-size: 16px; }
.side-title { font-size: 20px; font-weight: 600; }

.pips { display: flex; gap: 4px; }
.pip { flex: 1; height: 6px; border-radius: 3px; background: var(--line-2); }
.pip.on { background: var(--ember); }

.idle-row {
  padding: 6px 10px;
  margin: 0 -10px;
  border-radius: 8px;
}

.idle-row.has-idle { background: var(--ember-bg-2); color: #f0b98f; }
.idle-row.has-idle strong { color: var(--ember-light); }

.hint { margin: 2px 0 0; font-size: 14px; color: var(--text-4); }

.mat-list { display: flex; flex-direction: column; gap: 10px; }
.mat-list:empty { display: none; }

.recent-list { display: flex; flex-direction: column; gap: 8px; font-size: 15px; }
.recent-item { display: flex; justify-content: space-between; gap: 12px; }
.recent-item .when { color: var(--text-4); }
.recent-item.hl .what { color: var(--ember-light); font-weight: 600; }
.recent-empty { color: var(--text-4); font-size: 14px; }

/* ---------- Tiles ---------- */

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
}

.tile-grid--wide { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.tile-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.tile-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 18px; }

.tile {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tile.is-empty { opacity: 0.55; }

.tile-big {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text-strong);
}

.tile-big small { font-size: 17px; font-weight: 500; color: var(--text-4); }

.tile-val { font-size: 24px; font-weight: 700; color: var(--text-strong); }

.tile--warn { background: var(--ember-bg); border-color: var(--ember-line); }
.tile--warn .eyebrow { color: var(--ember-soft); }
.tile--warn .tile-big { color: var(--ember-light); }
.tile--warn .tile-big small { color: #d9a07c; }

.tile--bad { background: #251314; border-color: #6b2a26; }

/* ---------- Shop ---------- */

.shop-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  font-size: 15px;
}

.segmented {
  display: flex;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
}

.segmented button {
  min-width: 56px;
  height: 36px;
  padding: 0 14px;
  background: transparent;
  border: 0;
  border-radius: 7px;
  color: var(--text-3);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--ember); color: var(--ember-ink); }

/* ---------- Offline summary dialog ---------- */

.modal {
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 24px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
}

.modal[open] { display: flex; flex-direction: column; gap: 12px; }
.modal::backdrop { background: rgba(5, 6, 7, 0.72); }

.modal-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 40px;
  font-weight: 500;
  line-height: 1;
  color: var(--text-strong);
}

.modal-note { margin: 0; font-size: 15px; color: var(--text-3); }

.offline-list {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line);
  overflow-y: auto;
}

.offline-item {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 0;
  font-size: 16px;
  border-bottom: 1px solid var(--line-soft);
}

.offline-item .gain { color: var(--good); font-weight: 600; }
.offline-item .loss { color: var(--bad); font-weight: 600; }
.offline-item.hl { color: var(--ember-light); font-weight: 600; }

.offline-warnings { display: flex; flex-direction: column; gap: 6px; }
.offline-warnings:empty { display: none; }

.offline-warn {
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--ember-bg-2);
  color: #f0b98f;
  font-size: 15px;
}

.modal form { margin: 4px 0 0; }
.modal-btn { width: 100%; }

/* ---------- Responsive ---------- */

@media (max-width: 1100px) {
  .page-cols { flex-direction: column; align-items: stretch; }
  .page-side { width: auto; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
  .tile-grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .resources { gap: 14px; }
}

@media (max-width: 900px) {
  .trow--bld { grid-template-columns: 1fr 1fr; row-gap: 10px; }
  .trow--bld.trow--head { display: none; }
  .trow--bld .end { justify-self: start; }
  .output { padding-right: 0; }
}

@media (max-width: 760px) {
  .app { flex-direction: column; }

  .rail {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: auto;
    height: 64px;
    flex-direction: row;
    justify-content: space-around;
    padding: 0 8px;
    border-right: 0;
    border-top: 1px solid var(--line);
  }

  .rail-brand { display: none; }
  .rail-btn { height: 56px; }
  .rail-menu { margin-top: 0; }
  .file-menu { left: auto; right: 0; bottom: 54px; }

  .main { padding-bottom: 64px; }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0 16px;
  }

  .tabs { min-height: 52px; }
  .resources { overflow-x: auto; padding: 8px 0 10px; gap: 16px; }
  .activity-bar { position: static; padding: 6px 16px; }
  .content { padding: 16px; }

  .hero-row { flex-direction: column; }
  .level-card { width: auto; }
  .now-name { font-size: 36px; }

  .col-opt { display: none; }
  .trow { padding: 0 12px; font-size: 15px; }
  .trow--wc   { grid-template-columns: minmax(80px, 1.6fr) repeat(4, minmax(34px, 0.8fr)) 80px; }
  .trow--fl   { grid-template-columns: minmax(90px, 1.6fr) 0.6fr minmax(90px, 1.6fr) 0.7fr 0.7fr 0.7fr 80px; }
  .trow--shop { grid-template-columns: minmax(80px, 1.4fr) 0.8fr 0.8fr 0.9fr 90px; }
  .btn-sm { width: 76px; }
  .lock-tag { width: 76px; }

  .trow--bld { grid-template-columns: 1fr; }
  .tile-grid--4, .tile-grid--3 { grid-template-columns: 1fr; }
}
