.game-setup-section {
  min-height: 100dvh;
  align-items: center;
  justify-content: center;
  padding: clamp(1.25rem, 4vw, 2.5rem) 1rem;
}

.game-setup-content {
  box-sizing: border-box;
  display: grid;
  width: min(100%, 900px);
  max-width: 900px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
  gap: 0.75rem;
  padding: clamp(1.1rem, 3vw, 1.8rem);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 1.25rem;
  background: rgba(20, 22, 38, 0.94);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
  animation: fadeUp 0.5s ease-out both;
}

.game-setup-content *,
.game-setup-content *::before,
.game-setup-content *::after {
  box-sizing: border-box;
}

.game-setup-content:hover {
  border-color: rgba(255, 255, 255, 0.16);
}

.flipquiz-setup-heading {
  grid-column: 1 / -1;
  margin-bottom: 0.25rem;
}

.flipquiz-setup-eyebrow {
  color: #fca5a5;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.15em;
}

.game-setup-content .flipquiz-setup-heading h2 {
  margin: 0.35rem 0;
  background: none;
  color: #f8fafc;
  font-size: clamp(1.7rem, 4vw, 2.25rem);
  letter-spacing: 0;
  text-align: left;
  -webkit-text-fill-color: currentColor;
}

.flipquiz-setup-heading p {
  margin: 0;
  color: #aab3c5;
  font-family: inherit;
  font-size: 0.92rem;
  line-height: 1.5;
}

.game-setup-content .setup-row {
  width: 100%;
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 0.6rem;
  margin: 0;
  padding: 0.85rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.85rem;
  background: rgba(255, 255, 255, 0.035);
}

.game-setup-content .setup-row:hover {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  transform: none;
}

.game-setup-content .setup-row label:first-child {
  min-width: 0;
  margin: 0;
  color: #aab3c5;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.game-setup-content .setup-radio-group {
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.game-setup-content .setup-number-btn {
  min-width: 42px;
  min-height: 40px;
  padding: 0.45rem 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 0.65rem;
  background: rgba(255, 255, 255, 0.045);
  color: #cbd5e1;
  font-family: inherit;
  font-size: 0.88rem;
}

.game-setup-content .setup-number-btn:hover {
  transform: none;
  border-color: rgba(248, 113, 113, 0.45);
  background: rgba(239, 68, 68, 0.08);
  box-shadow: none;
}

.game-setup-content .setup-number-btn.active {
  transform: none;
  border-color: rgba(248, 113, 113, 0.55);
  background: rgba(239, 68, 68, 0.14);
  color: #fecaca;
  box-shadow: none;
}

.game-setup-content .setup-number-btn:disabled {
  border-color: rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.02);
  color: #64748b;
  cursor: not-allowed;
  opacity: 0.55;
}

.card-count-notice {
  margin: 0;
  color: #94a3b8;
  font-family: inherit;
  font-size: 0.75rem;
  line-height: 1.45;
}

.setup-row--theme,
.volume-controls-section,
.quiz-selection-container {
  grid-column: 1 / -1;
}

.appearance-controls-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
  gap: 0.75rem;
  width: 100%;
}

.appearance-controls-row .setup-row--theme,
.appearance-controls-row .volume-controls-section {
  grid-column: auto;
  height: 100%;
  margin: 0;
}

.setup-theme-group {
  justify-content: flex-start;
  gap: 0.55rem;
}

.theme-current-button {
  display: flex;
  width: 100%;
  min-width: 0;
  align-items: center;
  gap: 0.75rem;
  min-height: 46px;
  padding: 0.4rem 0.75rem 0.4rem 0.45rem;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.72);
  color: #e2e8f0;
  font: 600 0.9rem 'Fredoka', sans-serif;
  cursor: pointer;
}

#flipquizSelectedThemeName {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.theme-current-chevron {
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  border-right: 2px solid #94a3b8;
  border-bottom: 2px solid #94a3b8;
  transform: translateY(-2px) rotate(45deg);
  transition: transform 0.18s ease;
}

.theme-current-button[aria-expanded="true"] .theme-current-chevron {
  transform: translateY(2px) rotate(225deg);
}

.theme-current-preview {
  width: 52px;
  height: 34px;
  flex: 0 0 52px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  background-position: center;
  background-size: cover;
}

.theme-current-button:hover {
  border-color: rgba(248, 113, 113, 0.6);
  background: rgba(127, 29, 29, 0.22);
}

.theme-dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  place-items: center;
  padding: 1rem;
  background: rgba(3, 5, 15, 0.78);
  backdrop-filter: blur(8px);
}

.theme-dialog-backdrop.is-open {
  display: grid;
}

