:root {
  /* Base colors */
  --white: #ffffff;
  --black: #000000;
  
  /* Glass effects */
  --glass-alpha: 0.45;
  --glass-alpha-hover: 0.65;
  --glass-bg: rgba(255, 255, 255, var(--glass-alpha));
  --glass-icon: var(--glass-bg);
  --glass-icon-hover: rgba(255, 255, 255, var(--glass-alpha-hover));
  --glass-border: rgba(255, 255, 255, 0.4);
  
  /* UI colors */
  --text-color: #1a1a1a;
  --link-color: #5425db;
  --link-hover: #359ada;
  --modal-bg: rgba(255, 255, 255, 0.7);
  --slider-border: var(--black);
}

[data-theme="dark"] {
  --glass-bg: rgba(0, 0, 0, var(--glass-alpha));
  --glass-icon: var(--glass-bg);
  --glass-icon-hover: rgba(0, 0, 0, var(--glass-alpha-hover));
  --glass-border: rgba(244, 239, 239, 0.2);
  --text-color: var(--white);
  --link-color: #9f8cff;
  --link-hover: #72b8ff;
  --modal-bg: rgba(0, 0, 0, 0.7);
  --slider-border: var(--white);
}

html {
  --random-bg-image: url('images/pink-blue-wave.jpg');  /* Default fallback */
  background: #f0f2f5;
  background-image: var(--random-bg-image);
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  height: 100%;
}


body::before {
  content: '';
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: 
    radial-gradient(circle at 25% 25%, rgba(89, 116, 255, 0.3) 0%, transparent 50%),
    radial-gradient(circle at 75% 75%, rgba(0, 255, 200, 0.3) 0%, transparent 50%),
    linear-gradient(135deg, rgba(129, 85, 255, 0.4) 0%, rgba(0, 255, 209, 0.4) 100%);
  opacity: 0.5;
  animation: subtle-shift 20s ease-in-out infinite;
  z-index: -1;
  will-change: transform;
  mix-blend-mode: soft-light;
}

@keyframes subtle-shift {
  0% {
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
  25% {
    transform: translate(-2%, 2%) rotate(1deg) scale(1.02);
  }
  50% {
    transform: translate(-1%, -1%) rotate(0deg) scale(1.01);
  }
  75% {
    transform: translate(1%, -2%) rotate(-1deg) scale(1.02);
  }
  100% {
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  padding: 20px;
  margin-top: 40px;
  text-align: center;
  line-height: 1.5;
  display: flex;
  align-items: center;
  justify-content: center;
}

a {
  color: var(--link-color);
}

a:hover, a:focus {
  color: var(--link-hover);
  text-decoration: underline;
}

.wrapper {
  width: 100%;
  max-width: 1000px;
  padding: 30px;
  position: relative;
  overflow: hidden;
  background: var(--glass-bg);
  backdrop-filter: blur(5px) saturate(200%);
  -webkit-backdrop-filter: blur(5px) saturate(200%);
  border-radius: 24px;
  border: 1px solid var(--glass-border);
  box-shadow: 
    0 8px 32px 0 rgba(31, 38, 135, 0.15),
    inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}

.icons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
  margin: 30px 0;
  padding: 0;
}

.icon {
  list-style: none;
  width: 110px;
  transition: transform 0.3s ease;
  will-change: transform;
}

.icon:hover {
  transform: translateY(-5px);
}

.icon>a {
  display: flex;
  align-items: center;
  flex-direction: column;
  padding: 15px 10px;
  background: var(--glass-icon);
  backdrop-filter: blur(5px) saturate(180%);
  -webkit-backdrop-filter: blur(5px) saturate(180%);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
  outline: 2px solid transparent;
  outline-offset: 2px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3);
}

.icon>a:focus-visible {
  outline-color: #5425db;
  outline-offset: 4px;
  background: var(--modal-bg);
}

.icon>a:hover {
  background: var(--glass-icon-hover);
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: 
    0 4px 15px rgba(31, 38, 135, 0.1),
    inset 0 0 0 1px rgba(255, 255, 255, 0.5);
  outline: none;
}

.icon.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.icon img {
  width: 50px;
  margin-bottom: 12px;
  filter: saturate(1.2);
  transition: transform 0.3s ease;
  will-change: transform;
}

.icon>a:hover img {
  transform: scale(1.1);
}

.spotlight {
  display: flex;
  gap: 20px;
}

@media screen and (min-width: 780px) {
  .spotlight {
    width: 80%;
    margin: auto;
  }
}

.spotlight .icon {
  width: 160px;
  flex: 1 1 160px;
  display: flex;
}

