.minigame-container {
  padding: 20px;
  max-width: 1400px;
  margin: 0 auto;
}

.minigame-header {
  text-align: center;
  margin-bottom: 40px;
  padding: 30px 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 15px;
  color: white;
}

.minigame-header h2 {
  margin: 0 0 10px 0;
  font-size: 2rem;
  font-weight: 600;
}

.minigame-header h2 i {
  margin-right: 10px;
}

.minigame-subtitle {
  margin: 0;
  font-size: 1rem;
  opacity: 0.9;
}

.minigame-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 25px;
  margin-bottom: 40px;
}

.minigame-card {
  background: white;
  border-radius: 15px;
  padding: 30px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  border: 2px solid transparent;
  display: flex;
  align-items: center;
  gap: 20px;
}

.minigame-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
  border-color: #667eea;
}

.minigame-card-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.minigame-card-icon img {
  border-radius: 12px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.minigame-card-content {
  flex: 1;
}

.minigame-card-title {
  margin: 0 0 10px 0;
  font-size: 1.3rem;
  font-weight: 600;
  color: #2d3748;
}

.minigame-card-desc {
  margin: 0 0 20px 0;
  color: #718096;
  font-size: 0.95rem;
}

.btn-minigame-play {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 12px 30px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 10px rgba(102, 126, 234, 0.3);
}

.btn-minigame-play:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 15px rgba(102, 126, 234, 0.4);
}

.btn-minigame-play:active {
  transform: scale(0.98);
}

.leaderboard-rules-notice {
  background: linear-gradient(135deg, #f6f8fb 0%, #e9ecef 100%);
  border-radius: 15px;
  padding: 25px 30px;
  margin-bottom: 30px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
  border-left: 5px solid #667eea;
}

.rules-header {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.2rem;
  font-weight: 600;
  color: #2d3748;
  margin-bottom: 15px;
}

.rules-header i {
  color: #667eea;
  font-size: 1.3rem;
}

.rules-content p {
  margin: 0 0 15px 0;
  color: #4a5568;
  line-height: 1.6;
}

.rules-list {
  list-style: none;
  padding: 0;
  margin: 15px 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 10px;
}

.rules-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 15px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
}

.rules-list li:hover {
  transform: translateX(5px);
  box-shadow: 0 4px 10px rgba(102, 126, 234, 0.2);
}

.rank-badge-mini {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}

.rank-badge-mini.gold {
  background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(255, 215, 0, 0.4);
}