.theme-dialog {
  width: min(100%, 620px);
  max-height: min(86vh, 720px);
  overflow-y: auto;
  padding: 1.25rem;
  border: 1px solid rgba(248, 113, 113, 0.28);
  border-radius: 20px;
  background: linear-gradient(145deg, #171a2d, #0e1120);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.55);
}

.theme-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.theme-dialog-header h2 {
  margin: 0;
  color: #f8fafc;
  font-size: 1.3rem;
}

.theme-dialog-header p {
  margin: 0.3rem 0 0;
  color: #9ba6bc;
  font-size: 0.88rem;
}

.theme-dialog-close {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  color: #cbd5e1;
  font-size: 1.2rem;
  cursor: pointer;
}

.theme-dialog-close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.theme-dialog .setup-theme-group {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: stretch;
  gap: 0.7rem;
}

.theme-dialog .setup-theme-btn {
  display: flex;
  width: 100%;
  min-width: 0;
  min-height: 112px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.55rem;
  border-radius: 0.75rem;
}

.theme-dialog .theme-preview {
  width: 100%;
  max-width: none;
  height: 68px;
  border-radius: 8px;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
}

.theme-dialog .theme-label {
  width: 100%;
  overflow: hidden;
  color: #cbd5e1;
  font-size: 0.75rem;
  line-height: 1.2;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.theme-current-button:focus-visible,
.theme-dialog button:focus-visible {
  outline: 3px solid #fca5a5;
  outline-offset: 3px;
}

.game-setup-content .setup-theme-btn {
  min-width: 76px;
  padding: 0.45rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.7rem;
  background: rgba(255, 255, 255, 0.035);
}

.game-setup-content .setup-theme-btn:hover,
.game-setup-content .setup-theme-btn.active {
  transform: none;
  border-color: rgba(248, 113, 113, 0.55);
  background: rgba(239, 68, 68, 0.1);
  box-shadow: none;
}

.theme-preview {
  width: 52px;
  height: 36px;
}

.theme-preview-default {
  border-color: rgba(191, 219, 254, 0.3);
  background: linear-gradient(145deg, #155e75 0%, #1d4ed8 55%, #312e81 100%);
}

.theme-label {
  color: #aab3c5;
  font-family: inherit;
  font-size: 0.68rem;
}

.volume-controls-section {
  min-width: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.85rem;
  background: rgba(255, 255, 255, 0.035);
}

.volume-controls-section:hover {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
}

.volume-control-group {
  display: grid;
  grid-template-columns: minmax(78px, 1fr) 34px minmax(148px, auto);
  align-items: center;
  min-width: 0;
  gap: 0.5rem;
  margin: 0;
}

.volume-label {
  min-width: 78px;
  width: auto;
  flex: none;
  white-space: nowrap;
  color: #aab3c5;
  font-family: inherit;
  font-size: 0.78rem;
  text-align: left;
}

.volume-rocker {
  display: grid;
  grid-template-columns: repeat(5, 28px);
  justify-content: center;
  flex: none;
  gap: 0.2rem;
  padding: 0.2rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.12);
}

.volume-btn {
  width: 28px;
  height: 28px;
  border: 1px solid transparent;
  background: transparent;
  color: #aab3c5;
  font-size: 0.72rem;
}

.volume-btn:hover,
.volume-btn.active {
  transform: none;
  border-color: rgba(248, 113, 113, 0.45);
  background: rgba(239, 68, 68, 0.14);
  color: #fecaca;
  box-shadow: none;
}

.game-setup-content #sfxToggleBtn.volume-mute-btn,
.game-setup-content #bgToggleBtn.volume-mute-btn {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 0.6rem;
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
}

.game-setup-content .volume-mute-btn .material-icons {
  font-size: 1.1rem;
}

.quiz-selection-container {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.7rem;
  margin-top: 0;
}

.game-setup-content .quiz-info-display {
  width: 100%;
  min-width: 0;
  min-height: 76px;
  margin: 0;
  padding: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.85rem;
  background: rgba(255, 255, 255, 0.035);
}

.game-setup-content .quiz-info-img,
.game-setup-content .quiz-info-img-placeholder {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.65rem;
  box-shadow: none;
}

.game-setup-content .quiz-info-img-placeholder {
  border-style: solid;
  background: rgba(239, 68, 68, 0.13);
}

.game-setup-content .quiz-info-img-placeholder .material-icons {
  color: #fca5a5;
}

.game-setup-content .quiz-info-title {
  overflow: hidden;
  margin: 0 0 0.2rem;
  color: #f8fafc;
  font-family: inherit;
  font-size: 0.92rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-setup-content .quiz-info-thumbnail {
  display: flex;
  width: 52px;
  flex: 0 0 52px;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.game-setup-content .quiz-info-thumbnail .quiz-info-img,
.game-setup-content .quiz-info-thumbnail .quiz-info-img-placeholder {
  width: 52px;
  height: 52px;
}

.game-setup-content .quiz-info-rating {
  width: 100%;
  color: #fcd34d;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
}

.game-setup-content .quiz-info-details {
  color: #aab3c5;
  font-size: 0.76rem;
}

.game-setup-content .quiz-info-meta {
  display: flex;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem 0.75rem;
  color: #aab3c5;
  font-size: 0.72rem;
  line-height: 1.35;
}

.game-setup-content .quiz-info-meta span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-setup-content .quiz-info-meta strong {
  color: #e2e8f0;
  font-weight: 700;
}

.quiz-button-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
  margin: 0;
  width: 100%;
}

.game-setup-content .start-game-btn {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 0.65rem 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 0.7rem;
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0;
  box-shadow: none;
}

.game-setup-content .flipquiz-exit-button {
  text-align: center;
  text-decoration: none;
}

.game-setup-content #startGameBtn:not(:disabled) {
  border: 0;
  background: linear-gradient(135deg, #16a34a, #22c55e);
  color: #fff;
  box-shadow: 0 6px 18px rgba(34, 197, 94, 0.22);
}

.game-setup-content .flipquiz-exit-button {
  border: 0;
  background: linear-gradient(135deg, #dc2626, #ef4444);
  color: #fff;
  box-shadow: 0 6px 18px rgba(239, 68, 68, 0.22);
  transition: transform 0.18s ease, filter 0.18s ease, box-shadow 0.18s ease;
}

.game-setup-content .flipquiz-exit-button:hover,
.game-setup-content .flipquiz-exit-button:active {
  transform: translateY(-2px);
  border-color: transparent;
  background: linear-gradient(135deg, #dc2626, #ef4444);
  filter: brightness(1.06);
  box-shadow: 0 6px 18px rgba(239, 68, 68, 0.22);
}

.game-setup-content .start-game-btn:hover:not(:disabled):not(#startGameBtn):not(.flipquiz-exit-button) {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.1);
  box-shadow: none;
}

.game-setup-content #startGameBtn {
  border-color: transparent;
  background: linear-gradient(135deg, #16a34a, #22c55e);
  color: #fff;
}

.game-setup-content #startGameBtn:not(:disabled),
.game-setup-content #startGameBtn:not(:disabled):hover,
.game-setup-content #startGameBtn:not(:disabled):active {
  border-color: transparent;
  background: linear-gradient(135deg, #16a34a, #22c55e);
  color: #fff;
  box-shadow: 0 6px 18px rgba(34, 197, 94, 0.22);
}

.game-setup-content #startGameBtn:not(:disabled),
.game-setup-content .flipquiz-exit-button {
  transition: transform 0.18s ease, filter 0.18s ease, box-shadow 0.18s ease;
}

.game-setup-content #startGameBtn:not(:disabled):hover,
.game-setup-content #startGameBtn:not(:disabled):active {
  transform: translateY(-2px);
  filter: brightness(1.06);
}

.game-setup-content #startGameBtn:disabled {
  border-color: rgba(255, 255, 255, 0.08) !important;
  background: rgba(255, 255, 255, 0.05) !important;
  color: #778094 !important;
  opacity: 1;
}

@media (max-width: 760px) {
  .theme-dialog .setup-theme-group {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .appearance-controls-row {
    grid-template-columns: 1fr;
  }

  .game-setup-section {
    min-height: 100dvh;
    align-items: center;
    justify-content: center;
    padding: 1rem 0.75rem;
  }

  .game-setup-content {
    width: 100%;
    grid-template-columns: 1fr;
    gap: 0.6rem;
    padding: 1rem;
    border-radius: 1rem;
  }

  .flipquiz-setup-heading,
  .setup-row--theme,
  .volume-controls-section,
  .quiz-selection-container {
    grid-column: 1;
  }

  .game-setup-content .setup-row {
    padding: 0.75rem;
  }

  .game-setup-content .setup-radio-group {
    justify-content: flex-start;
  }

  .game-setup-content .setup-number-btn {
    min-width: 40px;
    min-height: 40px;
    padding: 0.4rem 0.65rem;
  }

  .setup-theme-group {
    justify-content: space-between;
    gap: 0.3rem;
  }

  .theme-dialog {
    padding: 1rem;
    border-radius: 16px;
  }

  .theme-dialog .setup-theme-group {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
  }

  .theme-dialog .theme-preview {
    height: 74px;
  }

  .game-setup-content .setup-theme-btn {
    min-width: 0;
    flex: 1 1 0;
    padding: 0.35rem 0.2rem;
  }

  .theme-preview {
    width: 100%;
    max-width: 52px;
    height: 32px;
  }

  .volume-controls-section {
    grid-template-columns: 1fr;
    padding: 0.75rem;
  }

  .volume-control-group {
    grid-template-columns: minmax(78px, 1fr) 34px minmax(148px, auto);
    flex-wrap: nowrap;
  }

  .volume-label {
    width: auto;
    margin: 0;
    text-align: left;
  }

  .quiz-selection-container {
    grid-template-columns: 1fr;
  }

  .quiz-button-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