.spotlight .icon>a {
  padding: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

@media (prefers-reduced-motion: reduce) {
  .icon, .icon>a, .icon img {
    transition: none;
  }
  body::before {
    animation: none;
  }
  h1 {
    animation: none;
  }
  .icon:hover {
    transform: none;
  }
  .icon>a:hover img {
    transform: none;
  }
}

@media screen and (max-width: 480px) {
  .wrapper {
    padding: 20px;
  }
  
  .icon {
    width: calc(50% - 20px);
    min-width: 140px;
  }
  
  .spotlight .icon {
    width: 100%;
  }
  
  h1 {
    font-size: 2rem;
  }
}

 h1 {
  font-size: 40px;
  font-weight: 600;
  color: #fdfdfe;
  padding: 0;
  margin: 0 0 20px;
  text-shadow: 0px 0px 5px #1462aa, 0px 0px 10px #b393d3, 0px 0px 10px #b393d3,
    0px 0px 20px #b393d3;
}

@media screen and (min-width: 780px) {
  h1 {
    font-size: 50px;
  }
}



/* Settings Button */
.settings-button {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(25px) saturate(200%);
  -webkit-backdrop-filter: blur(25px) saturate(200%);
  box-shadow: 0 4px 16px rgba(31, 38, 135, 0.15);
  cursor: pointer;
  padding: 10px;
  transition: transform 0.3s ease, background-color 0.3s ease;
  z-index: 1000;
}

.settings-button:hover {
  transform: rotate(30deg);
  background: rgba(255, 255, 255, 0.8);
}

.settings-button:focus-visible {
  outline: 2px solid #5425db;
  outline-offset: 2px;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 1001;
}

.modal[hidden] {
  display: none;
}

.modal-content {
  background: var(--modal-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-color);
  border-radius: 24px;
  box-shadow: 0 8px 32px rgba(31, 38, 135, 0.15);
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  scrollbar-width: thin;
  scrollbar-color: var(--link-color) transparent;
}

.modal-content::-webkit-scrollbar {
  width: 8px;
}

.modal-content::-webkit-scrollbar-track {
  background: transparent;
}

.modal-content::-webkit-scrollbar-thumb {
  background-color: var(--link-color);
  border-radius: 20px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.4);
  position: sticky;
  top: 0;
  z-index: 1;
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
}

.modal-header h2 {
  margin: 0;
  color: var(--slider-border);
  font-size: 1.5rem;
}

.close-button {
  background: transparent;
  border: none;
  font-size: 24px;
  cursor: pointer;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--slider-border);
  transition: opacity 0.3s ease, background-color 0.3s ease, transform 0.3s ease;
  opacity: 0.8;
}

.close-button:hover {
  background: var(--glass-bg);
  opacity: 1;
  transform: scale(1.1);
}

.close-button:focus-visible {
  opacity: 1;
  outline: 2px solid var(--link-color);
  outline-offset: 2px;
}

.modal-body {
  padding: 20px;
}

.background-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 20px;
}

.bg-option {
  text-align: center;
}

.bg-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.bg-option label {
  display: block;
  cursor: pointer;
  padding: 10px;
  border-radius: 16px;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  background: var(--glass-bg);
}

.bg-option label:hover {
  transform: translateY(-5px);
  background: var(--glass-icon-hover);
}

.bg-option input[type="radio"]:checked + label {
  box-shadow: 0 0 0 3px var(--link-color);
  background: var(--glass-icon-hover);
}

.bg-option input[type="radio"]:focus-visible + label {
  outline: 2px solid var(--link-color);
  outline-offset: 4px;
  background: var(--glass-bg);
}

.bg-option img {
  width: 100%;
  height: 100px;
  object-fit: cover;
  border-radius: 12px;
  margin-bottom: 8px;
}

.bg-option span {
  display: block;
  margin-top: 8px;
  color: var(--text-color);
}

@media (prefers-reduced-motion: reduce) {
  .settings-button:hover {
    transform: none;
  }
  
  .bg-option label:hover {
    transform: none;
  }
}

/* Theme Toggle */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 20px;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  transition: transform 0.3s ease;
}

.theme-label {
  color: var(--text-color);
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 4px;
  user-select: none;
}

.switch {
  position: relative;
  display: inline-block;
  width: 60px;
  height: 34px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--glass-bg);
  border: 1px solid var(--slider-border);
  transition: 0.4s;
  border-radius: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px;
  box-shadow: 0 2px 8px rgba(31, 38, 135, 0.15);
}

.slider:before {
  position: absolute;
  content: "";
  height: 26px;
  width: 26px;
  left: 3px;
  bottom: 3px;
  background-color: var(--slider-border);
  transition: 0.4s;
  border-radius: 50%;
  z-index: 2;
}

input:checked + .slider:before {
  transform: translateX(26px);
}

.sun, .moon {
  font-size: 14px;
  line-height: 1;
}

.sun {
  margin-right: 5px;
}

.moon {
  margin-left: 5px;
}

.switch input:focus-visible ~ .slider {
  outline: 2px solid var(--link-color);
  outline-offset: 2px;
}

[data-theme="dark"] .icon.invert img {
  filter: brightness(0) invert(.6) saturate(1.2);
}