/* AEONS — Idle Civilization | style.css */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }

:root {
  --bg: #141210;
  --bg-card: #1c1916;
  --bg-hover: #242018;
  --bg-header: #1a1714;
  --border: #2e2822;
  --border-light: #3a3228;
  --text: #d4c8b0;
  --text-dim: #7a6e58;
  --text-bright: #f0e6d2;
  --accent: #c89440;
  --food: #6abf4b;
  --production: #e0922e;
  --science: #4a9eed;
  --culture: #b06adf;
  --gold: #f0c040;
  --positive: #6abf4b;
  --negative: #e05050;
  --radius: 8px;
  --radius-sm: 4px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  line-height: 1.5;
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
  user-select: none;
  -webkit-user-select: none;
}

/* ── App layout ── */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
}

/* ── Header ── */
header {
  flex-shrink: 0;
  background: var(--bg-header);
  padding: calc(6px + var(--safe-top)) 14px 8px;
  border-bottom: 1px solid var(--border);
}
.era-banner {
  text-align: center;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 3px;
  padding: 2px 0 4px;
}
.era-stone { color: #8a7d68; }
.era-bronze { color: #cd8032; }
.era-classical { color: #d4b872; }
.era-medieval { color: #c04848; }
.era-renaissance { color: #6a9e4a; }
.era-industrial { color: #8a8a9a; }
.era-information { color: #4a9eed; }

#pop-row {
  text-align: center;
  font-size: 0.9rem;
  padding: 1px 0;
}
.pop-icon { margin-right: 2px; }
.pop-label { margin: 0 1px; }
.num { font-variant-numeric: tabular-nums; font-weight: 600; }
.dim { color: var(--text-dim); font-size: 0.85em; }
.has-idle { color: var(--positive); }

/* Growth bar */
#growth-container { margin: 5px 0 4px; }
#growth-bar {
  height: 6px;
  background: #1a1714;
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid var(--border);
}
#growth-fill {
  height: 100%;
  background: linear-gradient(90deg, #2a5a1a, var(--food));
  border-radius: 3px;
  transition: width 0.25s ease;
  width: 0%;
}
#growth-text {
  font-size: 0.72rem;
  color: var(--text-dim);
  text-align: center;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

/* Resource bar */
#resources-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
  margin-top: 4px;
}
.res-cell { text-align: center; padding: 2px 0; }
.res-icon { font-size: 0.85rem; }
.res-val { display: block; font-size: 0.85rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.res-rate { display: block; font-size: 0.68rem; font-variant-numeric: tabular-nums; }
.res-rate.positive { color: var(--positive); }
.res-rate.negative { color: var(--negative); }
.color-food { color: var(--food); }
.color-production { color: var(--production); }
.color-science { color: var(--science); }
.color-culture { color: var(--culture); }
.color-gold { color: var(--gold); }

/* ── Main content ── */
main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 10px 10px calc(10px + var(--safe-bottom));
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Bottom tabs ── */
#tabs {
  flex-shrink: 0;
  display: flex;
  background: var(--bg-header);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
}
.tab-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 7px 0 5px;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.tab-btn span { font-size: 0.6rem; letter-spacing: 0.5px; }
.tab-btn.active { color: var(--accent); }

/* ── Era dividers ── */
.era-divider {
  font-family: Georgia, serif;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 1px;
  padding: 10px 0 5px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
  color: var(--text-dim);
}
.era-divider.era-stone { color: #8a7d68; border-color: #3a3228; }
.era-divider.era-bronze { color: #cd8032; border-color: #5a3a18; }
.era-divider.era-classical { color: #d4b872; border-color: #5a4a28; }
.era-divider.era-medieval { color: #c04848; border-color: #5a2828; }
.era-divider.era-renaissance { color: #6a9e4a; border-color: #2a5a1a; }
.era-divider.era-industrial { color: #8a8a9a; border-color: #3a3a4a; }
.era-divider.era-information { color: #4a9eed; border-color: #1a3a6a; }

/* ── Building toolbar ── */
.bld-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px; gap: 6px;
}
.buy-modes { display: flex; gap: 3px; }
.buy-mode-btn {
  padding: 4px 9px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-dim); font-size: 0.72rem;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.buy-mode-btn.active { border-color: var(--accent); color: var(--accent); }
.hide-toggle {
  padding: 4px 9px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-dim); font-size: 0.7rem;
  cursor: pointer; -webkit-tap-highlight-color: transparent; white-space: nowrap;
}
.hide-toggle.active { border-color: var(--positive); color: var(--positive); }

/* ── Building cards ── */
.bld-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 11px;
  margin-bottom: 7px;
}
.bld-card.locked { opacity: 0.35; padding: 7px 11px; }
.bld-header { display: flex; align-items: center; gap: 5px; }
.bld-icon { font-size: 0.95rem; }
.bld-name { flex: 1; font-weight: 600; font-size: 0.9rem; }
.bld-level {
  font-size: 1.2rem; font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 26px; text-align: right;
  color: var(--text-bright);
}
.bld-output { font-size: 0.82rem; margin: 3px 0 1px; }
.bld-per { color: var(--text-dim); font-size: 0.72rem; margin-left: 3px; }
.bld-lock { color: var(--text-dim); font-size: 0.78rem; font-style: italic; margin-top: 2px; }
.bld-actions { display: flex; align-items: center; gap: 6px; margin-top: 5px; }
.bld-cost {
  flex: 1; text-align: center;
  font-size: 0.75rem; color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.btn-minus, .btn-plus {
  width: 40px; height: 32px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  font-size: 1.15rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.1s, border-color 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.btn-plus:not(.disabled) {
  background: #1a2a15; border-color: #3a6a2a; color: var(--food);
}
.btn-plus:not(.disabled):active { background: #2a3a20; }
.btn-minus:not(.disabled):active { background: #3a2020; }
.btn-minus.disabled, .btn-plus.disabled { opacity: 0.2; cursor: default; }

/* ── Tech cards ── */
.tech-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 11px;
  margin-bottom: 5px;
}
.tech-card.researched { border-color: #2a5a1a; }
.tech-card.researched .tech-name { color: var(--positive); }
.tech-card.excluded { opacity: 0.25; }
.tech-header { display: flex; align-items: center; gap: 5px; }
.tech-status { font-size: 0.85rem; flex-shrink: 0; }
.tech-name { flex: 1; font-weight: 600; font-size: 0.88rem; }
.tech-cost { font-size: 0.78rem; color: var(--science); font-variant-numeric: tabular-nums; }
.tech-desc { font-size: 0.78rem; color: var(--text-dim); margin-top: 2px; }
.tech-excluded { font-size: 0.72rem; color: var(--negative); font-style: italic; margin-top: 3px; }
.tech-btn {
  margin-top: 5px; padding: 6px 14px; width: 100%;
  background: #152535; border: 1px solid #2a5080;
  border-radius: var(--radius-sm);
  color: var(--science); font-size: 0.82rem; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tech-btn.disabled { opacity: 0.25; cursor: default; }
.tech-btn:not(.disabled):active { background: #203a50; }
.tech-pair {
  border: 1px dashed var(--border-light);
  border-radius: var(--radius);
  padding: 7px; margin-bottom: 7px;
}
.tech-pair .tech-card { margin-bottom: 4px; }
.tech-pair .tech-card:last-child { margin-bottom: 0; }
.tech-pair-label {
  font-size: 0.72rem; color: var(--text-dim);
  text-align: center; margin-bottom: 5px; font-style: italic;
}

/* ── Era advancement ── */
.era-advance-box {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px; margin-bottom: 12px; text-align: center;
}
.era-advance-box.ready { border-color: var(--accent); }
.era-advance-title { font-weight: 700; font-size: 0.95rem; margin-bottom: 5px; }
.era-advance-reqs {
  display: flex; justify-content: center; gap: 14px;
  font-size: 0.82rem; margin-bottom: 8px;
}
.met { color: var(--positive); }
.unmet { color: var(--text-dim); }
.btn-advance {
  padding: 7px 22px;
  background: #3a2a10; border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  color: var(--accent); font-weight: 600; font-size: 0.9rem; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn-advance:active { background: #4a3a18; }

/* ── Policy cards ── */
.policy-slot { margin-bottom: 14px; }
.policy-slot.locked { opacity: 0.35; }
.policy-slot-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 0 5px; border-bottom: 1px solid var(--border); margin-bottom: 5px;
}
.policy-slot-name { font-weight: 700; font-size: 0.9rem; }
.policy-slot-req { font-size: 0.78rem; color: var(--text-dim); }
.policy-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 9px 11px; margin-bottom: 5px;
}
.policy-card.active { border-color: var(--culture); }
.policy-header { display: flex; align-items: center; gap: 6px; }
.policy-name { font-weight: 600; flex: 1; font-size: 0.88rem; }
.policy-active-badge {
  font-size: 0.65rem; background: var(--culture); color: #fff;
  padding: 1px 6px; border-radius: 3px; font-weight: 600;
}
.policy-desc { font-size: 0.78rem; color: var(--text-dim); margin: 3px 0; }
.policy-btn {
  padding: 5px 12px; width: 100%;
  background: #1a1530; border: 1px solid #4a3070;
  border-radius: var(--radius-sm);
  color: var(--culture); font-size: 0.78rem; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.policy-btn:active { background: #2a2040; }

/* ── Prestige / Legacy ── */
.prestige-box {
  background: var(--bg-card); border: 1px solid var(--accent);
  border-radius: var(--radius); padding: 14px; margin-bottom: 14px; text-align: center;
}
.prestige-box h3 { color: var(--accent); font-size: 1rem; margin-bottom: 5px; }
.prestige-box p { font-size: 0.82rem; color: var(--text-dim); margin-bottom: 8px; }
.prestige-info { font-size: 0.88rem; margin-bottom: 10px; }
.prestige-info div { margin: 3px 0; }
.btn-prestige {
  padding: 9px 26px;
  background: linear-gradient(135deg, #3a2a10, #5a3a18);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: var(--accent); font-weight: 700; font-size: 0.95rem; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn-prestige:active { background: #5a3a18; }

.section-title {
  font-size: 0.95rem; color: var(--text-dim);
  padding: 10px 0 6px; border-bottom: 1px solid var(--border); margin-bottom: 7px;
}
.legacy-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 9px 11px; margin-bottom: 5px;
}
.legacy-card.owned { border-color: var(--positive); opacity: 0.55; }
.legacy-card.available { border-color: var(--accent); }
.legacy-header { display: flex; justify-content: space-between; align-items: center; }
.legacy-name { font-weight: 600; font-size: 0.88rem; }
.legacy-cost { font-size: 0.82rem; color: var(--accent); }
.legacy-card.owned .legacy-cost { color: var(--positive); }
.legacy-desc { font-size: 0.78rem; color: var(--text-dim); margin: 3px 0; }
.legacy-btn {
  padding: 5px 12px; width: 100%; margin-top: 3px;
  background: #2a2010; border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  color: var(--accent); font-size: 0.78rem; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.legacy-btn.disabled {
  opacity: 0.25; cursor: default; border-color: var(--border); color: var(--text-dim);
}

/* ── Stats ── */
.tab-title { font-size: 1rem; color: var(--text-bright); margin-bottom: 10px; }
.tab-desc { font-size: 0.82rem; color: var(--text-dim); margin-bottom: 10px; }
.stats-section {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px; margin-bottom: 8px;
}
.stats-section h4 {
  font-size: 0.85rem; color: var(--text-dim);
  margin-bottom: 6px; border-bottom: 1px solid var(--border); padding-bottom: 3px;
}
.stat-row {
  display: flex; justify-content: space-between;
  font-size: 0.82rem; padding: 2px 0;
  font-variant-numeric: tabular-nums;
}
.stat-row .positive { color: var(--positive); }
.stat-row .negative { color: var(--negative); }

.ach-row {
  display: flex; align-items: center; gap: 5px;
  padding: 3px 0; font-size: 0.78rem;
}
.ach-row:not(.earned) { opacity: 0.35; }
.ach-icon { font-size: 0.85rem; flex-shrink: 0; }
.ach-name { font-weight: 600; min-width: 90px; }
.ach-desc { color: var(--text-dim); flex: 1; }

.settings-btn {
  padding: 7px 14px;
  background: var(--bg-card); border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text); font-size: 0.82rem; cursor: pointer;
  margin: 3px 3px 3px 0;
  -webkit-tap-highlight-color: transparent;
}
.settings-btn.danger { border-color: var(--negative); color: var(--negative); }

/* ── Modal ── */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.82);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
}
.modal.hidden { display: none; }
.modal-box {
  background: var(--bg-card); border: 1px solid var(--border-light);
  border-radius: 12px; padding: 22px; max-width: 340px; width: 100%;
}
.modal-box h2 {
  font-family: Georgia, serif; color: var(--accent);
  text-align: center; margin-bottom: 10px; letter-spacing: 2px;
}
.modal-box p { font-size: 0.88rem; margin-bottom: 8px; color: var(--text-dim); }
.modal-box ul { margin: 6px 0; padding-left: 18px; font-size: 0.82rem; }
.modal-box li { margin: 3px 0; color: var(--text); }
.modal-btn {
  display: block; width: 100%; padding: 9px; margin-top: 14px;
  background: #3a2a10; border: 1px solid var(--accent);
  border-radius: var(--radius); color: var(--accent);
  font-weight: 600; font-size: 0.95rem; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.modal-btn:active { background: #4a3a18; }
.offline-earnings div { padding: 3px 0; font-size: 0.88rem; }

/* ── Toast ── */
.toast {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  background: var(--bg-card); border: 1px solid var(--accent);
  border-radius: var(--radius); padding: 7px 18px;
  font-size: 0.82rem; color: var(--accent);
  z-index: 200; white-space: nowrap;
  transition: opacity 0.3s, transform 0.3s;
}
.toast.hidden {
  opacity: 0; transform: translateX(-50%) translateY(-16px); pointer-events: none;
}

/* ── Scrollbar ── */
main::-webkit-scrollbar { width: 3px; }
main::-webkit-scrollbar-track { background: transparent; }
main::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── Desktop tweaks ── */
@media (min-width: 540px) {
  #app { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}
