:root {
  --primary-color: #6366f1;
  --secondary-color: #8b5cf6;
  --accent-color: #06b6d4;
  --background: #0f172a;
  --card-bg: rgba(30, 41, 59, 0.95);
  --card-bg-light: rgba(51, 65, 85, 0.95);
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --border-color: #475569;
  --gold-color: #f59e0b;
  --stone-color: #64748b;
  --team1-color: #3b82f6;
  --team2-color: #ef4444;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --error-color: #ef4444;
}

body {
  font-family: "Cinzel", "Times New Roman", serif;
  background: linear-gradient(
    135deg,
    #0f172a 0%,
    #1e293b 50%,
    #334155 100%
  );
  margin: 0;
  padding: 20px;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(
      circle at 25% 25%,
      rgba(99, 102, 241, 0.1) 0%,
      transparent 50%
    ),
    radial-gradient(
      circle at 75% 75%,
      rgba(139, 92, 246, 0.1) 0%,
      transparent 50%
    );
  z-index: -1;
}

.container {
  background: var(--card-bg);
  padding: 32px;
  border-radius: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 0 0 2px var(--primary-color);
  width: 100%;
  max-width: 520px;
  transition: transform 0.3s ease;
  backdrop-filter: blur(10px);
  border: 3px solid var(--primary-color);
  position: relative;
}

.container::before {
  content: "⚔️";
  position: absolute;
  top: -15px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary-color);
  color: var(--text-primary);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

h3 {
  color: var(--primary-color);
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 24px 0;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--primary-color);
  text-align: center;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
  position: relative;
}

h3::before {
  margin-right: 12px;
}

h3::after {
  margin-left: 12px;
}

.player-row {
  display: flex;
  align-items: center;
  margin-bottom: 16px;
  padding: 16px;
  background: var(--card-bg-light);
  border-radius: 15px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transition: all 0.3s ease;
  border: 2px solid transparent;
  position: relative;
}

.room-row.player-row::before {
  display: none;
}

