:root {
    --bg-base: #eef2f7;
    --shadow-light: #ffffff;
    --shadow-dark: #cbd5e1;
}

html {
    height: 100%;
    overflow: hidden; /* 키보드생성 시 전체 페이지 스크롤 및 튀김 방지 */
}

body {
    height: var(--app-h, 100vh); /* 100dvh 대신 100vh 또는 ui.js 높이 사용 */
    min-height: -webkit-fill-available; /* iOS 브라우저 뷰포트 보정 */
    overflow: hidden;
    position: fixed; /* 키보드로 인한 화면 상하 밀림 현상 방지 */
    width: 100%;
    top: 0;
    left: 0;
    overscroll-behavior: none;
    font-family: 'Gothic A1', sans-serif;
    background-color: var(--bg-base);
    color: #334155;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
/* 입력창에서는 텍스트 선택/입력이 되도록 예외 처리 */
input,
textarea,
select {
    user-select: text;
    -webkit-user-select: text;
}

.font-jua {
    font-family: 'Jua', sans-serif;
}

.neu-flat {
    background: var(--bg-base);
    box-shadow: 8px 8px 16px var(--shadow-dark), -8px -8px 16px var(--shadow-light);
    border-radius: 24px;
}

.neu-pressed {
    background: var(--bg-base);
    box-shadow: inset 5px 5px 10px var(--shadow-dark), inset -5px -5px 10px var(--shadow-light);
    border-radius: 18px;
}

.neu-btn {
    background: var(--bg-base);
    box-shadow: 6px 6px 12px var(--shadow-dark), -6px -6px 12px var(--shadow-light);
    border-radius: 18px;
    transition: all 0.15s ease-in-out;
}

.neu-btn:active {
    box-shadow: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light);
    transform: scale(0.97);
}

.neu-circle {
    background: var(--bg-base);
    box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light);
    border-radius: 50%;
}

.neu-gradient {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    box-shadow: 6px 6px 14px var(--shadow-dark), -6px -6px 14px var(--shadow-light);
    color: white;
}

#explosionCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

.no-scrollbar::-webkit-scrollbar {
    display: none;
}

.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

@keyframes shake-wrong {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-12px); }
    40%, 80% { transform: translateX(12px); }
}

.shake-animation {
    animation: shake-wrong 0.4s ease-in-out;
}

@keyframes pulse-fast {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

.pulse-urgent {
    animation: pulse-fast 0.4s infinite ease-in-out;
}

/* 채팅 말풍선 */
.chat-p1 {
    background: #e0e7ff;
    color: #3730a3;
}

.chat-p2 {
    background: #fce7f3;
    color: #9d174d;
}

.chat-ai {
    background: #ecfdf5;
    color: #065f46;
}

.chat-error {
    background: #fef2f2;
    color: #b91c1c;
}

.chat-system {
    background: #f1f5f9;
    color: #475569;
}


/* 하트 깨짐 */
#playerHearts i,
#aiHearts i {
    transition: transform 0.25s ease, opacity 0.25s ease, color 0.25s ease;
}
.heart-broken {
    color: #cbd5e1 !important;
    opacity: 0.45;
    transform: scale(0.85);
}
.heart-break-anim {
    animation: heart-pop 0.35s ease-out;
}
@keyframes heart-pop {
    0% { transform: scale(1); }
    40% { transform: scale(1.35) rotate(-12deg); }
    100% { transform: scale(0.85); }
}


/* AI 타이핑 연출 */
.ai-typing {
    position: relative;
}
.ai-caret {
    display: inline-block;
    margin-left: 1px;
    color: #6366f1;
    font-weight: 700;
    animation: caret-blink 0.7s steps(1) infinite;
}
@keyframes caret-blink {
    0%, 50% { opacity: 1; }
    50.01%, 100% { opacity: 0; }
}
#currentWordDisplay.ai-typing {
    border-bottom: 2px solid #818cf8;
    padding-bottom: 2px;
}
.ai-typed-done {
    animation: typed-pop 0.35s ease-out;
}
@keyframes typed-pop {
    0% { transform: scale(1); }
    40% { transform: scale(1.06); }
    100% { transform: scale(1); }
}


