* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --c1: #e05a8d;
  --c2: #e8a238;
  --c3: #5cbdbd;
  --c4: #9b7ed8;
  --c5: #6bcf6b;
  --bg: #111113;
  --card: #1a1a1f;
  --border: #2a2a32;
  --text: #e2e2e2;
  --dim: #666;
  --gold: #daa520;
  --silver: #aaa;
  --bronze: #b87333;
}

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: var(--bg-image, none) center/cover no-repeat;
  z-index: -2;
}

#bg-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: -1;
}

/* fx canvas */
#fx {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
}

/* marquee */
.marquee {
  overflow: hidden;
  white-space: nowrap;
  border-bottom: 2px solid var(--border);
  background: rgba(0, 0, 0, 0.4);
  padding: 7px 0;
  z-index: 1;
  position: relative;
}

.marquee-track {
  display: inline-flex;
  animation: marquee 28s linear infinite;
}

.marquee-track span {
  padding-right: 50px;
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--dim);
}

@keyframes marquee {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* title */
.glitch {
  font-size: 2.4rem;
  font-weight: 900;
  text-align: center;
  color: #fff;
  margin: 1.2rem 0 0.6rem;
  letter-spacing: -0.02em;
  cursor: pointer;
  user-select: none;
  z-index: 1;
  position: relative;
}

.glitch::before, .glitch::after { display: none; }

/* stats */
.stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 1.2rem;
  z-index: 1;
  position: relative;
}

.stat { display: flex; flex-direction: column; align-items: center; }

.stat-value {
  font-size: 1.2rem;
  font-weight: 800;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 0.55rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--dim);
  margin-top: 2px;
}

/* layout */
.main-content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem 3rem;
  z-index: 1;
  position: relative;
}

.content-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.2rem;
  margin-bottom: 1.2rem;
}

/* panels */
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.panel-title {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 12px 16px;
  color: var(--c1);
  border-bottom: 1px solid var(--border);
}

.panel-title small {
  font-size: 0.6rem;
  color: var(--dim);
  font-weight: 500;
}

/* leaderboard */
.leaderboard-header {
  display: grid;
  grid-template-columns: 38px 1fr 80px;
  padding: 6px 16px;
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--dim);
  border-bottom: 1px solid var(--border);
}

.leaderboard-body { min-height: 60px; }

.lb-row {
  display: grid;
  grid-template-columns: 38px 1fr 80px;
  padding: 7px 16px;
  align-items: center;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  position: relative;
  overflow: hidden;
}

.lb-row:last-child { border-bottom: none; }
.lb-row:hover { background: rgba(255,255,255,0.03); }

.lb-bar {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  z-index: 0;
  transition: width 0.5s ease;
}

.lb-row .lb-bar { background: linear-gradient(90deg, rgba(92,189,189,0.12), transparent); }
.lb-row.rank-1 .lb-bar { background: linear-gradient(90deg, rgba(218,165,32,0.18), transparent); }
.lb-row.rank-2 .lb-bar { background: linear-gradient(90deg, rgba(170,170,170,0.12), transparent); }
.lb-row.rank-3 .lb-bar { background: linear-gradient(90deg, rgba(184,115,51,0.12), transparent); }

.lb-rank {
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--dim);
  position: relative; z-index: 1;
}

.rank-1 .lb-rank { color: var(--gold); font-size: 1rem; }
.rank-2 .lb-rank { color: var(--silver); }
.rank-3 .lb-rank { color: var(--bronze); }

.lb-name {
  font-weight: 600;
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative; z-index: 1;
}

.lb-count {
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 0.82rem;
  color: var(--c3);
  position: relative; z-index: 1;
}

.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--dim);
  font-size: 0.8rem;
}

/* section titles */
.section-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--c4);
  margin-bottom: 10px;
}

/* toys */
.toys-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.toy-wide { grid-column: 1 / -1; }

.toy-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}

