:root {
  --color-primary: rgba(220, 219, 219, 0.78);
  --color-surface: #242425;
  --time: 24s;
}

* {
  box-sizing: border-box;
}

body {
  width: 100vw;
  height: 100vh;
  display: grid;
  place-items: center;
  background-color: var(--color-surface);
  color: var(--color-primary);
  position: absolute;
  inset: 0;
  perspective: 80vmax;
  margin: 0;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body:before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 111;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.1);
  mask: linear-gradient(black 10%, transparent 30%, transparent 70%, black 80%);
  backdrop-filter: blur(5vmin) invert(0);
}

.stars {
  position: absolute;
  width: 100vmax;
  height: 100vmax;
}

.stars:before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  filter: url(#stars) saturate(0) brightness(1.5);
  mix-blend-mode: overlay;
  opacity: 0.15;
  animation: stars-animation 20s ease-in-out infinite;
}

.stars-highlights {
  position: absolute;
  width: 100vw;
  height: 100vh;
  opacity: 0.6;
}

.stars-highlights:before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  filter: url(#stars-highlights) saturate(0) brightness(1.5);
  mix-blend-mode: lighten;
  opacity: 0.2;
  animation: stars-animation-2 20s ease-in-out infinite;
}

@keyframes stars-animation {
  from { translate: 1vmin 2vmin; rotate: 0deg; }
  30% { translate: 1vmin -2vmin; }
  50% { translate: -1vmin 2vmin; rotate: 10deg; }
  to { translate: 1vmin 2vmin; rotate: 0deg; }
}

@keyframes stars-animation-2 {
  from { translate: 1vmin -2vmin; }
  30% { translate: -1vmin -2vmin; }
  50% { translate: 1vmin -2vmin; }
  to { translate: 1vmin -2vmin; }
}

.startails > div {
  border-radius: 50%;
  width: 0.55vmax;
  aspect-ratio: 3 / 1;
  background: white;
  position: absolute;
  opacity: 0;
  animation: startails-animation 10s linear infinite;
  box-shadow: 0 0 0.2vmax white;
}

@keyframes startails-animation {
  from { opacity: 1; scale: 0.9; }
  2% { scale: 0.4; }
  5% { opacity: 0; scale: 1; }
  to { opacity: 0; scale: 1; }
}

.scene {
  display: grid;
  place-items: center;
  position: absolute;
  animation: scene-zoom-in-out var(--time) ease-in-out infinite;
  transform-style: preserve-3d;
}

@keyframes scene-zoom-in-out {
  from { transform: scale(0.9); }
  50% { transform: scale(1); }
  to { transform: scale(0.9); }
}

