/* MD_Danger: plain black, no theme. */

:root {
  --bg: #000;
  --card: #0e0e0e;
  --field: #161616;
  --line: #2a2a2a;
  --text: #f2f2f2;
  --dim: #9a9a9a;
  --red: #e5484d;
  --red-deep: #8f1d22;
  --orange: #b26b00;
  --green: #3ddc84;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html.i18n-wait body { visibility: hidden; }

html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

input {
  width: 100%;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  font: inherit;
  font-size: max(16px, 1rem);
  padding: 0.7rem 0.8rem;
  outline: none;
}
input::placeholder { color: var(--dim); }
input:focus { border-color: var(--text); }

.btn {
  display: inline-block;
  border: 1px solid var(--text);
  background: var(--text);
  color: #000;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.6rem 1rem;
  border-radius: 12px;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
.btn:active { transform: scale(0.97); }
.btn--ghost { background: none; color: var(--text); border-color: var(--line); }
.btn--sm { padding: 0.4rem 0.75rem; font-size: 0.82rem; border-radius: 10px; }
.btn--big { padding: 0.85rem 1rem; }

/* ---- full-screen cards ------------------------------------------------------ */

.screen { min-height: 100vh; display: grid; place-items: center; padding: 1.2rem; }
.card {
  width: min(24rem, 100%);
  padding: 1.6rem 1.3rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  text-align: center;
}
.card input { text-align: center; }
.logo { width: 4.5rem; height: 4.5rem; margin: 0 auto; }
.title { margin: 0; font-size: 1.7rem; font-weight: 700; letter-spacing: 0.02em; }
.title--bar { font-size: 1.25rem; margin-right: auto; }
.lead { margin: 0; color: var(--dim); }
.small { margin: 0; color: var(--dim); font-size: 0.8rem; }
.error { color: var(--red); min-height: 1.2em; font-size: 0.9rem; }

/* ---- main ---------------------------------------------------------------------- */

.main {
  max-width: 34rem;
  margin: 0 auto;
  padding: calc(0.8rem + var(--safe-top)) 1rem calc(1.5rem + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.bar { display: flex; align-items: center; gap: 0.6rem; }
.bar__logo { width: 1.9rem; height: 1.9rem; }
.chip {
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.35rem 0.8rem;
  cursor: pointer;
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.watch { display: flex; flex-direction: column; gap: 0.4rem; }
.ok { color: var(--green); font-size: 0.85rem; }
.warn, .update {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  font-size: 0.85rem;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 12px;
  padding: 0.55rem 0.7rem;
}
.warn span { flex: 1; }
.update { border-color: var(--green); }

/* someone is in danger right now */
.banners { display: flex; flex-direction: column; gap: 0.5rem; }
.banner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.2rem 0.4rem;
  width: 100%;
  text-align: left;
  font: inherit;
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 0.75rem 0.9rem;
  background: var(--red);
  cursor: pointer;
  animation: pulse 1.6s ease-in-out infinite;
}
.banner b { font-size: 1.05rem; }
.banner small { flex-basis: 100%; opacity: 0.9; }

/* ---- DANGER button ---------------------------------------------------------------- */

.danger { display: flex; flex-direction: column; align-items: center; gap: 0.9rem; padding: 0.6rem 0 0.2rem; }

.danger__btn, .safe {
  position: relative;
  width: min(15rem, 62vw);
  aspect-ratio: 1;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  color: #fff;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
  display: grid;
  place-items: center;
  transition: transform 0.15s ease;
}
.danger__btn {
  background: var(--red);
  box-shadow: 0 0 0 8px rgba(229, 72, 77, 0.18);
}
.danger__btn.holding, .safe.holding { transform: scale(0.95); }
.danger__btn.wait { animation: beat 0.9s ease-in-out infinite; }
.danger__label { display: flex; flex-direction: column; align-items: center; gap: 0.2rem; pointer-events: none; }
.danger__label b { font-size: clamp(1.7rem, 8vw, 2.3rem); letter-spacing: 0.08em; }
.danger__label small, .safe small { display: block; font-size: 0.8rem; letter-spacing: 0.2em; text-transform: uppercase; opacity: 0.85; }

.ring { position: absolute; inset: -2px; width: calc(100% + 4px); height: calc(100% + 4px); transform: rotate(-90deg); pointer-events: none; }
.ring circle { fill: none; stroke: #fff; stroke-width: 5; stroke-linecap: round; stroke-dasharray: 352; stroke-dashoffset: 352; }

.help { margin: 0; text-align: center; color: var(--dim); font-size: 0.88rem; max-width: 26rem; }
.help b { color: var(--text); }

/* my danger ping is running */
.alarm {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 1.2rem 1rem 1.3rem;
  border-radius: 20px;
  color: #fff;
  text-align: center;
  background: var(--red-deep);
  border: 2px solid var(--red);
  animation: pulse 1.6s ease-in-out infinite;
}
.alarm__title { font-size: 1.3rem; font-weight: 800; letter-spacing: 0.08em; }
.alarm__sub { opacity: 0.9; font-size: 0.9rem; }
.alarm__place { font-weight: 700; font-size: 1.1rem; margin-top: 0.3rem; }
.alarm__since { opacity: 0.85; font-size: 0.82rem; }
.ringok { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.4rem; font-size: 0.85rem; cursor: pointer; }
.ringok input { width: 1.1rem; height: 1.1rem; accent-color: #fff; }
.safe {
  width: min(9.5rem, 42vw);
  margin-top: 0.9rem;
  background: var(--green);
  color: #002611;
  font: inherit;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: 0.06em;
}
.safe span { pointer-events: none; }
.safe .ring circle { stroke: #002611; }
body.alarm-on { box-shadow: inset 0 0 0 4px var(--red); }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(229, 72, 77, 0.55); }
  50% { box-shadow: 0 0 0 12px rgba(229, 72, 77, 0); }
}
@keyframes beat { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }

/* ---- map + list ---------------------------------------------------------------- */

.section { display: flex; flex-direction: column; gap: 0.6rem; }
.h2 { margin: 0.4rem 0 0; font-size: 0.78rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim); font-weight: 600; }

.map { height: 42vh; min-height: 15rem; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); background: #000; z-index: 0; }
.leaflet-container { font-family: inherit; background: #000; }
.tiles--streets { filter: invert(1) hue-rotate(180deg) brightness(0.85) contrast(0.9) saturate(0.3); }
.leaflet-control-attribution { font-size: 10px; background: rgba(0, 0, 0, 0.7) !important; color: var(--dim) !important; }
.leaflet-control-attribution a { color: var(--dim) !important; }

.pinicon, .meicon { background: none; border: none; }
.me { position: relative; width: 20px; height: 20px; }
.me__dot { position: absolute; inset: 2px; border-radius: 50%; background: #3b82f6; border: 3px solid #fff; }

.dpin { position: relative; width: 36px; height: 36px; }
.dpin__dot {
  position: absolute; inset: 4px; border-radius: 50%; display: grid; place-items: center;
  background: var(--red); border: 3px solid #fff; color: #fff; font-weight: 900; font-size: 15px;
}
.dpin__ring { position: absolute; inset: -10px; border-radius: 50%; background: var(--red); opacity: 0; animation: ping 1.4s ease-out infinite; }
.dpin__name {
  position: absolute; top: 38px; left: 50%; transform: translateX(-50%); white-space: nowrap;
  font-size: 12px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--red); color: #fff;
}
.dpin--lost .dpin__dot, .dpin--lost .dpin__name { background: var(--orange); }
.dpin--ended .dpin__dot, .dpin--ended .dpin__name { background: #555; }
.dpin--ended .dpin__ring, .dpin--lost .dpin__ring { display: none; }
@keyframes ping { 0% { transform: scale(0.5); opacity: 0.6; } 100% { transform: scale(1.5); opacity: 0; } }

.acc { fill: #3b82f6; fill-opacity: 0.12; stroke: #3b82f6; stroke-opacity: 0.4; stroke-width: 1; }
.leaflet-interactive.acc--danger { fill: var(--red); stroke: var(--red); }

.dangers { display: flex; flex-direction: column; gap: 0.6rem; }
.dcard { display: flex; flex-direction: column; gap: 0.3rem; padding: 0.8rem 0.9rem; border-radius: 14px; border: 1px solid var(--red); background: #1a0607; }
.dcard--lost { border-color: var(--orange); background: #1a1203; }
.dcard--ended { border-color: var(--line); background: var(--card); opacity: 0.75; }
.dcard__head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.dcard__head b { font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { font-size: 0.68rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; padding: 0.15rem 0.5rem; border-radius: 999px; background: var(--red); color: #fff; }
.dcard--lost .tag { background: var(--orange); }
.dcard--ended .tag { background: var(--green); color: #002611; }
.dcard__place { font-weight: 600; }
.dcard small { color: var(--dim); font-size: 0.8rem; }
.dcard__actions { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.2rem; }
.ringbtn { background: var(--red); border-color: var(--red); color: #fff; }
.muted { color: var(--dim); font-size: 0.8rem; align-self: center; }
.empty { margin: 0; color: var(--dim); font-size: 0.9rem; }

/* ---- ping someone / footer ---------------------------------------------------- */

.pingform { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.pingform input { flex: 1 1 9rem; width: auto; min-width: 0; }

.foot { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; color: var(--dim); font-size: 0.78rem; text-align: center; margin-top: 0.6rem; }
.foot p { margin: 0; }
.version { font-family: ui-monospace, monospace; }
.link { background: none; border: none; color: var(--red); font: inherit; font-size: 0.82rem; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* ---- toasts ----------------------------------------------------------------------- */

.toast-stack {
  position: fixed; left: 1rem; right: 1rem; bottom: calc(1rem + var(--safe-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 0.5rem; z-index: 2000; pointer-events: none;
}
.toast {
  background: #1c1c1c; border: 1px solid var(--line); border-radius: 12px; padding: 0.6rem 0.9rem; font-size: 0.9rem;
  opacity: 0; transform: translateY(8px); transition: opacity 0.3s, transform 0.3s;
}
.toast--in { opacity: 1; transform: none; }
.toast--error { border-color: var(--red); color: #ff9a9d; }

@media (prefers-reduced-motion: reduce) {
  .alarm, .banner, .dpin__ring, .danger__btn.wait { animation: none; }
}
