/* =========================================
   消消乐游戏 - 现代化深色主题样式
   使用 Glassmorphism 和渐变效果
   ========================================= */

/* CSS 变量：颜色主题 */
:root {
  /* 主色调 */
  --primary: #8b5cf6;
  --primary-light: #a78bfa;
  --primary-dark: #7c3aed;

  /* 渐变背景 */
  --bg-gradient: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);

  /* 玻璃效果 */
  --glass-bg: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.15);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);

  /* 文字颜色 */
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  /* 方块颜色 */
  --gem-red: #ef4444;
  --gem-blue: #3b82f6;
  --gem-green: #22c55e;
  --gem-yellow: #eab308;
  --gem-purple: #a855f7;

  /* 尺寸 */
  --cell-size: min(10vw, 60px);
  --board-gap: 4px;
  --border-radius: 16px;

  /* 动画 */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s ease;
}

/* 全局样式重置 */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-gradient);
  min-height: 100vh;
  color: var(--text-primary);
  overflow-x: hidden;
}

/* 容器 */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* =========== 头部标题 =========== */
.header {
  text-align: center;
  padding: 20px 0 30px;
}

.title {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 700;
  background: linear-gradient(135deg, #f472b6, #8b5cf6, #06b6d4);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 0 40px rgba(139, 92, 246, 0.5);
  animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
  from {
    filter: drop-shadow(0 0 20px rgba(139, 92, 246, 0.3));
  }

  to {
    filter: drop-shadow(0 0 30px rgba(139, 92, 246, 0.6));
  }
}

.subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-top: 8px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* =========== 游戏主区域 =========== */
.game-wrapper {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  flex: 1;
}

@media (min-width: 900px) {
  .game-wrapper {
    grid-template-columns: 1fr 320px;
  }
}

.game-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

/* =========== 信息栏 =========== */
.info-bar {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

.info-item {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 12px 24px;
  text-align: center;
  min-width: 100px;
}

.info-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.info-value {
  font-size: 1.5rem;
  font-weight: 700;
}

.info-value.score {
  color: var(--gem-yellow);
}

.info-value.combo {
  color: var(--gem-green);
}

.info-value.moves {
  color: var(--gem-blue);
}

.info-value.moves.warning {
  color: var(--gem-red);
  animation: shake 0.5s ease;
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-5px);
  }

  75% {
    transform: translateX(5px);
  }
}

/* =========== 关卡进度条 =========== */
.level-bar {
  width: 100%;
  max-width: 600px;
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 12px 20px;
}

.level-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.level-badge {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  padding: 4px 12px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.875rem;
}

.level-target {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.progress-container {
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--gem-green), var(--gem-yellow));
  border-radius: 4px;
  transition: width 0.3s ease;
}

.progress-bar.complete {
  background: linear-gradient(90deg, #22c55e, #10b981);
}

/* =========== 游戏棋盘 =========== */
.game-board {
  display: grid;
  grid-template-columns: repeat(8, var(--cell-size));
  grid-template-rows: repeat(8, var(--cell-size));
  gap: var(--board-gap);
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius);
  padding: 12px;
  box-shadow: var(--glass-shadow);
}

/* 方块样式 */
.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  border-radius: 10px;
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--cell-size) * 0.5);
}

.cell:hover {
  transform: scale(1.08);
  z-index: 2;
}

.cell.selected {
  transform: scale(1.12);
  animation: pulse 0.5s ease infinite;
  box-shadow: 0 0 20px currentColor;
}

@keyframes pulse {

  0%,
  100% {
    box-shadow: 0 0 15px currentColor;
  }

  50% {
    box-shadow: 0 0 25px currentColor;
  }
}

