:root {
  --bg: #07101d;
  --bg-2: #0b1628;
  --card: rgba(14, 27, 47, 0.88);
  --card-2: rgba(8, 17, 31, 0.72);
  --border: rgba(148, 163, 184, 0.18);
  --border-strong: rgba(255, 209, 102, 0.34);
  --text: #eaf2ff;
  --muted: #9fb0c7;
  --green: #44e39d;
  --green-soft: rgba(68, 227, 157, 0.14);
  --yellow: #ffd166;
  --yellow-soft: rgba(255, 209, 102, 0.16);
  --red: #ff6b6b;
  --blue: #7fb1ff;
  --shadow: 0 24px 90px rgba(0, 0, 0, 0.36);
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 8% 0%, rgba(68, 227, 157, 0.18), transparent 32rem),
    radial-gradient(circle at 92% 8%, rgba(255, 209, 102, 0.16), transparent 32rem),
    linear-gradient(180deg, #050b14 0%, var(--bg) 48%, #050914 100%);
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.page-shell {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.card {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 26px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(340px, 0.9fr);
  gap: 26px;
  align-items: center;
  padding: 34px;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  inset: -2px;
  background:
    linear-gradient(135deg, rgba(68, 227, 157, 0.16), transparent 42%, rgba(255, 209, 102, 0.18));
  pointer-events: none;
}

.hero > * {
  position: relative;
  z-index: 1;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 10px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 6px rgba(68, 227, 157, 0.12), 0 0 22px rgba(68, 227, 157, 0.8);
}

.status-dot.offline {
  background: var(--red);
  box-shadow: 0 0 0 6px rgba(255, 107, 107, 0.12), 0 0 22px rgba(255, 107, 107, 0.8);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.05;
}

h1 {
  max-width: 790px;
  font-size: clamp(34px, 5vw, 64px);
  letter-spacing: -0.06em;
}

h2 {
  font-size: clamp(22px, 2vw, 28px);
  letter-spacing: -0.035em;
}

h3 {
  font-size: 18px;
}

.subtitle,
.muted {
  color: var(--muted);
  line-height: 1.6;
}

.subtitle {
  max-width: 740px;
  font-size: 17px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 22px;
}

.primary-link,
.secondary-link,
.guild-button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 45px;
  padding: 12px 16px;
  border: 0;
  border-radius: 16px;
  cursor: pointer;
  font-weight: 900;
  text-decoration: none;
  transition: transform 160ms ease, filter 160ms ease, border-color 160ms ease;
}

.primary-link,
.guild-button,
button {
  color: #06111d;
  background: linear-gradient(135deg, var(--green), var(--yellow));
}

.secondary-link {
  color: var(--text);
  background: rgba(8, 17, 31, 0.62);
  border: 1px solid var(--border);
}

.primary-link:hover,
.secondary-link:hover,
.guild-button:hover,
button:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.stat-card {
  min-width: 0;
  padding: 18px;
  border: 1px solid rgba(148, 163, 184, 0.13);
  border-radius: 20px;
  background: rgba(8, 17, 31, 0.62);
}

.stat-card span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.stat-card strong {
  display: block;
  color: var(--yellow);
  font-size: clamp(20px, 2vw, 27px);
  line-height: 1.12;
}

.context-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 18px;
}

.context-card,
.search-card,
.chart-card,
.top-card,
.guild-card {
  padding: 24px;
}

.pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  margin-bottom: 12px;
  padding: 7px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.green-pill {
  color: var(--green);
  background: var(--green-soft);
  border: 1px solid rgba(68, 227, 157, 0.24);
}

.yellow-pill {
  color: var(--yellow);
  background: var(--yellow-soft);
  border: 1px solid rgba(255, 209, 102, 0.28);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-head.compact {
  margin-bottom: 14px;
}

.search-card {
  margin-top: 18px;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}

input,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 16px;
  outline: none;
  color: var(--text);
  background: rgba(8, 17, 31, 0.78);
  padding: 13px 15px;
}

input:focus,
select:focus {
  border-color: rgba(255, 209, 102, 0.56);
  box-shadow: 0 0 0 4px rgba(255, 209, 102, 0.08);
}

