/* ═══════════════════════════════════════════════════════════
   Shared Settings theme — matches Guess the Flag's settings look.
   Self-contained colors so it works across all games regardless of
   each game's CSS variable names. Include with:
     <link rel="stylesheet" href="/shared/settings.css">
   ═══════════════════════════════════════════════════════════ */

dialog.settings-dialog {
  width: min(94vw, 520px);
  padding: 0;
  margin: auto;                 /* keep centered despite * { margin:0 } resets */
  border: 1px solid #404040;
  border-radius: 8px;
  background: transparent;
  color: #ffffff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.7);
}
dialog.settings-dialog::backdrop {
  background: rgba(0, 0, 0, 0.74);
  backdrop-filter: blur(8px);
}

.settings-panel {
  display: grid;
  gap: 22px;
  padding: 22px;
  background: #121212;
}

.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.settings-head h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0;
  color: #ffffff;
}
.settings-close-btn {
  width: 32px; height: 32px;
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid #404040;
  border-radius: 50%;
  background: #181818;
  color: #a7a7a7;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  transition: border-color .18s ease, color .18s ease, background .18s ease;
}
.settings-close-btn:hover {
  border-color: #1db954;
  color: #1db954;
}

.field-group {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.field-group legend,
.number-field > span {
  display: block;
  margin-bottom: 10px;
  color: #a7a7a7;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 6px;
  border: 1px solid #282828;
  border-radius: 999px;
  background: #181818;
}
.segmented-control.cols-4 { grid-template-columns: repeat(4, 1fr); }
.segmented-control label { min-width: 0; cursor: pointer; }
.segmented-control input,
.toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.segmented-control span {
  min-height: 42px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: #a7a7a7;
  font-weight: 800;
  cursor: pointer;
}
.segmented-control input:checked + span {
  background: #1db954;
  color: #041005;
}

.toggle-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.toggle {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid #282828;
  border-radius: 8px;
  background: #181818;
  color: #ffffff;
  font-weight: 800;
  cursor: pointer;
}
.toggle > span:first-of-type {
  min-width: 0;
  overflow-wrap: anywhere;
}
.toggle .switch {
  width: 46px; height: 26px;
  flex: 0 0 auto;
  position: relative;
  border-radius: 999px;
  background: #293129;
  transition: background .18s ease;
}
.switch::after {
  content: "";
  position: absolute;
  top: 4px; left: 4px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform .18s ease;
}
.toggle input:checked ~ .switch { background: #1db954; }
.toggle input:checked ~ .switch::after { transform: translateX(20px); background: #041005; }

.number-field {
  display: block;
  margin: 0;
}
.number-field input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid #282828;
  border-radius: 8px;
  background: #181818;
  color: #ffffff;
  font: inherit;
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.number-field input:focus {
  border-color: #1db954;
  box-shadow: 0 0 0 3px rgba(29, 185, 84, 0.12);
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  box-sizing: border-box;
  border: 1px solid #282828;
  border-radius: 8px;
  background: #181818;
  color: #ffffff;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  text-align: left;
  transition: border-color .18s ease, color .18s ease, background .18s ease;
}
.settings-row svg {
  width: 16px; height: 16px;
  flex-shrink: 0;
  color: #a7a7a7;
}
.settings-row:hover {
  border-color: #1db954;
  color: #1db954;
}
.settings-row:hover svg { color: #1db954; }
.settings-row.spinning svg { animation: settings-spin .9s linear infinite; }
@keyframes settings-spin { to { transform: rotate(360deg); } }

.settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.primary-button,
.secondary-button {
  min-height: 40px;
  padding: 10px 18px;
  border-radius: 999px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: border-color .18s ease, color .18s ease, background .18s ease;
}
.primary-button {
  background: #1db954;
  border: 1px solid #1db954;
  color: #041005;
}
.primary-button:hover { background: #1ed760; }
.secondary-button {
  background: transparent;
  border: 1px solid #404040;
  color: #ffffff;
}
.secondary-button:hover {
  border-color: #1db954;
  color: #1db954;
}

.settings-error {
  margin: 0;
  color: #e3a900;
  font-weight: 700;
}

/* ── Light mode ── */
[data-theme="light"] dialog.settings-dialog { border-color: #b0b0b0; }
[data-theme="light"] .settings-panel { background: #f5f5f5; }
[data-theme="light"] .settings-head h2 { color: #121212; }
[data-theme="light"] .settings-close-btn { border-color: #b0b0b0; background: #ffffff; color: #555; }
[data-theme="light"] .field-group legend,
[data-theme="light"] .number-field > span { color: #555; }
[data-theme="light"] .segmented-control { border-color: #d0d0d0; background: #ffffff; }
[data-theme="light"] .segmented-control span { color: #555; }
[data-theme="light"] .segmented-control input:checked + span { background: #1db954; color: #041005; }
[data-theme="light"] .toggle { border-color: #d0d0d0; background: #ffffff; color: #121212; }
[data-theme="light"] .toggle .switch { background: #d0d0d0; }
[data-theme="light"] .toggle input:checked ~ .switch { background: #1db954; }
[data-theme="light"] .toggle input:checked ~ .switch::after { background: #041005; }
[data-theme="light"] .number-field input { border-color: #d0d0d0; background: #ffffff; color: #121212; }
[data-theme="light"] .settings-row { border-color: #d0d0d0; background: #ffffff; color: #121212; }
[data-theme="light"] .settings-row svg { color: #555; }
[data-theme="light"] .settings-row:hover { border-color: #1db954; color: #1db954; }
[data-theme="light"] .settings-row:hover svg { color: #1db954; }
[data-theme="light"] .secondary-button { border-color: #b0b0b0; color: #121212; }
[data-theme="light"] .secondary-button:hover { border-color: #1db954; color: #1db954; }
