/* Shared simulator styles plus the responsive rules for this layout. */
/* Theme */
:root {
  --bg: #07111f;
  --bg-soft: rgba(255, 255, 255, 0.08);
  --card: rgba(8, 18, 34, 0.86);
  --card-soft: rgba(255, 255, 255, 0.92);
  --border: rgba(154, 182, 214, 0.2);
  --text: #f7fbff;
  --muted: #d8e6f6;
  --primary: #25a7ff;
  --primary-hover: #178de0;
  --danger: #f97316;
  --danger-hover: #ea580c;
  --accent: #67e8f9;
  --shadow: 0 24px 60px rgba(2, 8, 22, 0.34);
  --radius: 20px;
  --drawer-width: min(86vw, 360px);
  --sheet-height: 72vh;
}

/* General */
.eq-simulation-toast {
  position: fixed;
  top: calc(20px + env(safe-area-inset-top));
  right: calc(20px + env(safe-area-inset-right));
  z-index: 30001;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 14px 16px;
  border: 1px solid rgba(251, 191, 36, 0.5);
  border-left: 4px solid #fbbf24;
  border-radius: 14px;
  background: #172337;
  box-shadow: 0 18px 45px rgba(2, 8, 22, 0.3);
  color: #f8fafc;
  font-size: 14px;
  line-height: 1.5;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-12px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}
.eq-simulation-toast.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}
.eq-simulation-toast[data-kind="success"] { border-color: rgba(74, 222, 128, 0.5); border-left-color: #4ade80; }
.eq-simulation-toast[data-kind="info"] { border-color: rgba(56, 189, 248, 0.5); border-left-color: #38bdf8; }
.eq-simulation-toast-message { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.eq-simulation-toast-close {
  flex: none;
  border: 0;
  padding: 0 2px;
  background: transparent;
  color: #cbd5e1;
  cursor: pointer;
  font: inherit;
  font-size: 20px;
  line-height: 1;
}
.eq-simulation-toast-close:hover { color: #fff; }
.eq-simulation-toast-close:focus-visible { outline: 2px solid #fff; outline-offset: 3px; border-radius: 3px; }
@media (prefers-reduced-motion: reduce) {
  .eq-simulation-toast { transition: none; }
}

/* Avoid extra vertical scroll caused by body padding with fixed height */
html {
  height: 100%;
  background:
    radial-gradient(1200px 680px at 10% -10%, rgba(34, 211, 238, 0.14), transparent 58%),
    radial-gradient(980px 560px at 100% 0%, rgba(37, 99, 235, 0.18), transparent 52%),
    linear-gradient(180deg, #06101d, #030914);
}
body { min-height: 100%; }
body {
  margin: 0;
  padding: 0 12px 16px;
  /* Use dynamic viewport units to avoid iOS/Android URL bar issues */
  min-height: 100vh;
  min-height: 100dvh;
  box-sizing: border-box;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  background:
    radial-gradient(1200px 600px at 18% -10%, rgba(37, 167, 255, 0.14), transparent 62%),
    radial-gradient(1000px 500px at 100% 0%, rgba(103, 232, 249, 0.08), transparent 50%),
    transparent;
  color: var(--text);
  font-family: "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}

/* Prevent horizontal scroll */
html, body { overflow-x: hidden; }

/* Prevent first-paint layout flicker on simulation page. */
body:not(.sim-ready) #layout-container {
  visibility: hidden;
}

.left-overlay { display: none; }

/* Layout */
#layout-container {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 18px;
  max-width: 12000px;
  margin: 0 auto;
}

#left-stack {
  width: 100%;
  max-width: 390px;
  display: grid;
  gap: 10px;
  flex: 0 0 390px;
  box-sizing: border-box;
}

/* Hide stray aside that reused the same id */
aside#layout-container { display: none !important; }
/* Legacy extra box is no longer used. Hide to prevent stray empty panel. */
#sidebar-extra-box { display: none !important; }
#left-sidebar {
  width: 390px;
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  overflow-y: visible;
  overflow-x: hidden;
  overscroll-behavior: auto;
  position: relative;
  top: auto;
  height: auto;
  max-height: none;
}

#left-sidebar .ls-header { display:flex; align-items:center; justify-content:center; gap:8px; padding: 12px 0; }
#left-sidebar h2 { margin: 0; font-size: 18px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }
.ls-collapse {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px;
  cursor: pointer;
  display: none; /* keep hidden (no mobile reveal) */
}
.ls-collapse:hover { background: var(--bg-soft); }
.ls-close-mobile {
  display: none;
  margin-left: auto;
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.collapsed { width: 28px !important; padding: 8px !important; }
.collapsed h2, .collapsed .ls-section { display: none !important; }
.ls-section { margin-top: 10px; }
.ls-toggle { width: 100%; text-align: left; background: var(--card); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; font-weight: 700; cursor: pointer; display:flex; align-items:center; justify-content:space-between; position: relative; overflow: hidden; }
.ls-toggle::before { content: ""; position: absolute; right: 0; top: 0; bottom: 0; width: 1.6em; background: var(--card); }
.ls-toggle::after { content: "\25B8"; /* ▸ */ position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.ls-section.open > .ls-toggle::after { content: "\25BE"; /* ▾ */ }
.ls-body { margin-top: 8px; display: none; }
.ls-section.open .ls-body { display: block; }
.ls-body .dropdown-panel { display: grid; gap: 10px; }

/* Submenu inside manual section */
.ls-sub-toggle {
  width: 100%;
  text-align: left;
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 6px;
}
.ls-sub-body { display: none; margin: 8px 0; }
.ls-sub-open + .ls-sub-body { display: block; }

/* Removed topbar styles */

/* Map */
#map-container {
  flex: 2;
  max-width: 400px;
  position: relative;
  width: 100%;
  height: 400px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02)),
    rgba(7, 16, 31, 0.72);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  box-sizing: border-box;
  overflow: hidden;
  /* Performance: isolate layout/paint to reduce scroll jank */
  contain: layout paint;
  will-change: transform;
  transform: translateZ(0);
}

/* Remove focus outline when map container is focused for keyboard control */
#map-container:focus { outline: none; }

#korea-map {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: 42% 50%;
  border-radius: calc(var(--radius) - 1px);
}

#coordinates {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(2, 6, 23, 0.55);
  border: 1px solid rgba(148, 163, 184, 0.25);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  z-index: 10;
}

/* Sidebar */
#sidebar {
  width: 256px;
  padding: 20px;
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03)), var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  overflow-y: auto;
}

#sidebar h2 {
  margin: 0 0 12px;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

#sidebar label {
  display: block;
  margin: 10px 0 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

#sidebar input,
#sidebar select,
#sidebar button {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 14px;
  font-size: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  border-radius: 10px;
  box-sizing: border-box;
}

#sidebar input:focus,
#sidebar select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.2);
}

#sidebar button {
  background: linear-gradient(180deg, var(--primary), var(--primary-hover));
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.2px;
  transition: transform 0.06s ease, box-shadow 0.2s ease, filter 0.2s ease;
  box-shadow: 0 6px 16px rgba(59,130,246,0.35);
}
#sidebar button:hover { filter: brightness(1.05); }
#sidebar button:active { transform: translateY(1px); }

/* Reset button emphasis */
#reset-simulation {
  background: linear-gradient(180deg, var(--danger), var(--danger-hover)) !important;
  box-shadow: 0 6px 16px rgba(220,53,69,0.35);
}

/* User mode toggle */
#user-mode-toggle {
  margin-bottom: 10px;
}
#user-mode-toggle #user-mode-btn {
  width: 100%;
  max-width: 220px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 10px;
  background: linear-gradient(180deg, #2563eb, #1d4ed8);
  color: #fff;
  border: none;
  border-radius: 999px;
  box-shadow: none;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}
#user-mode-toggle #user-mode-btn .mode-text {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.2px;
}
body[data-user-mode="basic"] #user-mode-btn .mode-text {
  left: 34px;
  right: auto;
}
body[data-user-mode="advanced"] #user-mode-btn .mode-text {
  left: 12px;
  right: auto;
}
body[data-user-mode="challenge"] #user-mode-btn .mode-text {
  left: 12px;
  right: auto;
}
#user-mode-toggle #user-mode-btn .mode-thumb {
  width: 22px;
  height: 22px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 3px 8px rgba(0,0,0,0.18);
  position: absolute;
  top: 3px;
  left: 3px;
  transform: translate(0, 0);
  transition: transform 0.2s ease, background 0.2s ease;
}
body[data-user-mode="basic"] #user-mode-btn {
  background: linear-gradient(180deg, #2563eb, #1d4ed8);
  color: #fff;
  box-shadow: none;
}
body[data-user-mode="basic"] #user-mode-btn .mode-thumb {
  left: 4px;
  right: auto;
  transform: translateX(0);
}
body[data-user-mode="advanced"] #user-mode-btn {
  background: linear-gradient(180deg, #f8fafc, #e2e8f0);
  color: #334155;
  box-shadow: none;
}
body[data-user-mode="advanced"] #user-mode-btn .mode-thumb {
  left: calc(50% - 11px);
  right: auto;
  transform: translateX(0);
}
body[data-user-mode="challenge"] #user-mode-btn {
  background: linear-gradient(180deg, #64748b, #475569);
  color: #fff;
  box-shadow: none;
}
body[data-user-mode="challenge"] #user-mode-btn .mode-thumb {
  left: auto;
  right: 4px;
  transform: translateX(0);
}