.toy-title {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--c2);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toy-hint {
  font-size: 0.55rem;
  color: var(--dim);
  text-align: center;
  margin-top: 5px;
}

.reset-btn {
  font-size: 0.5rem;
  padding: 2px 7px;
  background: transparent;
  border: 1px solid var(--c1);
  color: var(--c1);
  border-radius: 3px;
  cursor: pointer;
  font-weight: 600;
}

.reset-btn:hover { background: rgba(224,90,141,0.15); }

/* spinner */
.spinner-container {
  display: flex;
  justify-content: center;
  padding: 4px 0;
}

.spinner-body {
  width: 95px;
  height: 95px;
  position: relative;
  cursor: grab;
}

.spinner-body:active { cursor: grabbing; }

.spinner-arm {
  position: absolute;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--c3);
  border: 2px solid rgba(255,255,255,0.15);
}

.spinner-arm:nth-child(1) { top: 0; left: calc(50% - 15px); }
.spinner-arm:nth-child(2) { bottom: 4px; left: 4px; }
.spinner-arm:nth-child(3) { bottom: 4px; right: 4px; }

.spinner-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--c1);
  border: 2px solid rgba(255,255,255,0.2);
  z-index: 2;
}

.spinner-body::before {
  content: '';
  position: absolute;
  top: 15px; left: 50%;
  transform: translateX(-50%);
  width: 5px; height: 34px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
}

.spinner-body::after {
  content: '';
  position: absolute;
  bottom: 16px; left: 10px; right: 10px;
  height: 5px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
}

/* clicker */
.clicker-count {
  text-align: center;
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--c4);
  margin-bottom: 8px;
  font-variant-numeric: tabular-nums;
}

.clicker-btn {
  display: block;
  width: 70px; height: 70px;
  border-radius: 50%;
  background: var(--c4);
  border: 2px solid rgba(255,255,255,0.15);
  color: #fff;
  font-weight: 800;
  font-size: 0.7rem;
  cursor: pointer;
  transition: transform 0.1s;
  margin: 0 auto;
  user-select: none;
}

.clicker-btn:hover { transform: scale(1.05); }
.clicker-btn:active, .clicker-btn.pulse { transform: scale(0.88); }

/* bubbles */
.bubble-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
}

.bubble {
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(92,189,189,0.5), rgba(92,189,189,0.15));
  border: 1px solid rgba(92,189,189,0.3);
  cursor: pointer;
  transition: all 0.1s;
  box-shadow: inset 0 -2px 3px rgba(0,0,0,0.3);
}

.bubble:hover:not(.popped) { transform: scale(1.1); }

.bubble.popped {
  background: rgba(255,255,255,0.02);
  border-color: rgba(255,255,255,0.05);
  transform: scale(0.8);
  cursor: default;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.4);
}

/* piano */
.piano-keys {
  display: flex;
  justify-content: center;
  height: 95px;
  padding: 6px 4px;
  user-select: none;
}

.key {
  cursor: pointer;
  transition: background 0.06s, transform 0.06s;
  flex-shrink: 0;
  border-radius: 0 0 3px 3px;
}