.player-row::before {
  content: "👤";
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--gold-color);
  color: var(--background);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.player-row:hover {
  transform: translateY(-2px) scale(1.02);
  border-color: var(--gold-color);
  box-shadow: 0 8px 24px rgba(212, 175, 55, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.player-info {
  flex: 1;
  font-size: 16px;
  color: var(--text-primary);
  font-weight: 600;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
  margin-left: 20px;
}

.player-winrate {
  width: 70px;
  text-align: center;
  font-size: 14px;
  color: var(--accent-color);
  font-weight: 600;
  margin-left: 10px;
  display: none;
}

.winrate-loading {
  color: var(--warning-color);
  font-style: italic;
  font-size: 12px;
}

.winrate-error {
  color: var(--error-color);
  font-weight: 700;
  cursor: help;
}

.debug-mode {
  background: var(--error-color);
  color: white;
  padding: 8px;
  border-radius: 8px;
  text-align: center;
  margin-bottom: 16px;
  font-weight: 600;
  font-size: 14px;
}

.player-score {
  width: 90px;
  padding: 10px 14px;
  border: 2px solid var(--primary-color);
  border-radius: 12px;
  font-size: 16px;
  text-align: center;
  appearance: none;
  background: var(--card-bg-light);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

.player-score:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.3),
    inset 0 2px 4px rgba(0, 0, 0, 0.1);
  transform: scale(1.05);
}

.team-label {
  width: 40px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  margin-left: 12px;
  color: var(--gold-color);
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

button {
  background: linear-gradient(
    135deg,
    var(--gold-color),
    var(--accent-color)
  );
  color: var(--text-primary);
  border: none;
  padding: 18px 24px;
  border-radius: 15px;
  cursor: pointer;
  width: 100%;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1px;
  transition: all 0.3s ease;
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  text-transform: uppercase;
  position: relative;
  overflow: hidden;
}

#fetch-btn {
  background: linear-gradient(
    135deg,
    var(--primary-color),
    var(--secondary-color)
  );
}

#calculate-btn {
  background: linear-gradient(
    135deg,
    var(--gold-color),
    var(--accent-color)
  );
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(99, 102, 241, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

button:active {
  transform: translateY(0px);
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

button:disabled {
  background: var(--stone-color);
  color: #a0a0a0;
  cursor: not-allowed;
  box-shadow: none;
}

.result-container {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 2px solid var(--primary-color);
}

.team-display {
  margin-top: 24px;
}

.team {
  padding: 20px;
  border-radius: 18px;
  margin-bottom: 20px;
  background: var(--card-bg-light);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  border: 2px solid;
  position: relative;
}

.team::before {
  content: "";
  position: absolute;
  top: -8px;
  left: 20px;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
}

.team-1-bg {
  border-color: var(--team1-color);
  background: linear-gradient(
    135deg,
    rgba(65, 105, 225, 0.1),
    var(--card-bg-light)
  );
}

.team-1-bg::before {
  border-bottom: 8px solid var(--team1-color);
}

.team-2-bg {
  border-color: var(--team2-color);
  background: linear-gradient(
    135deg,
    rgba(220, 20, 60, 0.1),
    var(--card-bg-light)
  );
}

.team-2-bg::before {
  border-bottom: 8px solid var(--team2-color);
}

.team-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
  align-items: center;
}

.team-1-bg .team-title {
  color: var(--team1-color);
}

.team-2-bg .team-title {
  color: var(--team2-color);
}

.team-title::before {
  content: "🛡️";
  margin-right: 8px;
}

.player-item {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  font-size: 14px;
  color: var(--text-primary);
  border-bottom: 1px solid rgba(71, 85, 105, 0.3);
  font-weight: 500;
  align-items: center;
}

.player-item:last-child {
  border-bottom: none;
}

.player-item::before {
  content: "⚔️";
  margin-right: 8px;
  opacity: 0.7;
}

.status {
  padding: 16px;
  border-radius: 12px;
  font-size: 16px;
  margin: 20px 0;
  display: none;
  text-align: center;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.loading {
  background: linear-gradient(
    135deg,
    rgba(245, 158, 11, 0.2),
    rgba(245, 158, 11, 0.1)
  );
  color: #d97706;
  border: 2px solid rgba(245, 158, 11, 0.4);
}

.error {
  background: linear-gradient(
    135deg,
    rgba(239, 68, 68, 0.2),
    rgba(239, 68, 68, 0.1)
  );
  color: #dc2626;
  border: 2px solid rgba(239, 68, 68, 0.4);
}

.success {
  background: linear-gradient(
    135deg,
    rgba(16, 185, 129, 0.2),
    rgba(16, 185, 129, 0.1)
  );
  color: #059669;
  border: 2px solid rgba(16, 185, 129, 0.4);
}

.result-options {
  display: grid;
  gap: 12px;
  margin: 20px 0;
}

.result-option {
  padding: 16px;
  border-radius: 12px;
  background: var(--card-bg-light);
  border: 2px solid var(--border-color);
  font-size: 16px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 600;
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.result-option:hover {
  border-color: var(--primary-color);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.3);
}

.result-option.active {
  border-color: var(--primary-color);
  background: linear-gradient(
    135deg,
    rgba(99, 102, 241, 0.2),
    var(--card-bg-light)
  );
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

input[type="text"] {
  padding: 12px 16px;
  border: 2px solid var(--primary-color);
  border-radius: 12px;
  font-size: 16px;
  flex: 1;
  margin-left: 12px;
  background: var(--card-bg-light);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.3),
    inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.update-time {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 16px;
  text-align: center;
  font-style: italic;
}

#room-selector {
  display: none;
  margin-top: 16px;
  padding: 16px;
  border-radius: 12px;
  background: var(--card-bg-light);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  border: 2px solid var(--gold-color);
}

/* 响应式设计 */
@media (max-width: 600px) {
  .container {
    margin: 10px;
    padding: 20px;
  }

  h3 {
    font-size: 20px;
    padding-top: 20px;
  }

  .player-row {
    padding: 12px;
  }

  .player-info {
    font-size: 14px;
  }

  .player-score {
    width: 70px;
    padding: 8px 10px;
  }
}

/* 动画效果 */
@keyframes shimmer {
  0% {
    background-position: -200px 0;
  }
  100% {
    background-position: 200px 0;
  }
}

.loading-shimmer {
  background: linear-gradient(
    90deg,
    transparent,
    rgba(99, 102, 241, 0.3),
    transparent
  );
  background-size: 200px 100%;
  animation: shimmer 1.5s infinite;
}
