/* CSS Reset & Variable Design Tokens */
:root {
  --primary-color: #6c5ce7;
  --primary-light: #a29bfe;
  --secondary-color: #00cec9;
  --bg-color: #f7f9fc;
  --card-bg: #ffffff;
  --text-main: #2d3436;
  --text-muted: #636e72;
  --border-color: #dfe6e9;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 16px 32px rgba(108, 92, 231, 0.15);
  
  --font-family: 'Outfit', 'Noto Sans KR', sans-serif;
  --transition-normal: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  --transition-bounce: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.6;
  overflow-x: hidden;
}

/* App Container Layout */
.app-container {
  display: flex;
  min-height: 100vh;
  width: 100vw;
}

/* Left Panel: Visual Stack Panel */
.visual-panel {
  width: 400px;
  min-width: 360px;
  background: linear-gradient(135deg, #1e1b4b 0%, #0f172a 100%);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  padding: 2.5rem 2rem;
  position: sticky;
  top: 0;
  height: 100vh;
  box-shadow: 4px 0 24px rgba(0,0,0,0.15);
  z-index: 10;
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(to right, #a29bfe, #81ecec);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0.5rem;
}

.brand-icon {
  width: 28px;
  height: 28px;
  color: #81ecec;
}

.panel-header .subtitle {
  font-size: 0.9rem;
  color: #94a3b8;
  font-weight: 300;
}

/* Stacking Area */
.stack-container {
  flex: 1;
  margin: 2rem 0;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 20px;
  border: 1px dashed rgba(255, 255, 255, 0.1);
  position: relative;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  padding: 1.5rem;
  overflow-y: auto;
  gap: 8px;
}

/* Screen shake effect when box hits */
.stack-container.shake {
  animation: shake 0.2s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* Decoration Layer */
.deco-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 6;
}

/* Draggable Meeple Decorator */
.deco-meeple {
  position: absolute;
  font-size: 2.5rem;
  cursor: move;
  pointer-events: auto;
  user-select: none;
  animation: bounceDeco 1.5s ease-in-out infinite alternate;
}

.deco-meeple:hover {
  transform: scale(1.2);
}

@keyframes bounceDeco {
  0% { transform: translateY(0); }
  100% { transform: translateY(-8px); }
}

/* Custom Scrollbar for Stack Container */
.stack-container::-webkit-scrollbar {
  width: 6px;
}
.stack-container::-webkit-scrollbar-thumb {
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

/* Empty Stack Placeholder */
.empty-stack-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  height: 100%;
  color: #64748b;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80%;
}

.placeholder-icon {
  width: 64px;
  height: 64px;
  margin-bottom: 1rem;
  color: rgba(255, 255, 255, 0.15);
}

.empty-stack-placeholder p {
  font-size: 0.9rem;
}

/* Total Height Counter & Guide */
.height-counter-wrapper {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.height-counter {
  background: rgba(255, 255, 255, 0.07);
  padding: 1rem 1.5rem;
  border-radius: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.height-counter .label {
  font-size: 0.9rem;
  color: #94a3b8;
}

.height-counter .value {
  font-size: 1.4rem;
  font-weight: 800;
  color: #00cec9;
}

.btn-capture {
  background: linear-gradient(135deg, #0984e3 0%, #6c5ce7 100%);
  color: #ffffff;
  border-radius: 12px;
  padding: 0.8rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(108, 92, 231, 0.2);
}

.btn-capture:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(108, 92, 231, 0.4);
}

.deco-guide {
  font-size: 0.75rem;
  color: #94a3b8;
  text-align: center;
}

/* Dynamic Box Elements */
.game-box-item {
  width: 90%;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1.2rem;
  font-weight: 600;
  color: #ffffff;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3), inset 0 2px 4px rgba(255,255,255,0.2);
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
  font-size: 0.9rem;
  position: relative;
  overflow: hidden;
  animation: dropIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.15) forwards;
  cursor: pointer;
  transition: var(--transition-bounce);
  flex-shrink: 0;
  border: 1.5px solid rgba(255,255,255,0.15);
}

.game-box-item:hover {
  transform: scale(1.03);
  box-shadow: 0 8px 20px rgba(0,0,0,0.4), inset 0 2px 4px rgba(255,255,255,0.3);
  z-index: 5;
}

.game-box-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 70%;
}

.game-box-height-badge {
  font-size: 0.75rem;
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Outfit', sans-serif;
}

/* Box dropping animation */
@keyframes dropIn {
  0% {
    opacity: 0;
    transform: translateY(-100px) scaleY(1.4);
  }
  70% {
    transform: translateY(5px) scaleY(0.85);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scaleY(1);
  }
}

/* Right Content Panel */
.content-panel {
  flex: 1;
  padding: 3rem;
  overflow-y: auto;
  max-height: 100vh;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.header-action-group {
  display: flex;
  gap: 12px;
  align-items: center;
}

.dashboard-header h2 {
  font-size: 1.8rem;
  font-weight: 700;
}

/* General Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0.8rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  transition: var(--transition-normal);
  font-family: var(--font-family);
}

.btn-primary {
  background-color: var(--primary-color);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background-color: #5b4bc4;
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-secondary {
  background-color: var(--border-color);
  color: var(--text-muted);
}

.btn-secondary:hover {
  background-color: #cbd5e1;
}

/* Sound volume control design */
.btn-sound-toggle {
  background: var(--card-bg);
  border: 1.5px solid var(--border-color);
  color: var(--text-muted);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
  transition: var(--transition-normal);
  box-shadow: var(--shadow-sm);
}

.btn-sound-toggle:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
  transform: scale(1.05);
}

.btn-sound-toggle.muted {
  background: rgba(255, 118, 117, 0.1);
  border-color: #ff7675;
  color: #ff7675;
}

.btn-sound-toggle i {
  width: 20px;
  height: 20px;
}

/* Stats Cards Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.2rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(226, 232, 240, 0.8);
  transition: var(--transition-normal);
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.stat-icon {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon i {
  width: 24px;
  height: 24px;
}

.icon-plays { background-color: rgba(108, 92, 231, 0.1); color: var(--primary-color); }
.icon-time { background-color: rgba(0, 206, 201, 0.1); color: var(--secondary-color); }
.icon-rank { background-color: rgba(253, 203, 110, 0.15); color: #f39c12; }

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.stat-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 2px;
}

/* Analysis Grid (Winrate & Best Mate) */
.analysis-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 3rem;
}

.analysis-card {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(226, 232, 240, 0.8);
}

.analysis-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.analysis-title i {
  width: 18px;
  height: 18px;
  color: var(--primary-color);
}

.winrate-visual {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.winrate-circle {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  border: 6px solid var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
}

.winrate-value {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--primary-color);
}

.winrate-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.winrate-details strong {
  color: var(--text-main);
}

/* Best Mate Area */
.mate-visual {
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: center;
  min-height: 70px;
}

.mate-empty {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
}

.mate-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8fafc;
  padding: 8px 12px;
  border-radius: 8px;
}

