:root {
  /* Dark theme (default) */
  --bg-primary: #0b1622;
  --bg-secondary: #1a2332;
  --bg-tertiary: #151f2e;
  --bg-quaternary: #32445b;
  --text-primary: #8596a5;
  --text-secondary: #a8b5c4;
  --border-color: #32445b;
  --hover-bg: #2a3441;
  --special-color: #00bfff;
  --special-color-hover: #57d5ff;
}

[data-theme="light"] {
  --bg-primary: #e7f0f8;
  --bg-secondary: #b7e0f7;
  --bg-tertiary: #DCECF8;
  --bg-quaternary: #ffffff;
  --text-primary: #0b5f97;
  --text-secondary: #0b5f97;
  --border-color: #DCECF8;
  --hover-bg: #cfe8f7;
  --special-color: #00bfff;
  --special-color-hover: #57d5ff;
}

[data-theme="brown"] {
  --bg-primary: #271c19;
  --bg-secondary: #55423d;
  --bg-tertiary: #5e4a43;
  --bg-quaternary: #3f2d28;
  --text-primary: #faeee7;
  --text-secondary: #faeee7;
  --border-color: #3f2d28;
  --hover-bg: #3f2d28;
  --special-color: #df5c38;
  --special-color-hover: #dd866e;
}

a {
  color: var(--special-color);
  text-decoration: none;
}

a:hover {
  color: var(--special-color-hover);
}

p {
  color: var(--text-primary);
}

/* --- Scoring System Section --- */
.scoring-system-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
}

#rating-mode-select {
  width: 100%;
  max-width: 220px;
  font-size: 1rem;
  text-align: center;
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.6rem;
  margin-bottom: 4.7rem;
}

/* Custom Select Styles */
.custom-select-wrapper {
  position: relative;
  width: 100%;
  max-width: 220px;
  user-select: none;
  margin-bottom: 4.7rem;
}

.custom-select {
  position: relative;
}

.custom-select-trigger {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  padding: 0.6rem;
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
}

.custom-select-trigger > span:first-child {
  margin-right: auto;
}

.custom-select-trigger .rating-icon-group {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  margin-right: 0.5rem;
}

.arrow {
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid var(--text-primary);
  transition: transform 0.2s ease;
}

.custom-select.open .arrow {
  transform: rotate(180deg);
}

.custom-options {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  z-index: 10;
  display: none;
  max-height: 200px;
  overflow-y: auto;
}

.custom-select.open .custom-options {
  display: block;
}

.custom-option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.custom-option:hover {
  background-color: var(--hover-bg);
}

.custom-option.selected {
  background-color: var(--bg-quaternary);
}

.rating-icon-group {
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

.rating-icon-group.stars-group {
  gap: 0;
}

.rating-svg-icon {
  width: 1.2rem;
  height: 1.2rem;
  vertical-align: middle;
}

.rating-svg-icon.star-icon {
  color: gold;
}

/* p_settings.css */

body {
  font-family: "Segoe UI", Tahoma, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  overflow-y: scroll;
}

h1 {
  margin-bottom: 1rem;
  font-size: 1.8rem;
  color: var(--text-primary);
}



/* Table styling */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
}

th,
td {
  padding: 8px;
  border: 1px solid var(--border-color);
  text-align: left;
}

input,
select {
  width: 100%;
  padding: 6px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 0.95rem;
}

button {
  padding: 6px 12px;
  border: none;
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s;
}

button:hover {
  background-color: var(--bg-quaternary);
}

button:disabled {
  background-color: #9ca3af;
  cursor: not-allowed;
}

.settings-page-content {
  margin-top: 5.5rem;
  max-width: 1000px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1rem;
  padding-right: 1rem;
}

.settings-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border-color);
}

.tab-button {
  padding: 1rem 2rem;
  background: var(--bg-tertiary);
  border: none;
  color: var(--text-primary);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  border-top: 3px solid transparent;
  font-size: 1rem;
  border-radius: 4px 4px 0 0;
}

.tab-button:hover {
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

.tab-button.active {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border-top-color: var(--text-secondary);
}

.tab-content {
  display: none;
  padding: 2rem 0;
}

.tab-content.active {
  display: block;
}

table input,
table select {
  height: 32px;
  box-sizing: border-box;
  padding: 4px 6px;
  font-size: 0.9rem;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  background: var(--bg-quaternary);
}

table td:last-child .save-btn {
  float: left;
}

table td:last-child .delete-btn {
  float: right;
}

.backup-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

#backup-cancel-btn:hover {
  background: #a82a36 !important;
}

