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

:root {
  --bg: #0d0d1a;
  --surface: #1a1a2e;
  --bubble: #2d1b4e;
  --accent: #ff4757;
  --accent-dim: rgba(255, 71, 87, 0.15);
  --text: #e8e0f0;
  --text-dim: rgba(232, 224, 240, 0.45);
}

html { height: 100%; }

body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* Header */

.header {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 56px;
  padding: 0 14px;
  background: linear-gradient(180deg, rgba(30, 18, 48, 0.98), var(--surface));
  border-bottom: 1px solid rgba(255, 71, 87, 0.1);
  flex-shrink: 0;
}

.back-btn {
  color: var(--text-dim);
  text-decoration: none;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  transition: background 0.15s;
}
.back-btn:hover { background: var(--accent-dim); }
.back-btn:active { background: var(--accent-dim); }
.back-btn svg { display: block; }

.header-title {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 7px;
}

.header-icon {
  font-size: 1.35rem;
  line-height: 1;
}

.header h1 {
  font-size: 1.1rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), #ff8a5c);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.02em;
}

.header-actions {
  display: flex;
  gap: 4px;
}

.header-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.header-btn:hover {
  background: var(--accent-dim);
  border-color: rgba(255, 71, 87, 0.2);
  color: var(--text);
}
.header-btn:active { transform: scale(0.92); }
.header-btn svg { display: block; }

/* Warning */

.warning-bar {
  text-align: center;
  padding: 5px 12px;
  font-size: 0.68rem;
  color: var(--text-dim);
  background: rgba(255, 71, 87, 0.03);
  border-bottom: 1px solid rgba(255, 71, 87, 0.04);
  flex-shrink: 0;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Chat */

.chat-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.chat-area::-webkit-scrollbar { width: 3px; }
.chat-area::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
}

/* Empty state */

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  min-height: 200px;
}
.empty-state .emoji { font-size: 3rem; margin-bottom: 6px; }
.empty-state .main-text { color: var(--text-dim); font-size: 0.95rem; }
.empty-state .sub-text { color: var(--text-dim); font-size: 0.78rem; opacity: 0.5; }

/* Message row (KakaoTalk 스타일) */

.msg-row {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 6px;
  padding: 2px 0;
  opacity: 0;
  transform: translateY(10px) scale(0.97);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.msg-row.show {
  opacity: 1;
  transform: none;
}

.msg-time {
  font-size: 0.62rem;
  color: var(--text-dim);
  flex-shrink: 0;
  padding-bottom: 1px;
  white-space: nowrap;
}

.msg-bubble {
  max-width: 72%;
  background: var(--bubble);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 16px 16px 4px 16px;
  font-size: 0.93rem;
  line-height: 1.5;
  word-break: break-word;
  user-select: none;
  -webkit-user-select: none;
}

/* Toolbar */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 0 8px;
  background: var(--surface);
  border-top: 1px solid rgba(255, 71, 87, 0.06);
  flex-shrink: 0;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.3s, opacity 0.3s, padding 0.3s;
}
.toolbar.visible {
  max-height: 140px;
  opacity: 1;
  padding: 6px 8px;
}

.toolbar button {
  flex: 1 0 calc(25% - 4px);
  min-width: 0;
  background: var(--accent-dim);
  border: none;
  color: var(--text);
  font-size: 0.68rem;
  padding: 7px 1px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, transform 0.1s;
}
.toolbar button:active {
  transform: scale(0.93);
  background: rgba(255, 71, 87, 0.3);
}
.toolbar button.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 12px rgba(255, 71, 87, 0.4);
}

/* Toolbar floats above canvas during interactive mode */
.toolbar.z-top {
  position: relative;
  z-index: 103;
}

/* Input bar */

.input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid rgba(255, 71, 87, 0.08);
  flex-shrink: 0;
}

.input-bar input {
  flex: 1;
  background: var(--bg);
  border: 1px solid rgba(255, 71, 87, 0.1);
  color: var(--text);
  font-size: 0.92rem;
  padding: 10px 16px;
  border-radius: 22px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
}
.input-bar input::placeholder { color: var(--text-dim); }
.input-bar input:focus { border-color: rgba(255, 71, 87, 0.35); }

.send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  color: #fff;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.1s;
}
.send-btn:active { transform: scale(0.9); }
.send-btn svg { display: block; }

/* Catharsis */