.sun {
  border-radius: 50%;
  width: 25vmax;
  aspect-ratio: 1;
  background: radial-gradient(circle at 60% 60%, #f6f6f6, #e8dbdd, #d9d9d9);
  position: absolute;
  transform: translateY(-20vmax);
  box-shadow: 0 0 14vmax rgba(255, 255, 255, 0.5), 0 0 22vmax rgba(255, 255, 255, 0.05), 0 0 42vmax rgba(255, 255, 255, 0.4);
  transform-style: preserve-3d;
}

.planet {
  border-radius: 50%;
  width: 17vmax;
  aspect-ratio: 1;
  background: radial-gradient(90% 90% at 60% 55%, #252525, #2a2f33 52%, #ede9ea 62%), #ede9ea;
  position: absolute;
  transform: translateY(-10vmax) translateX(10vmax);
  box-shadow: 0 0 2.5vmax rgba(255, 255, 255, 0.12);
  filter: blur(0.05vmax);
  transform-style: preserve-3d;
}

.planet-2, .planet-3, .planet-4, .planet-5, .planet-6 {
  border-radius: 50%;
  position: absolute;
  transform-style: preserve-3d;
}

.planet-2 {
  width: 13vmax;
  aspect-ratio: 1;
  background: radial-gradient(90% 90% at 60% 55%, #e3e3e3, #d2c6c8 52%, #212528 62%, transparent 82%);
  transform: translateY(-35vmax) translateX(-20vmax);
}

.planet-3 {
  width: 2vmax;
  aspect-ratio: 1;
  background: radial-gradient(90% 90% at 70% 50%, #eeeeee 16%, #b7aeb0 38%, #3c4144 52%, #2d3134 60%, transparent 82%);
  transform: translateY(-10vmax) translateX(-20vmax);
  opacity: 0.6;
}

.planet-4 {
  width: 1vmax;
  aspect-ratio: 1;
  background: radial-gradient(90% 90% at 70% 50%, #d0d0d0, #b7aeb0 38%, #121415 52%, #131617 60%, transparent 82%);
  transform: translateY(-11vmax) translateX(-22vmax);
  opacity: 0.5;
}

.planet-5 {
  width: 10vmax;
  aspect-ratio: 1;
  background: radial-gradient(90% 90% at 30% 55%, #797777, #515051 52%, #212528 62%, transparent 82%);
  transform: translateY(-35vmax) translateX(18vmax);
  clip-path: circle();
  overflow: clip;
}

.planet-5 .structure-1, .planet-5 .structure-2, .planet-5 .structure-3 {
  position: absolute;
  inset: -20vmax;
  filter: url(#planet-structure) saturate(0);
  mix-blend-mode: lighten;
}

.planet-5 .structure-1 { opacity: 0.4; transform: scale(4) translateX(1vmax); }
.planet-5 .structure-2 { opacity: 0.5; transform: scale(7.5); }
.planet-5 .structure-3 { opacity: 0.1; transform: scale(0.2) translateX(1vmax); }

.planet-6 {
  width: 7vmax;
  aspect-ratio: 1;
  background: radial-gradient(90% 90% at 30% 55%, #f3ecec, #7a7a7a 52%, #212528 72%, transparent);
  transform: translateY(-39.6vmax) translateX(23vmax);
  display: grid;
  place-items: center;
}

.planet-6::before, .planet-6::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  width: 12vmax;
  height: 1vmax;
  box-shadow: inset 0 0 1rem black;
  transform: rotate(25deg);
  mask: radial-gradient(circle at 50% -20%, transparent 30%, black);
  clip-path: ellipse(47% 22% at 50% 50%);
}

.planet-6::before {
  border: 1vmax solid #5e5e5e;
  filter: blur(0.5vmax);
}

.planet-6::after {
  border: 2.6vmax solid #43484c;
}

.planets > div, .planets-2 > div {
  border-radius: 50%;
  position: absolute;
  background: radial-gradient(90% 90% at 70% 50%, #bbbaba, #888586 38%, #121415 52%, #131617 60%, transparent 82%);
}

.planets > div {
  width: 1.6vmax;
  aspect-ratio: 1;
  opacity: 0.5;
  filter: blur(0.1rem);
}

.planets-2 > div {
  width: 0.5vmax;
  aspect-ratio: 1;
  opacity: 0.6;
}

.highlight {
  position: absolute;
  height: 100vh;
  width: 100vw;
  background: radial-gradient(50vmin 70vmin at 70% 70%, rgba(255, 255, 255, 0.12), transparent),
              radial-gradient(40vmin 30vmin at 70% 70%, rgba(255, 255, 255, 0.12), transparent),
              radial-gradient(40vmin 60vmin at 10% 70%, rgba(255, 255, 255, 0.14), transparent),
              radial-gradient(80vmin 100vh at 30% 70%, rgba(255, 255, 255, 0.1), transparent);
  filter: blur(5vmin);
  pointer-events: none;
  z-index: 1;
}

.color-filter {
  position: absolute;
  height: 100vh;
  width: 100vw;
  background: conic-gradient(at 50% 60%, rgb(50 56 92 / 27%), rgb(152 75 132 / 7%), rgb(150 75 152 / 4%), rgb(50 56 92 / 27%));
  mix-blend-mode: color;
  pointer-events: none;
  z-index: 1;
}

.filter {
  position: absolute;
  width: 0;
  height: 0;
}

.top-nav {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 1rem;
  z-index: 300;
}

.nav-button {
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  letter-spacing: 0.1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

.nav-button:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.2);
}

.nav-button.wallet {
  background: rgba(100, 150, 255, 0.15);
  border-color: rgba(100, 150, 255, 0.4);
}

.nav-button.wallet:hover {
  background: rgba(100, 150, 255, 0.25);
  border-color: rgba(100, 150, 255, 0.6);
}

.toggle-button {
  position: absolute;
  top: 15px;
  right: 15px;
  width: 35px;
  height: 35px;
  padding: 0;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.3s ease;
}

.toggle-button:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
  transform: rotate(90deg);
}

/* Unified Container Layout */
.unified-container {
  position: relative;
  z-index: 200;
  display: flex;
  flex-direction: column;
  min-height: auto;
  max-height: none;
  width: 90%;
  max-width: 700px;
  background: transparent;
  border: none;
  border-radius: 16px;
  overflow: visible;
  transition: all 0.3s ease;
  padding: 2rem 0;
}

.unified-container:hover {
  background: rgba(36, 36, 37, 0.15);
  box-shadow: 0 0 60px rgba(74, 144, 226, 0.1);
}

/* Top Bar */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2rem;
  border-bottom: none;
  gap: 2rem;
  background: transparent;
}

.top-bar .title {
  font-size: 2rem;
  margin: 0;
  letter-spacing: 0.2rem;
  color: #fff;
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
  flex-shrink: 0;
}

.wallet-section {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  flex-shrink: 0;
}

.wallet-button {
  padding: 0.75rem 1.5rem;
  background: linear-gradient(135deg, rgba(74, 144, 226, 0.15) 0%, rgba(74, 144, 226, 0.1) 100%);
  border: 2px solid rgba(74, 144, 226, 0.3);
  border-radius: 8px;
  color: #4a90e2;
  font-size: 0.9rem;
  font-weight: bold;
  font-family: 'Courier New', monospace;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.wallet-button:hover {
  background: linear-gradient(135deg, rgba(74, 144, 226, 0.3) 0%, rgba(74, 144, 226, 0.2) 100%);
  border-color: rgba(74, 144, 226, 0.6);
  box-shadow: 0 0 20px rgba(74, 144, 226, 0.4);
}

.balance-info {
  font-size: 0.85rem;
  font-family: 'Courier New', monospace;
}

.balance-info span {
  color: #00ff00;
  text-shadow: 0 0 10px rgba(0, 255, 0, 0.3);
  font-weight: bold;
}

/* Wallet Menu */
.wallet-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.5rem;
  background: rgba(36, 36, 37, 0.95);
  border: 1px solid rgba(74, 144, 226, 0.3);
  border-radius: 8px;
  backdrop-filter: blur(10px);
  z-index: 300;
  min-width: 160px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.4);
}

.wallet-menu-item {
  display: block;
  width: 100%;
  padding: 0.75rem 1rem;
  background: transparent;
  border: none;
  color: #fff;
  text-align: left;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: bold;
  transition: all 0.2s ease;
}

.wallet-menu-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.wallet-menu-item.disconnect {
  color: #ff6b6b;
}

.wallet-menu-item.disconnect:hover {
  background: rgba(255, 107, 107, 0.2);
}

/* Main Content Area */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: auto;
}

.content-section {
  flex: 0 1 auto;
  display: flex;
  flex-direction: column;
  padding: 2rem;
  gap: 1.5rem;
  overflow-y: visible;
  min-height: auto;
  transition: opacity 0.3s ease;
  background: transparent;
}

.score-display {
  text-align: center;
  margin-bottom: 2rem;
}

.score-section {
  text-align: center;
  padding: 1rem 0;
}

.final-score {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.final-score .label {
  font-size: 0.95rem;
  letter-spacing: 0.2rem;
  opacity: 0.7;
}

.final-score .value {
  font-size: 3rem;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.8);
}

/* Leaderboard Section */
.leaderboard-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  flex: 1;
  overflow: hidden;
}

.leaderboard-section h2 {
  font-size: 1.2rem;
  margin: 0;
  letter-spacing: 0.2rem;
  opacity: 0.9;
  color: #fff;
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
  flex: 1;
  padding-right: 0.5rem;
}

.leaderboard-list::-webkit-scrollbar {
  width: 6px;
}

.leaderboard-list::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
}

.leaderboard-list::-webkit-scrollbar-thumb {
  background: rgba(74, 144, 226, 0.4);
  border-radius: 3px;
}

.leaderboard-list::-webkit-scrollbar-thumb:hover {
  background: rgba(74, 144, 226, 0.6);
}

.leaderboard-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.9rem;
  background: transparent;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.leaderboard-entry:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
}