/* 方块颜色 */
.cell.red {
  background: linear-gradient(135deg, #f87171, var(--gem-red));
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.cell.blue {
  background: linear-gradient(135deg, #60a5fa, var(--gem-blue));
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.cell.green {
  background: linear-gradient(135deg, #4ade80, var(--gem-green));
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.4);
}

.cell.yellow {
  background: linear-gradient(135deg, #fde047, var(--gem-yellow));
  box-shadow: 0 4px 12px rgba(234, 179, 8, 0.4);
}

.cell.purple {
  background: linear-gradient(135deg, #c084fc, var(--gem-purple));
  box-shadow: 0 4px 12px rgba(168, 85, 247, 0.4);
}

/* 十字星特殊道具 */
.cell.special {
  background: linear-gradient(135deg, #fbbf24, #f97316, #ef4444);
  box-shadow: 0 0 20px rgba(251, 191, 36, 0.8);
  animation: sparkle 1s ease-in-out infinite;
  border: 2px solid rgba(255, 255, 255, 0.8);
}

.cell.special.cross {
  font-size: calc(var(--cell-size) * 0.6);
}

@keyframes sparkle {

  0%,
  100% {
    box-shadow: 0 0 15px rgba(251, 191, 36, 0.8), 0 0 30px rgba(249, 115, 22, 0.4);
    transform: scale(1);
  }

  50% {
    box-shadow: 0 0 25px rgba(251, 191, 36, 1), 0 0 50px rgba(249, 115, 22, 0.6);
    transform: scale(1.05);
  }
}

/* 特殊方块爆炸动画 */
.cell.exploding {
  animation: bigExplode 0.4s ease forwards;
}

@keyframes bigExplode {
  0% {
    transform: scale(1);
    opacity: 1;
  }

  30% {
    transform: scale(1.5);
    opacity: 1;
    box-shadow: 0 0 40px rgba(251, 191, 36, 1);
  }

  100% {
    transform: scale(0);
    opacity: 0;
  }
}

/* 消除动画 */
.cell.matched {
  animation: explode 0.3s ease forwards;
}

@keyframes explode {
  0% {
    transform: scale(1);
    opacity: 1;
  }

  50% {
    transform: scale(1.3);
    opacity: 0.5;
  }

  100% {
    transform: scale(0);
    opacity: 0;
  }
}

/* 下落动画 */
.cell.falling {
  animation: fall 0.3s ease;
}

@keyframes fall {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* =========== 控制按钮 =========== */
.controls {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn {
  padding: 12px 28px;
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.5);
}

.btn-secondary {
  background: var(--glass-bg);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(8px);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.15);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 16px;
}

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

/* =========== 排行榜 =========== */
.leaderboard-section {
  display: flex;
  flex-direction: column;
}

.leaderboard-card {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius);
  padding: 20px;
  box-shadow: var(--glass-shadow);
  flex: 1;
  display: flex;
  flex-direction: column;
}

.leaderboard-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 16px;
  text-align: center;
}

.leaderboard-list {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 12px;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 8px;
  background: rgba(255, 255, 255, 0.03);
  transition: background var(--transition-fast);
}

.leaderboard-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.leaderboard-item.top-1 {
  background: linear-gradient(90deg, rgba(234, 179, 8, 0.2), transparent);
}

.leaderboard-item.top-2 {
  background: linear-gradient(90deg, rgba(156, 163, 175, 0.2), transparent);
}

.leaderboard-item.top-3 {
  background: linear-gradient(90deg, rgba(180, 83, 9, 0.2), transparent);
}

.rank {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.875rem;
  border-radius: 50%;
  margin-right: 12px;
  background: rgba(255, 255, 255, 0.1);
}

.top-1 .rank {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #1f2937;
}

.top-2 .rank {
  background: linear-gradient(135deg, #9ca3af, #6b7280);
  color: #1f2937;
}

.top-3 .rank {
  background: linear-gradient(135deg, #d97706, #b45309);
  color: #fef3c7;
}

.player-name {
  flex: 1;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-score {
  font-weight: 700;
  color: var(--gem-yellow);
}

.loading,
.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 20px;
}

/* =========== 弹窗 =========== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: linear-gradient(145deg, #24243e, #1a1a2e);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius);
  padding: 32px 40px;
  text-align: center;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from {
    transform: scale(0.9);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

.modal-content h2 {
  font-size: 1.75rem;
  margin-bottom: 12px;
}

.modal-content p {
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.modal-content input {
  width: 100%;
  padding: 14px 18px;
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  font-size: 1rem;
  font-family: inherit;
  margin-bottom: 20px;
  outline: none;
  transition: border-color var(--transition-fast);
}

.modal-content input:focus {
  border-color: var(--primary);
}

.final-score {
  font-size: 4rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--gem-yellow), #f97316);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 16px 0;
}

.modal-content.success {
  border: 2px solid var(--gem-green);
  box-shadow: 0 0 40px rgba(34, 197, 94, 0.3);
}

.bonus-text {
  color: var(--gem-green);
  font-weight: 600;
  font-size: 1.25rem;
}

.modal-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 8px;
}

/* =========== 响应式适配 =========== */
@media (max-width: 600px) {
  :root {
    --cell-size: min(11vw, 45px);
  }

  .container {
    padding: 12px;
  }

  .header {
    padding: 12px 0 20px;
  }

  .info-item {
    padding: 8px 16px;
    min-width: 80px;
  }

  .info-value {
    font-size: 1.25rem;
  }

  .game-board {
    padding: 8px;
  }

  .leaderboard-card {
    padding: 16px;
  }
}

/* =========== 洗牌提示 =========== */
.shuffle-notification {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.95), rgba(124, 58, 237, 0.95));
  color: white;
  padding: 20px 40px;
  border-radius: 16px;
  font-size: 1.25rem;
  font-weight: 600;
  z-index: 200;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
  animation: popIn 0.3s ease;
}

@keyframes popIn {
  from {
    transform: translate(-50%, -50%) scale(0.5);
    opacity: 0;
  }

  to {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}

.shuffle-notification.fade-out {
  animation: fadeOut 0.5s ease forwards;
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}