.catharsis {
  text-align: center;
  font-size: 1.3rem;
  padding: 40px 0;
  opacity: 0;
  transform: scale(0.7);
  transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.catharsis.show { opacity: 1; transform: scale(1); }
.catharsis.hide {
  opacity: 0;
  transform: scale(0.7);
  transition: all 0.4s ease;
}

/* Canvas overlay */

.destroy-canvas {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  pointer-events: none;
}
.destroy-canvas.active { display: block; }
.destroy-canvas.interactive {
  pointer-events: auto;
  cursor: crosshair;
}
.destroy-canvas.interactive.smash-cursor {
  cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 100 100'><text y='80' font-size='80'>🔨</text></svg>") 16 16, crosshair;
}
.destroy-canvas.interactive.water-cursor {
  cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 100 100'><text y='80' font-size='80'>💦</text></svg>") 12 12, crosshair;
}
.destroy-canvas.interactive.paint-cursor {
  cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='6' height='6'><circle cx='3' cy='3' r='3' fill='%23ff4757'/></svg>") 3 3, crosshair;
}
.destroy-canvas.interactive.lightning-cursor {
  cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 100 100'><text y='80' font-size='80'>⚡</text></svg>") 12 12, crosshair;
}
.destroy-canvas.interactive.axe-cursor {
  cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 100 100'><text y='80' font-size='80'>🪓</text></svg>") 16 16, crosshair;
}
.destroy-canvas.interactive.gun-cursor {
  cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'><circle cx='12' cy='12' r='10' fill='none' stroke='rgba(255,70,70,0.7)' stroke-width='1.5'/><line x1='12' y1='4' x2='12' y2='8' stroke='rgba(255,70,70,0.7)' stroke-width='1.5'/><line x1='12' y1='16' x2='12' y2='20' stroke='rgba(255,70,70,0.7)' stroke-width='1.5'/><line x1='4' y1='12' x2='8' y2='12' stroke='rgba(255,70,70,0.7)' stroke-width='1.5'/><line x1='16' y1='12' x2='20' y2='12' stroke='rgba(255,70,70,0.7)' stroke-width='1.5'/><circle cx='12' cy='12' r='2' fill='rgba(255,70,70,0.8)'/></svg>") 12 12, crosshair;
}

/* Destroy hint */

.destroy-hint {
  position: fixed;
  top: 45%;
  left: 0;
  right: 0;
  text-align: center;
  color: rgba(255, 255, 255, 0.85);
  font-size: 1rem;
  font-weight: 500;
  z-index: 101;
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s, transform 0.3s;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
}
.destroy-hint.show { opacity: 1; transform: none; }

/* Screen shake */

@keyframes shake {
  0%, 100% { transform: translate(0); }
  10% { transform: translate(-5px, 3px); }
  20% { transform: translate(5px, -3px); }
  30% { transform: translate(-7px, 4px); }
  40% { transform: translate(7px, -4px); }
  50% { transform: translate(-5px, 2px); }
  60% { transform: translate(5px, -2px); }
  70% { transform: translate(-3px, 3px); }
  80% { transform: translate(3px, -3px); }
  90% { transform: translate(-2px, 1px); }
}
body.shake { animation: shake 0.5s ease; }

/* Toast */

.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: rgba(45, 27, 78, 0.92);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 0.82rem;
  opacity: 0;
  transition: all 0.3s;
  z-index: 200;
  pointer-events: none;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Modal */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: modalFade 0.2s ease;
}

@keyframes modalFade { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border: 1px solid rgba(255, 71, 87, 0.12);
  border-radius: 18px;
  padding: 28px 24px 20px;
  max-width: 300px;
  width: 85%;
  text-align: center;
  transform: scale(0.95);
  animation: modalPop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes modalPop { to { transform: scale(1); } }

.modal h2 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.modal p {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-bottom: 22px;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.modal-actions button {
  flex: 1;
  padding: 11px;
  border-radius: 12px;
  border: none;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.modal-actions button:active { transform: scale(0.95); }

.modal-cancel {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-dim);
}

.modal-confirm {
  background: var(--accent);
  color: white;
}

/* Egg splat drip */

.egg-drip {
  position: fixed;
  pointer-events: none;
  z-index: 101;
  border-radius: 50%;
  animation: drip 1.5s ease-in forwards;
}

@keyframes drip {
  0% { transform: translateY(0) scaleX(1); opacity: 0.7; }
  100% { transform: translateY(60px) scaleX(0.6); opacity: 0; }
}

/* Flush CSS on messages */

.msg-row.flushing {
  transition: transform 1s cubic-bezier(0.4, 0, 1, 1), opacity 1s ease;
  transform: translateY(120vh) rotate(-720deg) scale(0);
  opacity: 0;
}

/* 모션 감소 설정 대응 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
