:root {
  --game-purple: #6656e8;
  --game-yellow: #d89b17;
  --game-red: #df4e56;
  --game-blue: #2c77c9;
  --game-navy: #27345f;
  --game-green: #208767;
  --game-coral: #e76855;
}

.games-back { color: var(--brand); font-weight: 800; text-decoration: none; }
.games-content { max-width: 1350px; margin: auto; padding: 32px 38px 60px; }
.games-hero { display: flex; align-items: end; justify-content: space-between; gap: 20px; padding: 25px 0 12px; }
.games-hero h1 { margin: 4px 0; font-size: 34px; }
.games-hero p { margin: 0; color: var(--muted); font-size: 16px; }
.question-bank-link { flex: 0 0 auto; text-decoration: none; }

.games-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  margin: 30px 0 14px;
  color: var(--muted);
}
.games-section-head > div { display: flex; align-items: center; gap: 10px; }
.games-section-head h2 { color: var(--ink); font-size: 21px; }
.games-main-head { margin-bottom: 18px; }
.step {
  display: inline-grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border-radius: 9px;
  color: #5145bd;
  background: #eae7ff;
  font-weight: 900;
}

.game-mode-list { display: grid; gap: 24px; }
.game-mode {
  --mode-color: #6656e8;
  --mode-soft: #f3f1ff;
  overflow: hidden;
  padding: 0 20px 20px;
  background: linear-gradient(135deg, var(--mode-soft), #fff 48%);
  border: 1px solid color-mix(in srgb, var(--mode-color) 25%, #dfe4ed);
  border-top: 6px solid var(--mode-color);
  border-radius: 20px;
  box-shadow: 0 12px 34px rgba(31, 43, 77, .06);
}
.game-mode-solo { --mode-color: #6556e8; --mode-soft: #f1efff; }
.game-mode-classe { --mode-color: #e0782e; --mode-soft: #fff4e9; }
.game-mode-multiplayer { --mode-color: #16876d; --mode-soft: #eaf9f4; }
.game-mode-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 2px 16px;
  border-bottom: 1px solid color-mix(in srgb, var(--mode-color) 18%, #e5e8ef);
}
.mode-icon {
  display: grid;
  flex: 0 0 43px;
  place-items: center;
  width: 43px;
  height: 43px;
  color: #fff;
  background: var(--mode-color);
  border-radius: 13px;
  font-size: 17px;
  box-shadow: 0 8px 20px color-mix(in srgb, var(--mode-color) 25%, transparent);
}
.mode-label {
  display: block;
  margin-bottom: 2px;
  color: var(--mode-color);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .9px;
  text-transform: uppercase;
}
.game-mode-head h3 { margin: 0; color: var(--ink); font-size: 21px; }
.game-mode-head p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 13px;
  padding-top: 17px;
}
.game-choice {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  min-height: 128px;
  padding: 16px;
  text-align: left;
  background: #fff;
  border: 1px solid #dce2eb;
  border-radius: 16px;
  box-shadow: 0 6px 20px rgba(35, 33, 72, .04);
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.game-choice:hover { transform: translateY(-3px); border-color: var(--game-color); box-shadow: 0 12px 26px rgba(35, 33, 72, .11); }
.game-choice:focus-visible { outline: 3px solid color-mix(in srgb, var(--game-color) 28%, transparent); outline-offset: 2px; }
.game-choice.selected { border-color: var(--game-color); box-shadow: 0 0 0 3px color-mix(in srgb, var(--game-color) 18%, transparent); }
.game-emoji {
  display: grid;
  place-items: center;
  width: 49px;
  height: 49px;
  background: color-mix(in srgb, var(--game-color) 12%, white);
  border-radius: 14px;
  font-size: 25px;
}
.game-copy { display: grid; align-content: start; }
.game-copy strong { font: 800 16px Manrope; }
.game-copy small { margin-top: 5px; color: var(--muted); line-height: 1.4; }
.game-badge {
  position: absolute;
  bottom: 13px;
  left: 16px;
  color: var(--game-color);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .6px;
  text-transform: uppercase;
}

#quizArea, .direct-launch { scroll-margin-top: 18px; }
.quiz-search {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 11px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.quiz-search input { width: 190px; border: 0; outline: 0; }
.quiz-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 11px; }
.quiz-choice {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  text-decoration: none;
}
.quiz-choice:hover { transform: translateY(-1px); border-color: #afa8ef; }
.quiz-choice:focus-visible { outline: 3px solid rgba(101, 86, 232, .22); outline-offset: 2px; }
.quiz-choice[hidden] { display: none; }
.quiz-icon {
  display: grid;
  place-items: center;
  width: 39px;
  height: 39px;
  color: #5145bd;
  background: #eeecff;
  border-radius: 11px;
  font-weight: 900;
}
.quiz-choice strong, .quiz-choice small { display: block; }
.quiz-choice small { color: var(--muted); }
.quiz-choice b { color: var(--brand); font-size: 13px; }
.quiz-choice.personal-quiz { border-color: #b9aef8; background: linear-gradient(135deg, #f5f2ff, #eef8ff); }
.quiz-choice.personal-quiz .quiz-icon { color: #fff; background: linear-gradient(135deg, #6552e8, #4788f5); }
.games-empty, .direct-launch {
  padding: 30px;
  color: var(--muted);
  background: #fff;
  border: 1px dashed #ced2df;
  border-radius: 15px;
  text-align: center;
}
.direct-launch { margin-top: 28px; }
.direct-launch h2 { margin: 10px 0 3px; color: var(--ink); }
.direct-launch p { margin: 0 0 17px; }

.quiz-guide[hidden] { display: none; }
.quiz-guide {
  position: fixed;
  z-index: 2000;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(29, 57, 82, .74);
  backdrop-filter: blur(4px);
  animation: guide-fade .2s ease-out;
}
.quiz-guide-card {
  display: grid;
  place-items: center;
  min-width: min(520px, 92vw);
  padding: 36px 30px;
  color: #fff;
  background: transparent;
  border: 0;
  border-radius: 22px;
  text-align: center;
  cursor: pointer;
}
.quiz-guide-card > span { font-size: clamp(26px, 4vw, 38px); font-weight: 800; line-height: 1.35; text-shadow: 0 2px 18px rgba(0, 0, 0, .25); }
.quiz-guide-card b { margin: 20px 0 8px; font-size: 60px; line-height: 1; animation: guide-arrow 1s ease-in-out infinite; }
.quiz-guide-card small { padding: 7px 12px; color: rgba(255, 255, 255, .9); border: 1px solid rgba(255, 255, 255, .35); border-radius: 999px; font-weight: 700; }
.quiz-guide-card:focus-visible { outline: 3px solid #fff; outline-offset: 5px; }
.quiz-guide-open { overflow: hidden; }

.quiz-head-actions { display: flex; align-items: center; gap: 9px; }
.custom-quiz-open { padding: 11px 14px; color: #fff; background: linear-gradient(135deg, #6552e8, #4788f5); border: 0; border-radius: 10px; font: inherit; font-weight: 850; cursor: pointer; }
.custom-quiz-dialog { width: min(1040px, calc(100% - 24px)); max-height: 92vh; padding: 0; color: var(--ink); background: #f7f8fc; border: 0; border-radius: 20px; box-shadow: 0 28px 90px rgba(22, 29, 55, .3); }
.custom-quiz-dialog::backdrop { background: rgba(25, 34, 60, .66); backdrop-filter: blur(3px); }
.custom-quiz-shell { display: grid; gap: 13px; padding: 20px; }
.custom-quiz-shell > header { display: flex; justify-content: space-between; gap: 20px; }
.custom-quiz-shell > header span { color: var(--brand); font-size: 10px; font-weight: 900; letter-spacing: .12em; }
.custom-quiz-shell h2 { margin: 3px 0; font-size: 27px; }
.custom-quiz-shell header p { margin: 0; color: var(--muted); }
.custom-dialog-close { align-self: flex-start; width: 38px; height: 38px; color: #586178; background: #fff; border: 1px solid var(--line); border-radius: 50%; font-size: 25px; cursor: pointer; }
.custom-quiz-name { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 12px; }
.custom-quiz-name label > span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 11px; }
.custom-quiz-name input, .custom-quiz-search input { width: 100%; padding: 11px 12px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 10px; font: inherit; }
#customSelectedCount { padding: 10px 12px; color: #5142c5; background: #ece9ff; border-radius: 999px; font-size: 12px; white-space: nowrap; }
.custom-quiz-search { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.custom-quiz-search button { padding: 0 19px; color: #fff; background: var(--brand); border: 0; border-radius: 10px; font: inherit; font-weight: 850; cursor: pointer; }
.custom-quiz-status { margin: -3px 0 0; color: var(--muted); font-size: 12px; }
.custom-quiz-status.working { color: #5142c5; }.custom-quiz-status.error { color: #a3322a; }
.custom-quiz-columns { display: grid; grid-template-columns: 1.18fr .82fr; gap: 12px; min-height: 310px; }
.custom-quiz-columns > section { min-width: 0; padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: 13px; }
.custom-quiz-columns h3 { margin: 0 0 9px; font-size: 14px; }
.custom-results, .custom-selected { display: grid; gap: 7px; max-height: 40vh; overflow: auto; }
.custom-results > p, .custom-selected > p { margin: 0; padding: 25px 10px; color: var(--muted); text-align: center; }
.custom-result-card, .custom-selected-card { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 10px; border: 1px solid #e4e7ef; border-radius: 10px; }
.custom-result-card strong, .custom-result-card small, .custom-selected-card strong, .custom-selected-card small { display: block; }
.custom-result-card small, .custom-selected-card small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.custom-result-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 5px; }
.custom-result-tags b { padding: 3px 5px; color: #5b6376; background: #f0f2f6; border-radius: 5px; font-size: 9px; }
.custom-result-card > button, .custom-selected-card > button { flex: 0 0 auto; padding: 7px 8px; color: #5142c5; background: #eeebff; border: 0; border-radius: 7px; font: inherit; font-size: 11px; font-weight: 850; cursor: pointer; }
.custom-result-card > button:disabled { color: #18704c; background: #e5f8ef; }
.custom-selected-card > button { color: #a3322a; background: #fff0ee; }
.custom-quiz-shell > footer { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.custom-save-choice { display: flex; align-items: flex-start; gap: 8px; cursor: pointer; }
.custom-save-choice input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--brand); }
.custom-save-choice span, .custom-save-choice strong, .custom-save-choice small { display: block; }.custom-save-choice small { color: var(--muted); }
.custom-quiz-shell > footer > div { display: flex; gap: 8px; }
.custom-quiz-shell > footer button { padding: 10px 13px; color: #565f75; background: #fff; border: 1px solid var(--line); border-radius: 9px; font: inherit; font-weight: 800; cursor: pointer; }
.custom-quiz-shell > footer .custom-play { color: #fff; background: linear-gradient(135deg, #6552e8, #4788f5); border: 0; }.custom-quiz-shell > footer .custom-play:disabled { opacity: .45; cursor: not-allowed; }

@keyframes guide-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes guide-arrow { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(9px); } }

@media (max-width: 760px) {
  .games-content { padding: 22px 16px 100px; }
  .games-hero { align-items: stretch; flex-direction: column; }
  .question-bank-link { width: 100%; }
  .games-section-head { align-items: stretch; flex-direction: column; }
  .game-mode { padding: 0 14px 14px; border-radius: 17px; }
  .game-mode-head { align-items: flex-start; }
  .games-grid, .quiz-grid { grid-template-columns: 1fr; }
  .quiz-search { width: 100%; }
  .quiz-search input { width: 100%; }
  .quiz-head-actions { align-items: stretch; flex-direction: column; }
  .custom-quiz-columns { grid-template-columns: 1fr; }
  .custom-results, .custom-selected { max-height: 32vh; }
  .custom-quiz-shell > footer { align-items: stretch; flex-direction: column; }
  .custom-quiz-shell > footer > div, .custom-quiz-shell > footer button { width: 100%; }
  .quiz-guide-card { padding-inline: 8px; }
  .quiz-guide-card > span { font-size: 27px; }
}

@media (prefers-reduced-motion: reduce) {
  .game-choice, .quiz-choice, .quiz-guide, .quiz-guide-card b { animation: none; transition: none; }
}
