/* Khopi — accueil, style épuré (inspiré design système Apple) */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #f5f5f7;
  --bg-elevated: #ffffff;
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #86868b;
  --separator: rgba(60, 60, 67, 0.12);
  --separator-strong: rgba(60, 60, 67, 0.18);
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-pressed: #006edb;
  --focus-ring: rgba(0, 125, 250, 0.45);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 24px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.12);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --bg-elevated: #1c1c1e;
    --text: #f5f5f7;
    --text-secondary: #a1a1a6;
    --text-tertiary: #8e8e93;
    --separator: rgba(84, 84, 88, 0.48);
    --separator-strong: rgba(84, 84, 88, 0.65);
    --accent: #0a84ff;
    --accent-hover: #409cff;
    --accent-pressed: #0066cc;
    --focus-ring: rgba(10, 132, 255, 0.5);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 16px 56px rgba(0, 0, 0, 0.55);
  }
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html,
body {
  width: 100%;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.47059;
  letter-spacing: -0.022em;
}

/* ── En-tête ── */
.header {
  padding: 56px 24px 40px;
  text-align: center;
  border-bottom: 1px solid var(--separator);
  background: var(--bg);
}

.header-content {
  max-width: 980px;
  margin: 0 auto;
}

.logo {
  margin: 0 auto 10px;
  line-height: 0;
}

.logo-img {
  display: block;
  margin: 0 auto;
  height: clamp(44px, 11vw, 72px);
  width: auto;
  max-width: min(280px, 88vw);
  object-fit: contain;
}

.tagline {
  font-size: 19px;
  font-weight: 400;
  letter-spacing: -0.015em;
  color: var(--text-secondary);
}

/* ── Contenu principal ── */
.container {
  max-width: 1068px;
  margin: 0 auto;
  padding: 48px 22px 80px;
}

/* ── Choix du mode ── */
.player-selection {
  text-align: center;
}

.section-title {
  font-size: clamp(28px, 4vw, 34px);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.15;
  color: var(--text);
  margin-bottom: 28px;
}

.mode-buttons {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

.mode-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-width: 200px;
  padding: 28px 36px;
  background: var(--bg-elevated);
  border: 1px solid var(--separator);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), border-color 0.2s var(--ease);
  box-shadow: var(--shadow-sm);
  color: inherit;
  font: inherit;
}

.mode-btn:hover {
  border-color: var(--separator-strong);
  box-shadow: var(--shadow-md);
}

.mode-btn:active {
  transform: scale(0.98);
}

.mode-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px var(--focus-ring);
}

.mode-icon {
  font-size: 40px;
  line-height: 1;
  opacity: 0.92;
}

.mode-text {
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--text);
}

/* ── Liste des jeux ── */
.games-section {
  display: none;
}

.games-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}

.games-header .section-title {
  margin-bottom: 0;
  flex: 1;
  min-width: min(100%, 240px);
}

.toggle-mode-btn {
  padding: 10px 20px;
  background: var(--accent);
  color: #ffffff;
  border: none;
  border-radius: 980px;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: background 0.2s var(--ease), transform 0.15s var(--ease);
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
  font-family: inherit;
}

.toggle-mode-btn:hover {
  background: var(--accent-hover);
}

.toggle-mode-btn:active {
  background: var(--accent-pressed);
  transform: scale(0.98);
}

.toggle-mode-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px var(--focus-ring);
}

/* ── Grille ── */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
  align-items: stretch;
}

/* ── Cartes jeu ── */
.game-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-elevated);
  border: 1px solid var(--separator);
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), border-color 0.25s var(--ease);
  box-shadow: var(--shadow-sm);
}

.game-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--separator-strong);
}

.card-img {
  width: 100%;
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.card-img::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06) 0%, transparent 40%);
  pointer-events: none;
}

@media (prefers-color-scheme: dark) {
  .card-img::after {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0%, transparent 45%);
  }
}

.card-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.022em;
  color: #ffffff;
  text-align: center;
  padding: 0 14px;
  position: relative;
  z-index: 1;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.35);
}

.card-link {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  background: transparent;
  color: var(--accent);
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.01em;
  transition: color 0.2s var(--ease), background 0.2s var(--ease);
  border: none;
  border-top: 1px solid var(--separator);
  cursor: pointer;
  padding: 14px 16px;
  width: 100%;
  font-family: inherit;
}

.card-link:hover {
  color: var(--accent-hover);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.card-link:active {
  color: var(--accent-pressed);
}

.card-link:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--focus-ring);
  z-index: 1;
}

.game-card:hover .card-link {
  color: #ffffff;
  background: var(--accent);
}

.game-card:hover .card-link:hover {
  background: var(--accent-hover);
  color: #ffffff;
}

/* ── Modale ── */
.game-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s var(--ease), visibility 0.35s;
}

.game-modal.active {
  opacity: 1;
  visibility: visible;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}

.modal-content {
  position: relative;
  width: min(92vw, 1120px);
  height: min(88vh, 820px);
  background: var(--bg-elevated);
  border: 1px solid var(--separator);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--separator);
  min-height: 52px;
}

.modal-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.022em;
  color: var(--text);
  margin: 0;
}

.modal-controls {
  display: flex;
  gap: 8px;
}

.modal-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: 1px solid var(--separator);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease);
  font-size: 16px;
  line-height: 1;
}

.modal-btn:hover {
  background: color-mix(in srgb, var(--text) 6%, transparent);
  color: var(--text);
  border-color: var(--separator-strong);
}

.modal-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.modal-body {
  flex: 1;
  position: relative;
  min-height: 0;
  background: #000000;
}

#gameFrame {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* ── Pied de page ── */
.footer {
  text-align: center;
  padding: 28px 22px;
  border-top: 1px solid var(--separator);
  margin-top: auto;
  color: var(--text-tertiary);
  font-size: 12px;
  letter-spacing: -0.01em;
}

/* ── Accessibilité : réduire les animations ── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .header {
    padding: 44px 20px 32px;
  }

  .container {
    padding: 36px 18px 64px;
  }

  .games-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 14px;
  }

  .mode-buttons {
    flex-direction: column;
    align-items: stretch;
  }

  .mode-btn {
    min-width: unset;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
  }

  .modal-content {
    width: 94vw;
    height: 90vh;
    border-radius: var(--radius-md);
  }

  .modal-header {
    padding: 12px 14px;
  }
}

@media (max-width: 480px) {
  .games-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
  }

  .card-title {
    font-size: 15px;
  }

  .card-link {
    font-size: 14px;
    padding: 12px;
  }

  .section-title {
    font-size: 24px;
  }

  .mode-icon {
    font-size: 34px;
  }

  .mode-text {
    font-size: 16px;
  }
}
