/* Main Styles for SGameTune */
:root {
  --primary-bg: #1a1b26;
  --secondary-bg: #24273a;
  --card-bg: #2a2c3e;
  --primary-text: #ffffff;
  --secondary-text: #a9b1d6;
  --accent-color: #7957f3;
  --accent-hover: #6a46e5;
  --card-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  --header-height: 60px;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--primary-bg);
  color: var(--primary-text);
  margin: 0;
  padding: 0;
}

/* Header Styles */
.site-header {
  background-color: var(--secondary-bg);
  height: var(--header-height);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.header-container {
  display: flex;
  align-items: center;
  padding: 0.75rem 1.5rem;
  background-color: var(--header-bg);
  max-width: 1400px;
  margin: 0 auto;
  gap: 1rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo img {
  height: 36px;
  width: auto;
}

.logo-text {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-color);
  text-decoration: none;
}

.search-container {
  flex: 1;
  max-width: 400px;
  position: relative;
}

.search-input {
  width: 100%;
  padding: 0.6rem 2.25rem;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background-color: var(--search-bg);
  color: var(--text-color);
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.search-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.9rem;
}

.user-actions {
  display: flex;
  align-items: center;
}

.user-actions a {
  margin-left: 15px;
  color: var(--secondary-text);
  font-size: 1.2rem;
}

/* Main Content */
.main-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem;
}

.welcome-banner {
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

.welcome-text {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-color);
  margin-right: 20px;
}

.features {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

.feature {
  display: flex;
  align-items: center;
  font-size: 0.9rem;
  color: var(--secondary-text);
}

.feature svg {
  margin-right: 8px;
  color: var(--accent-color);
}

/* Game Categories */
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.5rem;
  margin: 1rem 0;
}

.game-card {
  position: relative;
  background: var(--card-bg);
  border-radius: 12px;
  overflow: hidden;
  transition: transform 0.2s ease;
  cursor: pointer;
}

.game-info {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0));
}

