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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: system-ui, sans-serif;
  display: flex;
  flex-direction: column;
}

#map {
  flex: 1;
  min-height: 0;  /* required for flex children to shrink */
}

/* ── Timeline bar ──────────────────────────────────────────────────────────── */

#timeline-bar {
  flex-shrink: 0;
  height: 68px;
  background: white;
  border-top: 1px solid #e8e8e8;
  padding: 4px 8px 2px;
}

#timeline-svg {
  display: block;
  width: 100%;
  height: 62px;
}

/* ── Emoji markers ─────────────────────────────────────────────────────────── */

.emoji-marker {
  background: none !important;
  border: none !important;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.4));
  transition: opacity 0.5s;
}

/* ── Emoji panel ───────────────────────────────────────────────────────────── */

#emoji-panel {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
  background: white;
  border-radius: 16px;
  padding: 24px;
  max-width: 340px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

#emoji-panel p {
  margin-bottom: 16px;
  font-size: 16px;
  text-align: center;
  color: #333;
}

#emoji-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}

.emoji-btn {
  font-size: 24px;
  padding: 6px 4px;
  border: 2px solid transparent;
  border-radius: 8px;
  background: none;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  line-height: 1;
}

.emoji-btn:hover    { background: #f0f0f0; }
.emoji-btn.selected { border-color: #4caf50; background: #f0faf0; }

/* ── Info button ───────────────────────────────────────────────────────────── */

#info-btn {
  position: absolute;
  bottom: 88px;  /* above the timeline bar */
  left: 20px;
  z-index: 1000;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: white;
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
  font-size: 16px;
  font-weight: bold;
  color: #555;
  cursor: pointer;
  transition: background 0.15s;
}

#info-btn:hover { background: #f5f5f5; }

/* ── Info panel ────────────────────────────────────────────────────────────── */

#info-panel {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
  background: white;
  border-radius: 16px;
  padding: 32px 28px 28px;
  max-width: 460px;
  width: 92%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

#info-panel.open { display: block; }

#info-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  font-size: 18px;
  color: #999;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

#info-close:hover { color: #333; }

#info-panel h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 20px;
  color: #1a1a1a;
}

#info-panel p {
  font-size: 15px;
  line-height: 1.65;
  color: #444;
  margin-bottom: 14px;
}

#info-panel p:last-child { margin-bottom: 0; }

/* ── Debug panel ───────────────────────────────────────────────────────────── */

#debug-panel {
  display: none;
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 1001;
  background: rgba(20, 20, 20, 0.92);
  color: #e8e8e8;
  border-radius: 12px;
  padding: 12px 14px 14px;
  min-width: 240px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  font-size: 13px;
}

#debug-panel.open { display: block; }

#debug-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #aaa;
}

#debug-close {
  background: none;
  border: none;
  color: #777;
  cursor: pointer;
  font-size: 14px;
  padding: 0 2px;
  line-height: 1;
}

#debug-close:hover { color: #ddd; }

#debug-time {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 12px;
}

#debug-speed-row,
#debug-seek-row {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 7px;
}

#debug-speed-row span {
  font-size: 11px;
  color: #888;
  margin-right: 2px;
  white-space: nowrap;
}

.speed-btn,
.seek-btn,
#debug-now {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  color: #ccc;
  cursor: pointer;
  font-size: 12px;
  padding: 4px 8px;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
}

.speed-btn:hover, .seek-btn:hover, #debug-now:hover {
  background: rgba(255,255,255,0.18);
  color: #fff;
}

.speed-btn.active {
  background: #2d6a4f;
  border-color: #52b788;
  color: #fff;
}

#debug-shortcut-row {
  margin-top: 2px;
}

#debug-goto-event {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  color: #ccc;
  cursor: pointer;
  font-size: 12px;
  padding: 4px 10px;
  width: 100%;
  transition: background 0.12s, color 0.12s;
}

#debug-goto-event:hover {
  background: rgba(255,255,255,0.18);
  color: #fff;
}

/* Timeline becomes a seek bar in debug mode */
#timeline-bar.debug-mode #timeline-svg {
  cursor: crosshair;
}

/* ── Status bar ────────────────────────────────────────────────────────────── */

#status {
  position: absolute;
  bottom: 88px;  /* above the timeline bar */
  right: 20px;
  z-index: 1000;
  background: white;
  border-radius: 20px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #444;
  box-shadow: 0 2px 10px rgba(0,0,0,0.12);
}

#status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ccc;
  flex-shrink: 0;
}

#status-dot.online  { background: #4caf50; }
#status-dot.offline { background: #f44336; }
#status-dot.error   { background: #ff9800; }