.key.white {
  width: 25px; height: 82px;
  background: linear-gradient(180deg, #ddd, #fff);
  border: 1px solid rgba(0,0,0,0.2);
  z-index: 1;
}

.key.black {
  width: 16px; height: 50px;
  background: linear-gradient(180deg, #444, #1a1a1a);
  border: 1px solid #000;
  margin-left: -8px; margin-right: -8px;
  z-index: 2;
}

.key.white.active { background: var(--c3); transform: scaleY(0.97); }
.key.black.active { background: var(--c1); transform: scaleY(0.95); }

/* soundboard */
.sound-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.sound-btn {
  padding: 12px 6px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  font-weight: 700;
  font-size: 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.1s;
  user-select: none;
}

.sound-btn:hover { background: rgba(255,255,255,0.08); }
.sound-btn.active { background: var(--c4); color: #fff; transform: scale(0.92); }

/* 3d cube */
.cube-scene {
  width: 80px; height: 80px;
  margin: 6px auto;
  perspective: 280px;
  cursor: grab;
}

.cube-scene:active { cursor: grabbing; }

.cube-3d {
  width: 80px; height: 80px;
  position: relative;
  transform-style: preserve-3d;
  transform: rotateX(-25deg) rotateY(35deg);
}

.cube-face {
  position: absolute;
  width: 80px; height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 900;
  border: 1.5px solid var(--c3);
  background: rgba(92,189,189,0.06);
  color: var(--c3);
  backface-visibility: visible;
}

.cube-face.front  { transform: translateZ(40px); }
.cube-face.back   { transform: rotateY(180deg) translateZ(40px); }
.cube-face.right  { transform: rotateY(90deg) translateZ(40px); }
.cube-face.left   { transform: rotateY(-90deg) translateZ(40px); }
.cube-face.top    { transform: rotateX(90deg) translateZ(40px); }
.cube-face.bottom { transform: rotateX(-90deg) translateZ(40px); }

/* gravity */
.gravity-panel { margin-bottom: 1.2rem; }

#gravity-canvas {
  width: 100%;
  height: 200px;
  display: block;
  cursor: crosshair;
}

/* dvd logo */
#dvd-logo {
  position: fixed;
  font-size: 1.3rem;
  font-weight: 900;
  z-index: 3;
  pointer-events: none;
  opacity: 0.4;
}

/* floating images */
#floating-images {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.floating-img {
  position: fixed;
  width: 110px;
  height: auto;
  border-radius: 5px;
  border: 1px solid rgba(255,255,255,0.12);
  opacity: 0.55;
  pointer-events: auto;
  cursor: grab;
  animation: float-y var(--float-duration, 20s) ease-in-out infinite alternate;
  transition: opacity 0.2s;
  user-select: none;
}

.floating-img:hover { opacity: 0.85; }

.floating-img.dragging {
  cursor: grabbing;
  animation: none !important;
  opacity: 1;
  z-index: 100;
  border-color: rgba(255,255,255,0.3);
}

@keyframes float-y {
  0% { transform: translateY(0) rotate(-1deg); }
  100% { transform: translateY(-20px) rotate(1deg); }
}

/* rainbow button */
.rainbow-btn {
  position: fixed;
  bottom: 16px;
  right: 16px;
  padding: 8px 16px;
  background: linear-gradient(135deg, #e05a8d, #e8a238, #5cbdbd, #9b7ed8, #e05a8d);
  background-size: 400% 400%;
  animation: rainbow-bg 5s linear infinite;
  border: none;
  border-radius: 20px;
  color: #fff;
  font-weight: 700;
  font-size: 0.55rem;
  cursor: pointer;
  z-index: 1000;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
  transition: transform 0.15s;
}

.rainbow-btn:hover { transform: scale(1.06); }
.rainbow-btn.active { outline: 2px solid #fff; outline-offset: 2px; }

@keyframes rainbow-bg {
  0% { background-position: 0% 50%; }
  100% { background-position: 100% 50%; }
}

/* responsive */
@media (max-width: 900px) {
  .content-grid { grid-template-columns: 1fr; }
  .glitch { font-size: 1.7rem; }
  .stats { gap: 1rem; }
  .stat-value { font-size: 1rem; }
}

@media (max-width: 600px) {
  .glitch { font-size: 1.3rem; }
  .toys-grid { grid-template-columns: 1fr; }
  .toy-wide { grid-column: 1; }
  .leaderboard-header, .lb-row {
    grid-template-columns: 34px 1fr 60px;
    padding: 6px 10px;
  }
  .floating-img { width: 55px; }
  .rainbow-btn { bottom: 10px; right: 10px; padding: 6px 12px; font-size: 0.5rem; }
}

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 2px; }