.rank-badge-mini.silver {
  background: linear-gradient(135deg, #C0C0C0 0%, #A8A8A8 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(192, 192, 192, 0.4);
}

.rank-badge-mini.bronze {
  background: linear-gradient(135deg, #CD7F32 0%, #B8860B 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(205, 127, 50, 0.4);
}

.rank-badge-mini.top10 {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.rank-badge-mini.top50 {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(79, 172, 254, 0.3);
}

.rank-badge-mini.participant {
  background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
  color: #2d3748;
  box-shadow: 0 2px 8px rgba(168, 237, 234, 0.3);
}

.rules-note {
  margin-top: 15px !important;
  padding: 12px 15px;
  background: rgba(102, 126, 234, 0.1);
  border-radius: 8px;
  color: #4a5568;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.rules-note i {
  color: #667eea;
}

.minigame-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 0;
}

.minigame-tab {
  background: transparent;
  border: none;
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 500;
  color: #718096;
  cursor: pointer;
  position: relative;
  transition: all 0.3s ease;
  border-radius: 8px 8px 0 0;
}

.minigame-tab:hover {
  background: rgba(102, 126, 234, 0.05);
  color: #667eea;
}

.minigame-tab.active {
  color: #667eea;
  background: rgba(102, 126, 234, 0.1);
}

.minigame-tab.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 3px 3px 0 0;
}

.minigame-leaderboard-container {
  background: white;
  border-radius: 15px;
  padding: 30px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.leaderboard-content {
  display: flex;
  flex-direction: column;
  gap: 30px;
}

.user-best-score {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  border-radius: 12px;
  padding: 25px;
  color: white;
}

.best-score-header {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.best-score-body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 15px;
  margin-bottom: 20px;
}

.best-score-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.best-score-item .label {
  font-size: 0.85rem;
  opacity: 0.9;
}

.best-score-item .value {
  font-size: 1.3rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  line-height: 1.2;
}

.best-score-item .value.highlight {
  font-size: 1.5rem;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.btn-view-history {
  background: white;
  color: #f5576c;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-view-history:hover {
  background: rgba(255, 255, 255, 0.9);
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.leaderboard-table-container {
  background: white;
  border-radius: 12px;
  overflow: hidden;
}

.leaderboard-table-wrapper {
  overflow-x: auto;
}

.leaderboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.leaderboard-header h3 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}

.total-count {
  font-size: 0.9rem;
  opacity: 0.9;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
}

.leaderboard-table thead {
  background: #f7fafc;
}

.leaderboard-table th {
  padding: 15px;
  text-align: left;
  font-weight: 600;
  color: #2d3748;
  border-bottom: 2px solid #e2e8f0;
  font-size: 0.95rem;
}

.leaderboard-table tbody tr {
  border-bottom: 1px solid #e2e8f0;
  transition: all 0.2s ease;
}

.leaderboard-table tbody tr:hover {
  background: #f7fafc;
}

.leaderboard-table tbody tr.rank-1 {
  background: linear-gradient(90deg, rgba(255, 215, 0, 0.1) 0%, rgba(255, 215, 0, 0) 100%);
}

.leaderboard-table tbody tr.rank-2 {
  background: linear-gradient(90deg, rgba(192, 192, 192, 0.1) 0%, rgba(192, 192, 192, 0) 100%);
}

.leaderboard-table tbody tr.rank-3 {
  background: linear-gradient(90deg, rgba(205, 127, 50, 0.1) 0%, rgba(205, 127, 50, 0) 100%);
}

.leaderboard-table tbody tr.rank-top10 {
  background: linear-gradient(90deg, rgba(102, 126, 234, 0.05) 0%, rgba(102, 126, 234, 0) 100%);
}

.leaderboard-table td {
  padding: 15px;
  color: #4a5568;
}

.rank-cell {
  font-weight: 600;
  font-size: 1.1rem;
}

.player-cell {
  font-weight: 500;
}

.player-name {
  color: #2d3748;
}

.rank-badge {
  display: inline-block;
  padding: 0;
  background: transparent;
  border-radius: 0;
  font-size: 25px;
  font-weight: 700;
  letter-spacing: 0.5px;
  line-height: 1;
}

.rank-badge.rank-sss-plus {
  background: linear-gradient(90deg, 
    #ff0066 0%,
    #ff6600 12.5%,
    #ffff00 25%,
    #00ff00 37.5%,
    #00ffff 50%,
    #0066ff 62.5%,
    #cc00ff 75%,
    #ff0066 100%
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  background-size: 300% auto;
  animation: rainbow-flow-fast 2s linear infinite, pulse-scale 2s ease-in-out infinite;
  text-shadow: 
    0 0 15px rgba(255, 215, 0, 0.8),
    0 0 30px rgba(255, 215, 0, 0.5),
    0 0 45px rgba(255, 215, 0, 0.3);
  filter: brightness(1.3) contrast(1.3);
}

@keyframes rainbow-flow-fast {
  0% {
    background-position: 0% 50%;
  }
  100% {
    background-position: 300% 50%;
  }
}

@keyframes pulse-scale {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

.rank-badge.rank-sss {
  background: linear-gradient(90deg, 
    #ff0000 0%, 
    #ff7f00 16.66%, 
    #ffff00 33.33%, 
    #00ff00 50%, 
    #0000ff 66.66%, 
    #4b0082 83.33%, 
    #9400d3 100%
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  background-size: 200% auto;
  animation: rainbow-flow 3s linear infinite;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
  filter: brightness(1.1) contrast(1.2);
}

@keyframes rainbow-flow {
  0% {
    background-position: 0% 50%;
  }
  100% {
    background-position: 200% 50%;
  }
}

.rank-badge.rank-ss {
  color: #E8E8E8;
  text-shadow: 0 0 8px rgba(232, 232, 232, 0.6), 
               0 0 15px rgba(232, 232, 232, 0.3);
}

.rank-badge.rank-s {
  color: #FFD700;
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.5);
}

.rank-badge.rank-a {
  color: #4A90E2;
  text-shadow: 0 0 5px rgba(74, 144, 226, 0.3);
}

.rank-badge.rank-b {
  color: #CD7F32;
  text-shadow: 0 0 5px rgba(205, 127, 50, 0.3);
}

.rank-badge.rank-c {
  color: #4A5568;
}

.score-cell {
  font-size: 1.1rem;
  font-weight: 600;
  color: #667eea;
}

.time-cell {
  color: #718096;
  font-size: 0.9rem;
}

.empty-message {
  text-align: center;
  padding: 40px !important;
  color: #a0aec0;
  font-size: 1rem;
}

.empty-message i {
  display: block;
  font-size: 3rem;
  margin-bottom: 10px;
  opacity: 0.5;
}

.minigame-play-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 80px);
  background: #1a202c;
}

.minigame-play-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 15px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  color: white;
}

.btn-back {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
}

.btn-back:hover {
  background: rgba(255, 255, 255, 0.3);
}

.minigame-play-header h2 {
  margin: 0;
  font-size: 1.3rem;
}

.minigame-iframe-wrapper {
  flex: 1;
  background: black;
  position: relative;
}

.minigame-iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.minigame-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s ease;
  padding: 20px;
}

.minigame-modal.show {
  opacity: 1;
}

.minigame-modal-content {
  background: white;
  border-radius: 15px;
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.minigame-modal.show .minigame-modal-content {
  transform: scale(1);
}

.minigame-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 25px;
  border-bottom: 2px solid #e2e8f0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 15px 15px 0 0;
}

.minigame-modal-header h3 {
  margin: 0;
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.minigame-modal-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 1.5rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.minigame-modal-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg);
}

