:root {
  color-scheme: dark;
  --bg: #02050c;
  --panel: rgba(8, 17, 31, .68);
  --border: rgba(255, 255, 255, .12);
  --text: #f4f7fb;
  --muted: #9aa9bd;
  --accent: #55d6ff;
}

* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; background: var(--bg); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--text); }
button, select, input { font: inherit; }
button, select { color: inherit; }

#app, #globe { position: fixed; inset: 0; }
#globe canvas { display: block; width: 100%; height: 100%; cursor: grab; }
#globe canvas:active { cursor: grabbing; }

.glass {
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: 0 16px 50px rgba(0,0,0,.28);
  backdrop-filter: blur(15px) saturate(135%);
  -webkit-backdrop-filter: blur(15px) saturate(135%);
}

.topbar {
  position: absolute;
  top: max(18px, env(safe-area-inset-top));
  left: 18px;
  right: 18px;
  padding: 13px 16px;
  border-radius: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: auto;
}
.eyebrow { color: #a7d9e8; font-size: 11px; letter-spacing: .15em; font-weight: 800; }
.live-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 7px; background: #52ffa8; box-shadow: 0 0 12px #52ffa8; animation: blink 1.8s infinite; }
@keyframes blink { 50% { opacity: .4; } }
h1 { font-size: clamp(18px, 2vw, 26px); margin: 2px 0 0; font-weight: 680; letter-spacing: -.02em; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.status { color: var(--muted); font-size: 12px; }
.icon-btn, .secondary-btn {
  border: 1px solid var(--border);
  background: rgba(255,255,255,.07);
  border-radius: 10px;
  cursor: pointer;
}
.icon-btn { width: 35px; height: 35px; font-size: 20px; line-height: 1; }
.icon-btn:hover, .secondary-btn:hover { background: rgba(255,255,255,.12); }
.icon-btn.loading { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.controls {
  position: absolute;
  left: 18px;
  top: 105px;
  width: min(290px, calc(100vw - 36px));
  padding: 14px;
  border-radius: 16px;
  display: grid;
  gap: 13px;
}
.controls label > span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; }
select {
  width: 100%;
  padding: 9px 10px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: #0c1625;
  outline: none;
}
input[type="range"] { width: 100%; accent-color: var(--accent); }
.toggle-row { display: flex !important; align-items: center; gap: 9px; color: var(--text); font-size: 13px; }
.toggle-row span { margin: 0 !important; color: var(--text) !important; }
.toggle-row input { accent-color: var(--accent); }
.secondary-btn { padding: 9px 11px; font-size: 12px; }

.stats {
  position: absolute;
  right: 18px;
  top: 105px;
  border-radius: 16px;
  display: grid;
  grid-template-columns: repeat(3, minmax(86px, 1fr));
  overflow: hidden;
}
.stats > div { padding: 12px 14px; border-left: 1px solid var(--border); }
.stats > div:first-child { border-left: none; }
.stats span { display: block; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.stats strong { display: block; margin-top: 3px; font-size: 16px; }

.legend {
  position: absolute;
  left: 50%;
  bottom: 42px;
  transform: translateX(-50%);
  padding: 8px 12px;
  border-radius: 999px;
  display: flex;
  gap: 12px;
  white-space: nowrap;
  font-size: 10px;
  color: #c8d2df;
}
.legend span { display: flex; align-items: center; gap: 5px; }
.legend i { width: 8px; height: 8px; border-radius: 50%; box-shadow: 0 0 7px currentColor; }
.m1 { background: #52c7ff; color: #52c7ff; }
.m2 { background: #ffd166; color: #ffd166; }
.m3 { background: #ff9f43; color: #ff9f43; }
.m4 { background: #ff5d5d; color: #ff5d5d; }
.m5 { background: #ff2d95; color: #ff2d95; }

.events {
  position: absolute;
  right: 18px;
  top: 182px;
  width: min(290px, calc(100vw - 36px));
  max-height: min(42vh, calc(100vh - 300px));
  padding: 12px 6px 10px 12px;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  z-index: 15;
}
.events[hidden] { display: none; }
.events h2 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.event-list {
  margin: 0;
  padding: 0 6px 0 0;
  list-style: none;
  overflow-y: auto;
  display: grid;
  gap: 2px;
}
.event-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.event-item:hover { background: rgba(255,255,255,.08); }
.event-item[aria-current="true"] { background: rgba(85,214,255,.16); }
.event-item:focus-visible,
.icon-btn:focus-visible,
.secondary-btn:focus-visible,
select:focus-visible,
input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.event-mag {
  flex: none;
  width: 30px;
  font-size: 13px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.event-text { min-width: 0; display: grid; }
.event-place {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}
.event-time { color: var(--muted); font-size: 10px; }
.event-empty { margin: 2px 6px 4px 0; color: var(--muted); font-size: 11px; }
.event-empty[hidden] { display: none; }

.fatal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(2,5,12,.92);
}
.fatal[hidden] { display: none; }
.fatal-box { max-width: 440px; padding: 22px 24px; border-radius: 16px; }
.fatal-box h2 { margin: 0 0 10px; font-size: 19px; }
.fatal-box p { margin: 0 0 8px; color: #c8d2df; font-size: 13px; line-height: 1.5; }
.fatal-hint { color: var(--muted) !important; }
.fatal-box a { color: #8ee4ff; }

.quake-card {
  position: absolute;
  right: 18px;
  bottom: 78px;
  width: min(330px, calc(100vw - 36px));
  padding: 18px;
  border-radius: 16px;
}
.quake-card[hidden] { display: none; }
.card-close { position: absolute; top: 8px; right: 9px; width: 30px; height: 30px; border: 0; color: #aeb9c8; background: transparent; font-size: 24px; cursor: pointer; }
.quake-mag { display: inline-block; padding: 5px 8px; border-radius: 7px; background: rgba(255,93,93,.16); color: #ffb0b0; font-weight: 800; }
.quake-card h2 { margin: 9px 25px 12px 0; font-size: 18px; line-height: 1.25; }
dl { margin: 0 0 12px; }
dl div { display: flex; justify-content: space-between; gap: 16px; padding: 5px 0; border-bottom: 1px solid rgba(255,255,255,.07); font-size: 12px; }
dt { color: var(--muted); }
dd { margin: 0; text-align: right; }
.quake-card a { color: #8ee4ff; text-decoration: none; font-size: 12px; }

.tooltip {
  position: fixed;
  z-index: 20;
  max-width: 260px;
  padding: 7px 9px;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 8px;
  background: rgba(4,10,19,.92);
  box-shadow: 0 8px 28px rgba(0,0,0,.35);
  color: #eef7ff;
  font-size: 11px;
  pointer-events: none;
}
.tooltip[hidden] { display: none; }

.credits { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); color: rgba(213,224,237,.45); font-size: 9px; white-space: nowrap; pointer-events: none; }

@media (max-width: 760px) {
  .topbar { left: 10px; right: 10px; top: max(10px, env(safe-area-inset-top)); }
  .status { display: none; }
  .controls { top: 92px; left: 10px; width: 205px; padding: 11px; gap: 9px; }
  .stats { top: auto; right: 10px; left: 10px; bottom: 58px; grid-template-columns: repeat(3, 1fr); }
  .stats > div { padding: 9px 10px; }
  .stats strong { font-size: 14px; }
  .legend { bottom: 116px; max-width: calc(100vw - 20px); overflow-x: auto; justify-content: flex-start; }
  .quake-card { right: 10px; bottom: 128px; }
  .credits { display: none; }
  /* Auf kleinen Geräten ist die Liste ein Sheet über dem Globus; ein Listenklick schließt sie wieder. */
  .events {
    left: 10px;
    right: 10px;
    top: auto;
    bottom: 10px;
    width: auto;
    max-height: 52vh;
    z-index: 25;
  }
}
