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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: linear-gradient(135deg, #1a5f3c 0%, #0d3d25 100%);
  min-height: 100vh;
  color: #fff;
  overflow-x: hidden;
}

/* 主容器 */
.game-wrapper {
  max-width: 900px;
  margin: 0 auto;
  padding: 16px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* 标题 */
.game-title {
  text-align: center;
  font-size: 1.8rem;
  font-weight: bold;
  margin-bottom: 12px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

/* 顶部信息栏 */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 12px;
  margin-bottom: 16px;
}

.score-display {
  font-size: 1.1rem;
}

.score-display strong {
  color: #ffd700;
  font-size: 1.3rem;
}

/* 难度选择器 */
.difficulty-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 16px 0;
  padding: 16px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 12px;
}

.difficulty-btn {
  padding: 10px 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  background: rgba(0, 0, 0, 0.2);
  color: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 0.25s ease;
}

.difficulty-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.5);
}

.difficulty-btn.active {
  background: rgba(255, 215, 0, 0.25);
  border-color: #ffd700;
  color: #ffd700;
}

/* 手牌区域 */
.hand-area {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 24px 16px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 16px;
  min-height: 140px;
  margin-bottom: 16px;
}

/* 麻将牌 */
.tile {
  position: relative;
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.tile:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.tile.selected {
  transform: translateY(-16px);
  box-shadow: 0 12px 24px rgba(255, 215, 0, 0.4);
  border: 3px solid #ffd700;
}

.tile.orphan {
  background: rgba(255, 200, 0, 0.15);
}

.tile.optimal {
  animation: pulse 1s infinite;
  border: 2px solid #00ff00;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0, 255, 0, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(0, 255, 0, 0); }
}

/* 反馈区域 */
.feedback-area {
  padding: 16px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  margin-bottom: 16px;
}

.feedback {
  padding: 16px;
  border-radius: 10px;
}

.feedback.good {
  background: linear-gradient(135deg, rgba(46, 125, 50, 0.7), rgba(27, 94, 32, 0.7));
  border: 1px solid rgba(76, 175, 80, 0.5);
}

.feedback.ok {
  background: linear-gradient(135deg, rgba(237, 145, 33, 0.7), rgba(230, 126, 34, 0.7));
  border: 1px solid rgba(255, 193, 7, 0.5);
}

.feedback.bad {
  background: linear-gradient(135deg, rgba(198, 40, 40, 0.7), rgba(183, 28, 28, 0.7));
  border: 1px solid rgba(244, 67, 54, 0.5);
}

.feedback-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.score-badge {
  font-size: 1.8rem;
  font-weight: bold;
  color: #ffd700;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.feedback-text {
  font-size: 1.1rem;
}

.optimal-choice {
  padding: 12px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  margin-bottom: 12px;
}

.optimal-choice .tile-name {
  font-size: 1.3rem;
  font-weight: bold;
  color: #ffd700;
  margin-right: 8px;
}

.optimal-choice .reason {
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.95rem;
}

.loss-info {
  display: flex;
  gap: 24px;
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.85);
}

.loss-info strong {
  color: #fff;
}

.candidates-list {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.candidates-list .label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.7);
}

.candidates-list ul {
  list-style: none;
  font-size: 0.9rem;
}

.candidates-list li {
  padding: 4px 0;
  color: rgba(255, 255, 255, 0.85);
}

.loss.low { color: #4caf50; }
.loss.medium { color: #ff9800; }
.loss.high { color: #f44336; }

/* 控制按钮区域 */
.controls-area {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: auto;
  padding-top: 16px;
}

.confirm-btn, .next-btn, .start-btn {
  padding: 14px 32px;
  font-size: 1.1rem;
  font-weight: bold;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.25s ease;
}

.confirm-btn, .start-btn {
  background: linear-gradient(135deg, #ffd700, #ffb300);
  color: #1a5f3c;
}

.confirm-btn:hover, .start-btn:hover {
  background: linear-gradient(135deg, #ffe44d, #ffc107);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 215, 0, 0.4);
}

.next-btn {
  background: linear-gradient(135deg, #4caf50, #388e3c);
  color: #fff;
}

.next-btn:hover {
  background: linear-gradient(135deg, #66bb6a, #43a047);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
}

/* 开始界面 */
.setup-screen {
  text-align: center;
  padding: 40px 20px;
}

.setup-screen h1 {
  font-size: 2.2rem;
  margin-bottom: 8px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.subtitle {
  font-size: 1.1rem;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 24px;
}

/* 加载中 */
.loading {
  text-align: center;
  padding: 40px;
  font-size: 1.2rem;
}

/* 响应式布局 */
@media (max-width: 480px) {
  .game-wrapper {
    padding: 10px;
  }

  .game-title {
    font-size: 1.4rem;
  }

  .top-bar {
    flex-direction: column;
    gap: 8px;
    padding: 10px;
  }

  .difficulty-selector {
    padding: 10px;
    gap: 6px;
  }

  .difficulty-btn {
    padding: 8px 12px;
    font-size: 0.85rem;
  }

  .hand-area {
    padding: 16px 10px;
    gap: 6px;
  }

  .tile.selected {
    transform: translateY(-12px);
  }

  .feedback-header {
    flex-direction: column;
    text-align: center;
  }

  .loss-info {
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }

  .confirm-btn, .next-btn, .start-btn {
    padding: 12px 24px;
    font-size: 1rem;
  }
}

@media (min-width: 481px) and (max-width: 768px) {
  .hand-area {
    gap: 8px;
  }
}