/* ============================================
   经典小游戏合集 - 公共样式
   ============================================ */

/* --- CSS Reset --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* --- CSS Variables --- */
:root {
  --primary: #667eea;
  --primary-dark: #764ba2;
  --bg: #1a1a2e;
  --card-bg: #16213e;
  --text: #eee;
  --text-secondary: #aaa;
  --success: #4caf50;
  --danger: #f44336;
  --warning: #ff9800;
}

/* --- Body --- */
body {
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", "PingFang SC", "Microsoft YaHei",
    sans-serif;
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* --- App Header --- */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  box-shadow: 0 2px 15px rgba(0, 0, 0, 0.3);
}

.app-header h1 {
  color: #fff;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 1px;
}

/* --- Buttons --- */
.btn {
  display: inline-block;
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.2s ease;
  text-decoration: none;
  color: #fff;
  background: var(--primary);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
}

.btn-primary:hover {
  box-shadow: 0 4px 15px rgba(118, 75, 162, 0.5);
}

.btn-danger {
  background: var(--danger);
}

.btn-danger:hover {
  box-shadow: 0 4px 12px rgba(244, 67, 54, 0.4);
}

.btn-small {
  padding: 6px 16px;
  font-size: 0.85rem;
  border-radius: 6px;
}

/* --- Game Grid (Catalog) --- */
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
  padding: 20px;
  max-width: 900px;
  margin: 0 auto;
}

/* --- Game Card --- */
.game-card {
  background: var(--card-bg);
  border-radius: 14px;
  padding: 28px 20px 20px;
  cursor: pointer;
  text-align: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  user-select: none;
}

.game-card:hover {
  transform: scale(1.03);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.25);
}

.game-card .icon {
  font-size: 3rem;
  line-height: 1;
}

.game-card .name {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
}

.game-card .score {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* --- Game Nav (inside game) --- */
.game-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  padding: 12px 16px;
  z-index: 50;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.game-nav .back-btn {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: background 0.2s;
}

.game-nav .back-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.game-nav .title {
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
}

.game-nav .score-display {
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
}

/* --- Game Container --- */
.game-container {
  max-width: 500px;
  margin: 80px auto 0;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* --- Game Info Bar --- */
.game-info {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

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

.modal {
  background: var(--card-bg);
  border-radius: 14px;
  padding: 30px 28px;
  text-align: center;
  max-width: 360px;
  width: 90%;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.modal h2 {
  margin-bottom: 12px;
  font-size: 1.3rem;
  color: var(--text);
}

.modal .btn {
  margin: 6px;
}

/* --- Hidden --- */
.hidden {
  display: none !important;
}

/* --- Difficulty Select --- */
.difficulty-select {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-top: 30px;
}

.difficulty-select .btn {
  width: 200px;
  text-align: center;
}

/* --- Control Hint --- */
.control-hint {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-align: center;
  margin-top: 16px;
}

/* --- Clear Data Button --- */
.clear-data-btn {
  display: block;
  margin: 20px auto 0;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.clear-data-btn:hover {
  background: rgba(244, 67, 54, 0.15);
  color: var(--danger);
  border-color: rgba(244, 67, 54, 0.3);
  box-shadow: none;
}

/* --- Responsive --- */
@media (max-width: 600px) {
  .app-header {
    padding: 14px 16px;
  }

  .app-header h1 {
    font-size: 1.2rem;
  }

  .game-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
    padding: 14px;
  }

  .game-card {
    padding: 22px 14px 16px;
    border-radius: 12px;
  }

  .game-card .icon {
    font-size: 2.4rem;
  }

  .game-card .name {
    font-size: 1rem;
  }

  .btn {
    padding: 8px 18px;
    font-size: 0.95rem;
  }

  .btn-small {
    padding: 5px 12px;
    font-size: 0.8rem;
  }

  .game-container {
    margin-top: 70px;
    padding: 14px;
  }

  .difficulty-select .btn {
    width: 160px;
  }
}