* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --background: #f4f6f7;
  --surface: #ffffff;
  --primary: #3498db;
  --primary-dark: #2980b9;
  --success: #2ecc71;
  --text: #2c3e50;
  --muted: #7f8c8d;
  --border: #e5e7eb;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

body {
  font-family: Arial, Helvetica, sans-serif;
  background: var(--background);
  color: var(--text);
  min-height: 100vh;
  transition:
    background 0.3s ease,
    color 0.3s ease;
}

.app {
  width: min(1100px, 94%);
  margin: auto;
  padding: 30px 0;
}

/* =========================================
   HEADER
========================================= */

.header {
  text-align: center;
  margin-bottom: 30px;
}

.header h1 {
  font-size: 38px;
  margin-bottom: 8px;
}

.header p {
  color: var(--muted);
  font-size: 15px;
}

/* =========================================
   CONTROLS
========================================= */

.controls {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 15px;
  flex-wrap: wrap;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.control-group label {
  font-size: 12px;
  font-weight: bold;
  color: var(--muted);
}

select {
  min-width: 130px;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}

button {
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.primary-btn, .success-btn,
.secondary-btn {
  padding: 11px 18px;
  border-radius: 10px;
  font-weight: bold;
  font-size: 14px;
  transition:
    transform 0.2s ease,
    opacity 0.2s ease;
}

.primary-btn {
  background: var(--primary);

  color: white;
}

.success-btn {
  background: var(--success);
  color: white;
}

.secondary-btn {
  background: var(--text);
  color: white;
}

.primary-btn:hover,
.secondary-btn:hover {
  transform: translateY(-2px);
  opacity: 0.9;
}

/* =========================================
   STATS
========================================= */

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 15px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
}

.stat-icon {
  font-size: 27px;
}

.stat-title {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}

.stat-card strong {
  font-size: 22px;
}

/* =========================================
   RECOMMENDATION
========================================= */

.recommendation {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  display: flex;
  gap: 15px;
  align-items: center;
  margin-bottom: 25px;
  box-shadow: var(--shadow);
}

.recommendation-icon {
  font-size: 35px;
}

.recommendation h3 {
  font-size: 15px;
  margin-bottom: 5px;
}

.recommendation p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

/* =========================================
   GAME BOARD
========================================= */

.game-board {
  display: grid;
  gap: 10px;
  justify-content: center;
  margin: auto;
  padding: 15px;
  width: fit-content;
  max-width: 100%;
}

/* =========================================
   CARDS
========================================= */

.card {
  width: 110px;
  height: 110px;
  border-radius: 15px;
  background: var(--primary);
  color: white;
  font-size: 38px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 5px 10px rgba(0, 0, 0, 0.12);
  transition:
    transform 0.25s ease,
    background 0.25s ease;
}

.card:hover {
  transform: translateY(-4px);
}

.card.flipped {
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--primary);
  transform: rotateY(180deg);
}

.card.matched {
  background: var(--success);
  cursor: default;
  transform: scale(0.95);
}

.card.disabled {
  pointer-events: none;
}

/* =========================================
   FOOTER
========================================= */

footer {
  text-align: center;
  margin-top: 35px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.8;
}

/* =========================================
   MODAL
========================================= */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}

.modal.show {
  display: flex;
}

.modal-content {
  width: min(720px, 95%);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 20px;
  padding: 30px;
  position: relative;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.modal-content h2 {
  text-align: center;
  margin-bottom: 25px;
}

.close-btn {
  position: absolute;
  right: 18px;
  top: 12px;
  font-size: 30px;
  background: transparent;
  color: var(--muted);
}

.analytics-section {
  margin-bottom: 25px;
  padding: 18px;
  border-radius: 14px;
  background: rgba(127, 140, 141, 0.08);
}

.analytics-section h3 {
  margin-bottom: 15px;
}

/* =========================================
   BEST TIMES
========================================= */

.best-times {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.best-time-card {
  padding: 15px;
  border-radius: 12px;
  background: var(--surface);
  text-align: center;
  border: 1px solid var(--border);
}

.best-time-card strong {
  display: block;
  margin-top: 8px;
  font-size: 20px;
}

/* =========================================
   OVERALL STATS
========================================= */

.overall-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.overall-item {
  background: var(--surface);
  padding: 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.overall-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}

.overall-item strong {
  font-size: 19px;
}

/* =========================================
   RESULT
========================================= */

.result-content {
  text-align: center;
  max-width: 500px;
}

.result-icon {
  font-size: 60px;
  margin-bottom: 10px;
}

.result-content > p {
  color: var(--muted);
  margin-bottom: 20px;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.result-stat {
  padding: 15px;
  background: rgba(52, 152, 219, 0.08);
  border-radius: 10px;
}

.result-stat span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}

.result-stat strong {
  font-size: 20px;
}

.result-recommendation {
  background: rgba(46, 204, 113, 0.1);
  border-radius: 12px;
  padding: 15px;
  text-align: left;
  margin-bottom: 20px;
}

.result-recommendation p {
  margin-top: 7px;
  color: var(--muted);
  line-height: 1.5;
}

/* =========================================
   RESPONSIVE
========================================= */

@media (max-width: 800px) {
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .card {
    width: 80px;
    height: 80px;
    font-size: 30px;
  }
}

@media (max-width: 500px) {
  .app {
    width: 96%;
  }

  .header h1 {
    font-size: 28px;
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .controls {
    align-items: stretch;
    flex-direction: column;
  }

  .control-group {
    width: 100%;
  }

  select {
    width: 100%;
  }

  .best-times {
    grid-template-columns: 1fr;
  }

  .card {
    width: 65px;
    height: 65px;
    font-size: 23px;
  }

  .game-board {
    gap: 6px;
  }
}