.results-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.result-item,
.top-item {
  min-width: 0;
  border: 1px solid rgba(148, 163, 184, 0.13);
  border-radius: 18px;
  background: rgba(8, 17, 31, 0.54);
  padding: 14px;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.result-item:hover,
.top-item:hover {
  border-color: rgba(255, 209, 102, 0.56);
  background: rgba(255, 209, 102, 0.08);
  transform: translateY(-1px);
}

.item-name {
  margin-bottom: 6px;
  font-weight: 900;
}

.item-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.52fr) minmax(320px, 0.72fr);
  gap: 18px;
  margin-top: 18px;
}

.chart-card {
  min-width: 0;
}

.chart-head {
  align-items: flex-start;
}

.certainty-badge {
  flex: 0 0 auto;
  max-width: 180px;
  color: #07111c;
  background: var(--yellow);
  padding: 11px 14px;
  border-radius: 999px;
  font-weight: 950;
  text-align: center;
}

canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 20px;
  background: rgba(4, 10, 19, 0.68);
}

.graph-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: 14px 0;
  color: var(--muted);
  font-size: 14px;
}

.legend-line {
  display: inline-block;
  width: 28px;
  height: 4px;
  margin-right: 7px;
  border-radius: 999px;
  vertical-align: middle;
}

.legend-line.actual {
  background: var(--green);
}

.legend-line.predicted {
  background: var(--yellow);
}

.selected-info {
  border-radius: 20px;
  padding: 18px;
}

.yellow-panel {
  border: 1px solid rgba(255, 209, 102, 0.22);
  background: linear-gradient(135deg, rgba(255, 209, 102, 0.14), rgba(8, 17, 31, 0.5));
}

.selected-info p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.58;
}

.top-list {
  display: grid;
  gap: 10px;
  max-height: 690px;
  overflow: auto;
  padding-right: 4px;
}

.top-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
}

.up {
  color: var(--green);
}

.down,
.warning {
  color: var(--red);
}

.stable {
  color: var(--yellow);
}

.guild-card {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: 18px;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.guild-card::before {
  content: "";
  position: absolute;
  inset: auto -80px -160px auto;
  width: 360px;
  height: 360px;
  border-radius: 999px;
  background: rgba(255, 209, 102, 0.12);
  pointer-events: none;
  z-index: -1;
}

/* Discord logo hard limits — prevents the giant SVG bug */
.discord-mark {
  width: 58px !important;
  height: 58px !important;
  min-width: 58px !important;
  max-width: 58px !important;
  min-height: 58px !important;
  max-height: 58px !important;
  flex: 0 0 58px !important;
  display: grid !important;
  place-items: center !important;
  overflow: hidden !important;
  border-radius: 18px;
  color: #07111c;
  background: linear-gradient(135deg, var(--green), var(--yellow));
}

.discord-mark svg,
.guild-card .discord-mark svg {
  display: block !important;
  width: 31px !important;
  height: 31px !important;
  min-width: 31px !important;
  max-width: 31px !important;
  min-height: 31px !important;
  max-height: 31px !important;
  overflow: hidden !important;
}

.guild-copy {
  min-width: 0;
  flex: 1 1 auto;
}

.guild-copy .muted {
  margin-bottom: 0;
}

.guild-button {
  flex: 0 0 auto;
  white-space: nowrap;
}

.error-card {
  border-color: rgba(255, 107, 107, 0.36);
  background: rgba(255, 107, 107, 0.08);
}

.empty-card {
  cursor: default;
}

@media (max-width: 980px) {
  .hero,
  .context-grid,
  .main-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 640px) {
  .page-shell {
    width: min(100% - 20px, 1240px);
    padding-top: 14px;
  }

  .hero,
  .context-card,
  .search-card,
  .chart-card,
  .top-card,
  .guild-card {
    padding: 18px;
    border-radius: 22px;
  }

  .stats-grid,
  .search-row {
    grid-template-columns: 1fr;
  }

  .section-head,
  .guild-card {
    align-items: stretch;
    flex-direction: column;
  }

  .guild-button {
    width: 100%;
  }

  .certainty-badge {
    max-width: none;
    width: fit-content;
  }
}


/* v11 chart overlap fix */
canvas#priceChart {
  min-height: 430px;
}


/* v12 minister context display */
#currentMayor,
#currentPerks {
  overflow-wrap: anywhere;
}

#currentPerks {
  line-height: 1.55;
}