.backup-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.8rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  background-color: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 2px solid var(--border-color);
  border-radius: 6px;
  transition: all 0.2s ease;
  min-width: 180px;
}

.backup-btn:hover {
  border-color: var(--text-secondary);
  background-color: var(--bg-tertiary);
}

.backup-btn svg {
  flex-shrink: 0;
}

.backup-info-box {
  margin-top: 1.5rem;
  padding: 1rem;
  background-color: var(--bg-tertiary);
  border: 2px solid var(--border-color);
  border-radius: 6px;
  font-size: 0.9rem;
  color: var(--text-primary);
  line-height: 1.6;
}

.api-info-box {
  margin-top: 1.5rem;
  padding: 1.5rem;
  background-color: var(--bg-tertiary);
  border: 2px solid var(--border-color);
  border-radius: 6px;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.api-service {
  display: grid;
  grid-template-columns: 140px 1fr auto auto;
  gap: 1rem;
  align-items: center;
  padding: 0.8rem;
  margin-bottom: 0.5rem;
  background-color: var(--bg-secondary);
  border-radius: 4px;
}

.api-service:last-child {
  margin-bottom: 0;
}

.api-service-name {
  font-weight: 600;
  color: var(--text-secondary);
}

.api-service-desc {
  color: var(--text-primary);
  font-size: 0.85rem;
}

.api-service a {
  padding: 0.3rem 0.8rem;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 0.85rem;
  transition: all 0.2s ease;
}

.api-service a:hover {
  border-color: var(--special-color);
  color: var(--special-color);
}

.collapsible-content h3 {
  display: flex;
  align-items: center;
  justify-content: center;
}

#nav-items-form {
  display: flex;
  justify-content: center;
  gap: 0.8rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.nav-item-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 0.8rem;
  background: var(--bg-tertiary);
  border: 2px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease;
  min-width: 70px;
  position: relative;
}

.nav-item-box:hover {
  background: var(--hover-bg);
}

.nav-item-box.active {
  border-color: var(--special-color);
}

.nav-item-box.active .nav-item-icon {
  color: var(--special-color);
}

.nav-item-box.dragging {
  opacity: 0.5;
}

.nav-item-checkbox {
  display: none;
}

.nav-item-icon {
  width: 32px;
  height: 32px;
  color: var(--text-primary);
  transition: color 0.2s ease;
}

.nav-item-icon svg {
  width: 100%;
  height: 100%;
}

.nav-item-name {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-align: center;
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-left: 8px;
  border: 2px solid #ccc;
  border-top-color: #333;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  vertical-align: middle;
}

.preferences-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
}

.preference-toggle-label {
  display: block;
  cursor: pointer;
  user-select: none;
  width: 100%;
  max-width: 220px;
}

.preference-toggle-label input[type="checkbox"] {
  display: none;
}

.preference-toggle-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem;
  background-color: var(--bg-tertiary);
  border: 2px solid var(--border-color);
  border-radius: 6px;
  transition: all 0.2s ease;
}

.preference-toggle-label:hover .preference-toggle-content {
  background-color: var(--hover-bg);
  color: var(--text-secondary);
}

.preference-toggle-label:hover .preference-toggle-icon {
  color: var(--text-secondary);
}

.preference-toggle-icon {
  width: 20px;
  height: 20px;
  color: var(--text-primary);
  flex-shrink: 0;
  transition: color 0.2s ease;
  margin-right: 0.2rem;
}

.preference-toggle-text {
  line-height: 1.4;
  font-size: 1rem;
}

.settings-separator {
  display: block;
  margin: 2.5rem auto;
  width: 90%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-color) 20%, var(--border-color) 80%, transparent);
  border: none;
}

.preference-toggle-label input:checked + .preference-toggle-content { 
  border-color: var(--special-color);
  color: var(--text-secondary);
}

.preference-toggle-label input:checked + .preference-toggle-content .preference-toggle-icon {
  color: var(--special-color);
}

.preferences-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
  margin: 0 0;
}

.preferences-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.preferences-section h3 {
  margin: 0 0 1.2rem 0;
  font-size: 1.1rem;
  color: var(--text-secondary);
  text-align: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.8rem;
}

.nav-buttons-section {
  grid-column: 1 / -1;
  max-width: none;
}

.info-section {
  grid-column: 1 / -1;
  max-width: none;
}

