:root {
  --bg: #071019;
  --panel: rgba(6, 14, 24, 0.56);
  --panel-strong: rgba(7, 18, 30, 0.84);
  --line: rgba(255, 255, 255, 0.1);
  --text: #f4f8ff;
  --muted: rgba(244, 248, 255, 0.72);
  --accent: #ff4d4d;
  --accent-2: #ffe42f;
  --green: #48d597;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 10%, rgba(56, 149, 180, 0.35), transparent 30%),
    radial-gradient(circle at 90% 20%, rgba(255, 228, 47, 0.1), transparent 25%),
    linear-gradient(180deg, #04101c 0%, #07141f 100%);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI',
    sans-serif;
}

#map {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: #091723;
}

.app-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

.glass {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
}

.topbar,
.latest-card,
.right-rail,
.bottom-bar {
  position: absolute;
  z-index: 6;
}

.topbar {
  top: 18px;
  left: 18px;
  right: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 16px 18px;
  border-radius: 999px;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.brand-kicker,
.section-label {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.68rem;
  color: #9fd1ff;
}

.brand strong {
  font-size: 1.02rem;
  letter-spacing: 0.03em;
}

.status-cluster {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.status-pill,
.mini-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.status-pill.live::before {
  content: '';
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #3ef39a;
  box-shadow: 0 0 0 6px rgba(62, 243, 154, 0.18);
}

.status-pill.live {
  font-weight: 700;
}

.mini-chip.accent {
  background: rgba(255, 77, 77, 0.16);
  border-color: rgba(255, 77, 77, 0.25);
}

.floating {
  z-index: 6;
}

.latest-card {
  top: 84px;
  left: 18px;
  width: min(420px, calc(100vw - 36px));
  padding: 20px;
  border-radius: var(--radius-xl);
}

.right-rail {
  top: 84px;
  right: 18px;
  width: min(360px, calc(100vw - 36px));
  display: grid;
  gap: 14px;
}

.right-rail > section {
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.info-card,
.shakemap-card,
.feed-card {
  padding: 16px;
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.card-top.compact {
  margin-bottom: 12px;
}

.card-top h1 {
  margin: 6px 0 0;
  font-size: 1.4rem;
  line-height: 1.05;
}

.latest-grid {
  display: grid;
  grid-template-columns: 118px 1fr;
  gap: 14px;
  align-items: stretch;
}

.magnitude-box {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 132px;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255, 77, 77, 0.26), rgba(255, 196, 77, 0.18));
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.magnitude-label {
  color: rgba(255, 255, 255, 0.82);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.68rem;
  margin-bottom: 10px;
}

.magnitude-box strong {
  font-size: clamp(2.7rem, 7vw, 4rem);
  line-height: 0.9;
}

.latest-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  min-height: 132px;
}

.latest-copy p,
.info-line span,
.shakemap-meta,
.bottom-bar span,
.feed-item .meta,
.warning-box {
  color: var(--muted);
}

.latest-copy p {
  margin: 0;
  font-size: 0.9rem;
}

.latest-copy h2 {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.15;
}

.latest-copy span,
.info-line strong {
  font-size: 0.95rem;
}

.meta-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.meta-row > div,
.info-line {
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.meta-row span,
.info-line span {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  margin-bottom: 6px;
}

.meta-row strong {
  font-size: 0.95rem;
  line-height: 1.35;
}

.warning-box {
  margin-top: 14px;
  padding: 14px 15px;
  border-radius: 18px;
  background: rgba(255, 228, 47, 0.09);
  border: 1px solid rgba(255, 228, 47, 0.18);
  line-height: 1.55;
  min-height: 64px;
}

.info-stack {
  display: grid;
  gap: 10px;
}

.info-line strong {
  display: block;
}

.shakemap-shell {
  position: relative;
  min-height: 180px;
  border-radius: 18px;
  overflow: hidden;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.14), transparent 45%),
    linear-gradient(180deg, rgba(10, 20, 33, 0.9), rgba(16, 27, 42, 0.92));
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.shakemap-shell img,
.shakemap-empty {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.shakemap-shell img {
  object-fit: cover;
  display: none;
}

.shakemap-empty {
  display: grid;
  place-items: center;
  text-align: center;
  padding: 18px;
  color: var(--muted);
  font-size: 0.92rem;
}

.shakemap-meta {
  padding-top: 10px;
  font-size: 0.85rem;
  line-height: 1.45;
}

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

.feed-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 12px 13px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.feed-dot {
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 999px;
  background: #f6c14e;
  box-shadow: 0 0 0 6px rgba(246, 193, 78, 0.14);
}

.feed-item strong {
  display: block;
  font-size: 0.95rem;
  line-height: 1.35;
  margin-bottom: 5px;
}

.feed-item .meta {
  font-size: 0.78rem;
  line-height: 1.4;
}

.feed-item .value {
  text-align: right;
  white-space: nowrap;
}

.feed-item .value strong {
  font-size: 1rem;
  margin-bottom: 0;
}

.feed-item .value span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.bottom-bar {
  left: 18px;
  right: 18px;
  bottom: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-radius: 22px;
}

.bottom-bar strong {
  display: block;
  font-size: 0.95rem;
  margin-bottom: 2px;
}

.bottom-bar span {
  font-size: 0.85rem;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 0.82rem;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.dot-red {
  background: #ff4d4d;
}

.dot-amber {
  background: #ffcc4d;
}

.dot-green {
  background: #48d597;
}

/* Leaflet polish */
.leaflet-container {
  background: #06111a;
  outline: none;
}

.leaflet-control-zoom {
  margin: 14px !important;
  border: none !important;
  box-shadow: var(--shadow) !important;
}

.leaflet-control-zoom a {
  width: 34px !important;
  height: 34px !important;
  border-radius: 10px !important;
  border: none !important;
  background: rgba(9, 18, 29, 0.85) !important;
  color: #fff !important;
}

.leaflet-control-zoom a:hover {
  background: rgba(21, 34, 51, 0.95) !important;
}

.quake-marker {
  position: relative;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ff4d4d;
  border: 2px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 10px rgba(255, 77, 77, 0.16);
}

.quake-marker::after {
  content: '';
  position: absolute;
  inset: -14px;
  border-radius: 50%;
  border: 1px solid rgba(255, 77, 77, 0.25);
  animation: pulse 2s ease-in-out infinite;
}

.latest-quake-icon {
  background: transparent;
  border: none;
}

.latest-quake-marker {
  position: relative;
  width: 84px;
  height: 84px;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.live-now-badge {
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 45, 45, 0.92);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.3);
  white-space: nowrap;
}

.latest-quake-core {
  position: relative;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ff2d2d;
  border: 2px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 0 0 10px rgba(255, 45, 45, 0.18);
  animation: livePulse 1.2s ease-in-out infinite;
}

.latest-quake-ripple {
  position: absolute;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: 2px solid rgba(255, 45, 45, 0.28);
  animation: ripple 1.8s ease-out infinite;
}

@keyframes pulse {
  0% {
    transform: scale(0.7);
    opacity: 0.9;
  }
  100% {
    transform: scale(1.3);
    opacity: 0;
  }
}

@keyframes livePulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 10px rgba(255, 45, 45, 0.16);
  }
  50% {
    transform: scale(1.15);
    box-shadow: 0 0 0 14px rgba(255, 45, 45, 0.26);
  }
}

@keyframes ripple {
  0% {
    transform: scale(0.45);
    opacity: 0.95;
  }
  100% {
    transform: scale(1.1);
    opacity: 0;
  }
}

@media (max-width: 1180px) {
  .topbar {
    border-radius: 28px;
    flex-direction: column;
    align-items: flex-start;
  }

  .status-cluster {
    justify-content: flex-start;
  }

  .latest-card {
    width: min(460px, calc(100vw - 36px));
  }

  .right-rail {
    width: min(320px, calc(100vw - 36px));
  }
}

@media (max-width: 980px) {
  html,
  body {
    overflow: auto;
  }

  .app-shell {
    min-height: 100vh;
    height: auto;
  }

  #map {
    position: fixed;
  }

  .topbar,
  .latest-card,
  .right-rail,
  .bottom-bar {
    position: relative;
    left: auto;
    right: auto;
    top: auto;
    bottom: auto;
    width: auto;
    margin: 14px;
  }

  .app-shell {
    display: grid;
    gap: 0;
    padding-bottom: 16px;
  }

  #map {
    height: 58vh;
    min-height: 420px;
    position: relative;
  }

  .right-rail {
    display: grid;
    width: auto;
    margin-top: 0;
  }

  .bottom-bar {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 640px) {
  .topbar,
  .latest-card,
  .right-rail,
  .bottom-bar {
    margin: 10px;
  }

  .latest-grid,
  .meta-row {
    grid-template-columns: 1fr;
  }

  .status-cluster,
  .legend {
    width: 100%;
  }

  .status-pill,
  .mini-chip,
  .legend-item {
    width: 100%;
    justify-content: center;
  }

  .feed-item {
    grid-template-columns: auto 1fr;
  }

  .feed-item .value {
    grid-column: 2;
    text-align: left;
  }
}