/* Sidebar mode label */
.mode-label {
  display: inline-block;
  margin-right: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
  line-height: 1.2;
  background: #e2e8f0;
  color: #1f2937;
  vertical-align: middle;
}
.mode-label.basic {
  background: #e2f7ec;
  color: #166534;
}
.mode-label.advanced {
  background: #fee2e2;
  color: #991b1b;
}
.mode-label.challenge {
  background: #111827;
  color: #f9fafb;
}

/* Mode-based visibility helpers */
body[data-user-mode="basic"] .advanced-only {
  display: none !important;
}
body[data-user-mode="advanced"] .basic-only {
  display: none !important;
}
body[data-user-mode="challenge"] .advanced-only {
  display: none !important;
}

body[data-user-mode="advanced"] #epicenter-location {
  display: none !important;
}
body[data-user-mode="basic"] #toggle-epicenter-click {
  display: none !important;
}
/* Requested: hide epicenter-click button from right settings UI */
#toggle-epicenter-click {
  display: none !important;
}
html[data-site-theme="light"] #toggle-observer-info {
  color: #fff !important;
}
body[data-user-mode="challenge"] #toggle-epicenter-click,
body[data-user-mode="challenge"] #toggle-observer-info {
  display: none !important;
}
body[data-user-mode="challenge"] #preset-dock {
  display: none !important;
}
body[data-user-mode="challenge"] #eq-info-panel {
  display: none !important;
}
body[data-user-mode="challenge"] #manual-stations {
  display: none !important;
}
body[data-user-mode="challenge"] #map-epicenter-hint {
  display: none !important;
}
body[data-user-mode="challenge"] .report-panel.report-floating-window.report-left-slot {
  display: none !important;
}
body[data-user-mode="challenge"] #map-extra-slot .map-action[data-click-target="reset-simulation-img"],
body[data-user-mode="challenge"] #map-extra-slot .map-action[data-click-target="share-link-img"],
body[data-user-mode="challenge"] #map-extra-slot .map-action[data-click-target="download-pdf-img"],
body[data-user-mode="challenge"] #start-simulation {
  display: none !important;
}
body[data-user-mode="advanced"] #eq-info-panel {
  padding-top: 8px;
  padding-bottom: 8px;
}

/* Station lookup (advanced-only, right sidebar) */
.station-lookup {
  margin-bottom: 12px;
}
.station-lookup label {
  font-weight: 600;
  display: block;
  margin-bottom: 6px;
}
.station-lookup-row {
  display: flex;
  gap: 6px;
  align-items: center;
}
.station-lookup-row input {
  flex: 1 1 auto;
  min-width: 0;
  height: 38px;
  box-sizing: border-box;
  margin: 0 !important;
}
.station-lookup-row button {
  height: 38px;
  padding: 0 12px;
  box-sizing: border-box;
  margin: 0 !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: #f8fafc;
  font-weight: 600;
  cursor: pointer;
}
.station-lookup-output {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  font-size: 13px;
  line-height: 1.45;
  color: #111827;
}
.station-lookup-output.error {
  border-color: #fecaca;
  background: #fff1f2;
  color: #991b1b;
}
.station-lookup-title {
  font-weight: 700;
  margin-bottom: 4px;
}
.station-lookup-placeholder {
  color: #6b7280;
}

/* Dim only the inputs when locked */
#settings input:disabled,
#settings select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.inline-toggle #user-mode-btn {
  min-width: 112px;
  width: 136px;
  max-width: 150px;
  height: 32px;
  padding: 0 8px;
  box-shadow: 0 4px 12px rgba(34,197,94,0.25);
}
.inline-toggle #user-mode-btn .mode-thumb {
  width: 24px;
  height: 24px;
  top: 4px;
  left: 4px;
}
.inline-toggle { display: inline-flex; transform: translateY(2px); }
.inline-toggle #user-mode-btn .mode-text { font-size: 12px; }

/* Preset list */
.preset-list {
  display: grid;
  gap: 8px;
}

.preset-dock {
  width: 100%;
  position: relative;
  padding: 12px 12px 10px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 12px;
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.12);
  box-sizing: border-box;
}

.preset-dock-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  padding-right: 62px;
}

.preset-dock-head strong {
  color: #0f172a;
  font-size: 14px;
  font-weight: 900;
}

#preset-more-btn,
#preset-floating-close {
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 8px;
  background: #f8fafc;
  color: #0f172a;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

#preset-more-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 7px;
  min-height: 24px;
}

.preset-random-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
}

.preset-random-list .preset-item {
  display: none;
}

.preset-random-list .preset-item.is-featured {
  display: block;
}

.preset-dock .preset-item {
  padding: 5px 8px;
  border-radius: 7px;
  box-shadow: none;
}

.preset-dock .preset-title {
  font-size: 12px;
  line-height: 1.2;
}

.preset-dock .preset-meta {
  font-size: 10px;
  line-height: 1.25;
  margin-top: 2px;
}

#eq-info-panel {
  width: 100%;
  max-width: 390px;
  margin-top: 10px;
  box-sizing: border-box;
  overflow: hidden;
}

#challenge-mode-slot .ls-section {
  margin: 6px 0 12px 0;
}

#preset-dock,
body .report-panel.report-floating-window.report-left-slot {
  box-sizing: border-box;
}

.hazard-head-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 178px));
  justify-content: flex-start;
  gap: 6px;
}

.preset-floating-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.36);
  z-index: 14000;
}

.preset-floating-panel {
  position: fixed;
  left: 50%;
  top: 50%;
  width: min(92vw, 460px);
  max-height: min(78vh, 680px);
  transform: translate(-50%, -50%);
  padding: 14px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 28px 70px rgba(15, 23, 42, 0.28);
  z-index: 14010;
  box-sizing: border-box;
  overflow: auto;
}

.preset-floating-head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 28px;
  margin-bottom: 10px;
  padding-right: 36px;
}

.preset-floating-head h3 {
  margin: 0;
  color: #0f172a;
  font-size: 15px;
  font-weight: 900;
}

#preset-floating-close {
  position: absolute;
  top: 0;
  right: 0;
  width: 28px;
  height: 28px;
  padding: 0;
}

.preset-floating-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.preset-floating-list .preset-item {
  padding: 7px 9px;
  border-radius: 8px;
  box-shadow: none;
}

.preset-floating-list .preset-title {
  font-size: 12px;
  line-height: 1.2;
}

.preset-floating-list .preset-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px 8px;
  margin-top: 3px;
  font-size: 10px;
  line-height: 1.3;
}

.preset-item {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid rgba(154, 182, 214, 0.22);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(241,245,249,0.98));
  color: #0f172a;
  box-shadow: 0 14px 24px rgba(2, 8, 22, 0.12);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.16s ease, filter 0.12s ease, border-color 0.12s ease;
}
.preset-item:hover {
  filter: brightness(1.01);
  box-shadow: 0 18px 28px rgba(2, 8, 22, 0.16);
  border-color: rgba(37, 167, 255, 0.35);
}
.preset-item:active { transform: translateY(1px); }
.preset-title { font-weight: 900; color: #0f172a; }
.preset-meta { font-size: 12px; color: #475569; margin-top: 4px; line-height: 1.55; }

/* Sidebar preset toggle button (keep white, remove neon) */
.preset-toggle {
  background: rgba(255, 255, 255, 0.96) !important;
  color: #0f172a !important;
  border: 1px solid rgba(154, 182, 214, 0.24) !important;
  border-radius: 14px;
  box-shadow: 0 10px 18px rgba(2, 8, 22, 0.1) !important;
}

/* Epicenter & Observer */
.epicenter, .observer {
  position: absolute;
  transform: translate(-50%, -50%);
}
.epicenter {
  width: 20px;
  height: 20px;
  z-index: 20;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.45));
}
.observer {
  width: 10px;
  height: 10px;
  z-index: 15;
    box-sizing: border-box;
    background: transparent;
    color: var(--text);
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    z-index: 20000;
}

