/* Uptime: The Incident Never Ends */

:root {
  --bg-0: #0b0f14;
  --bg-1: #121820;
  --bg-2: #1a2330;
  --bg-3: #243041;
  --border: #2e3d52;
  --border-glow: #3d7ea6;
  --text: #e6edf5;
  --text-dim: #8b9bb0;
  --text-muted: #5c6b7e;
  --accent: #3dbb8a;
  --accent-2: #4da3ff;
  --warn: #e6b84d;
  --danger: #e85d5d;
  --purple: #a78bfa;
  --good: #3dbb8a;
  --great: #5eead4;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  --radius: 12px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Ubuntu, sans-serif;
  --mono: "SF Mono", "Cascadia Code", "Consolas", ui-monospace, monospace;
  --header-h: 72px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(61, 187, 138, 0.08), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(77, 163, 255, 0.06), transparent);
  min-height: 100vh;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

code {
  font-family: var(--mono);
  background: var(--bg-3);
  padding: 0.1em 0.35em;
  border-radius: 4px;
  font-size: 0.9em;
}

blockquote {
  margin: 0.75rem 0;
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--warn);
  background: var(--bg-2);
  color: var(--warn);
  font-style: italic;
}

#app {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 1rem 2rem;
}

/* —— Header —— */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.75rem 1rem;
  min-height: var(--header-h);
  padding: 0.75rem 0;
  background: linear-gradient(to bottom, var(--bg-0) 70%, transparent);
  backdrop-filter: blur(8px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--bg-0);
  font-weight: 700;
  font-size: 14px;
}

.brand-title {
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.1;
}

.brand-sub {
  font-size: 0.7rem;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.currency-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.45rem;
  min-width: 0;
  width: 100%;
}

.currency-pill {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 0.35rem 0.55rem;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.currency-pill[hidden] {
  display: none !important;
}

/* When LD is hidden, stretch the remaining three pills */
.currency-strip:not(:has(#pill-ld:not([hidden]))) {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.currency-pill[data-level="good"] { border-color: rgba(61, 187, 138, 0.45); }
.currency-pill[data-level="great"] { border-color: rgba(94, 234, 212, 0.55); }
.currency-pill[data-level="warn"] { border-color: rgba(230, 184, 77, 0.55); }
.currency-pill[data-level="bad"] {
  border-color: rgba(232, 93, 93, 0.65);
  animation: pulse-border 1.2s ease infinite;
}

@keyframes pulse-border {
  50% { box-shadow: 0 0 0 3px rgba(232, 93, 93, 0.2); }
}

.pill-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pill-value {
  font-family: var(--mono);
  font-weight: 600;
  font-size: clamp(0.78rem, 2.4vw, 1.05rem);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
}

.pill-sub {
  font-size: clamp(0.62rem, 1.8vw, 0.72rem);
  color: var(--text-dim);
  font-family: var(--mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-1);
  font-size: 1.1rem;
}

.icon-btn:hover,
.icon-btn:focus-visible {
  border-color: var(--accent-2);
  outline: none;
}

.degraded-banner {
  margin-bottom: 0.75rem;
  padding: 0.65rem 1rem;
  background: rgba(232, 93, 93, 0.12);
  border: 1px solid rgba(232, 93, 93, 0.45);
  border-radius: var(--radius);
  color: #ffb4b4;
  font-size: 0.9rem;
}

/* —— Layout —— */
.layout {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr) minmax(280px, 360px);
  gap: 1rem;
  align-items: start;
}

.panel {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
}

.panel-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

/* —— Click panel —— */
.panel-click {
  padding: 1.25rem 1rem 1rem;
  position: sticky;
  top: calc(var(--header-h) + 8px);
}

.server-stage {
  position: relative;
  text-align: center;
  padding: 1rem 0 0.5rem;
}

.server-glow {
  position: absolute;
  inset: 10% 15%;
  background: radial-gradient(circle, rgba(61, 187, 138, 0.18), transparent 70%);
  pointer-events: none;
}

.ping-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
  max-width: 240px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
  border-radius: 16px;
  border: 2px solid rgba(61, 187, 138, 0.45);
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  transition: transform 0.08s ease, border-color 0.15s, box-shadow 0.15s;
  box-shadow: 0 0 0 0 rgba(61, 187, 138, 0.3);
}

.ping-btn:hover,
.ping-btn:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 24px rgba(61, 187, 138, 0.25);
  outline: none;
}

.ping-btn:active {
  transform: scale(0.97);
}

.ping-icon {
  font-size: 2.5rem;
  line-height: 1;
  filter: grayscale(0.2);
}