.leaderboard-entry.current {
  background: rgba(74, 144, 226, 0.2);
  border-color: rgba(74, 144, 226, 0.5);
}

.leaderboard-entry .rank {
  font-weight: bold;
  min-width: 2rem;
  color: #4a90e2;
}

.leaderboard-entry .score {
  font-weight: bold;
  color: #00ff00;
}

/* Floating Action Buttons */
.floating-buttons {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 1rem;
  z-index: 201;
  pointer-events: auto;
  max-width: 700px;
  width: 90%;
  padding: 0 2rem;
}

.action-button {
  flex: 1;
  padding: 1rem 1.5rem;
  font-size: 1rem;
  letter-spacing: 0.1rem;
  font-weight: bold;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: #fff;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
  position: relative;
  z-index: 202;
  pointer-events: auto;
}

.action-button:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.15);
}

.action-button:active {
  transform: translateY(0);
}

.action-button:disabled {
  cursor: not-allowed;
  opacity: 0.7;
  box-shadow: none;
}

.action-button.primary {
  color: #00ff64;
}

.action-button.primary:hover {
  background: rgba(0, 255, 100, 0.15);
  box-shadow: 0 0 20px rgba(0, 255, 100, 0.4);
}

.action-button.primary:disabled {
  color: #00cc50;
  background: rgba(0, 255, 100, 0.1);
}

