
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --text: #191919;
  --chat-bg: #bacee0;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont,
    "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  color: var(--text);
}

button {
  font: inherit;
  border: 0;
  cursor: pointer;
}

.screen {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: none;
}

.screen.active {
  display: flex;
}

/* =========================
   전화 수신 화면
========================= */

#callScreen {
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding:
    max(12vh, calc(env(safe-area-inset-top) + 50px))
    24px
    max(10vh, calc(env(safe-area-inset-bottom) + 45px));
  background: radial-gradient(
    ellipse at 50% 40%,
    #34363e 0%,
    #191a20 45%,
    #0d0e12 100%
  );
  color: white;
  text-align: center;
}

.call-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.call-label {
  color: #b8b8c0;
  font-size: 15px;
  letter-spacing: 1px;
}

.caller-avatar {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin: 20px 0 8px;
  background: linear-gradient(145deg, #d9d9e1, #777b89);
  font-size: 48px;
  font-weight: 300;
}

.caller-name {
  font-size: clamp(28px, 7vw, 36px);
  font-weight: 500;
}

.caller-number {
  color: #b5b5bf;
  font-size: 15px;
}

.call-actions {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.call-buttons {
  width: 100%;
  max-width: 300px;
  display: flex;
  justify-content: space-around;
  align-items: center;
}

.call-button-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 13px;
  color: #d6d6dc;
  font-size: 13px;
}

.call-button {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: white;
  transition: transform .18s ease;
}

.call-button:active {
  transform: scale(.92);
}

.call-button svg {
  width: 29px;
  height: 29px;
  fill: currentColor;
}

.answer-button {
  background: #25c765;
  animation: answerPulse 1.8s ease-out infinite;
}

.answer-button svg {
  transform: rotate(-10deg);
}

.decline-button {
  background: #f04444;
}

.decline-button svg {
  transform: rotate(135deg);
}

@keyframes answerPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(37, 199, 101, .6);
  }

  70% {
    box-shadow: 0 0 0 17px rgba(37, 199, 101, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(37, 199, 101, 0);
  }
}

/* =========================
   메신저 화면
========================= */

#chatScreen {
  flex-direction: column;
  background: var(--chat-bg);
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

.chat-header {
  flex-shrink: 0;
  min-height: 62px;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 10px 16px;
  background: #f9f9f9;
  border-bottom: 1px solid rgba(0, 0, 0, .05);
  z-index: 1;
}

.back-button {
  background: none;
  color: #333;
  font-size: 28px;
  padding: 0 4px;
}

.chat-avatar,
.message-avatar {
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #e4d9c9;
}

.chat-avatar {
  width: 39px;
  height: 39px;
  font-size: 20px;
  flex-shrink: 0;
}

.chat-user {
  flex: 1;
  min-width: 0;
}

.chat-user strong {
  display: block;
  font-size: 16px;
  font-weight: 600;
}

.chat-user span {
  display: block;
  font-size: 11px;
  color: #888;
  margin-top: 3px;
}

.header-menu {
  background: none;
  font-size: 24px;
  color: #444;
  padding: 8px;
}

.chat-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scrollbar-width: thin;
}

.date-divider {
  align-self: center;
  padding: 7px 12px;
  border-radius: 20px;
  color: white;
  background: rgba(45, 60, 72, .35);
  font-size: 11px;
  margin-bottom: 4px;
}

.system-message {
  align-self: center;
  color: #506474;
  font-size: 12px;
  text-align: center;
  line-height: 1.6;
  padding: 5px 10px;
}

.message {
  display: flex;
  align-items: flex-end;
  gap: 7px;
  max-width: 88%;
  animation: messageIn .22s ease-out;
}

.message.incoming {
  align-self: flex-start;
}

.message.outgoing {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-avatar {
  width: 31px;
  height: 31px;
  flex-shrink: 0;
  font-size: 16px;
}

.message-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.sender-name {
  font-size: 12px;
  color: #475866;
  margin-bottom: 2px;
}

.bubble-row {
  display: flex;
  align-items: flex-end;
  gap: 5px;
}

.message.outgoing .bubble-row {
  flex-direction: row-reverse;
}

.bubble {
  padding: 10px 12px;
  border-radius: 4px 15px 15px 15px;
  background: #fff;
  font-size: 15px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  box-shadow: 0 1px 1px rgba(0, 0, 0, .04);
}

.message.outgoing .bubble {
  background: #fee66b;
  border-radius: 15px 4px 15px 15px;
}

.message-time {
  flex-shrink: 0;
  font-size: 10px;
  color: #536674;
  padding-bottom: 2px;
}

/* 하단 전송 영역 */

.chat-footer {
  flex-shrink: 0;
  padding: 10px 12px 12px;
  background: #f8f8f8;
  border-top: 1px solid rgba(0, 0, 0, .05);
}

.composer {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
}

.composer-input {
  flex: 1;
  min-width: 0;
  height: 43px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  border: 1px solid #e6e6e6;
  border-radius: 23px;
  color: #999;
  background: white;
  font-size: 13px;
}

.send-button {
flex-shrink: 0;
min-width: 65px;
height: 43px;
border-radius: 22px;
background: #fee66b;
color: #333;
font-size: 14px;
font-weight: 600;
transition: opacity .15s, transform .15s;
}

/* 첫 전송 유도: 더 강하게 통통 튀는 효과 */
.send-button.first-send-hint {
position: relative;
z-index: 1;
animation: sendPulse 1.5s ease-in-out infinite;
}

@keyframes sendPulse {
0%, 100% {
transform: scale(1);
box-shadow:
0 0 0 0 rgba(255, 193, 7, 0.9),
0 0 8px rgba(255, 193, 7, 0.6);
filter: brightness(1);
}

50% {
transform: scale(1.18);
box-shadow:
0 0 0 12px rgba(255, 193, 7, 0.25),
0 0 24px rgba(255, 193, 7, 1);
filter: brightness(1.15);
}
}



.send-button:active:not(:disabled) {
  transform: scale(.95);
}

.send-button:disabled {
  opacity: .4;
  cursor: default;
}

.progress-label {
  text-align: center;
  font-size: 10px;
  color: #999;
  margin-top: 8px;
}

/* 메시지 등장 애니메이션 */

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}




/* =====================================
   엔딩 팝업
===================================== */

.ending-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 24px;
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);

  opacity: 1;
  animation: endingFadeIn 0.6s ease forwards;
}

.ending-overlay[hidden] {
  display: none;
}

.ending-modal {
  width: 100%;
  max-width: 360px;
  padding: 30px 24px;

  color: #f1f1f1;
  text-align: center;

  background: rgba(24, 25, 29, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;

  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);

  animation: endingModalIn 0.65s ease both;
}

.ending-text {
  margin: 0 0 28px;
  font-size: 15px;
  line-height: 1.9;
  letter-spacing: -0.3px;
  word-break: keep-all;
  color: #e4e4e7;
}

.ending-home-button {
  width: 100%;
  padding: 14px 16px;

  color: #f5f5f5;
  font-size: 14px;
  letter-spacing: 0.2px;

  background: #34353b;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 9px;

  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.ending-home-button:hover {
  background: #45464e;
  border-color: rgba(255, 255, 255, 0.4);
}

.ending-home-button:active {
  transform: scale(0.98);
}

@keyframes endingFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes endingModalIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}


.caller-avatar img,
.chat-avatar img,
.message-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}