.mate-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-main);
}

.mate-count {
  font-size: 0.8rem;
  color: var(--primary-color);
  font-weight: 600;
}

/* Character Section (Meeples Unlock) */
.characters-section {
  margin-bottom: 3rem;
}

.characters-section h3 {
  font-size: 1.2rem;
  margin-bottom: 2px;
  font-weight: 700;
  color: var(--text-main);
}

.section-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1.2rem;
}

.character-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 1rem;
}

.character-badge {
  background: var(--card-bg);
  border: 1.5px solid var(--border-color);
  border-radius: 16px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: var(--transition-normal);
  filter: grayscale(1);
  opacity: 0.5;
  text-align: center;
  cursor: not-allowed;
}

.character-badge.unlocked {
  filter: none;
  opacity: 1;
  border-color: var(--primary-light);
  box-shadow: 0 4px 12px rgba(108, 92, 231, 0.08);
  cursor: pointer;
}

.character-badge.unlocked:hover {
  transform: translateY(-4px);
  border-color: var(--primary-color);
}

.character-avatar {
  font-size: 2.2rem;
  animation: float 3s ease-in-out infinite;
}

.character-badge:nth-child(even) .character-avatar {
  animation-delay: 1.5s;
}

.character-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-main);
}

.character-cond {
  font-size: 0.7rem;
  color: var(--text-muted);
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

/* Tabs System Styles */
.tab-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 8px;
}

.tab-buttons {
  display: flex;
  gap: 16px;
}

.tab-btn {
  background: none;
  border: none;
  font-family: var(--font-family);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px 12px;
  position: relative;
  transition: var(--transition-normal);
  display: flex;
  align-items: center;
  gap: 6px;
}

.tab-btn:hover {
  color: var(--primary-color);
}