/* Epicenter input */
#epicenter-input {
  margin: 10px 0 16px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(154, 182, 214, 0.16);
  border-radius: 16px;
}
#epicenter-input .epicenter-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
#epicenter-input .epicenter-field {
  flex: 1 1 0;
  min-width: 0;
}
#epicenter-input .epicenter-field label {
  display: block;
  margin-bottom: 6px;
}
#epicenter-input input {
  width: 100%;
  margin-bottom: 10px;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.96);
  color: #0f172a;
}
#epicenter-input button {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(180deg, var(--primary), var(--primary-hover));
  border: none;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(59,130,246,0.35);
}
#epicenter-input button:hover { filter: brightness(1.05); }
body[data-user-mode="advanced"] #epicenter-input input {
  margin-bottom: 0;
}
body[data-user-mode="advanced"] #epicenter-input .epicenter-row {
  margin-bottom: 10px;
}

/* Speed control in map extra slot */
#map-extra-slot .speed-control {
  order: 3;
  flex: 0 0 100%;
  min-width: 200px;
  max-width: 300px;
  width: 100%;
  margin: 8px 0 0 !important;
  text-align: center;
}
#map-extra-slot .speed-control label { text-align: center; }
#map-extra-slot .speed-row { justify-content: center; }
#map-extra-slot #speed-slider {
  width: 100%;
  max-width: 100%;
}
#map-extra-slot .speed-display-text {
  font-size: 13px;
}

/* Waves */
.p-wave, .s-wave {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  border: 1px solid #ffffff;
}

.t-wave {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  border: 3px solid #1d4ed8;
  box-shadow: 0 0 18px rgba(29, 78, 216, 0.65);
  background: transparent;
  z-index: 955;
}
/* Controls */
#controls {
  margin-top: 12px;
  text-align: center;
  padding: 10px 12px;
  background: var(--card-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
#elapsed-time { font-weight: 800; color: var(--text); }

#speed-slider {
  width: 320px;
  max-width: 80vw;
  margin: 10px auto;
  appearance: none;
  height: 8px;
  background: linear-gradient(90deg, #22c55e 0%, #ef4444 100%);
  border-radius: 999px;
  outline: none;
}
#speed-slider::-webkit-slider-runnable-track {
  height: 8px;
  background: linear-gradient(90deg, #22c55e 0%, #ef4444 100%);
  border-radius: 999px;
}
#speed-slider::-moz-range-track {
  height: 8px;
  background: linear-gradient(90deg, #22c55e 0%, #ef4444 100%);
  border-radius: 999px;
}
#speed-slider::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #111827;
  box-shadow: 0 4px 12px rgba(0,0,0,0.35);
}
#speed-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #111827;
  box-shadow: 0 4px 12px rgba(0,0,0,0.35);
}

/* Report */
#report-container {
  flex: 1;
  width: 100%;
  max-width: none;
  box-sizing: border-box;
  padding: 14px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03)), var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

/* Settings cards */
.setting-card {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(154, 182, 214, 0.16);
  border-radius: 16px;
  padding: 10px;
  margin-bottom: 10px;
}
.setting-card.setting-dual {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: end;
}
.setting-card label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--muted);
}
#report-container h2 {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 700;
  text-align: center;
}
#report-content p { margin: 6px 0; font-size: 14px; color: var(--muted); }

/* Manual stations */
#manual-stations {
  margin-top: 20px;
  padding: 16px 16px 14px;
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03)), var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: grid;
  gap: 10px;
}
.manual-disabled {
  opacity: 0.6;
  pointer-events: none;
  filter: saturate(0.2);
}
/* Hide manual panel only in the right sidebar; allow it in KES left */
#sidebar #manual-stations { display: none !important; }
#manual-stations h3 { margin: 0; font-size: 16px; font-weight: 800; color: var(--text); }
.manual-header { display:flex; align-items:center; gap:10px; justify-content: space-between; }
.manual-pill { padding: 6px 10px; background: #ecfeff; color: #0ea5e9; border: 1px solid #bae6fd; border-radius: 999px; font-weight: 700; font-size: 12px; }
.manual-subtitle { margin: 0; font-size: 13px; color: var(--muted); }
.manual-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-items: center;
}
.manual-grid .full-span { grid-column: 1 / 3; }
.manual-grid label { font-size: 12px; font-weight: 700; color: var(--muted); }
.manual-grid input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card-soft);
  box-sizing: border-box;
}
.manual-grid input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.18); }
.manual-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.manual-actions button {
  flex: 1 1 160px;
  margin: 0;
}
.manual-actions .ghost {
  background: var(--bg-soft) !important;
  color: var(--text);
  border: 1px solid var(--border) !important;
  box-shadow: none !important;
}
.manual-list {
  margin-top: 4px;
  max-height: 180px;
  overflow: auto;
  border: 1px dashed rgba(154, 182, 214, 0.24);
  padding: 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
}
#manual-stations-list button,
button[data-remove-index] {
  background: linear-gradient(180deg, var(--danger), var(--danger-hover)) !important;
  color: #fff !important;
  border: none !important;
  padding: 6px 10px !important;
  border-radius: 8px !important;
  box-shadow: 0 4px 12px rgba(220,53,69,0.35);
}

/* Scrollbar */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: rgba(30,41,59,0.6); }
*::-webkit-scrollbar-thumb { background: rgba(148,163,184,0.35); border-radius: 999px; }

/* === Station Info Popup (JS-created) === */
.station-popup {
  position: absolute;
  min-width: 110px; /* ~50% of previous 220px */
  max-width: 140px; /* ~50% of previous 280px */
  background: #ffffff;
  border: 1px solid #e5e7eb;
  box-shadow: 0 6px 18px rgba(0,0,0,0.15);
  border-radius: 8px;
  padding: 5px 6px;
  font-size: 10px;
  line-height: 1.3;
  z-index: 3000;
  pointer-events: auto;
}

.station-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.station-popup-title {
  font-size: 11px;
  font-weight: 700;
}

.station-popup-close {
  border: none;
  background: transparent;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  color: #9ca3af;
}

/* === Wave visuals (shared properties; color set in JS) === */
.p-wave, .s-wave {
  position: absolute;
  border-radius: 50%;
  opacity: 0.5;
  pointer-events: none;
  z-index: 1000;
  box-sizing: border-box;
}

/* Distinct borders for P/S waves */
.p-wave { border: 2px solid blue; }
.s-wave { border: 2px solid red; }

/* Left sidebar banner (title-underline slot) */
.ls-banner {
  margin: 6px 0 12px 0;
  padding: 10px 12px;
  border: 1px dashed rgba(154, 182, 214, 0.24);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
}
.ls-banner-title {
  font-weight: 800;
  color: #ffffff;
  margin-bottom: 4px;
  font-size: 15px;
}
.ls-banner-body {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
}