.info-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.version-information{
  max-width: 20rem;
}

.resource-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 1rem 1.2rem;
  transition: all 0.2s ease;
}

.resource-card p {
  margin: 0.5rem 0;
  line-height: 1.6;
  color: var(--text-primary);
}

.resource-card p:first-child {
  margin-top: 0;
  font-size: 1rem;
}

.resource-card p:last-child {
  margin-bottom: 0;
}

.tips-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 1rem 1.2rem;
  margin-top: 0.5rem;
}

.tips-card p {
  margin: 0.7rem 0;
  line-height: 1.6;
  color: var(--text-primary);
}

.tips-card p:first-child {
  margin-top: 0;
}

.tips-card p:last-child {
  margin-bottom: 0;
}

.version-info-content {
  text-align: center;
  margin: 1.5rem 0;
}

.version-info-content p {
  margin: 0.7rem 0;
  font-weight: 600;
  color: var(--text-primary);
  font-size: 1rem;
}

.support-links {
  text-align: center;
  margin-top: 1.5rem;
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.support-links a {
  padding: 0.5rem 1rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  transition: all 0.2s ease;
}

.support-links a:hover {
  border-color: var(--special-color);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Theme Selector Styles */
.theme-selector {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.theme-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.theme-option:hover:not(.disabled) {
  background: var(--hover-bg);
}

.theme-option[data-theme="dark"]:hover {
  background: #2a3441;
}

.theme-option[data-theme="light"]:hover {
  background: #cfe8f7;
}

.theme-option[data-theme="brown"]:hover {
  background: #3f2d28;
}

.theme-option[data-theme="dark"] span {
  color: #8596a5;
}

.theme-option[data-theme="light"] span {
  color: #0b5f97;
}

.theme-option[data-theme="brown"] span {
  color: #faeee7;
}

.theme-option[data-theme="green"] span {
  color: white;
}

.theme-option.active {
  background: var(--bg-quaternary);
}

.theme-option.disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.theme-cube {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1.2rem;
  transition: all 0.2s ease;
}

.theme-dark {
  background: #0b1622;
  color: #8596a5;
}

.theme-light {
  background: #e7f0f8;
  color: #0b5f97;
}

.theme-brown {
  background: #271c19;
  color: #faeee7;
}

.theme-green {
  background: #0d4f3c;
  color: #ffffff;
}

.theme-option span {
  font-size: 0.9rem;
  font-weight: 500;
}

.theme-option.active span {
  color: var(--text-secondary);
}

/* Information section link hover effects */


#music-player-container {
  position: fixed !important;
  z-index: 9999 !important;
  line-height: 0 !important;
}

.music-player-container iframe {
  display: block !important;
  border: none !important;
}

@media (orientation: portrait) {

  #backup-modal-title,
  #backup-status-text,
  #backup-cancel-btn {
    font-size: 2.5rem !important;
  }

  .backup-modal-content {
    max-width: unset !important;
  }

  .settings-page-content {
    transform: scale(2);
    transform-origin: top;
    max-width: 28.5rem;
  }

  .settings-tabs {
    transform: scale(1);
    transform-origin: top;
    margin-bottom: 1rem;
    width: 100%;
  }

  .tab-button {
    padding: 0.8rem 1.2rem;
    font-size: 0.9rem;
  }

  .preferences-container {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  #nav-items-form {
    grid-template-columns: repeat(2, 1fr);
    transform: scale(1.1);
    transform-origin: top;
    padding-bottom: 3rem;
  }

  .backup-actions {
    flex-direction: column;
    align-items: center;
  }

  table {
    font-size: 0.8rem;
  }

  table input,
  table select {
    font-size: 0.7rem;
    padding: 2px 4px;
  }
}

/* Backup Progress Modal */
@keyframes progress-stripes {
  from {
    background-position: 1rem 0;
  }

  to {
    background-position: 0 0;
  }
}

.progress-animated {
  background-image: linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
  background-size: 1rem 1rem;
  animation: progress-stripes 1s linear infinite;
}

.backup-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 10000;
  display: none;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.backup-modal-content {
  background: var(--bg-secondary, #1a2332);
  padding: 2rem;
  border-radius: 12px;
  width: 90%;
  max-width: 400px;
  text-align: center;
  color: var(--text-primary, #fff);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.backup-modal-overlay.visible {
  opacity: 1;
}

.backup-modal-overlay.visible .backup-modal-content {
  transform: scale(1);
}