/* ===== CSS Variables for Dark/Light Mode ===== */
:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f5f5f5;
  --bg-card: #ffffff;
  --text-primary: #333333;
  --text-secondary: #666666;
  --accent-primary: #4a90e2;
  --accent-secondary: #357abd;
  --accent-hover: #2c5fa3;
  --border-color: #e0e0e0;
  --shadow: rgba(0, 0, 0, 0.1);
  --shadow-hover: rgba(0, 0, 0, 0.2);
  --success: #4caf50;
  --warning: #ff9800;
  --error: #f44336;
  --focus-ring: rgba(74, 144, 226, 0.5);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-card: #252525;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --accent-primary: #5fa3e8;
    --accent-secondary: #4a90e2;
    --accent-hover: #6bb0f0;
    --border-color: #404040;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-hover: rgba(0, 0, 0, 0.5);
    --success: #66bb6a;
    --warning: #ffa726;
    --error: #ef5350;
  }
}

/* ===== Reset & Base Styles ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
    Ubuntu, Cantarell, sans-serif;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== Layout ===== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}

/* ===== Header ===== */
header {
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 2px 4px var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0.5rem 1rem;
  max-width: 1200px;
  margin: 0 auto;
}

.logo {
  font-size: 1.25rem;
  font-weight: bold;
  color: var(--accent-primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo:hover {
  color: var(--accent-secondary);
}

.logo:focus {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ===== Search & Filters ===== */
.search-section {
  margin: 2rem 0;
}

.search-box {
  width: 100%;
  max-width: 500px;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  background-color: var(--bg-card);
  color: var(--text-primary);
  transition: border-color 0.3s;
}

.search-box:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.filter-buttons {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 0.5rem 1rem;
  background-color: var(--bg-card);
  color: var(--text-primary);
  border: 2px solid var(--border-color);
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.3s;
}

.filter-btn:hover {
  background-color: var(--accent-primary);
  color: white;
  border-color: var(--accent-primary);
}

.filter-btn.active {
  background-color: var(--accent-primary);
  color: white;
  border-color: var(--accent-primary);
}

.filter-btn:focus {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* ===== Section Headers ===== */
.section-title {
  font-size: 1.8rem;
  margin: 2rem 0 1rem;
  color: var(--text-primary);
}

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

@media (max-width: 768px) {
  .game-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
  }
}

/* ===== Game Card ===== */
.game-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
  transition: all 0.3s;
  cursor: pointer;
  text-decoration: none;
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  box-shadow: 0 2px 4px var(--shadow);
}

.game-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 12px var(--shadow-hover);
  border-color: var(--accent-primary);
}

.game-card:focus {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.game-icon {
  font-size: 3rem;
  text-align: center;
  margin-bottom: 1rem;
}

.game-title {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.game-category {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.game-description {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  flex-grow: 1;
}

.game-stats {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-secondary);
  padding-top: 0.5rem;
  border-top: 1px solid var(--border-color);
}

/* ===== Buttons ===== */
.btn {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}

.btn-primary {
  background-color: var(--accent-primary);
  color: white;
}

.btn-primary:hover {
  background-color: var(--accent-hover);
}

.btn-primary:focus {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.btn-secondary {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border: 2px solid var(--border-color);
}

.btn-secondary:hover {
  background-color: var(--border-color);
}

.btn-secondary:focus {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* ===== Stats Cards ===== */
.stats-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.5rem;
  margin: 0;
}

.stat-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.5rem;
  text-align: center;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--accent-primary);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.1rem;
}

/* ===== Footer ===== */
footer {
  margin-top: 4rem;
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-secondary);
  border-top: 1px solid var(--border-color);
}

/* ===== Game Page Styles ===== */
.game-container {
  max-width: 900px;
  margin: 2rem auto;
  padding: 1rem;
}

.game-header {
  text-align: center;
  margin-bottom: 2rem;
}

.game-canvas-wrapper {
  position: relative;
  max-width: 100%;
  margin: 0 auto;
  background-color: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
}

.game-canvas-wrapper iframe {
  overflow: hidden;
}

canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

.game-controls {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.game-info {
  display: flex;
  justify-content: space-around;
  margin: 1rem 0;
  padding: 1rem;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
}

.info-item {
  text-align: center;
}

.info-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.info-value {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--accent-primary);
}

/* ===== Modal/Overlay ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal {
  background-color: var(--bg-card);
  border-radius: 12px;
  padding: 2rem;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 4px 20px var(--shadow-hover);
}

.modal-title {
  font-size: 1.8rem;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.modal-content {
  margin-bottom: 1.5rem;
  color: var(--text-secondary);
}

.modal-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
}

/* ===== Utility Classes ===== */
.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .header-content {
    justify-content: center;
    align-items: center;
  }

  .section-title {
    font-size: 1.5rem;
  }

  .game-info {
    flex-direction: column;
    gap: 1rem;
  }
}
