/* 도파민 카드 스타일시트 */

/* ===== Reset & Base ===== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #020617;
  color: #e5e7eb;
  -webkit-font-smoothing: antialiased;
}

/* ===== App Container ===== */
.app {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 520px;
  margin: 0 auto;
  background: radial-gradient(circle at 50% 50%, #1e1b4b 0%, #020617 50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* ===== Top Bar ===== */
.top-bar {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top, 0px));
  left: 0;
  right: 0;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  z-index: 10;
}

.title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 20px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.subtitle {
  font-size: 13px;
  color: #94a3b8;
  text-align: center;
}

.moka-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  padding: 10px 18px;
  background: rgba(212, 165, 116, 0.1);
  color: #d4a574;
  font-size: 13px;
  font-weight: 500;
  border-radius: 999px;
  text-decoration: none;
  border: 1px solid rgba(212, 165, 116, 0.3);
  transition: all 0.2s;
}

.moka-link:hover {
  background: rgba(212, 165, 116, 0.2);
  border-color: rgba(212, 165, 116, 0.5);
}

.moka-link:active {
  transform: scale(0.97);
}

/* ===== Stats Bar ===== */
.stats {
  display: flex;
  gap: 6px;
  font-size: 11px;
  margin-top: 4px;
  flex-wrap: wrap;
  justify-content: center;
}

.chip {
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.4);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  gap: 4px;
}

.chip-collection {
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.chip-collection:hover {
  background: rgba(30, 41, 59, 0.9);
  border-color: rgba(148, 163, 184, 0.6);
}

.chip-rare {
  border-color: rgba(250, 204, 21, 0.6);
  color: #facc15;
}

.chip-epic {
  border-color: rgba(192, 132, 252, 0.6);
  color: #c084fc;
}

.chip-legendary {
  border-color: rgba(245, 158, 11, 0.6);
  color: #f59e0b;
}

.chip-daily {
  border-color: rgba(34, 197, 94, 0.6);
  color: #22c55e;
}

.chip-daily.exhausted {
  border-color: rgba(239, 68, 68, 0.6);
  color: #ef4444;
}

.new-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 8px;
  height: 8px;
  background: #ef4444;
  border-radius: 50%;
  animation: pulse-badge 1.5s ease-in-out infinite;
}

.new-badge.hidden {
  display: none;
}

@keyframes pulse-badge {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.8; }
}

/* ===== Card Spread Area ===== */
.card-spread {
  position: relative;
  width: 100%;
  height: 350px;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 1200px;
}

/* ===== Individual Card ===== */
.card {
  position: absolute;
  width: clamp(70px, 18vw, 110px);
  height: clamp(98px, 25vw, 154px);
  cursor: pointer;
  transform-style: preserve-3d;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  -webkit-tap-highlight-color: transparent;
  transform-origin: center center;
}

.card:hover:not(.selected):not(.hidden) {
  transform: var(--hover-transform);
  z-index: 50 !important;
}

.card.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.5) translateY(100px) !important;
}

.card.selected {
  z-index: 100 !important;
  transform: translateX(0) translateY(0) rotate(0deg) scale(2.2) !important;
}

.card.selected.flipped .card-inner {
  transform: rotateY(180deg);
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 
    0 8px 30px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.1) inset;
  overflow: hidden;
}

/* Card Back */
.card-back {
  background: linear-gradient(145deg, #312e81 0%, #1e1b4b 100%);
  border: 1.5px solid rgba(129, 140, 248, 0.3);
}

.card-back::before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(129, 140, 248, 0.2);
  border-radius: 6px;
}

.card-back-symbol {
  font-size: 28px;
  color: rgba(165, 180, 252, 0.5);
  animation: pulse 2s ease-in-out infinite;
}

