/* Quizzma - Moroccan football games platform
   Colors from the Moroccan flag: red #C1272D, green #006233 */

:root {
  --ma-red: #C1272D;
  --ma-red-dark: #8E1B22;
  --ma-green: #006233;
  --ma-green-dark: #004822;
  --ma-gold: #D4AF37;
  --bg: #0F1419;
  --bg-card: #1A2028;
  --bg-elevated: #232B36;
  --border: #2D3743;
  --text: #E8ECF1;
  --text-muted: #8A95A5;
  --correct: #538D4E;
  --present: #B59F3B;
  --absent: #3A3A3C;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--ma-gold); text-decoration: none; }
a:hover { text-decoration: underline; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

/* Header */
.site-header {
  background: linear-gradient(135deg, var(--ma-red) 0%, var(--ma-red-dark) 100%);
  padding: 14px 20px;
  border-bottom: 4px solid var(--ma-green);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.site-header .inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 22px;
  font-weight: 800;
  color: white;
  letter-spacing: 0.5px;
}
.brand .star { color: var(--ma-green); font-size: 26px; line-height: 1; }
.brand a { color: white; text-decoration: none; }

.nav-links { display: flex; gap: 18px; align-items: center; }
.nav-links a {
  color: white;
  font-weight: 500;
  font-size: 14px;
  opacity: 0.9;
}
.nav-links a:hover { opacity: 1; text-decoration: none; }

.lang-switcher {
  display: flex;
  background: rgba(0,0,0,0.25);
  border-radius: 6px;
  overflow: hidden;
}
.lang-switcher button {
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  color: white;
  opacity: 0.6;
}
.lang-switcher button.active { background: var(--ma-green); opacity: 1; }

/* Hero */
.hero {
  background:
    radial-gradient(ellipse at top, rgba(193, 39, 45, 0.18) 0%, transparent 60%),
    radial-gradient(ellipse at bottom, rgba(0, 98, 51, 0.18) 0%, transparent 60%);
  padding: 50px 20px 30px;
  text-align: center;
}
.hero h1 {
  font-size: clamp(28px, 5vw, 44px);
  font-weight: 800;
  margin-bottom: 12px;
  background: linear-gradient(90deg, var(--ma-red) 0%, var(--ma-gold) 50%, var(--ma-green) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero p {
  font-size: 16px;
  color: var(--text-muted);
  max-width: 620px;
  margin: 0 auto;
}

/* Layout */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 30px 20px;
}

.section-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* Games grid */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 36px;
}
.game-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
}
.game-card:hover {
  transform: translateY(-3px);
  border-color: var(--ma-gold);
  box-shadow: 0 8px 24px rgba(212, 175, 55, 0.15);
  text-decoration: none;
}
.game-card .icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  background: linear-gradient(135deg, var(--ma-red), var(--ma-red-dark));
}
.game-card.green .icon { background: linear-gradient(135deg, var(--ma-green), var(--ma-green-dark)); }
.game-card.gold .icon { background: linear-gradient(135deg, var(--ma-gold), #8B7320); }
.game-card h3 { font-size: 17px; font-weight: 700; }
.game-card p { font-size: 13px; color: var(--text-muted); line-height: 1.4; }
.game-card .badge {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 3px 7px;
  border-radius: 4px;
  background: var(--ma-green);
  color: white;
  text-transform: uppercase;
}

/* Game container shared */
.game-wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}
.game-header {
  text-align: center;
  margin-bottom: 24px;
}
.game-header h2 {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 6px;
}
.game-header .subtitle {
  font-size: 13px;
  color: var(--text-muted);
}
.daily-tag {
  display: inline-block;
  background: var(--ma-green);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

/* Buttons */
.btn {
  background: var(--ma-red);
  color: white;
  padding: 10px 18px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  border: none;
  transition: background 0.15s ease;
}
.btn:hover { background: var(--ma-red-dark); }
.btn.secondary { background: var(--bg-elevated); color: var(--text); }
.btn.secondary:hover { background: var(--border); }
.btn.green { background: var(--ma-green); }
.btn.green:hover { background: var(--ma-green-dark); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Inputs */
.text-input {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 14px;
  border-radius: 8px;
  font-size: 15px;
  width: 100%;
  font-family: inherit;
}
.text-input:focus {
  outline: none;
  border-color: var(--ma-gold);
}

/* Autocomplete */
.autocomplete { position: relative; }
.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 8px 8px;
  max-height: 240px;
  overflow-y: auto;
  z-index: 50;
}
.autocomplete-list div {
  padding: 9px 14px;
  cursor: pointer;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}
.autocomplete-list div:hover,
.autocomplete-list div.active {
  background: var(--ma-red);
  color: white;
}

/* Wordle grid */
.wordle-grid {
  display: grid;
  gap: 6px;
  margin: 24px auto;
  justify-content: center;
}
.wordle-row { display: grid; gap: 6px; justify-content: center; }
.wordle-cell {
  width: 52px;
  height: 52px;
  border: 2px solid var(--border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  text-transform: uppercase;
}
.wordle-cell.filled { border-color: #565758; }
.wordle-cell.correct { background: var(--correct); border-color: var(--correct); color: white; }
.wordle-cell.present { background: var(--present); border-color: var(--present); color: white; }
.wordle-cell.absent { background: var(--absent); border-color: var(--absent); color: white; }

/* Keyboard */
.keyboard {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 20px auto;
  max-width: 500px;
}
.kb-row { display: flex; gap: 5px; justify-content: center; }
.kb-key {
  background: var(--bg-elevated);
  color: var(--text);
  border: none;
  border-radius: 4px;
  height: 48px;
  min-width: 30px;
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-transform: uppercase;
  user-select: none;
}
.kb-key.wide { flex: 1.5; font-size: 11px; }
.kb-key.correct { background: var(--correct); color: white; }
.kb-key.present { background: var(--present); color: white; }
.kb-key.absent { background: var(--absent); color: white; }

/* Career path */
.career-table {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 18px;
}
.career-table table { width: 100%; border-collapse: collapse; }
.career-table th, .career-table td {
  padding: 10px 12px;
  text-align: left;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}
.career-table th {
  background: var(--bg-elevated);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}
.career-table tr:last-child td { border-bottom: none; }
.career-table .hidden-row { color: var(--text-muted); }

/* Guesses display */
.guesses-list {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 14px;
  min-height: 50px;
}
.guesses-list .guess {
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 14px;
  margin: 2px 0;
  background: var(--bg-elevated);
}
.guesses-list .guess.correct { background: var(--correct); color: white; font-weight: 700; }
.guesses-list .guess.skipped { background: var(--absent); color: var(--text-muted); }

/* Pitch / Missing XI */
.pitch {
  background: linear-gradient(180deg, #0a4d2a 0%, #1a6b3a 100%);
  border: 2px solid white;
  border-radius: 10px;
  position: relative;
  width: 100%;
  aspect-ratio: 0.7;
  max-width: 480px;
  margin: 16px auto;
  background-image:
    linear-gradient(180deg, transparent 49.5%, rgba(255,255,255,0.5) 49.5%, rgba(255,255,255,0.5) 50.5%, transparent 50.5%);
}
.pitch::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 80px;
  height: 80px;
  border: 2px solid rgba(255,255,255,0.5);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}
.shirt {
  position: absolute;
  width: 56px;
  height: 60px;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: default;
}
.shirt-num {
  background: var(--ma-red);
  color: white;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 800;
  font-size: 14px;
  border: 2px solid white;
}
.shirt-name {
  background: rgba(0,0,0,0.7);
  color: white;
  font-size: 9px;
  padding: 2px 4px;
  border-radius: 3px;
  margin-top: 2px;
  max-width: 70px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.shirt.found .shirt-num { background: var(--correct); }
.shirt.found .shirt-name { background: var(--correct); font-weight: 700; }

/* Who Are Ya */
.player-photo {
  width: 200px;
  height: 200px;
  border-radius: 12px;
  overflow: hidden;
  margin: 0 auto 18px;
  background: var(--bg-elevated);
  position: relative;
}
.player-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: blur(20px);
  transition: filter 0.4s ease;
}
.attr-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.attr-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}
.attr-cell {
  background: var(--absent);
  color: white;
  padding: 8px 4px;
  border-radius: 4px;
  font-size: 11px;
  text-align: center;
  font-weight: 600;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.attr-cell.match { background: var(--correct); }
.attr-cell.partial { background: var(--present); }

/* Connections */
.connections-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.conn-cell {
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  border-radius: 6px;
  padding: 14px 6px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  transition: transform 0.1s ease;
}
.conn-cell.selected {
  background: var(--ma-red);
  color: white;
  border-color: var(--ma-red);
  transform: scale(0.97);
}
.conn-cell.solved { cursor: default; }
.solved-group {
  background: var(--ma-green);
  color: white;
  padding: 12px;
  border-radius: 6px;
  margin-bottom: 8px;
  text-align: center;
}
.solved-group h4 { font-size: 13px; margin-bottom: 4px; }
.solved-group p { font-size: 12px; opacity: 0.9; }

/* Result modal */
.result-card {
  background: var(--bg-card);
  border: 2px solid var(--ma-gold);
  border-radius: 12px;
  padding: 24px;
  margin-top: 20px;
  text-align: center;
}
.result-card h3 { font-size: 22px; margin-bottom: 10px; }
.result-card p { color: var(--text-muted); margin-bottom: 16px; font-size: 14px; }
.streak-row {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin: 14px 0;
}
.streak-row div { text-align: center; }
.streak-row .num { font-size: 26px; font-weight: 800; color: var(--ma-gold); }
.streak-row .lbl { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }

/* Footer */
.site-footer {
  text-align: center;
  padding: 30px 20px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 40px;
}
.site-footer .flag { color: var(--ma-red); }

/* Toast */
.toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  border: 1px solid var(--ma-gold);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  z-index: 200;
  animation: toastIn 0.2s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* RTL */
html[dir="rtl"] body { font-family: "Segoe UI", "Tahoma", "Arial", sans-serif; }
html[dir="rtl"] .career-table th,
html[dir="rtl"] .career-table td { text-align: right; }

/* Responsive */
@media (max-width: 600px) {
  .wordle-cell { width: 44px; height: 44px; font-size: 20px; }
  .games-grid { grid-template-columns: 1fr 1fr; }
  .game-card { padding: 14px; }
  .nav-links { display: none; }
  .hero { padding: 30px 16px 20px; }
  .connections-grid { gap: 6px; }
  .conn-cell { font-size: 10px; padding: 10px 4px; }
  .pitch { max-width: 100%; }
  .shirt { width: 44px; height: 50px; }
  .shirt-num { width: 26px; height: 26px; font-size: 11px; }
  .shirt-name { font-size: 8px; max-width: 56px; }
}