/* 콤보 플래시 */
.combo-flash {
  position: absolute;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%) scale(0.5);
  z-index: 300;
  pointer-events: none;
  text-align: center;
  opacity: 0;
  transition: transform 0.28s cubic-bezier(0.2, 1.4, 0.3, 1), opacity 0.28s ease;
}
.combo-flash-in {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1.2);
}
.combo-flash-out {
  opacity: 0;
  transform: translate(-50%, -70%) scale(1.4);
}
.combo-flash .combo-num {
  display: block;
  font-family: Jua, sans-serif;
  font-size: 3.2rem;
  line-height: 1;
  color: #f59e0b;
  text-shadow: 0 3px 0 #b45309, 0 0 24px rgba(245, 158, 11, 0.7);
}
.combo-flash .combo-label {
  display: block;
  font-family: Jua, sans-serif;
  font-size: 1.4rem;
  color: #fbbf24;
  letter-spacing: 0.08em;
  text-shadow: 0 1px 0 #b45309;
}

/* AI 타이핑 강화 */
.chat-ai.ai-typing {
  min-width: 3.5rem;
  background: linear-gradient(135deg, #ecfdf5, #d1fae5) !important;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25);
}
.ai-caret {
  display: inline-block;
  margin-left: 2px;
  color: #10b981;
  font-weight: 800;
  animation: caret-blink 0.55s steps(1) infinite;
}
#currentWordDisplay.ai-typing {
  color: #4f46e5;
  border-bottom: 3px solid #818cf8;
  padding-bottom: 2px;
  animation: typing-pulse 0.9s ease-in-out infinite;
}
@keyframes typing-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.75; }
}


/* 입력 잠금 (AI 턴) */
#wordInput.input-locked {
    opacity: 0.55;
    cursor: not-allowed;
    background: #e8eef6 !important;
}

/* AI 타이핑 가독성 */
.ai-type-text {
    font-family: 'Jua', 'Gothic A1', sans-serif !important;
    letter-spacing: 0.04em;
    font-weight: 700;
    color: #065f46;
    -webkit-font-smoothing: antialiased;
}
.chat-ai.ai-typing {
    min-width: 3.5rem;
    background: linear-gradient(135deg, #ecfdf5, #d1fae5) !important;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.3);
    line-height: 1.35;
}
.ai-caret {
    display: inline-block;
    margin-left: 3px;
    color: #059669;
    font-weight: 800;
    font-size: 0.85em;
    vertical-align: baseline;
    animation: caret-blink 0.6s steps(1) infinite;
}
#currentWordDisplay.ai-typing {
    color: #4338ca !important;
    border-bottom: 3px solid #818cf8;
    padding-bottom: 2px;
    letter-spacing: 0.06em;
    font-family: 'Jua', sans-serif !important;
}


.chat-p1 {
    font-size: 1.05rem;
}
.ai-error-pop {
    animation: error-flash 0.35s ease-out;
}
@keyframes error-flash {
    0% { transform: scale(1); }
    40% { transform: scale(1.06); }
    100% { transform: scale(1); }
}


/* 입력창: iOS Safari는 16px 미만이면 포커스 시 화면을 자동 확대함 */
#wordInput {
    font-size: 16px;
}

/* 노치/홈 인디케이터 안전영역 */
.safe-top {
    padding-top: max(1rem, env(safe-area-inset-top));
}
.safe-bottom {
    padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
}

/* 화면 안 알림 (alert 대체) */
.wc-toast {
    position: absolute;
    left: 50%;
    top: 72px;
    transform: translate(-50%, -8px);
    max-width: 86%;
    padding: 10px 16px;
    border-radius: 16px;
    background: rgba(30, 41, 59, 0.92);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    line-height: 1.4;
    opacity: 0;
    pointer-events: none;
    z-index: 70;
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.wc-toast-in {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* 화면 안 확인창 (confirm 대체) */
.wc-dialog-overlay {
    position: absolute;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(6px);
}
.wc-dialog-card {
    width: 100%;
    max-width: 20rem;
    padding: 24px;
    text-align: center;
}
/* 메인 게임 컨테이너: 키보드가 떠도 전체 틀이 줄어들지 않도록 설정 */
#app, #game-container, .game-layout {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    overflow: hidden;
}

/* 채팅/메시지 내역 영역: 내부 스크롤 허용 */
.chat-container, #chatList, #wordHistory {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* 하단 입력창 영역: 키보드 바로 위에 탄탄하게 고정 */
.input-container, #inputArea {
    flex-shrink: 0;
}