.card-back-pattern {
  position: absolute;
  inset: 0;
  background: 
    radial-gradient(circle at 30% 30%, rgba(129, 140, 248, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 70% 70%, rgba(167, 139, 250, 0.1) 0%, transparent 50%);
}

/* Card Front */
.card-front {
  transform: rotateY(180deg);
  padding: 10px 8px 22px;
  text-align: center;
}

.card-front.common {
  background: linear-gradient(145deg, #f8fafc 0%, #e2e8f0 100%);
  border: 1.5px solid rgba(148, 163, 184, 0.4);
}

.card-front.rare {
  background: linear-gradient(145deg, #fef9c3 0%, #fde047 100%);
  border: 1.5px solid rgba(202, 138, 4, 0.5);
  box-shadow: 
    0 8px 30px rgba(0, 0, 0, 0.4),
    0 0 25px rgba(250, 204, 21, 0.2);
}

.card-front.epic {
  background: linear-gradient(145deg, #f3e8ff 0%, #d8b4fe 100%);
  border: 1.5px solid rgba(147, 51, 234, 0.5);
  box-shadow: 
    0 8px 30px rgba(0, 0, 0, 0.4),
    0 0 30px rgba(192, 132, 252, 0.25);
}

.card-front.legendary {
  background: linear-gradient(145deg, #fef3c7 0%, #fbbf24 50%, #f59e0b 100%);
  border: 2px solid rgba(245, 158, 11, 0.8);
  box-shadow: 
    0 8px 30px rgba(0, 0, 0, 0.4),
    0 0 40px rgba(245, 158, 11, 0.4),
    0 0 60px rgba(245, 158, 11, 0.2);
  animation: legendary-glow 2s ease-in-out infinite;
}

@keyframes legendary-glow {
  0%, 100% { box-shadow: 0 8px 30px rgba(0,0,0,0.4), 0 0 40px rgba(245,158,11,0.4); }
  50% { box-shadow: 0 8px 30px rgba(0,0,0,0.4), 0 0 60px rgba(245,158,11,0.6); }
}

.card-emoji {
  font-size: clamp(24px, 7vw, 32px);
  margin-bottom: 4px;
  flex-shrink: 0;
}

.card-text {
  font-size: clamp(6px, 1.8vw, 8px);
  line-height: 1.35;
  color: #1e293b;
  font-weight: 500;
  word-break: keep-all;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  max-height: 44px;
  padding: 0 4px;
}

.card-rarity {
  position: absolute;
  bottom: 6px;
  font-size: 6px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 2px 5px;
  border-radius: 999px;
}

.card-rarity.common {
  background: rgba(100, 116, 139, 0.2);
  color: #64748b;
}

.card-rarity.rare {
  background: rgba(202, 138, 4, 0.2);
  color: #a16207;
}

.card-rarity.epic {
  background: rgba(147, 51, 234, 0.2);
  color: #7e22ce;
}

.card-rarity.legendary {
  background: rgba(180, 83, 9, 0.25);
  color: #92400e;
}

/* ===== Bottom Area ===== */
.bottom-area {
  position: absolute;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  z-index: 10;
}

.hint {
  font-size: 13px;
  color: #64748b;
  text-align: center;
  transition: opacity 0.3s;
}

.btn-group {
  display: flex;
  gap: 10px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s;
}

.btn-group.visible {
  opacity: 1;
  pointer-events: auto;
}

.btn {
  padding: 10px 18px;
  border: none;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.btn:active {
  transform: scale(0.96);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: white;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.btn-share {
  background: linear-gradient(135deg, #f97316, #ec4899, #8b5cf6);
  color: white;
  box-shadow: 0 4px 15px rgba(236, 72, 153, 0.4);
}

.btn-kakao {
  background: #FEE500;
  color: #191919;
  box-shadow: 0 4px 15px rgba(254, 229, 0, 0.4);
}

.btn-kakao img {
  border-radius: 4px;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(15, 23, 42, 0.95);
  color: white;
  padding: 14px 24px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s;
  z-index: 1000;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.1);
  min-width: fit-content;
  max-width: 360px;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  word-break: break-all;
  white-space: pre-wrap;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (max-width: 400px) {
  .toast {
    font-size: 13px;
    padding: 12px 20px;
  }
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== Collection Modal ===== */
.collection-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s;
}

.collection-modal.open {
  opacity: 1;
}

.collection-modal.closing {
  opacity: 0;
}

.collection-content {
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  background: linear-gradient(180deg, #1e1b4b 0%, #0f172a 100%);
  border-radius: 24px 24px 0 0;
  padding: 20px;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.collection-modal.open .collection-content {
  transform: translateY(0);
}

.collection-modal.closing .collection-content {
  transform: translateY(100%);
}

.collection-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.collection-header h2 {
  font-size: 20px;
  font-weight: 700;
}

.collection-close {
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: #94a3b8;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
}

.collection-close:hover {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

.collection-stats {
  text-align: center;
  margin-bottom: 20px;
}

.stat-main {
  font-size: 14px;
  margin-bottom: 4px;
}

.stat-number {
  font-size: 36px;
  font-weight: 700;
  color: #a5b4fc;
}

.stat-total {
  color: #64748b;
}

.stat-percent {
  color: #94a3b8;
  font-size: 14px;
}

.stat-draws {
  font-size: 12px;
  color: #64748b;
}

.collection-progress {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
}

.progress-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.progress-label {
  width: 70px;
  font-weight: 600;
}

.progress-bar {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease-out;
}

.progress-count {
  width: 40px;
  text-align: right;
  color: #94a3b8;
}

.collection-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.tab-btn {
  padding: 8px 16px;
  border: none;
  background: rgba(255, 255, 255, 0.05);
  color: #94a3b8;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.tab-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.tab-btn.active {
  background: rgba(99, 102, 241, 0.3);
  color: white;
}

.collection-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.rarity-section {
  grid-column: 1 / -1;
  margin-top: 12px;
  margin-bottom: 4px;
}

.rarity-section:first-child {
  margin-top: 0;
}

.rarity-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.collection-card {
  aspect-ratio: 5/7;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all 0.2s;
}

.collection-card.owned {
  background: linear-gradient(145deg, rgba(255,255,255,0.1), rgba(255,255,255,0.05));
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.collection-card.owned.rare {
  border-color: rgba(250, 204, 21, 0.5);
  box-shadow: 0 0 10px rgba(250, 204, 21, 0.2);
}

.collection-card.owned.epic {
  border-color: rgba(192, 132, 252, 0.5);
  box-shadow: 0 0 10px rgba(192, 132, 252, 0.2);
}

.collection-card.owned.legendary {
  border-color: rgba(245, 158, 11, 0.6);
  box-shadow: 0 0 15px rgba(245, 158, 11, 0.3);
  animation: legendary-card-glow 2s ease-in-out infinite;
}

@keyframes legendary-card-glow {
  0%, 100% { box-shadow: 0 0 10px rgba(245,158,11,0.3); }
  50% { box-shadow: 0 0 20px rgba(245,158,11,0.5); }
}

.collection-card.locked {
  background: rgba(0, 0, 0, 0.3);
  border: 1px dashed rgba(255, 255, 255, 0.1);
}

.collection-card .card-emoji {
  font-size: 24px;
  margin: 0;
}

.collection-card.locked .card-emoji {
  opacity: 0.3;
  filter: grayscale(1);
}

.collection-card .card-count {
  position: absolute;
  bottom: 4px;
  right: 4px;
  font-size: 9px;
  color: #94a3b8;
  background: rgba(0, 0, 0, 0.5);
  padding: 1px 4px;
  border-radius: 4px;
}

.collection-card.owned {
  cursor: pointer;
}

.collection-card.owned:active {
  transform: scale(0.95);
}

/* ===== Card Detail Modal ===== */
.card-detail-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}

.card-detail-modal.open {
  opacity: 1;
}

.card-detail-modal.closing {
  opacity: 0;
}

.card-detail-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.card-detail-content {
  position: relative;
  width: 280px;
  padding: 32px 24px;
  border-radius: 20px;
  text-align: center;
  transform: scale(0.9);
  transition: transform 0.2s;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.card-detail-modal.open .card-detail-content {
  transform: scale(1);
}

.card-detail-modal.closing .card-detail-content {
  transform: scale(0.9);
}

.card-detail-content.common {
  background: linear-gradient(145deg, #f8fafc 0%, #e2e8f0 100%);
  color: #1e293b;
}

.card-detail-content.rare {
  background: linear-gradient(145deg, #fef9c3 0%, #fde047 100%);
  color: #1e293b;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(250, 204, 21, 0.3);
}

.card-detail-content.epic {
  background: linear-gradient(145deg, #f3e8ff 0%, #d8b4fe 100%);
  color: #1e293b;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(192, 132, 252, 0.3);
}

.card-detail-content.legendary {
  background: linear-gradient(145deg, #fef3c7 0%, #fbbf24 50%, #f59e0b 100%);
  color: #1e293b;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 50px rgba(245, 158, 11, 0.5);
}

.card-detail-emoji {
  font-size: 72px;
  margin-bottom: 16px;
}

.card-detail-text {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.5;
  margin-bottom: 16px;
  word-break: keep-all;
}

.card-detail-rarity {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 16px;
}

.card-detail-stats {
  display: flex;
  justify-content: center;
  gap: 16px;
  font-size: 12px;
  color: #64748b;
  margin-bottom: 20px;
}

.card-detail-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.card-detail-kakao {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: 999px;
  background: #FEE500;
  color: #191919;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.card-detail-kakao:hover {
  background: #F5DC00;
}

.card-detail-kakao:active {
  transform: scale(0.96);
}

.card-detail-kakao img {
  border-radius: 4px;
}

.card-detail-close {
  padding: 10px 24px;
  border: none;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.1);
  color: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.card-detail-close:hover {
  background: rgba(0, 0, 0, 0.2);
}

/* ===== Animations ===== */
@keyframes pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 0.8; }
}

/* ===== Responsive ===== */
@media (max-width: 400px) {
  .card.selected {
    transform: translateX(0) translateY(0) rotate(0deg) scale(2.5) !important;
  }
  
  .card-text {
    -webkit-line-clamp: 3;
  }
  
  .card-back-symbol {
    font-size: 18px;
  }
  
  .card-rarity {
    font-size: 5px;
    padding: 1px 4px;
  }

  .stats {
    gap: 4px;
  }

  .chip {
    padding: 3px 8px;
    font-size: 10px;
  }

  .collection-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .collection-card .card-emoji {
    font-size: 20px;
  }
}