.tab-btn.active {
  color: var(--primary-color);
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 0;
  right: 0;
  height: 3px;
  background-color: var(--primary-color);
  border-radius: 2px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* Encyclopedia Filter Controls */
.encyclopedia-filters {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.filter-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.filter-buttons {
  display: flex;
  gap: 4px;
  background: var(--bg-color);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
}

.filter-btn {
  background: none;
  border: none;
  font-family: var(--font-family);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 8px;
  transition: var(--transition-normal);
}

.filter-btn:hover {
  color: var(--text-main);
}

.filter-btn.active {
  background: var(--primary-color);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(108, 92, 231, 0.2);
}

/* Board Game Info Grid */
.game-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

/* Encyclopedia Card styles (Locked vs Unlocked) */
.info-card {
  background: var(--card-bg);
  border-radius: 20px;
  border: 1.5px solid var(--border-color);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: var(--transition-bounce);
  cursor: pointer;
  position: relative;
}

.info-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-light);
}

.info-card-header {
  height: 140px;
  position: relative;
  background: #dfe6e9;
  overflow: hidden;
}

.info-card-blur-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: blur(15px);
  opacity: 0.6;
  transform: scale(1.1);
}

.info-card-img {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  height: 110px;
  width: 110px;
  object-fit: cover;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
  border: 2px solid #ffffff;
  z-index: 2;
}

.info-card-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.info-card-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.info-card-stat-row {
  display: flex;
  gap: 10px;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.info-card-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

/* Locked Card Style Overrides */
.info-card.locked {
  cursor: not-allowed;
}

.info-card.locked .info-card-header {
  filter: grayscale(1) contrast(0.7);
  opacity: 0.4;
}

.info-card.locked .info-card-body {
  filter: grayscale(1);
  opacity: 0.55;
}

.info-card-lock-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.04);
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #64748b;
  font-weight: 700;
  font-size: 0.95rem;
  gap: 8px;
  pointer-events: none;
}

.info-card-lock-overlay i {
  width: 28px;
  height: 28px;
}

/* Feed Log Card: Layout fix for text cutoff/wrapping bug */
.log-card {
  background: var(--card-bg);
  border-radius: 18px;
  padding: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start; /* 줄높이 다양화에 대응 */
  gap: 16px;
  border: 1.5px solid var(--border-color);
  transition: var(--transition-normal);
  position: relative;
  overflow: hidden;
  min-height: 110px;
}

.log-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-light);
}

.log-card-left {
  display: flex;
  gap: 1.25rem;
  flex: 1; /* 왼쪽 내용 영역이 유연하게 확장 */
  min-width: 0; /* flex 자식의 overflow 방지 */
}

.log-color-indicator {
  width: 8px;
  height: 100%;
  border-radius: 4px;
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
}

.log-meta-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 0; /* 중요: 내부 텍스트 자식들이 말줄임 처리되거나 끊기지 않게 방지 */
}

.log-game-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: normal; /* 긴 이름 줄바꿈 허용 */
  word-break: keep-all; /* 단어 단위 줄바꿈 */
  line-height: 1.4;
}