.game-title {
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-category {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-transform: capitalize;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.game-category[data-category="horror"] {
  color: #ff4d4d;
}

.game-category[data-category="racing"] {
  color: #3b82f6;
}

.game-category[data-category="simulation"] {
  color: #818cf8;
}

.game-category[data-category="action"] {
  color: #f97316;
}

.game-category[data-category="puzzle"] {
  color: #14b8a6;
}

.game-category[data-category="sports"] {
  color: #22c55e;
}

.game-category[data-category="strategy"] {
  color: #f59e0b;
}

.game-category[data-category="shooting"] {
  color: #ef4444;
}

.game-category[data-category="adventure"] {
  color: #8b5cf6;
}

.game-category[data-category="arcade"] {
  color: #ec4899;
}

.game-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.game-thumb {
  position: relative;
  padding-top: 75%; /* 4:3 aspect ratio */
  overflow: hidden;
  background: var(--thumb-bg);
}

.game-thumb img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.game-card:hover .game-thumb img {
  transform: scale(1.05);
}

.game-badge {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  color: white;
  z-index: 1;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.game-badge.featured {
  background: linear-gradient(135deg, #FF6B6B, #FF4081);
  box-shadow: 0 2px 4px rgba(255, 64, 129, 0.3);
}

.game-badge.new {
  background: linear-gradient(135deg, #4CAF50, #8BC34A);
  box-shadow: 0 2px 4px rgba(76, 175, 80, 0.3);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.section-title h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-color);
  margin: 0;
}

.view-more {
  color: var(--primary-color);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: opacity 0.2s ease;
}

.view-more:hover {
  opacity: 0.8;
}

/* Game Detail Page */
.game-detail-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.game-title-main {
  font-size: 2rem;
  margin: 0;
  padding: 0;
}

.game-meta {
  display: flex;
  gap: 15px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.game-meta-item {
  display: flex;
  align-items: center;
  font-size: 0.9rem;
  color: var(--secondary-text);
}

.game-meta-item i {
  margin-right: 5px;
}

.game-main-content {
  display: grid;
  grid-template-columns: 1fr;
  gap: 30px;
}

@media (min-width: 1024px) {
  .game-main-content {
    grid-template-columns: 2fr 1fr;
  }
}

.game-left-column {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.game-frame-container {
  position: relative;
  width: 100%;
  background-color: #000;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  max-height: 70vh; /* 限制最大高度为视口高度的70% */
  min-height: 400px; /* 确保最小高度 */
}

.game-frame {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
  background-color: #1a1b26;
}

.game-loading-indicator {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  z-index: 5;
  border-radius: 8px;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 5px solid rgba(121, 87, 243, 0.2);
  border-top: 5px solid #7957f3;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 15px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.game-description {
  padding: 20px;
  background-color: var(--card-bg);
  border-radius: 12px;
}

.game-description p {
  line-height: 1.6;
  color: var(--secondary-text);
  margin-top: 0;
}

.game-instructions {
  margin-top: 20px;
}

.game-instructions h2 {
  font-size: 1.2rem;
  margin-bottom: 10px;
}

.related-games {
  background-color: var(--card-bg);
  border-radius: 12px;
  padding: 20px;
}

.related-games h2 {
  margin-top: 0;
  margin-bottom: 15px;
  font-size: 1.3rem;
}

.related-games-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 15px;
}

.related-game-card {
  display: flex;
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  height: 90px;
}

.related-game-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

.related-game-thumb {
  width: 80px;
  height: 90px;
  flex-shrink: 0;
}

.related-game-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.related-game-info {
  padding: 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.related-game-title {
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0 0 5px 0;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}

.related-game-category {
  font-size: 0.75rem;
  color: var(--secondary-text);
  margin: 0;
}

/* Footer Styles */
.site-footer {
  background-color: var(--secondary-bg);
  padding: 40px 0 20px;
  margin-top: 60px;
}

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

.footer-logo {
  display: flex;
  align-items: center;
  margin-bottom: 30px;
}

.footer-logo img {
  height: 30px;
  margin-right: 10px;
}

.footer-logo span {
  font-size: 1.2rem;
  font-weight: 600;
  color: white;
}

.footer-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 30px;
  margin-bottom: 30px;
}

.footer-column h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 15px;
  color: white;
}

.footer-column ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.footer-column ul li {
  margin-bottom: 10px;
}

.footer-column ul li a {
  color: var(--secondary-text);
  text-decoration: none;
  transition: color 0.2s;
}

.footer-column ul li a:hover {
  color: var(--accent-color);
}

.social-links {
  display: flex;
  gap: 15px;
}

.social-links a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  color: var(--secondary-text);
  transition: all 0.2s;
}

.social-links a:hover {
  background-color: var(--accent-color);
  color: white;
}

.footer-bottom {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 20px;
  text-align: center;
  color: var(--secondary-text);
  font-size: 0.9rem;
}

/* Category Card Styles */
.category-card {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 120px;
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
  border: 1px solid #333;
  border-radius: 12px;
}

.category-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 15px rgba(0, 0, 0, 0.3);
}

.category-content h3 {
  color: white;
  font-size: 1.2rem;
  font-weight: 600;
  margin: 0 0 5px 0;
}

.category-content p {
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.9rem;
  margin: 0;
}

/* Game Loading and Error Overlays */
.game-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(26, 27, 38, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: 8px;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 5px solid rgba(121, 87, 243, 0.3);
  border-radius: 50%;
  border-top-color: var(--accent-color);
  animation: spin 1s ease-in-out infinite;
  margin-bottom: 20px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.game-loading-overlay p {
  color: var(--primary-text);
  font-size: 18px;
  font-weight: 500;
}

/* 游戏iframe加载指示器 */
.game-loading-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 400px;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 5px solid rgba(121, 87, 243, 0.2);
  border-top: 5px solid #7957f3;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.game-loading-indicator p {
  color: #7957f3;
  font-size: 16px;
}

/* 连接错误对话框样式 */
.connection-error-dialog {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(26, 27, 38, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  box-sizing: border-box;
  z-index: 20;
  border-radius: 8px;
}

.error-icon {
  margin-bottom: 15px;
}

.error-icon svg {
  fill: var(--accent-color);
}

.connection-error-dialog h3 {
  font-size: 22px;
  margin-bottom: 10px;
  color: var(--primary-text);
}

.connection-error-dialog p {
  color: var(--secondary-text);
  margin-bottom: 25px;
  max-width: 80%;
  line-height: 1.5;
}

.error-buttons {
  display: flex;
  gap: 15px;
}

.error-buttons button {
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
}

.offline-button {
  background-color: transparent;
  border: 1px solid var(--accent-color) !important;
  color: var(--primary-text);
}

.offline-button:hover {
  background-color: rgba(121, 87, 243, 0.1);
}

.reload-button {
  background-color: var(--accent-color);
  color: white;
}

.reload-button:hover {
  background-color: var(--accent-hover);
}

/* Responsive Design */
@media (max-width: 1024px) {
  .game-detail-container {
    grid-template-columns: 1fr;
  }
  
  .related-games {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
  }
  
  .related-game-card {
    display: block;
    margin-bottom: 0;
  }
  
  .related-game-thumb {
    width: 100%;
    height: 120px;
  }
}

@media (max-width: 768px) {
  .search-container {
    max-width: none;
    margin: 0 10px;
  }
  
  .game-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
  
  .welcome-banner {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .welcome-text {
    margin-bottom: 10px;
  }
  
  .features {
    flex-direction: column;
    gap: 10px;
  }
  
  .related-games-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .header-container {
    padding: 0 10px;
  }
  
  .logo img {
    height: 30px;
  }
  
  .logo-text {
    font-size: 1.2rem;
  }
  
  .search-input {
    padding: 8px 15px 8px 35px;
  }
  
  .game-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 15px;
  }
}

@media (max-width: 480px) {
  .site-header {
    height: auto;
    padding: 10px 0;
  }
  
  .header-container {
    flex-direction: column;
    gap: 10px;
  }
  
  .search-container {
    width: 100%;
    margin: 10px 0;
  }
  
  .user-actions {
    width: 100%;
    justify-content: space-around;
  }
  
  .game-detail-container {
    grid-template-columns: 1fr;
  }
  
  .footer-links {
    grid-template-columns: 1fr;
    gap: 20px;
  }
}

/* Game Thumbnail Hover Effect */
.game-thumbnail {
  position: relative;
  overflow: hidden;
  border-radius: 12px 12px 0 0;
}

.game-thumbnail::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(to bottom, rgba(0,0,0,0) 70%, rgba(0,0,0,0.7) 100%);
  opacity: 0;
  transition: opacity 0.3s;
}

.game-card:hover .game-thumbnail::after {
  opacity: 1;
}

.game-thumbnail img {
  transition: transform 0.3s;
}

.game-card:hover .game-thumbnail img {
  transform: scale(1.05);
}

/* 游戏界面相关样式 */

/* 可玩游戏卡片 */
.playable-game-card {
  background-color: #1e1f2c;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
  transition: transform 0.3s ease;
  margin-bottom: 20px;
  width: 100%;
}

.playable-game-card:hover {
  transform: translateY(-5px);
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 20px;
  background-color: #252838;
}

.game-header h2 {
  margin: 0;
  font-size: 1.4rem;
}

.play-badge {
  background-color: #7957f3;
  color: white;
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 14px;
}

.game-preview {
  position: relative;
  width: 100%;
  overflow: hidden;
}

.game-thumbnail {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.3s ease;
}

.play-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  cursor: pointer;
}

.game-preview:hover .play-overlay {
  opacity: 1;
}

.game-preview:hover .game-thumbnail {
  transform: scale(1.05);
}

.play-button {
  width: 70px;
  height: 70px;
  background-color: rgba(121, 87, 243, 0.8);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 24px;
  transform: scale(0.8);
  transition: transform 0.3s ease;
}

.play-overlay:hover .play-button {
  transform: scale(1);
  background-color: rgba(121, 87, 243, 1);
}

.game-actions {
  display: flex;
  padding: 15px 20px;
  gap: 10px;
}

.play-now-btn, .open-new-tab-btn {
  padding: 10px 15px;
  border-radius: 5px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background-color 0.2s ease;
}

.play-now-btn {
  background-color: #7957f3;
  color: white;
  flex: 2;
}

.play-now-btn:hover {
  background-color: #6a46e5;
}

.open-new-tab-btn {
  background-color: transparent;
  border: 1px solid #7957f3;
  color: #7957f3;
  flex: 1;
}

.open-new-tab-btn:hover {
  background-color: rgba(121, 87, 243, 0.1);
}

/* 游戏错误消息 */
.game-error {
  background-color: #1e1f2c;
  border-radius: 12px;
  padding: 30px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 300px;
}

.error-icon {
  color: #ff5252;
  font-size: 48px;
  margin-bottom: 20px;
}

.game-error h3 {
  font-size: 1.5rem;
  margin-bottom: 15px;
}

.game-error p {
  margin-bottom: 25px;
  color: #b0b0b0;
  line-height: 1.6;
}

.game-error button {
  background-color: #7957f3;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 5px;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.game-error button:hover {
  background-color: #6a46e5;
}