/* Left sidebar banner (title-underline slot) */
.ls-banner {
  margin: 6px 0 12px 0;
  padding: 10px 12px;
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  background: #f8fafc;
}
.ls-banner-title {
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 4px;
  font-size: 15px;
}
.ls-banner-body {
  font-size: 13px;
  color: #475569;
  line-height: 1.45;
}
.top-pga-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(154, 182, 214, 0.22);
  border-radius: 14px;
  box-shadow: 0 12px 22px rgba(2, 8, 22, 0.12);
}
.top-pga-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: #e2e8f0;
  background-size: cover;
  background-position: center;
  border: 1px solid #cbd5e1;
  flex-shrink: 0;
}
.top-pga-text { display:flex; flex-direction:column; gap:2px; }
.top-pga-label { font-size:12px; color:#475569; font-weight:700; }
.top-pga-value { font-size:14px; color:#0f172a; font-weight:800; }
.top-pga-desc.fineprint { color:#94a3b8; font-size:11px; }
.city-shake-wrap {
  margin-top: 10px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  background: #e2e8f0;
}
.city-shake {
  display: block;
  width: 100%;
  height: auto;
  --shake-amp: 0px;
  transform-origin: center;
}
@keyframes city-shake {
  0%   { transform: translate3d(calc(var(--shake-amp) * -0.35), calc(var(--shake-amp) * -0.1), 0) rotate(-0.4deg); }
  25%  { transform: translate3d(calc(var(--shake-amp) * 0.6),  calc(var(--shake-amp) * 0.25), 0) rotate(0.3deg); }
  50%  { transform: translate3d(calc(var(--shake-amp) * -0.45), calc(var(--shake-amp) * 0.3), 0) rotate(-0.25deg); }
  75%  { transform: translate3d(calc(var(--shake-amp) * 0.55), calc(var(--shake-amp) * -0.25), 0) rotate(0.35deg); }
  100% { transform: translate3d(calc(var(--shake-amp) * -0.35), calc(var(--shake-amp) * -0.1), 0) rotate(-0.4deg); }
}
.tsunami-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(154, 182, 214, 0.22);
  border-radius: 14px;
  box-shadow: 0 12px 22px rgba(2, 8, 22, 0.12);
}
.tsunami-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: #e2e8f0;
  background-size: cover;
  background-position: center;
  border: 1px solid #cbd5e1;
  flex-shrink: 0;
}
.tsunami-text { display:flex; flex-direction:column; gap:2px; }
.tsunami-label { font-size:12px; color:#475569; font-weight:700; }
.tsunami-value { font-size:14px; color:#0f172a; font-weight:800; }
.tsunami-desc { color:#64748b; font-size:12px; }
.tsunami-photo {
  margin-top: 10px;
  position: relative;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  background: #e2e8f0;
}
.tsunami-photo img {
  display: block;
  width: 100%;
  height: auto;
}
.tsunami-photo-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--wave-height, 0px);
  /* Uniform fill (no upward gradient) so the blue shape looks solid as it rises */
  background: rgba(59,130,246,0.28);
  pointer-events: none;
  transition: height 180ms ease;
}
.briefing-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  background: var(--card);
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 30px rgba(17, 24, 39, 0.12);
  z-index: 3000;
  transform: translateY(0%);
  transition: transform 240ms ease, opacity 240ms ease;
}
.briefing-inline {
  position: static;
  left: auto; right: auto; bottom: auto;
  /* Full width of parent container */
  display: block;
  width: 100%;
  border: 1px solid rgba(154, 182, 214, 0.2);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-top: 16px;
  transform: none;
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03)), var(--card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.briefing-hidden { transform: translateY(110%); opacity: 0; pointer-events: none; }
.briefing-inner {
  max-width: 100%;
  margin: 0 auto;
  padding: 10px 14px;
  min-height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center; /* center horizontally */
  justify-content: center; /* center vertically */
  gap: 4px;
}
.briefing-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; align-items: center; width: 100%; }
.briefing-title { font-weight: 800; font-size: 14px; color: var(--text); text-align: center; }
.briefing-body {
  color: var(--muted);
  font-size: 13px;
  /* Allow multiline so height can grow; keep width fixed */
  white-space: pre-line; /* preserve newlines as line breaks */
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: anywhere;
}

/* Colored lines by MMI level for briefing */
.briefing-body .brief-line {
  display: block;
  margin: 2px 0;
}
.briefing-body .brief-line strong { color: var(--text); }
.brief-lvl-11 { color: #b91c1c; font-weight: 700; } /* deep red */
.brief-lvl-10 { color: #dc2626; font-weight: 700; }
.brief-lvl-9  { color: #f97316; font-weight: 700; }
.brief-lvl-8  { color: #fb923c; font-weight: 700; }
.brief-lvl-7  { color: #f59e0b; font-weight: 700; }
.brief-lvl-6  { color: #ca8a04; font-weight: 700; }
.brief-lvl-5  { color: #475569; font-weight: 700; }

/* Earthquake simulator visual polish */
.map-top-info {
  padding: 12px 14px !important;
  border: 1px solid rgba(154, 182, 214, 0.18);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.88), rgba(241,245,249,0.95));
  box-shadow: 0 16px 30px rgba(2, 8, 22, 0.14);
}

.map-extra-slot {
  border: 1px solid rgba(154, 182, 214, 0.2) !important;
  border-radius: 18px !important;
  background: linear-gradient(180deg, rgba(255,255,255,0.94), rgba(241,245,249,0.98)) !important;
  box-shadow: 0 18px 34px rgba(2, 8, 22, 0.14);
}

.share-image-icon {
  border-radius: 12px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 10px 18px rgba(2, 8, 22, 0.12);
}

.challenge-panel,
.challenge-mode-card,
.preset-block,
.sidebar-extra {
  border-radius: 16px !important;
  border: 1px solid rgba(154, 182, 214, 0.2) !important;
  box-shadow: 0 14px 26px rgba(2, 8, 22, 0.12);
}

.challenge-panel,
.challenge-mode-card,
.preset-block {
  background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(241,245,249,0.98)) !important;
}

.challenge-result,
#challenge-pga-target {
  border-radius: 12px !important;
  background: linear-gradient(180deg, #f8fbff, #eef5ff) !important;
  border: 1px solid rgba(154, 182, 214, 0.2) !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.7);
}

.challenge-mode-card.active {
  border-color: rgba(37, 167, 255, 0.5) !important;
  background: linear-gradient(180deg, #eef7ff, #dfeeff) !important;
  box-shadow: 0 18px 30px rgba(37, 99, 235, 0.16) !important;
}

.speed-control label,
.speed-display-text {
  color: #0f172a !important;
  font-weight: 800;
}

#coordinates {
  color: #eff6ff;
  box-shadow: 0 10px 18px rgba(2, 8, 22, 0.22);
}

/* Deeper polish for the earthquake simulator */
#layout-container {
  gap: 18px !important;
  align-items: stretch;
}

#left-sidebar,
#sidebar,
.report-panel,
#report-container {
  position: relative;
}

#left-sidebar::before,
#sidebar::before,
.report-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0)),
    radial-gradient(320px 140px at 0% 0%, rgba(37, 167, 255, 0.08), transparent 70%);
}

#left-sidebar,
#sidebar,
.report-panel {
  overflow: hidden;
}

#left-sidebar .ls-header,
#sidebar h2 {
  position: relative;
  z-index: 1;
}

#left-sidebar .ls-header {
  margin-bottom: 8px;
  padding: 10px 0 14px;
}

#left-sidebar h2,
#sidebar h2,
#report-container h2 {
  color: #ffffff;
  letter-spacing: -0.02em;
}

.ls-toggle {
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.94);
  color: #0f172a;
  border: 1px solid rgba(154, 182, 214, 0.22);
  box-shadow: 0 12px 22px rgba(2, 8, 22, 0.1);
  font-weight: 800;
}

.ls-section.open > .ls-toggle {
  border-color: rgba(37, 167, 255, 0.34);
  box-shadow: 0 16px 26px rgba(37, 99, 235, 0.12);
}

.mode-label {
  box-shadow: 0 10px 18px rgba(2, 8, 22, 0.12);
}

#map-container {
  border-radius: 24px;
  border: 1px solid rgba(154, 182, 214, 0.24);
  box-shadow:
    0 30px 50px rgba(2, 8, 22, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

#map-container::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    radial-gradient(220px 160px at 14% 8%, rgba(37, 167, 255, 0.12), transparent 65%),
    linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0));
  z-index: 1;
}

#korea-map {
  filter: saturate(1.04) contrast(1.03);
}

.map-top-info {
  gap: 8px !important;
  font-size: 14px;
  font-weight: 800;
}

.map-top-info span {
  color: #0f4bcf;
}

.map-extra-slot {
  gap: 10px !important;
  min-height: 78px !important;
}

.icon-group {
  gap: 8px !important;
}

.share-image-icon {
  transition: transform 0.14s ease, box-shadow 0.16s ease, filter 0.14s ease !important;
}

.share-image-icon:hover {
  box-shadow: 0 16px 28px rgba(2, 8, 22, 0.18);
  filter: brightness(1.03);
}

#back-to-sim-btn,
.challenge-actions .ghost-btn,
#challenge-cancel-btn {
  box-shadow: 0 12px 22px rgba(2, 8, 22, 0.1) !important;
}

.challenge-panel {
  padding: 12px !important;
}

.challenge-status {
  color: #334155 !important;
}

.challenge-mode-card strong {
  font-size: 14px !important;
  font-weight: 900 !important;
}

.challenge-mode-card p {
  line-height: 1.55 !important;
}

.challenge-pill {
  background: linear-gradient(180deg, #e0f2fe, #dbeafe);
  border: 1px solid rgba(37, 167, 255, 0.2);
  box-shadow: 0 8px 14px rgba(37, 99, 235, 0.08);
}

.challenge-result,
#challenge-pga-target {
  font-size: 13px !important;
  line-height: 1.7 !important;
}

#settings,
#epicenter-input,
.preset-block,
#manual-stations {
  box-shadow: 0 18px 34px rgba(2, 8, 22, 0.14);
}

#report-content p,
.manual-subtitle,
.station-lookup-placeholder,
.briefing-body {
  color: var(--muted);
}

#report-container {
  border-radius: 22px;
}

#report-container::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0)),
    radial-gradient(260px 140px at 0% 0%, rgba(37, 167, 255, 0.08), transparent 68%);
}

.briefing-inline {
  overflow: hidden;
}