.log-details-row {
  display: flex;
  flex-wrap: wrap; /* 모바일 대응 자동 개행 */
  gap: 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.log-detail-item {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.log-detail-item i {
  width: 14px;
  height: 14px;
}

.log-review {
  margin-top: 6px;
  font-size: 0.9rem;
  color: var(--text-main);
  background: #f8fafc;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border-left: 3px solid var(--primary-light);
  line-height: 1.5;
  word-break: break-all; /* 긴 영문/한글 문자열 자동 개행 */
  white-space: pre-wrap; /* 사용자가 엔터 친 개행도 반영 */
}

.log-card-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: space-between;
  min-height: 80px;
  flex-shrink: 0; /* 가로 압축 방지 */
}

.log-date {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.log-badge-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

.result-badge {
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 6px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-win { background-color: rgba(46, 204, 113, 0.15); color: #27ae60; }
.badge-lose { background-color: rgba(231, 76, 60, 0.15); color: #c0392b; }
.badge-draw { background-color: rgba(52, 152, 219, 0.15); color: #2980b9; }
.badge-none { background-color: rgba(149, 165, 166, 0.15); color: #7f8c8d; }

.log-stars {
  color: #f1c40f;
  display: flex;
  gap: 2px;
}

.log-stars i {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.action-buttons {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: var(--transition-normal);
}

.log-card:hover .action-buttons {
  opacity: 1;
}

.edit-log-btn,
.delete-log-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: var(--transition-normal);
}

.edit-log-btn {
  color: var(--primary-color);
}

.edit-log-btn:hover {
  background: rgba(108, 92, 231, 0.1);
}

.delete-log-btn {
  color: #ff7675;
}

.delete-log-btn:hover {
  background: rgba(255, 118, 117, 0.1);
}

/* 3D Card Opening / Draw Overlay Layout */
.card-draw-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(10, 10, 26, 0.92);
  backdrop-filter: blur(12px);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

.card-draw-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* Card Glow behind pack */
.glow-effect {
  position: absolute;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(108, 92, 231, 0.5) 0%, rgba(0, 206, 201, 0.2) 50%, transparent 100%);
  filter: blur(40px);
  z-index: 1;
  animation: rotateGlow 15s linear infinite;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1s ease;
}

.card-draw-overlay.active .glow-effect {
  opacity: 1;
}

@keyframes rotateGlow {
  0% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(180deg) scale(1.15); }
  100% { transform: rotate(360deg) scale(1); }
}

.card-pack-wrapper {
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
}

/* 3D Flip Anim Container */
.flip-card-container {
  width: 320px;
  height: 480px;
  perspective: 1200px;
  cursor: pointer;
}

.flip-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  transform-style: preserve-3d;
}

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

.flip-card-back, .flip-card-front {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 24px;
  box-shadow: 0 15px 45px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.1);
  overflow: hidden;
}

/* Card Back Design (Mystery) */
.flip-card-back {
  background: linear-gradient(145deg, #2c1a4d 0%, #0f0a20 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid #6c5ce7;
}

.card-pack-art {
  padding: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: #ffffff;
}

.logo-circle {
  font-size: 3.5rem;
  width: 100px;
  height: 100px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed rgba(162, 155, 254, 0.5);
  animation: pulseLogo 2s infinite alternate;
}

@keyframes pulseLogo {
  0% { transform: scale(1); box-shadow: 0 0 0 rgba(108, 92, 231, 0); }
  100% { transform: scale(1.08); box-shadow: 0 0 20px rgba(108, 92, 231, 0.5); }
}

.card-pack-art h3 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 2px;
  background: linear-gradient(to right, #a29bfe, #81ecec);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.card-pack-art p {
  font-size: 0.85rem;
  color: #94a3b8;
  letter-spacing: 4px;
  text-transform: uppercase;
}

.pulse-indicator {
  margin-top: 2rem;
  font-size: 0.85rem;
  color: #a29bfe;
  animation: blinkText 1.5s infinite;
}

@keyframes blinkText {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

/* Card Front Design (Unlocked/Info) */
.flip-card-front {
  background: #ffffff;
  transform: rotateY(180deg);
  border: 3px solid #00cec9;
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  text-align: left;
  color: var(--text-main);
  justify-content: space-between;
}

.card-header-glow {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  margin: -1.5rem -1.5rem 1.25rem -1.5rem;
  padding: 1.5rem;
  height: 180px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-front-thumb {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 12px;
  border: 3px solid #ffffff;
  box-shadow: var(--shadow-md);
  z-index: 2;
}

.card-badge-tag {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(0, 206, 201, 0.95);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  box-shadow: 0 2px 8px rgba(0, 206, 201, 0.3);
  z-index: 3;
}

.card-front-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card-front-title {
  font-size: 1.3rem;
  font-weight: 800;
  color: #1e293b;
  line-height: 1.3;
}

.card-front-stars {
  color: #f1c40f;
  display: flex;
  gap: 3px;
}

.card-front-stars i {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.card-front-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  padding: 6px 0;
}

.card-front-stats span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.card-front-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 4px;
}

.card-front-footer {
  font-size: 0.75rem;
  text-align: center;
  color: var(--primary-color);
  font-weight: 700;
  border-top: 1px dashed var(--border-color);
  padding-top: 10px;
  margin-top: 8px;
}

.close-card-btn {
  animation: slideUp 0.5s ease-out forwards;
  box-shadow: 0 10px 25px rgba(108, 92, 231, 0.4);
}

@keyframes slideUp {
  0% { transform: translateY(20px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

/* Modals */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--card-bg);
  border-radius: 24px;
  width: 90%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(20px);
  transition: transform 0.3s ease;
}

.modal-backdrop.active .modal-card {
  transform: translateY(0);
}

.modal-header {
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 700;
}

.close-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: var(--transition-normal);
}

.close-btn:hover {
  background: var(--bg-color);
  color: var(--text-main);
}

.modal-body {
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  max-height: 70vh;
  overflow-y: auto;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

input[type="text"],
input[type="number"],
input[type="date"],
textarea,
select {
  padding: 0.8rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  font-family: var(--font-family);
  font-size: 0.95rem;
  background-color: var(--bg-color);
  outline: none;
  transition: var(--transition-normal);
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(162, 155, 254, 0.25);
  background-color: #ffffff;
}

/* Difficulty Option Customization */
.difficulty-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.diff-option {
  cursor: pointer;
}

.diff-option input {
  display: none;
}

.diff-badge {
  display: block;
  text-align: center;
  padding: 0.6rem 0.4rem;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 2px solid transparent;
  transition: var(--transition-normal);
}

.badge-easy { background-color: rgba(46, 204, 113, 0.1); color: #27ae60; }
.badge-medium { background-color: rgba(241, 196, 15, 0.1); color: #d35400; }
.badge-heavy { background-color: rgba(231, 76, 60, 0.1); color: #c0392b; }

.diff-option input:checked + .diff-badge {
  border-color: var(--primary-color);
  box-shadow: 0 4px 10px rgba(108, 92, 231, 0.15);
  transform: translateY(-2px);
}

/* Color Picker */
.color-picker-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}

.color-chip {
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: var(--transition-bounce);
  position: relative;
}

.color-chip.selected {
  border-color: #ffffff;
  box-shadow: 0 0 0 2px var(--primary-color);
  transform: scale(1.15);
  z-index: 2;
}

/* Star Rating */
.star-rating {
  display: flex;
  gap: 6px;
  color: #dfe6e9;
}

.star-rating i {
  width: 28px;
  height: 28px;
  cursor: pointer;
  transition: var(--transition-bounce);
}

.star-rating i.active,
.star-rating i.hover {
  color: #f1c40f;
  fill: #f1c40f;
}

.modal-footer {
  padding: 1.5rem 2rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* ===== Ranking Tab Styles ===== */
.rank-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.rank-section {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}

.rank-section-wide {
  grid-column: 1 / -1;
}

.rank-section-title {
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 1rem;
  color: var(--text-main);
}

.rank-section-title i {
  width: 18px;
  height: 18px;
  color: var(--primary-color);
}

.rank-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rank-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--bg-color);
  transition: var(--transition-normal);
}

.rank-row:hover {
  transform: translateX(4px);
}

.rank-empty-row {
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.rank-badge {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 800;
  color: #ffffff;
  flex-shrink: 0;
  background: #94a3b8;
}

.rank-1 { background: linear-gradient(135deg, #f1c40f, #f39c12); }
.rank-2 { background: linear-gradient(135deg, #bdc3c7, #95a5a6); }
.rank-3 { background: linear-gradient(135deg, #e67e22, #d35400); }
.rank-4 { background: #6c5ce7; }
.rank-5 { background: #0984e3; }

.rank-name {
  flex: 1;
  font-size: 0.85rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-bar-wrap {
  flex: 1;
  height: 8px;
  background: var(--border-color);
  border-radius: 4px;
  overflow: hidden;
  max-width: 120px;
}

.rank-bar {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--primary-color), var(--primary-light));
  transition: width 0.6s ease;
}

.rank-bar-star {
  background: linear-gradient(90deg, #f1c40f, #f39c12);
}

.rank-bar-comp {
  background: linear-gradient(90deg, #00cec9, #81ecec);
}

.rank-bar-easy {
  background: linear-gradient(90deg, #2ecc71, #55efc4);
}

.rank-bar-medium {
  background: linear-gradient(90deg, #fdcb6e, #f39c12);
}

.rank-bar-heavy {
  background: linear-gradient(90deg, #e74c3c, #ff7675);
}

.rank-value {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary-color);
  min-width: 40px;
  text-align: right;
}

/* Difficulty Distribution */
.diff-dist {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.diff-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.diff-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 50px;
}

.diff-row .rank-bar-wrap {
  flex: 1;
  max-width: none;
}

.diff-count {
  font-size: 0.8rem;
  font-weight: 700;
  min-width: 40px;
  text-align: right;
}

/* Winrate Big Display */
.winrate-big {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.winrate-ring {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 6px solid var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--primary-color);
  flex-shrink: 0;
}

.winrate-labels {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.winrate-labels strong {
  color: var(--text-main);
}

/* Monthly Chart */
.month-chart {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  height: 120px;
  padding-top: 10px;
}

.month-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 100%;
  justify-content: flex-end;
}

.month-bar {
  width: 100%;
  max-width: 36px;
  min-height: 4px;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(to top, var(--primary-color), var(--primary-light));
  transition: height 0.6s ease;
}

.month-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.month-count {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-main);
}

.rank-empty {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: var(--text-muted);
  gap: 12px;
}

.rank-empty i {
  width: 48px;
  height: 48px;
}

/* Responsive CSS */
@media (max-width: 900px) {
  .app-container {
    flex-direction: column;
  }
  
  .visual-panel {
    width: 100%;
    height: 50vh;
    position: relative;
  }
  
  .content-panel {
    max-height: none;
    padding: 2rem 1.5rem;
  }
  
  .analysis-grid {
    grid-template-columns: 1fr;
  }

  .rank-grid {
    grid-template-columns: 1fr;
  }
}
