/* ===========================
   ZeroKoi Karte0 Chat Styles
   (HTMLそのまま対応版)
   =========================== */

/* ---- Base ---- */

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #0b1220 0%, #020617 40%, #020617 100%);
  color: #e5e7eb;
  -webkit-font-smoothing: antialiased;
}

/* ===========================
   Top bar (title + distance)
   =========================== */

.top-bar-wrap {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
  background: linear-gradient(
    120deg,
    rgba(15, 23, 42, 0.96),
    rgba(15, 23, 42, 0.94)
  );
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.top-bar {
  max-width: 640px;
  margin: 0 auto;
  padding: 10px 16px 8px;
  box-sizing: border-box;
}

.top-title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.top-sub {
  font-size: 12px;
  opacity: 0.9;
  margin-bottom: 6px;
}

/* distance 400km → 0m */

.distance-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: #9ca3af;
}

.distance-label-left {
  white-space: nowrap;
}

.distance-label-right {
  margin-left: auto;
  white-space: nowrap;
}

.distance-bar {
  position: relative;
  flex: 1;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, #0ea5e9, #22c55e);
  opacity: 0.35;
  overflow: hidden;
}

.distance-dot {
  position: absolute;
  top: 50%;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #38bdf8;
  transform: translate(-50%, -50%);
  left: 12%; /* Karte0用。Karte番号で動かしたかったらここ調整 */
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.7);
}

/* ===========================
   Chat main area
   =========================== */

.chat-wrapper {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px 112px; /* fixed footerぶんの余白 */
  box-sizing: border-box;
}

/* each message block */

.msg-block {
  margin: 8px 0 14px;
}

/* meta (name + time) */

.msg-meta {
  font-size: 11px;
  color: #9ca3af;
  margin-bottom: 2px;
}

.msg-meta.rin {
  text-align: left;
  padding-left: 6px;
}

.msg-meta.natsu {
  text-align: right;
  padding-right: 6px;
}

/* bubble */

.msg {
  display: block;
  width: fit-content;
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 16px;
  line-height: 1.7;
  font-size: 15px;
  word-break: break-word;
  white-space: pre-wrap;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25);
  margin: 6px 0;
}

/* extra gap when direction changes */

.msg.rin + .msg.natsu,
.msg.natsu + .msg.rin {
  margin-top: 14px;
}

/* left / right */

.msg.rin {
  background: #e2edff;
  color: #111827;
  margin-right: auto;
  margin-left: 6px;
  border-bottom-left-radius: 4px;
}

.msg.natsu {
  background: #ffe3cc;
  color: #111827;
  margin-left: auto;
  margin-right: 6px;
  border-bottom-right-radius: 4px;
}

/* system message (center text) */

.system-msg {
  text-align: center;
  font-size: 13px;
  color: #9ca3af;
  margin: 14px 0;
  white-space: pre-wrap;
}

/* ===========================
   Monologue blocks
   =========================== */

.mono-rin {
  max-width: 92%;
  background: rgba(15, 23, 42, 0.4);
  color: #dbeafe;
  font-size: 14px;
  border-left: 3px solid #60a5fa;
  padding: 8px 12px;
  margin: 12px 0;
  white-space: pre-wrap;
}

.mono-natsu {
  max-width: 92%;
  background: rgba(15, 23, 42, 0.4);
  color: #fed7aa;
  font-size: 14px;
  border-right: 3px solid #fb923c;
  padding: 8px 12px;
  margin: 12px 0;
  margin-left: auto;
  text-align: right;
  white-space: pre-wrap;
}

/* ===========================
   Footer (next button)
   =========================== */

.footer-area {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 8px 8px 12px;
  box-sizing: border-box;
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(10px);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.5);
  z-index: 30;
}

.footer-inner {
  max-width: 640px;
  margin: 0 auto;
}

.next-btn {
  border: none;
  width: 100%;
  padding: 12px 0;
  background: linear-gradient(90deg, #38bdf8, #0ea5e9);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  border-radius: 999px;
  cursor: pointer;
}

.next-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

/* ===========================
   Overlay (view selector / end)
   =========================== */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none; /* JSで .show を付けて表示 */
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(14px);
  background: rgba(15, 23, 42, 0.75);
  padding: 16px;
  box-sizing: border-box;
}

.overlay.show {
  display: flex;
}

.overlay-card {
  max-width: 520px;
  width: 100%;
  background: rgba(15, 23, 42, 0.98);
  border-radius: 18px;
  padding: 18px 18px 16px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.35);
}

.overlay-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 8px;
}

.overlay-text {
  font-size: 13px;
  line-height: 1.7;
  color: #e5e7eb;
  margin: 0 0 14px;
  white-space: pre-wrap;
}

.overlay-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.overlay-btn {
  width: 100%;
  border-radius: 999px;
  border: none;
  padding: 9px 0;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

/* overlay button variations */

.overlay-btn-main {
  background: linear-gradient(90deg, #38bdf8, #0ea5e9);
  color: #0f172a;
}

.overlay-btn-sub {
  background: rgba(148, 163, 184, 0.25);
  color: #e5e7eb;
}

.overlay-btn-ghost {
  background: transparent;
  color: #9ca3af;
  border: 1px solid rgba(148, 163, 184, 0.35);
}

/* ===========================
   General links & text
   =========================== */

a {
  color: #38bdf8;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

p {
  margin: 0 0 0.8em;
  line-height: 1.7;
}

/* ===========================
   Responsive tweaks
   =========================== */

@media (max-width: 640px) {
  .top-bar {
    padding: 10px 12px 8px;
  }

  .chat-wrapper {
    padding: 14px 12px 112px;
  }

  .overlay-card {
    padding: 16px 14px 14px;
  }

  .overlay-title {
    font-size: 14px;
  }

  .overlay-text {
    font-size: 12px;
  }

  .overlay-btn {
    font-size: 12px;
    padding: 8px 0;
  }
}