.briefing-title {
  color: #ffffff;
  font-size: 15px;
}

/* Sidebar redesign */
#left-sidebar,
#sidebar {
  padding: 18px !important;
}

#left-sidebar {
  border-radius: 28px;
}

#sidebar {
  border-radius: 28px;
}

#left-sidebar .ls-header {
  justify-content: space-between;
  align-items: center;
  padding-bottom: 16px;
  margin-bottom: 10px;
  border-bottom: 1px solid rgba(154, 182, 214, 0.14);
}

#left-sidebar h2 {
  font-size: 20px;
  font-weight: 900;
  text-align: left;
}

#sidebar h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  font-size: 22px;
  font-weight: 900;
}

.ls-section {
  margin-top: 12px;
}

.ls-body {
  margin-top: 10px;
}

.ls-banner,
#settings,
#epicenter-input,
.preset-block,
#manual-stations,
.challenge-panel,
.challenge-mode-card,
.station-lookup-output,
.setting-card {
  border-radius: 18px !important;
}

#sidebar label,
.challenge-guess-grid label,
.challenge-pga-input label,
.manual-grid label,
.station-lookup label {
  color: #eff6ff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.01em;
}

#sidebar input,
#sidebar select,
#sidebar button,
#epicenter-input input,
.challenge-guess-grid input,
.challenge-pga-input input,
.manual-grid input,
.station-lookup-row input,
.station-lookup-row button {
  border-radius: 14px !important;
}

#sidebar input,
#sidebar select,
#epicenter-input input,
.challenge-guess-grid input,
.challenge-pga-input input,
.manual-grid input,
.station-lookup-row input {
  min-height: 42px;
  padding: 11px 13px !important;
  border: 1px solid rgba(154, 182, 214, 0.22) !important;
  background: rgba(255, 255, 255, 0.97) !important;
  color: #0f172a !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.68);
}

#sidebar input::placeholder,
#epicenter-input input::placeholder,
.challenge-guess-grid input::placeholder,
.challenge-pga-input input::placeholder,
.manual-grid input::placeholder,
.station-lookup-row input::placeholder {
  color: #64748b;
}

#sidebar button,
#epicenter-input button,
.manual-actions button,
.challenge-actions button,
.station-lookup-row button {
  min-height: 42px;
  font-weight: 800 !important;
  letter-spacing: 0.01em;
}

#sidebar .ghost,
.challenge-actions .ghost-btn,
#back-to-sim-btn,
.station-lookup-row button {
  background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(241,245,249,0.98)) !important;
  color: #0f172a !important;
  border: 1px solid rgba(154, 182, 214, 0.22) !important;
}

.preset-toggle,
.ls-toggle {
  min-height: 44px;
  padding: 10px 14px !important;
}

.preset-title {
  font-size: 14px;
  letter-spacing: -0.01em;
}

.preset-meta {
  font-size: 12px;
  line-height: 1.62;
}

.challenge-panel {
  padding: 14px !important;
}

.challenge-actions {
  gap: 10px !important;
}

.challenge-status,
.manual-subtitle,
.station-lookup-output,
.challenge-result {
  font-size: 13px !important;
}

.station-lookup-output,
.challenge-result,
#challenge-pga-target {
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.75);
}

#manual-stations-list {
  border-radius: 14px;
}

#manual-stations-list em {
  color: var(--muted);
}

.ls-collapse,
.ls-close-mobile {
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  color: #0f172a;
  border: 1px solid rgba(154, 182, 214, 0.22);
  box-shadow: 0 10px 18px rgba(2, 8, 22, 0.1);
}

/* Dark text on light surfaces */
.map-top-info,
.map-top-info div,
.map-top-info span,
.map-extra-slot,
.preset-item,
.preset-title,
.preset-meta,
.preset-toggle,
.challenge-panel,
.challenge-panel strong,
.challenge-panel p,
.challenge-mode-card,
.challenge-mode-card strong,
.challenge-mode-card p,
.challenge-status,
.challenge-pill,
.challenge-result,
#challenge-pga-target,
.station-lookup-output,
.station-lookup-title,
.station-lookup-placeholder,
.ls-collapse,
.ls-close-mobile,
#back-to-sim-btn,
.ghost-btn,
.station-lookup-row button,
.manual-pill {
  color: #0f172a !important;
}

.challenge-pill,
.manual-pill {
  color: #075985 !important;
}

#left-sidebar h2,
#sidebar h2,
#report-container h2,
.briefing-title {
  color: #0f172a !important;
}

#magnitude-depth-row label,
.param-field label,
#station-lookup label,
label[for="scale"] {
  color: #0f172a !important;
}

#magnitude-depth-row {
  display: grid !important;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: start;
}

#magnitude-depth-row .param-field {
  display: grid;
  grid-template-rows: auto auto;
  gap: 6px;
  min-width: 0;
}

#magnitude-depth-row .param-field input[type="number"] {
  margin-bottom: 0 !important;
}

.mobile-actions {
  display: none;
}

/* UI/UX refresh: map-first simulator workspace */
:root {
  --shadow: 0 14px 30px rgba(2, 8, 22, 0.18);
  --radius: 12px;
}

html {
  background:
    linear-gradient(180deg, #07111f 0%, #0b1524 52%, #f1f5f9 52%, #e8eef6 100%);
}

body {
  padding: 0 14px 18px;
  background: transparent;
}

#layout-container {
  width: 100%;
  max-width: 1420px;
  margin: 0 auto !important;
  gap: 14px !important;
}

#left-sidebar,
#sidebar,
.report-panel,
#report-container,
.map-top-info,
.map-extra-slot {
  border-radius: 12px !important;
}

#left-sidebar,
#sidebar {
  background: rgba(255, 255, 255, 0.94) !important;
  border: 1px solid rgba(148, 163, 184, 0.28) !important;
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.12) !important;
  color: #0f172a !important;
}

#left-sidebar::before,
#sidebar::before,
.report-panel::before,
#report-container::before,
#map-container::before {
  display: none !important;
}

#left-sidebar h2,
#sidebar h2,
#report-container h2,
.briefing-title {
  color: #0f172a !important;
  letter-spacing: 0 !important;
}

#left-sidebar .ls-header {
  padding: 4px 0 12px !important;
  margin-bottom: 8px !important;
  border-bottom: 1px solid rgba(148, 163, 184, 0.22) !important;
}

#left-sidebar h2,
#sidebar h2 {
  font-size: 18px !important;
  line-height: 1.25;
}

.ls-section {
  margin-top: 8px !important;
}

.ls-body {
  margin-top: 7px !important;
}

.ls-toggle,
.preset-toggle {
  min-height: 38px !important;
  padding: 8px 12px !important;
  border-radius: 8px !important;
  background: #f8fafc !important;
  border: 1px solid rgba(148, 163, 184, 0.26) !important;
  box-shadow: none !important;
  color: #0f172a !important;
  font-weight: 800 !important;
}

.ls-section.open > .ls-toggle {
  background: #eef6ff !important;
  border-color: rgba(37, 99, 235, 0.26) !important;
  box-shadow: none !important;
}

.ls-banner,
#settings,
#epicenter-input,
.preset-block,
#manual-stations,
.challenge-panel,
.challenge-mode-card,
.station-lookup-output,
.setting-card {
  border-radius: 10px !important;
  box-shadow: none !important;
}

.ls-banner,
#settings,
#epicenter-input,
.preset-block,
.challenge-panel {
  background: #ffffff !important;
  border: 1px solid rgba(148, 163, 184, 0.22) !important;
}

.top-pga-box,
.tsunami-box {
  border-radius: 10px !important;
}

.city-shake-wrap,
.tsunami-photo {
  border-radius: 10px !important;
  overflow: hidden;
}

.map-top-info {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px !important;
  width: 100%;
  max-width: 440px;
  order: 0;
  margin-bottom: 10px;
  padding: 10px 12px !important;
  background: rgba(255, 255, 255, 0.96) !important;
  border: 1px solid rgba(148, 163, 184, 0.24) !important;
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.1) !important;
  color: #0f172a !important;
}

.map-top-info div {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#map-container {
  width: 100% !important;
  max-width: 440px !important;
  aspect-ratio: 1 / 1;
  height: auto !important;
  margin: 0 auto;
  order: 1;
  border-radius: 14px !important;
  border: 1px solid rgba(15, 23, 42, 0.16) !important;
  box-shadow: 0 20px 34px rgba(15, 23, 42, 0.2) !important;
}

#korea-map {
  border-radius: 13px !important;
  transition: transform 0.12s ease;
  -webkit-user-drag: none;
  user-select: none;
  -webkit-user-select: none;
}

