:root {
  --navy-950: #060B14;
  --navy-900: #0A1A2F;
  --navy-800: #0F2740;
  --navy-700: #1B2740;
  --cyan: #22E6FF;
  --blue: #0057FF;
  --text-light: #E5E9F0;
  --text-muted: #8CA0BC;
  --radius: 14px;
  --font-display: "Space Grotesk", "Segoe UI", sans-serif;
  --font-body: "Inter", "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--text-light);
  background:
    radial-gradient(120% 140% at 15% -10%, rgba(34,230,255,0.10), transparent 55%),
    radial-gradient(90% 120% at 100% 0%, rgba(0,87,255,0.18), transparent 50%),
    linear-gradient(180deg, var(--navy-950) 0%, var(--navy-900) 100%);
  padding: 24px 16px 60px;
}

#game-container {
  max-width: 920px;
  margin: 0 auto;
  position: relative;
}

.game-header {
  text-align: center;
  margin-bottom: 22px;
  position: relative;
}

.back-link {
  position: absolute;
  left: 0;
  top: 6px;
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
}
.back-link:hover { color: var(--cyan); }

.game-header h1 {
  font-family: var(--font-display);
  font-size: clamp(24px, 4vw, 32px);
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}

.game-header p {
  color: var(--text-muted);
  font-size: 14.5px;
  margin: 0;
  max-width: 480px;
  margin-inline: auto;
}

.icon-btn {
  position: absolute;
  right: 0;
  top: 4px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(140,160,188,0.25);
  border-radius: 999px;
  width: 36px;
  height: 36px;
  font-size: 16px;
  cursor: pointer;
  color: var(--text-light);
}
.icon-btn:hover { border-color: var(--cyan); }

#hud {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.hud-box {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(140,160,188,0.2);
  border-radius: var(--radius);
  padding: 10px 14px;
  text-align: center;
}

.hud-task { grid-column: span 2; }

.hud-label {
  display: block;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.hud-value {
  display: block;
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 600;
}

.hud-combo .hud-value { color: var(--cyan); }

#timer-bar-wrap {
  height: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  overflow: hidden;
  margin-bottom: 22px;
}

#timer-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--blue), var(--cyan));
  transition: width 1s linear, background 0.3s ease;
  border-radius: 999px;
}

#timer-bar.low { background: linear-gradient(90deg, #E24B4A, #F09595); }

#workspace {
  display: flex;
  gap: 26px;
  align-items: flex-start;
  margin-bottom: 18px;
}

#pc-area {
  position: relative;
  width: 56%;
  aspect-ratio: 340 / 460;
}

#pc-case { width: 100%; height: 100%; display: block; }

.slot {
  position: absolute;
  border: 2px dashed transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.slot-icon {
  width: 70%;
  height: 70%;
  object-fit: contain;
  opacity: 0;
  transform: scale(0.7);
  transition: all 0.25s ease;
}

.slot-check {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--cyan);
  color: var(--navy-950);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0);
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.slot.filled .slot-icon { opacity: 1; transform: scale(1); }
.slot.filled .slot-check { opacity: 1; transform: scale(1); }

.slot.active {
  border-color: var(--cyan);
  box-shadow: 0 0 0 4px rgba(34,230,255,0.15), 0 0 24px rgba(34,230,255,0.35);
  animation: slot-pulse 1.4s ease-in-out infinite;
}

.slot.active .slot-icon { opacity: 0.35; transform: scale(0.85); }

.slot.wrong {
  border-color: #E24B4A;
  box-shadow: 0 0 0 4px rgba(226,75,74,0.2);
  animation: slot-shake 0.35s ease;
}

.slot.dragover-active {
  border-color: #fff;
  box-shadow: 0 0 0 6px rgba(255,255,255,0.2);
}

@keyframes slot-pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(34,230,255,0.15), 0 0 24px rgba(34,230,255,0.35); }
  50% { box-shadow: 0 0 0 8px rgba(34,230,255,0.08), 0 0 36px rgba(34,230,255,0.55); }
}

@keyframes slot-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

#parts {
  width: 44%;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  align-content: start;
}

.parts-label {
  grid-column: span 2;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 0 0 2px;
}

.part {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(140,160,188,0.22);
  border-radius: var(--radius);
  padding: 10px 8px 8px;
  text-align: center;
  cursor: grab;
  touch-action: none;
  user-select: none;
  transition: border-color 0.2s, transform 0.15s;
}

.part:hover { border-color: rgba(34,230,255,0.4); }
.part:active { cursor: grabbing; }
.part.dragging { opacity: 0.35; }

.part img { width: 100%; height: 46px; object-fit: contain; pointer-events: none; }

.part span {
  display: block;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 4px;
}

.drag-ghost {
  position: fixed;
  width: 64px;
  height: 64px;
  pointer-events: none;
  z-index: 999;
  filter: drop-shadow(0 8px 16px rgba(0,0,0,0.5));
  transform: translate(-50%, -50%) scale(1.1);
}

.drag-ghost img { width: 100%; height: 100%; object-fit: contain; }

#diagnose {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(140,160,188,0.2);
  border-radius: var(--radius);
  padding: 16px 20px;
  min-height: 24px;
  font-size: 14.5px;
  color: var(--text-light);
  text-align: center;
}

#diagnose.ok { border-color: rgba(34,230,255,0.4); color: var(--cyan); }
#diagnose.err { border-color: rgba(226,75,74,0.4); color: #F09595; }

.floater {
  position: fixed;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 20px;
  color: var(--cyan);
  pointer-events: none;
  z-index: 998;
  animation: float-up 0.9s ease forwards;
}

.floater.neg { color: #F09595; }

@keyframes float-up {
  0% { opacity: 0; transform: translate(-50%, 0); }
  15% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -60px); }
}

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(6,11,20,0.82);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 20px;
  z-index: 50;
  padding: 20px;
}

.overlay-card {
  text-align: center;
  max-width: 420px;
}

.overlay-card h2 {
  font-family: var(--font-display);
  font-size: 26px;
  margin: 0 0 12px;
}

.overlay-card p {
  color: var(--text-muted);
  font-size: 15px;
  margin: 0 0 22px;
  line-height: 1.6;
}

.final-score {
  font-family: var(--font-mono);
  font-size: 28px !important;
  color: var(--cyan);
  font-weight: 700;
}

.newrecord {
  color: #FAC775;
  font-weight: 600;
  margin-top: -12px !important;
}

.btn-play {
  background: linear-gradient(135deg, var(--blue), var(--cyan));
  color: #fff;
  border: none;
  padding: 14px 34px;
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(0,87,255,0.4);
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn-play:hover { transform: translateY(-1px); box-shadow: 0 14px 30px rgba(0,87,255,0.5); }

@media (max-width: 720px) {
  #workspace { flex-direction: column; }
  #pc-area { width: 100%; max-width: 340px; margin: 0 auto; }
  #parts { width: 100%; grid-template-columns: repeat(3, 1fr); }
  .hud-task { grid-column: span 4; }
  #hud { grid-template-columns: repeat(2, 1fr); }
  .back-link { position: static; display: block; margin-bottom: 8px; }
  .icon-btn { position: static; margin: 8px auto 0; }
}