.action-button.secondary {
  color: #fff;
}

.action-button.secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.2);
}

/* Responsive */
@media (max-width: 768px) {
  .unified-container {
    max-height: none;
    min-height: auto;
    width: 95%;
    max-width: none;
    padding: 0.5rem 0;
  }

  .top-bar {
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
    align-items: center;
  }

  .top-bar .title {
    font-size: 1.3rem;
    text-align: center;
  }

  .wallet-section {
    width: auto;
    align-items: center;
    gap: 0.4rem;
  }

  .wallet-button {
    padding: 0.6rem 1.2rem;
    font-size: 0.85rem;
    text-align: center;
  }

  .balance-info {
    font-size: 0.75rem;
    text-align: center;
  }

  .content-section {
    padding: 1rem;
    gap: 1rem;
  }

  .final-score .value {
    font-size: 2.5rem;
  }

  .floating-buttons {
    bottom: 20px;
    gap: 0.75rem;
    padding: 0 1rem;
  }

  .action-button {
    padding: 0.85rem 1.2rem;
    font-size: 0.9rem;
  }

  .leaderboard-entry {
    font-size: 0.85rem;
    padding: 0.5rem 0.75rem;
  }
}

/* ============ Modal Dialog ============ */

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    pointer-events: all;
}

.modal-backdrop.active {
    display: flex;
}

.modal-box {
    background: linear-gradient(135deg, rgba(20, 30, 50, 0.95) 0%, rgba(10, 20, 40, 0.95) 100%);
    border: 2px solid rgba(74, 144, 226, 0.4);
    border-radius: 8px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 0 30px rgba(74, 144, 226, 0.2), inset 0 0 20px rgba(74, 144, 226, 0.05);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-30px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-title {
    font-size: 18px;
    font-weight: bold;
    color: #ffffff;
    margin-bottom: 15px;
    font-family: 'Courier New', monospace;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.modal-message {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 25px;
    line-height: 1.5;
    font-family: 'Courier New', monospace;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.modal-button {
    padding: 10px 20px;
    background: rgba(74, 144, 226, 0.3);
    border: 2px solid rgba(74, 144, 226, 0.5);
    color: rgba(74, 144, 226, 0.9);
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.3s ease;
    font-family: 'Courier New', monospace;
    letter-spacing: 0.5px;
    flex: 1;
}

.modal-button:hover {
    background: rgba(74, 144, 226, 0.4);
    border-color: rgba(74, 144, 226, 0.8);
    box-shadow: 0 0 15px rgba(74, 144, 226, 0.3);
}

.modal-button:active {
    transform: translateY(2px);
}