.map-epicenter-hint {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2000;
  max-width: min(72%, 260px);
  padding: 7px 9px;
  border: 1px solid rgba(37, 99, 235, 0.22);
  border-radius: 8px;
  background: rgba(239, 246, 255, 0.94);
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.25;
  text-align: right;
  pointer-events: none;
}

.map-epicenter-hint.is-hidden {
  display: none;
}

.map-legend {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 2000;
  display: grid;
  gap: 3px;
  min-width: 74px;
  padding: 6px 7px;
  border: 1px solid rgba(148, 163, 184, 0.32);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  color: #334155;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.1;
  pointer-events: auto;
  cursor: default;
}

.map-legend div {
  display: flex;
  align-items: center;
  gap: 5px;
}

.map-zoom-controls {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2100;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(2, 6, 23, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.map-zoom-controls button {
  width: 28px;
  height: 28px;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 7px;
  background: rgba(15, 23, 42, 0.85);
  color: #f8fafc;
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}

.map-zoom-controls button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

#map-zoom-level {
  min-width: 44px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: #e2e8f0;
}

#map-container {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#map-container img {
  -webkit-user-drag: none;
  user-select: none;
  -webkit-user-select: none;
}

#map-container.is-map-dragging #korea-map {
  transition: none;
}

#observer-canvas {
  position: absolute;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  transform: translate3d(0, 0, 0);
}

#map-container.observer-info-active {
  cursor: pointer;
}

/* The manual-stations card is placed directly in #left-stack. */
body #left-sidebar {
  display: none !important;
}

body .report-panel.report-floating-window.report-left-slot {
  display: block !important;
  position: relative !important;
  right: auto !important;
  bottom: auto !important;
  width: 100% !important;
  max-width: 390px !important;
  min-height: 0 !important;
  height: auto !important;
  max-height: none !important;
  overflow: auto !important;
  z-index: auto !important;
  margin: 0 !important;
  border-radius: 12px !important;
  box-shadow: 0 16px 34px rgba(15, 23, 42, 0.28) !important;
}

.legend-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 12px;
  height: 12px;
  flex: 0 0 12px;
}

.epicenter-mark {
  color: #ef4444;
  font-size: 12px;
  font-weight: 900;
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: 0 0 9px;
  box-sizing: border-box;
}

.observer-mark {
  background: #ffffff;
  border: 1px solid #94a3b8;
}

.legend-ring {
  width: 13px;
  height: 8px;
  border-radius: 999px;
  flex: 0 0 13px;
  box-sizing: border-box;
}

.p-ring {
  border: 2px solid #2563eb;
}

.s-ring {
  border: 2px solid #ef4444;
}

.map-extra-slot {
  width: 100%;
  max-width: 440px;
  display: flex !important;
  flex-wrap: wrap;
  align-items: center;
  min-height: 0 !important;
  margin-top: 10px;
  order: 2;
  padding: 8px 10px !important;
  gap: 8px !important;
  justify-content: center !important;
  background: rgba(255, 255, 255, 0.96) !important;
  border: 1px solid rgba(148, 163, 184, 0.24) !important;
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.1) !important;
}

.map-extra-slot .icon-group {
  justify-content: center !important;
}

.map-extra-slot > .map-action {
  flex: 0 0 auto;
  order: 0;
}

.map-panel {
  width: 100%;
  max-width: 464px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.12);
  box-sizing: border-box;
}

.map-panel .map-top-info,
.map-panel .map-extra-slot {
  border: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
}

.map-panel .map-top-info {
  padding: 2px 2px 9px !important;
  margin-bottom: 0;
}

.map-panel .map-extra-slot {
  padding: 9px 2px 0 !important;
  margin-top: 0;
}

.map-panel #map-container {
  box-shadow: 0 14px 24px rgba(15, 23, 42, 0.16) !important;
}

.map-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 30px;
  padding: 3px 7px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 8px;
  background: #f8fafc;
  color: #0f172a;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}

#map-extra-slot > .map-action[hidden] { display: none !important; }

.map-action picture {
  display: inline-flex;
}

.map-action:hover {
  background: #eef6ff;
  border-color: rgba(37, 99, 235, 0.28);
}

.share-image-icon {
  width: 24px !important;
  height: 24px !important;
  border-radius: 6px !important;
  padding: 2px !important;
  box-shadow: none !important;
  border: 0;
  background: transparent;
}

#user-mode-toggle #user-mode-btn {
  height: 34px !important;
  max-width: 150px !important;
  border-radius: 8px !important;
  box-shadow: none !important;
}

#user-mode-toggle #user-mode-btn .mode-thumb {
  display: none !important;
}

#user-mode-toggle #user-mode-btn .mode-text {
  position: static !important;
  transform: none !important;
  width: 100%;
  text-align: center;
  font-size: 12px !important;
  letter-spacing: 0 !important;
}

#sidebar h2 #user-mode-toggle {
  flex: 0 0 auto;
  margin: 0 !important;
  transform: none !important;
}

#sidebar h2 #user-mode-toggle #user-mode-btn {
  width: auto !important;
  min-width: 104px;
  max-width: none !important;
  height: 28px !important;
  min-height: 28px !important;
  margin: 0 !important;
  padding: 0 10px !important;
  border-radius: 999px !important;
  box-shadow: none !important;
}

#sidebar h2 #simulator-settings-btn {
  width: auto;
  min-width: 112px;
  min-height: 28px;
  margin: 0;
  padding: 0 11px;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #ffffff;
  color: #334155;
  box-shadow: none;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  white-space: nowrap;
}

#sidebar h2 #simulator-settings-btn:hover {
  border-color: #93c5fd;
  background: #eff6ff;
  color: #1d4ed8;
}

.simulator-mode-switch {
  position: relative;
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  margin: -8px -4px 14px;
  padding: 4px;
  border: 1px solid #cbd5e1;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.14);
}

#sidebar .simulator-mode-switch > button {
  width: 100%;
  min-height: 36px;
  margin: 0;
  padding: 7px 10px;
  border: 0;
  border-radius: 9px !important;
  background: transparent;
  color: #475569;
  box-shadow: none;
  font-size: 13px;
  font-weight: 800 !important;
  cursor: pointer;
}

#sidebar .simulator-mode-switch > button.is-active {
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  color: #fff !important;
  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.24);
}

#sidebar .simulator-mode-switch > button:not(.is-active):hover {
  background: #eff6ff;
  color: #1d4ed8;
}

#sidebar h2 .legacy-mode-control {
  display: none !important;
}

.map-top-info[hidden],
.map-legend[hidden] {
  display: none !important;
}

#sidebar h2 .sidebar-title {
  flex: 1 1 auto;
  min-width: 112px;
}

#map-extra-slot .speed-control {
  min-width: 190px;
  padding: 0 2px;
}

#map-extra-slot .speed-control label,
#map-extra-slot .speed-display-text {
  font-size: 12px !important;
  line-height: 1.25;
}

#map-extra-slot #speed-slider {
  width: 180px !important;
}

#sidebar label,
.challenge-guess-grid label,
.challenge-pga-input label,
.manual-grid label,
.station-lookup label,
#magnitude-depth-row label,
.param-field label,
#station-lookup label,
label[for="scale"] {
  color: #334155 !important;
  letter-spacing: 0 !important;
}

#sidebar input,
#sidebar select,
#sidebar button,
#epicenter-input input,
.challenge-guess-grid input,
.challenge-pga-input input,
.manual-grid input,
.station-lookup-row input,
.station-lookup-row button {
  border-radius: 8px !important;
}

#sidebar button,
#epicenter-input button,
.manual-actions button,
.challenge-actions button,
.station-lookup-row button,
.sheet-toggle,
#sidebar-toggle {
  box-shadow: none !important;
  letter-spacing: 0 !important;
}

.mode-label {
  border-radius: 999px !important;
  box-shadow: none !important;
}

#observatory-panel {
  background: #ffffff !important;
  border: 1px solid #dbe4ef !important;
  border-radius: 14px !important;
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.06) !important;
  padding: 12px !important;
  gap: 10px !important;
}

#observatory-panel:has(#observatory-controls-host:empty):has(#station-lookup-host:empty) {
  display: none !important;
}

#observatory-panel h3 {
  margin: 0 0 4px 0 !important;
  font-size: 15px !important;
  font-weight: 800 !important;
  color: #0f172a !important;
}

#observatory-panel .stacked-buttons,
#observatory-panel #station-lookup-host {
  display: grid;
  gap: 8px;
}

#observatory-panel .stacked-buttons > button {
  min-height: 38px;
  border: 1px solid #cfd8e3 !important;
  border-radius: 10px !important;
  background: #f8fafc !important;
}

#observatory-panel .stacked-buttons > button:hover {
  background: #f1f5f9 !important;
}