.ping-label {
  font-weight: 700;
  font-size: 1.05rem;
}

.ping-value {
  font-family: var(--mono);
  color: var(--accent);
  font-size: 0.95rem;
}

.server-tagline {
  margin: 0.85rem 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--mono);
}

.float-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
}

.float-num {
  position: absolute;
  font-family: var(--mono);
  font-weight: 700;
  color: var(--accent);
  animation: float-up 0.9s ease forwards;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  white-space: nowrap;
}

@keyframes float-up {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-48px) scale(1.1); }
}

.incident-zone {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.state-actor-panel,
.audit-panel {
  padding: 0.75rem;
  border-radius: 10px;
  border: 1px solid rgba(232, 93, 93, 0.5);
  background: rgba(232, 93, 93, 0.08);
}

.state-actor-panel {
  border-color: rgba(167, 139, 250, 0.55);
  background: rgba(167, 139, 250, 0.08);
  animation: sa-pulse 2s ease infinite;
}

@keyframes sa-pulse {
  50% { box-shadow: 0 0 20px rgba(167, 139, 250, 0.15); }
}

.sa-title,
.audit-title {
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
}

#btn-audit-speed {
  width: 100%;
  margin-top: 0.55rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.65rem 0.85rem;
}

#btn-audit-speed .audit-btn-label {
  font-weight: 700;
}

#btn-audit-speed .audit-btn-cost {
  font-family: var(--mono);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--warn);
}

#btn-audit-speed.affordable .audit-btn-cost {
  color: var(--accent);
}

#btn-audit-speed:disabled .audit-btn-cost {
  color: var(--text-muted);
}

.audit-hint {
  margin: 0.45rem 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
}

.sa-flavor,
.sa-hint {
  margin: 0.35rem 0;
  font-size: 0.82rem;
  color: var(--text-dim);
}

.pause-banner {
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  background: rgba(230, 184, 77, 0.12);
  border: 1px solid rgba(230, 184, 77, 0.4);
  color: var(--warn);
  font-size: 0.85rem;
  text-align: center;
}

.uptime-block {
  margin-top: 1rem;
}

.meter {
  margin: 0.5rem 0;
}

.meter-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-bottom: 0.3rem;
  font-family: var(--mono);
}

.meter-label > span:first-child {
  flex-shrink: 0;
}

.meter-label > span:last-child {
  text-align: right;
  min-width: 0;
}

.meter-track {
  height: 10px;
  background: var(--bg-0);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.meter-track.hit {
  animation: bar-hit 0.5s ease;
}

@keyframes bar-hit {
  0%, 100% { filter: none; }
  30% { filter: brightness(1.8) saturate(1.5); }
}

.meter-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  transition: width 0.2s linear;
  background: var(--accent);
}