.minigame-modal-body {
  padding: 25px;
  overflow-y: auto;
  flex: 1;
}

.history-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.stat-item {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 20px;
  border-radius: 12px;
  text-align: center;
  color: white;
}

.stat-label {
  display: block;
  font-size: 0.9rem;
  opacity: 0.9;
  margin-bottom: 8px;
}

.stat-value {
  display: block;
  font-size: 1.8rem;
  font-weight: 600;
}

.stat-value.highlight {
  font-size: 2rem;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.history-table-container {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #e2e8f0;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
}

.history-table thead {
  background: #f7fafc;
}

.history-table th {
  padding: 12px;
  text-align: left;
  font-weight: 600;
  color: #2d3748;
  border-bottom: 2px solid #e2e8f0;
  font-size: 0.9rem;
}

.history-table tbody tr {
  border-bottom: 1px solid #e2e8f0;
  transition: all 0.2s ease;
}

.history-table tbody tr:hover {
  background: #f7fafc;
}

.history-table tbody tr.best-record {
  background: linear-gradient(90deg, rgba(255, 215, 0, 0.15) 0%, rgba(255, 215, 0, 0) 100%);
}

.history-table td {
  padding: 12px;
  color: #4a5568;
}

.history-table .fa-crown {
  color: #FFD700;
  margin-left: 5px;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(1.1);
  }
}

.loading {
  text-align: center;
  padding: 40px;
  color: #718096;
  font-size: 1.1rem;
}

.loading i {
  font-size: 2rem;
  display: block;
  margin-bottom: 10px;
}

@media (max-width: 768px) {
  .minigame-container {
    padding: 15px;
  }

  .minigame-header {
    padding: 20px 15px;
    margin-bottom: 25px;
  }

  .minigame-header h2 {
    font-size: 1.5rem;
  }

  .minigame-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }

  .minigame-card {
    flex-direction: column;
    text-align: center;
    padding: 20px;
  }

  .minigame-card-icon {
    font-size: 3rem;
  }

  .leaderboard-rules-notice {
    padding: 20px;
  }
  
  .rules-list {
    grid-template-columns: 1fr;
  }

  .minigame-tabs {
    flex-direction: column;
    gap: 5px;
  }

  .minigame-tab {
    width: 100%;
    text-align: center;
  }

  .minigame-leaderboard-container {
    padding: 15px;
  }

  .leaderboard-table-container {
    overflow: visible;
  }

  .leaderboard-header {
    flex-shrink: 0;
  }

  .leaderboard-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .leaderboard-table {
    min-width: 600px;
  }

  .leaderboard-table th,
  .leaderboard-table td {
    padding: 10px 8px;
    font-size: 0.85rem;
  }

  .best-score-body {
    grid-template-columns: 1fr 1fr;
  }

  .history-stats {
    grid-template-columns: 1fr;
  }

  .history-table {
    min-width: 600px;
    font-size: 0.85rem;
  }

  .minigame-modal-content {
    max-width: 100%;
    margin: 10px;
  }

  .minigame-play-container {
    height: calc(100vh - 60px);
  }

  .rank-badge {
    font-size: 20px;
  }
}

@media (prefers-color-scheme: dark) {
  .minigame-card,
  .minigame-leaderboard-container,
  .leaderboard-table-container,
  .minigame-modal-content {
    background: #2d3748;
    color: #e2e8f0;
  }

  .minigame-card-title,
  .player-name,
  .leaderboard-table th {
    color: #e2e8f0;
  }

  .minigame-card-desc,
  .leaderboard-table td,
  .time-cell {
    color: #cbd5e0;
  }

  .leaderboard-table thead,
  .history-table thead {
    background: #1a202c;
  }

  .leaderboard-table tbody tr:hover,
  .history-table tbody tr:hover {
    background: #1a202c;
  }

  .leaderboard-table tbody tr,
  .history-table tbody tr {
    border-bottom-color: #4a5568;
  }

  .history-table-container {
    border-color: #4a5568;
  }
  
  .leaderboard-rules-notice {
    background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
    border-left-color: #667eea;
  }
  
  .rules-header,
  .rules-content p {
    color: #e2e8f0;
  }
  
  .rules-list li {
    background: #1a202c;
  }
  
  .rules-note {
    background: rgba(102, 126, 234, 0.15);
    color: #cbd5e0;
  }
}