#observatory-panel .station-lookup {
  margin-top: 2px;
  padding: 10px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #f8fafc;
}

#observatory-panel .station-lookup-row {
  gap: 6px;
}

#observatory-panel .station-lookup-row input {
  background: #ffffff !important;
}

#observatory-panel .station-lookup-output {
  background: #ffffff !important;
}

/* Feature visibility controlled by the earthquake simulator settings page. */
body[data-eq-show-presets="off"] #preset-dock,
body[data-eq-show-report="off"] #ls-report,
body[data-eq-show-briefing="off"] #ls-briefing,
body[data-eq-show-briefing="off"] #report-briefing-host,
body[data-eq-observer-details="off"] #toggle-observer-info,
body[data-eq-station-name-lookup="off"] #station-lookup,
body[data-eq-epicenter-coordinates="off"] #epicenter-input,
body[data-eq-manual-stations="off"] #manual-stations,
body[data-eq-north-korea-presets="off"] #ls-manual .dd-item[data-key="nk"],
body[data-eq-north-korea-presets="off"] #manual-views [data-view="nk"],
body[data-eq-enable-tsunami="off"] #ls-tsunami,
body[data-eq-enable-tsunami="off"] #tsunami-box,
body[data-eq-enable-tsunami="off"] .tsunami-photo,
body[data-eq-enable-tsunami="off"] .station-tsunami-detail,
body[data-eq-show-experience="off"] .hazard-visuals,
body[data-eq-show-experience="off"] .city-shake-wrap,
body[data-eq-show-experience="off"] .tsunami-photo,
body[data-eq-show-experience="off"] #top-pga-disclaimer {
  display: none !important;
}

/* A feature explicitly enabled in the detailed settings takes precedence over
   the general/advanced mode's default simplification. */
body[data-user-mode="basic"][data-eq-epicenter-coordinates="on"] #epicenter-input,
body[data-user-mode="basic"][data-eq-observer-details="on"] #toggle-observer-info,
body[data-user-mode="basic"][data-eq-station-name-lookup="on"] #settings > .advanced-only,
body[data-user-mode="basic"][data-eq-manual-stations="on"] #observatory-panel {
  display: block !important;
}

/* Keep manual-station text readable on the light card. */
html[data-site-theme="light"] #manual-stations {
  --text: #0f172a;
  --muted: #475569;
}

/* The report keeps the default dark card background unless light mode overrides it. */
html[data-site-theme="light"] :is(.report-panel, #report-container) {
  background: #ffffff !important;
  border-color: #d8e2ef !important;
  color: #0f172a !important;
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.12) !important;
}
html[data-site-theme="light"] #report-content p {
  color: #475569;
}
html[data-site-theme="light"] #report-content strong {
  color: #0f172a;
}

/* Dark-theme overrides are intentionally centralized here. */
html[data-site-theme="dark"] {
  color-scheme: dark;
  --eq-dark-panel: #172234;
  --eq-dark-control: #243247;
  --eq-dark-input: #0f172a;
  --eq-dark-border: #475569;
  --eq-dark-heading: #f1f5f9;
  --eq-dark-text: #e5edf7;
  --eq-dark-muted: #cbd5e1;
}

html[data-site-theme="dark"] body {
  background: linear-gradient(180deg, #07111f, #030914) !important;
  color: var(--eq-dark-text);
}

html[data-site-theme="dark"] #layout-container { color: var(--eq-dark-text); }

html[data-site-theme="dark"] :is(#left-sidebar, #preset-dock, #eq-info-panel, #sidebar, #sidebar .card, #settings, #epicenter-input, #observatory-panel, #report-container, #manual-stations, #manual-stations-block, #manual-dd, .map-panel, .report-panel, .ls-banner, .setting-card, .preset-block, .preset-floating-panel, .challenge-panel, .challenge-mode-card, .station-lookup, .station-lookup-output, .challenge-result, .manual-list, .dd-item, .dropdown-panel, .top-pga-box, .tsunami-box, .city-shake-wrap, .tsunami-photo, .map-top-info, .map-legend, .map-zoom-controls, .sheet-toggle) {
  background: var(--eq-dark-panel) !important;
  border-color: #334155 !important;
  color: var(--eq-dark-text) !important;
  box-shadow: 0 16px 34px rgba(0, 0, 0, .26) !important;
}

/* The main sidebar supplies the card surface for its simulation controls. */
#sidebar #settings {
  padding: 0 !important;
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

html[data-site-theme="dark"] :is(#sidebar h2, #sidebar h3, #left-stack h2, #left-stack h3, #left-stack strong, #sidebar label, .preset-title, .preset-floating-head h3, .top-pga-value, .tsunami-value) {
  color: var(--eq-dark-heading) !important;
}

html[data-site-theme="dark"] :is(#left-stack p, #sidebar p, .preset-meta, .station-lookup-placeholder, .challenge-status, .challenge-result, .top-pga-desc, .tsunami-label, .top-pga-label) {
  color: var(--eq-dark-muted) !important;
}

html[data-site-theme="dark"] :is(#sidebar input, #sidebar select, #left-stack input, #left-stack select, .station-lookup input) {
  background: var(--eq-dark-input) !important;
  border-color: var(--eq-dark-border) !important;
  color: #f8fafc !important;
}

html[data-site-theme="dark"] :is(#sidebar button:not(.primary-start-btn), #left-stack button, .map-action, .map-zoom-controls button, .preset-toggle) {
  background: var(--eq-dark-control) !important;
  border-color: var(--eq-dark-border) !important;
  color: var(--eq-dark-text) !important;
}

html[data-site-theme="dark"] :is(#sidebar button:not(.primary-start-btn):hover, #left-stack button:hover, .map-action:hover, .map-zoom-controls button:hover) {
  background: #334155 !important;
}

html[data-site-theme="dark"] .preset-item {
  background: linear-gradient(180deg, var(--eq-dark-control), #1b293b) !important;
  border-color: var(--eq-dark-border) !important;
  color: var(--eq-dark-heading) !important;
}

html[data-site-theme="dark"] :is(#manual-stations h3, .manual-subtitle, .manual-grid label, .manual-list, #manual-stations-list em) {
  color: var(--eq-dark-text) !important;
}

html[data-site-theme="dark"] .manual-grid input {
  background: var(--eq-dark-input) !important;
  border-color: var(--eq-dark-border) !important;
  color: #f8fafc !important;
}

html[data-site-theme="dark"] .manual-grid input::placeholder { color: #94a3b8 !important; }

html[data-site-theme="dark"] .manual-actions .ghost {
  background: var(--eq-dark-control) !important;
  border-color: var(--eq-dark-border) !important;
  color: var(--eq-dark-text) !important;
}

html[data-site-theme="dark"] #add-manual-station {
  background: linear-gradient(135deg, #0ea5e9, #2563eb) !important;
  border-color: transparent !important;
  color: #ffffff !important;
}

html[data-site-theme="dark"] :is(#manual-stations-list button, button[data-remove-index], #clear-all-manual) {
  background: linear-gradient(180deg, var(--danger), var(--danger-hover)) !important;
  border-color: transparent !important;
  color: #ffffff !important;
}

html[data-site-theme="dark"] :is(.top-pga-icon, .tsunami-icon) {
  background-color: var(--eq-dark-control);
  border-color: var(--eq-dark-border);
}

html[data-site-theme="dark"] .simulator-mode-switch {
  background: var(--eq-dark-input) !important;
  border-color: var(--eq-dark-border) !important;
  box-shadow: none !important;
}

html[data-site-theme="dark"] #sidebar .simulator-mode-switch > button {
  background: var(--eq-dark-control) !important;
  color: var(--eq-dark-text) !important;
}

html[data-site-theme="dark"] #sidebar .simulator-mode-switch > button.is-active {
  background: linear-gradient(135deg, #2563eb, #0ea5e9) !important;
  color: #ffffff !important;
}

html[data-site-theme="dark"] #sidebar .simulator-mode-switch > button:not(.is-active):hover {
  background: #334155 !important;
  color: #ffffff !important;
}

html[data-site-theme="dark"] :is(.map-extra-slot, .map-panel .map-extra-slot) { background: transparent !important; }

/* Light-panel text that may be supplied by legacy rules or inline styles. */
html[data-site-theme="dark"] :is(.ls-banner-title, .speed-control label, .speed-display-text, #report-container h2, #report-container p, .briefing-title, .briefing-text, #station-lookup label, label[for="scale"], .manual-pill, .dd-item, .map-top-info, .map-legend, .map-action span, .sheet-toggle, #map-zoom-level) {
  color: var(--eq-dark-text) !important;
}

html[data-site-theme="dark"] .map-top-info :is(div, span) {
  color: var(--eq-dark-text) !important;
}

html[data-site-theme="dark"] #layout-container :is([style*="color:#0f172a"], [style*="color: #0f172a"], [style*="color:#334155"], [style*="color: #334155"], [style*="color:#475569"], [style*="color: #475569"], [style*="color:#64748b"], [style*="color: #64748b"]) {
  color: var(--eq-dark-muted) !important;
}