.uptime-fill[data-level="good"] { background: linear-gradient(90deg, #2d9f72, var(--good)); }
.uptime-fill[data-level="great"] { background: linear-gradient(90deg, var(--good), var(--great)); }
.uptime-fill[data-level="warn"] { background: linear-gradient(90deg, #c4922e, var(--warn)); }
.uptime-fill[data-level="bad"] { background: linear-gradient(90deg, #b33b3b, var(--danger)); }

.sa-fill { background: linear-gradient(90deg, #6d28d9, var(--purple)); }
.audit-fill { background: linear-gradient(90deg, #b45309, var(--warn)); }

/* —— Buildings —— */
.buildings-list {
  max-height: calc(100vh - var(--header-h) - 80px);
  overflow-y: auto;
  padding: 0.5rem;
}

.buy-qty {
  display: flex;
  gap: 0.25rem;
}

.qty-btn {
  padding: 0.3rem 0.55rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  font-size: 0.78rem;
  font-family: var(--mono);
  color: var(--text-dim);
}

.qty-btn.active,
.qty-btn:hover,
.qty-btn:focus-visible {
  border-color: var(--accent-2);
  color: var(--text);
  outline: none;
}

.qty-btn.active {
  background: rgba(77, 163, 255, 0.15);
}

.tier-section {
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-2);
}

.tier-section.locked {
  opacity: 0.85;
}

.tier-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  background: var(--bg-3);
  border-bottom: 1px solid var(--border);
}

.tier-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.9rem;
}

.tier-badge {
  font-family: var(--mono);
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  background: rgba(77, 163, 255, 0.2);
  color: var(--accent-2);
}

.tier-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--mono);
}

.tier-unlock-row {
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.unlock-reqs {
  font-size: 0.82rem;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.building-row {
  display: flex;
  width: 100%;
  text-align: left;
  gap: 0.75rem;
  padding: 0.7rem 0.75rem;
  border-bottom: 1px solid rgba(46, 61, 82, 0.6);
  background: transparent;
  transition: background 0.12s, box-shadow 0.12s;
}

.building-row:last-child {
  border-bottom: none;
}

.building-row:hover:not(:disabled),
.building-row:focus-visible:not(:disabled) {
  background: rgba(77, 163, 255, 0.06);
  outline: none;
}

.building-row.affordable {
  box-shadow: inset 3px 0 0 var(--accent);
}

.building-row.affordable .cost-val {
  color: var(--accent);
}

.building-row:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.b-main {
  flex: 1;
  min-width: 0;
}

.b-name-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.b-name {
  font-weight: 600;
  font-size: 0.92rem;
}

.b-owned {
  font-family: var(--mono);
  color: var(--accent-2);
  font-size: 0.85rem;
}

.b-flavor {
  font-size: 0.88rem;
  line-height: 1.35;
  color: var(--text-dim);
  margin-top: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.building-row:hover .b-flavor,
.building-row:focus-visible .b-flavor {
  white-space: normal;
}

.b-stats {
  font-size: 0.84rem;
  line-height: 1.35;
  font-family: var(--mono);
  color: var(--text-dim);
  margin-top: 0.28rem;
}

.b-cost {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  min-width: 72px;
  font-family: var(--mono);
}

.cost-qty {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.cost-val {
  font-weight: 600;
  font-size: 0.9rem;
}

/* —— Side panel —— */
.panel-side {
  position: sticky;
  top: calc(var(--header-h) + 8px);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - var(--header-h) - 24px);
}

.side-drawer-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  flex-shrink: 0;
}

.side-drawer-title {
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

.side-drawer-close {
  width: 36px;
  height: 36px;
  font-size: 1rem;
}

.side-drawer-backdrop {
  display: none;
}

.mobile-side-fab {
  display: none;
}

.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  flex-shrink: 0;
}

.tab {
  flex: 1;
  padding: 0.7rem 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
}

.tab:hover,
.tab:focus-visible {
  color: var(--text);
  outline: none;
}

.tab.active {
  color: var(--text);
  border-bottom-color: var(--accent-2);
  background: rgba(77, 163, 255, 0.06);
}

.tab-panels {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
}

.side-section {
  margin-bottom: 1.25rem;
}

.side-section h3 {
  margin: 0 0 0.6rem;
  font-size: 0.88rem;
  font-weight: 600;
}

.muted {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.upgrade-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.upgrade-list.compact .upgrade-card {
  padding: 0.45rem 0.65rem;
}

.upgrade-card {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.7rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  transition: border-color 0.12s, background 0.12s;
}

.upgrade-card.affordable {
  border-color: rgba(61, 187, 138, 0.45);
}

.upgrade-card.affordable:hover,
.upgrade-card.affordable:focus-visible {
  background: rgba(61, 187, 138, 0.08);
  outline: none;
}

.upgrade-card.owned {
  opacity: 0.92;
  border-style: dashed;
  cursor: pointer;
}

.upgrade-card.owned-expandable {
  transition: border-color 0.12s, background 0.12s;
}

.upgrade-card.owned-expandable:hover,
.upgrade-card.owned-expandable:focus-visible {
  border-color: rgba(77, 163, 255, 0.45);
  background: rgba(77, 163, 255, 0.06);
  outline: none;
}

.owned-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.owned-chevron {
  color: var(--text-muted);
  font-size: 0.75rem;
  transition: transform 0.15s ease;
  flex-shrink: 0;
}

.owned-details {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.18s ease, margin 0.18s ease;
  margin-top: 0;
}

.owned-details > * {
  overflow: hidden;
  min-height: 0;
}

.owned-details .u-flavor {
  margin-top: 0.35rem;
}

.upgrade-card.owned-expandable.expanded .owned-details,
.upgrade-card.owned-expandable:hover .owned-details,
.upgrade-card.owned-expandable:focus-within .owned-details {
  grid-template-rows: 1fr;
  margin-top: 0.15rem;
}

.upgrade-card.owned-expandable.expanded .owned-chevron,
.upgrade-card.owned-expandable:hover .owned-chevron,
.upgrade-card.owned-expandable:focus-within .owned-chevron {
  transform: rotate(180deg);
}

/* Touch devices: rely on tap-to-expand, not sticky hover */
@media (hover: none) {
  .upgrade-card.owned-expandable:hover .owned-details {
    grid-template-rows: 0fr;
    margin-top: 0;
  }
  .upgrade-card.owned-expandable:hover .owned-chevron {
    transform: none;
  }
  .upgrade-card.owned-expandable.expanded:hover .owned-details,
  .upgrade-card.owned-expandable.expanded .owned-details {
    grid-template-rows: 1fr;
    margin-top: 0.15rem;
  }
  .upgrade-card.owned-expandable.expanded .owned-chevron {
    transform: rotate(180deg);
  }
}

.upgrade-card:disabled:not(.owned) {
  opacity: 0.5;
  cursor: not-allowed;
}

.u-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.u-flavor {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.u-effect {
  font-size: 0.72rem;
  font-family: var(--mono);
  color: var(--accent-2);
  margin-top: 0.3rem;
}

.u-cost {
  margin-top: 0.35rem;
  font-family: var(--mono);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--accent);
}

.ach-count {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 0.65rem;
}

.ach-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.ach-card {
  padding: 0.6rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  opacity: 0.55;
}

.ach-card.earned {
  opacity: 1;
  border-color: rgba(230, 184, 77, 0.45);
  background: rgba(230, 184, 77, 0.08);
}

.ach-card.secret {
  opacity: 0.4;
  font-style: italic;
}

.ach-name {
  font-weight: 600;
  font-size: 0.88rem;
}

.ach-desc {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 0.15rem;
}

.stats-grid {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.stat {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.45rem 0.55rem;
  border-radius: 6px;
  background: var(--bg-2);
  font-family: var(--mono);
  font-size: 0.82rem;
}

.stat.warn {
  border: 1px solid rgba(232, 93, 93, 0.4);
}

.stat-label {
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 0.8rem;
}

.ld-preview {
  font-size: 1rem;
}

/* —— Buttons —— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.88rem;
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s, transform 0.08s;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(180deg, #3ecf96, #2da574);
  color: #062016;
}

.btn-primary:hover:not(:disabled),
.btn-primary:focus-visible:not(:disabled) {
  filter: brightness(1.08);
  outline: none;
}

.btn-secondary {
  background: var(--bg-3);
  border-color: var(--border);
  color: var(--text);
}

.btn-secondary:hover:not(:disabled),
.btn-secondary:focus-visible:not(:disabled) {
  border-color: var(--accent-2);
  outline: none;
}

.btn-danger {
  background: linear-gradient(180deg, #e85d5d, #c23f3f);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-dim);
}

.btn-ghost:hover {
  color: var(--text);
}

/* —— Toasts —— */
.toast-host {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  z-index: 160;
  display: flex;
  flex-direction: column-reverse;
  align-items: stretch;
  gap: 0.65rem;
  width: min(440px, calc(100vw - 1.5rem));
  pointer-events: none;
}

.toast {
  position: relative;
  padding: 0.85rem 1rem 0.95rem;
  border-radius: 14px;
  background: rgba(26, 35, 48, 0.96);
  border: 1px solid var(--border);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.03) inset;
  font-size: 1rem;
  line-height: 1.4;
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: auto;
  cursor: pointer;
  overflow: hidden;
  backdrop-filter: blur(10px);
}

.toast.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.toast.hide {
  opacity: 0;
  transform: translateY(8px) scale(0.98);
}

.toast-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.toast-kind {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.toast-dismiss {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 8px;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.toast-dismiss:hover,
.toast-dismiss:focus-visible {
  color: var(--text);
  border-color: var(--border);
  background: var(--bg-3);
  outline: none;
}

.toast-body {
  color: var(--text);
  font-size: 1.02rem;
  font-weight: 500;
  word-wrap: break-word;
}

.toast-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.06);
}

.toast-progress-bar {
  height: 100%;
  width: 100%;
  transform-origin: left center;
  background: var(--accent-2);
  animation-name: toast-shrink;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

@keyframes toast-shrink {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

.toast-success { border-color: rgba(61, 187, 138, 0.65); }
.toast-success .toast-kind { color: var(--accent); }
.toast-success .toast-progress-bar { background: var(--accent); }

.toast-danger { border-color: rgba(232, 93, 93, 0.7); }
.toast-danger .toast-kind { color: #ff9b9b; }
.toast-danger .toast-progress-bar { background: var(--danger); }

.toast-warning { border-color: rgba(230, 184, 77, 0.7); }
.toast-warning .toast-kind { color: var(--warn); }
.toast-warning .toast-progress-bar { background: var(--warn); }

.toast-achievement {
  border-color: rgba(230, 184, 77, 0.85);
  background: linear-gradient(145deg, rgba(230, 184, 77, 0.2), rgba(26, 35, 48, 0.97) 55%);
}
.toast-achievement .toast-kind { color: #f0d078; }
.toast-achievement .toast-body { font-size: 1.06rem; }
.toast-achievement .toast-progress-bar { background: var(--warn); }

.toast-info { border-color: rgba(77, 163, 255, 0.55); }
.toast-info .toast-kind { color: var(--accent-2); }

/* —— Modal —— */
.modal-host {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.modal-host[hidden] {
  display: none !important;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 8, 12, 0.72);
  backdrop-filter: blur(4px);
}

.modal {
  position: relative;
  width: min(480px, 100%);
  max-height: min(85vh, 720px);
  overflow-y: auto;
  padding: 1.25rem 1.35rem;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.modal h2 {
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
}

.modal-body {
  font-size: 0.92rem;
  color: var(--text-dim);
}

.modal-body p {
  margin: 0 0 0.65rem;
  color: var(--text);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.15rem;
}

.reset-list {
  margin: 0.5rem 0;
  padding-left: 1.2rem;
  color: var(--text);
}

.settings-block {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.settings-block h4 {
  margin: 0 0 0.4rem;
  font-size: 0.88rem;
}

.danger-zone {
  border-color: rgba(232, 93, 93, 0.35);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.input {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-0);
  color: var(--text);
  margin: 0.35rem 0;
}

.input.code {
  font-family: var(--mono);
  font-size: 0.72rem;
  resize: vertical;
}

.input:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 1px;
}

/* —— Responsive —— */
@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr 1fr;
  }

  .panel-click {
    grid-column: 1 / -1;
    position: static;
  }

  .panel-side {
    position: static;
    max-height: min(70vh, 640px);
  }
}

/* Side panel becomes a slide-out drawer */
@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .panel-click {
    grid-column: auto;
  }

  .side-drawer-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 180;
    background: rgba(5, 8, 12, 0.55);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  .side-drawer-backdrop.show {
    opacity: 1;
    pointer-events: auto;
  }

  .panel-side {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 190;
    width: min(400px, 92vw);
    max-height: none;
    height: 100%;
    margin: 0;
    border-radius: 0;
    border-left: 1px solid var(--border);
    border-right: none;
    border-top: none;
    border-bottom: none;
    box-shadow: -12px 0 40px rgba(0, 0, 0, 0.45);
    transform: translateX(105%);
    transition: transform 0.22s ease;
    background: var(--bg-1);
  }

  .panel-side.drawer-open {
    transform: translateX(0);
  }

  .side-drawer-header {
    display: flex;
  }

  .panel-side .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .panel-side .tab {
    white-space: nowrap;
    padding: 0.75rem 0.7rem;
    flex: 1 0 auto;
    min-width: 5.5rem;
  }

  .panel-side .tab-panels {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .mobile-side-fab {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 120;
    padding: 0.75rem 1.05rem;
    border-radius: 999px;
    border: 1px solid rgba(77, 163, 255, 0.45);
    background: linear-gradient(180deg, #2a3d55, #1a2838);
    color: var(--text);
    font-weight: 700;
    font-size: 0.9rem;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  }

  .mobile-side-fab:hover,
  .mobile-side-fab:focus-visible {
    border-color: var(--accent-2);
    outline: none;
  }

  .mobile-side-fab .fab-icon {
    font-size: 1.05rem;
    line-height: 1;
  }

  /* Keep toasts above the Menu FAB */
  .toast-host {
    bottom: 5rem;
    width: min(440px, calc(100vw - 1.25rem));
  }

  .toast {
    padding: 0.95rem 1.05rem 1.05rem;
  }

  .toast-body {
    font-size: 1.05rem;
  }
}

@media (max-width: 720px) {
  .top-bar {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand settings"
      "stats stats";
    gap: 0.55rem 0.75rem;
  }

  .brand {
    grid-area: brand;
    min-width: 0;
  }

  .brand-sub {
    display: none;
  }

  #btn-settings {
    grid-area: settings;
  }

  .currency-strip {
    grid-area: stats;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .currency-strip:not(:has(#pill-ld:not([hidden]))) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .currency-strip:has(#pill-ld:not([hidden])) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .currency-pill {
    min-width: 0;
    padding: 0.4rem 0.55rem;
  }

  .pill-value {
    font-size: 0.95rem;
  }

  .buildings-list {
    max-height: none;
  }

  .b-flavor {
    white-space: normal;
  }
}

@media (max-width: 400px) {
  #app {
    padding: 0 0.5rem 1.5rem;
  }

  .pill-label {
    font-size: 0.58rem;
    letter-spacing: 0.04em;
  }

  .pill-value {
    font-size: 0.85rem;
  }

  .pill-sub {
    font-size: 0.6rem;
  }

  .brand-title {
    font-size: 0.95rem;
  }
}

/* Focus visibility for a11y */
:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}