#manual-stations .manual-pill {
  color: #000000 !important;
}




@media (max-width: 600px) {
  .eq-simulation-toast { top: calc(12px + env(safe-area-inset-top)); right: 16px; left: 16px; max-width: none; }
}

@media (max-width: 767px) {

/* show left collapse button on small screens */
  .ls-collapse { display: block; }
}

/* Mobile: hide the desktop static left sidebar so mobile uses collapsible UI */
@media (max-width: 767px) {
  #left-sidebar { display: block !important; }
  
  /* Mobile: hide report-panel since left-sidebar ls-report already shows it */
  .report-panel { display: none !important; }
  .report-panel .report-body { display: none; }
}

@media (max-width: 767px) {
  #sidebar,
  #left-sidebar {
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
  }
}

@media (max-width: 767px) {
  #layout-container {
    gap: 12px !important;
  }

  .map-top-info {
    border-radius: 14px;
    padding: 10px 12px !important;
  }

  .map-extra-slot {
    border-radius: 16px !important;
    padding: 10px !important;
  }

  #map-container {
    border-radius: 20px;
  }
}

@media (max-width: 767px) {
  #left-sidebar,
  #sidebar {
    border-radius: 24px;
    padding: 16px !important;
  }

  #left-sidebar .ls-header {
    padding-bottom: 12px;
    margin-bottom: 8px;
  }

  #sidebar h2,
  #left-sidebar h2 {
    font-size: 18px;
  }

  .ls-toggle,
  .preset-toggle {
    min-height: 42px;
  }
}

@media (max-width: 767px) {
  #left-sidebar { padding-bottom: 80px; } /* add breathing room at bottom for dropdowns */
  body.menu-open #topbar-mount,
  body.menu-open #topbar-mount .topbar {
    z-index: 1000 !important;
  }

  body.menu-open #left-sidebar,
  body.menu-open #left-sidebar.open {
    top: 0 !important;
    left: 0 !important;
    margin-top: 0 !important;
    inset: 0 auto 0 0 !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-height: 100vh !important;
    max-height: 100dvh !important;
    z-index: 12000 !important;
  }

  /* Right sidebar as bottom sheet */
  body.sheet-open { overflow: hidden; }
  #sidebar {
    position: fixed !important;
    left: 0;
    right: 0;
    width: 100vw;
    margin: 0 auto;
    bottom: 0;
    max-width: none;
    height: min(var(--sheet-height), calc(100dvh - 12px));
    max-height: calc(100dvh - 12px);
    background: var(--card);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -6px 24px rgba(0,0,0,0.15);
    padding: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    color: var(--text);
    display: block !important;
    transform: translateY(100%);
    transition: transform 0.28s ease;
    z-index: 2100;
    overflow-y: auto;
    box-sizing: border-box;
  }
  #sidebar::before {
    content: "";
    display: block;
    width: 52px;
    height: 5px;
    border-radius: 999px;
    background: #cbd5e1;
    margin: 6px auto 12px;
  }
  #sidebar.open { transform: translateY(0); }
  .sheet-toggle,
  #sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    margin: 12px auto 0;
    width: 80%;
    max-width: 520px;
    box-sizing: border-box;
    background: #0ea5e9;
    color: #fff;
    border: none;
    border-radius: 12px;
    font-weight: 800;
    box-shadow: var(--shadow);
    cursor: pointer;
  }
  /* Ensure the settings open button centers and scales like other mobile buttons */
  #sidebar-toggle,
  .mobile-actions #sidebar-toggle,
  .mobile-sheet-toggle {
    display: block;
    width: 80%;
    max-width: 520px;
    margin: 12px auto 0;
  }
  .sheet-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    backdrop-filter: blur(1px);
    z-index: 2050;
  }
  .sheet-overlay.show { display: block; }

  /* Mobile off-canvas left sidebar */
  body.menu-open { overflow: hidden; }
  #layout-container { flex-direction: column; gap: 12px; padding: 0 8px; }
  #left-sidebar {
    position: fixed !important;
    top: 0;
    left: 0;
    width: var(--drawer-width);
    max-width: 360px;
    height: 100vh;
    max-height: none;
    transform: translateX(-110%);
    transition: transform 0.28s ease, box-shadow 0.28s ease;
    z-index: 12000;
    border-radius: 0 12px 12px 0;
    box-shadow: none;
    padding: 16px;
  }
  #left-sidebar.open {
    transform: translateX(0);
    box-shadow: 0 10px 40px rgba(0,0,0,0.25);
  }
  #left-sidebar .ls-header { justify-content: flex-start; }
  #left-sidebar .ls-close-mobile { display: inline-flex; align-items: center; justify-content: center; }
  .left-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    backdrop-filter: blur(1px);
    z-index: 11900;
  }
  .left-overlay.show { display: block; }
/* ensure map and right sidebar order */
  #map-container { order: 1; }
  #sidebar { order: 2; }
}

@media (max-width: 767px) {
  .mobile-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    margin-top: 10px;
  }
  .mobile-actions button {
    width: 80%;
    max-width: 520px;
    border: none;
    padding: 12px 16px;
    border-radius: 12px;
    font-weight: 800;
    font-size: 15px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.08s ease, filter 0.08s ease, box-shadow 0.12s ease;
  }
  .mobile-actions button:active { transform: translateY(1px); }
  .mobile-actions button:hover { filter: brightness(1.03); }
}

@media (max-width: 767px) {
  body {
    padding: 0 8px 14px;
  }

  #layout-container {
    padding: 0 !important;
    gap: 10px !important;
  }

  .map-top-info {
    grid-template-columns: 1fr;
    gap: 5px !important;
    margin-bottom: 8px;
  }

  .map-top-info div {
    white-space: normal;
  }

  #map-container {
    width: 90vw !important;
    max-width: 90vw !important;
    height: auto !important;
    aspect-ratio: 1 / 1;
    margin-inline: auto !important;
    border: 0 !important;
    outline: 1px solid rgba(15, 23, 42, 0.16);
    border-radius: 12px !important;
  }

  #korea-map {
    border-radius: 11px !important;
  }

  .map-action {
    min-height: 26px;
    padding: 2px 5px;
    border-radius: 7px;
  }

  .share-image-icon {
    width: 20px !important;
    height: 20px !important;
    padding: 1px !important;
    border-radius: 5px !important;
  }

  .map-extra-slot {
    align-items: center;
    justify-content: center;
    gap: 4px !important;
    overflow-x: auto;
  }

  .map-extra-slot .icon-group {
    gap: 3px !important;
  }

  #preset-dock {
    width: 100%;
  }

  .preset-floating-panel {
    width: min(94vw, 420px);
    padding: 14px;
  }

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

  #map-extra-slot .speed-control {
    min-width: 170px;
  }

  #map-extra-slot #speed-slider {
    width: 160px !important;
  }

  #sidebar,
  #left-sidebar {
    border-radius: 12px !important;
  }

  #left-stack {
    width: 100%;
    max-width: none;
    min-width: 0;
  }

  #manual-stations {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin-top: 10px;
    box-sizing: border-box;
  }

  #manual-stations .manual-header {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  #manual-stations .manual-pill {
    max-width: 100%;
  }

  #manual-stations .manual-grid {
    grid-template-columns: 1fr;
  }

  #manual-stations .manual-grid .full-span {
    grid-column: 1;
  }

  #manual-stations .manual-actions {
    flex-direction: column;
  }

  #manual-stations .manual-actions button {
    width: 100%;
    flex: 0 0 auto;
  }
}

/* Keep the responsive map width stable across mobile browser UI and rotation. */
@media (max-width: 767px) {
  #layout-container > div:has(#map-container),
  .map-panel {
    width: 100% !important;
    max-width: none !important;
  }

  #map-container {
    flex: 0 0 auto !important;
    width: 90vw !important;
    min-width: 90vw !important;
    max-width: 90vw !important;
    height: auto !important;
    aspect-ratio: 1 / 1;
    margin-inline: auto !important;
  }

  .map-zoom-controls {
    top: 8px;
    left: 8px;
    gap: 5px;
    padding: 5px 6px;
    border-radius: 8px;
  }

  .map-zoom-controls button {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    font-size: 14px;
  }

  #map-zoom-level {
    min-width: 35px;
    font-size: 10px;
  }
}
