:root {
  --bg: #0d1220;
  --panel: #0f172a;
  --card: #0b1220;
  --card-ink: #dbeafe;
  --accent: #3b82f6;
  --accent-2: #22c55e;
  --muted: #94a3b8;
  --ring: #1f2937;
  --accent: #1d4ed8;
  --grad1: #1e293b55; /* layer aurora kiri atas */
  --grad2: #0ea5e955; /* layer aurora kanan atas */
  --text: #dbeafe;
}

* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu,
    Cantarell, Noto Sans, Helvetica Neue, Arial, "Apple Color Emoji",
    "Segoe UI Emoji";
  background: var(--bg);
  color: #e5e7eb;
  display: grid;
  place-items: center;
  padding: 24px;
  transition: background 0.6s ease-in-out;
}
/* Aurora effect */
body::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
      1200px 800px at 10% -10%,
      var(--grad1),
      transparent
    ),
    radial-gradient(1000px 700px at 110% 10%, var(--grad2), transparent),
    var(--bg);
  filter: blur(80px);
  z-index: -1;
  animation: auroraMove 20s ease-in-out infinite alternate;
}

/* Animasi slow move */
@keyframes auroraMove {
  0% {
    transform: translateY(0px) translateX(0px);
  }
  50% {
    transform: translateY(-40px) translateX(30px);
  }
  100% {
    transform: translateY(20px) translateX(-20px);
  }
}
.app {
  width: min(980px, 100%);
  background: linear-gradient(180deg, #0b1020, #0a1020);
  border: 1px solid #1e293b;
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 10px 40px rgba(2, 6, 23, 0.5),
    inset 0 0 0 1px rgba(148, 163, 184, 0.06);

  position: relative; /* penting biar absolute child ngikut frame */
  padding: 20px;
  background: var(--panel);
  border-radius: 16px;
}

.header {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: 0.2px;
}
.title .logo {
  font-size: 28px;
}

.stats {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 14px;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #0b1220;
  border: 1px solid #1e293b;
  padding: 6px 10px;
  border-radius: 999px;
}
.pill strong {
  color: #e5e7eb;
  font-weight: 700;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.btn {
  border: 1px solid #1e293b;
  background: #0b1220;
  color: #e5e7eb;
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.05s ease, background 0.2s ease, border-color 0.2s ease;
}
.btn:hover {
  background: #111b33;
  border-color: #334155;
}
.btn:active {
  transform: translateY(1px) scale(0.99);
}
.btn.primary {
  background: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 80%, black);
}
.btn.primary:hover {
  background: color-mix(in srgb, var(--accent) 80%, black);
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  padding: 10px;
}

.card {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  perspective: 800px;
  cursor: pointer;
  outline: none;
}

.inner {
  position: absolute;
  inset: 0;
  border-radius: 14px;
  transform-style: preserve-3d;
  transition: transform 0.5s ease;
  box-shadow: 0 2px 0 0 #0b1220, 0 0 0 1px #1e293b inset;
  background: linear-gradient(180deg, #0b1220, #0b1426);
}

.card.flipped .inner {
  transform: rotateY(180deg);
}
.card.matched {
  box-shadow: 0 0 0 2px #22c55e inset, 0 0 0 1px #14532d;
}

.face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 14px;
  backface-visibility: hidden;
}
.front {
  font-size: 34px;
  transform: rotateY(180deg);
}
.back {
  background: #0f172a;
}

.spark {
  position: absolute;
  inset: -2px;
  border-radius: 16px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  background: radial-gradient(
    120px 120px at var(--mx, 50%) var(--my, 50%),
    rgba(34, 197, 94, 0.25),
    transparent 60%
  );
}
.card.matched .spark {
  opacity: 1;
}

/* Responsive */
@media (max-width: 720px) {
  .grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
  }
  .header {
    gap: 10px;
  }
  .title {
    font-size: 16px;
  }
}
@media (max-width: 420px) {
  .grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.win-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 999;
  animation: fadeIn 0.5s ease forwards;
}

.win-message {
  font-size: 40px;
  font-weight: 800;
  color: #22c55e;
  background: #0b1220;
  padding: 20px 40px;
  border-radius: 16px;
  border: 2px solid #22c55e;
  box-shadow: 0 0 20px rgba(34, 197, 94, 0.7);
  animation: popUp 0.6s ease;
  max-width: 90%;
  text-align: center;
  word-wrap: break-word;
}

/* Animasi konfeti */
.confetti {
  position: fixed;
  width: 10px;
  height: 10px;
  background: var(--color, #facc15);
  top: -10px;
  animation: fall linear forwards;
  z-index: 1000;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes popUp {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes fall {
  to {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

/* Tablet */
@media (max-width: 768px) {
  .win-message {
    font-size: 28px;
    padding: 16px 28px;
    border-radius: 14px;
  }
}

/* HP */
@media (max-width: 480px) {
  .win-message {
    font-size: 22px;
    padding: 12px 20px;
    border-radius: 12px;
  }
}

button {
  transition: background 0.3s ease, color 0.3s ease;
}
.color-switch {
  position: absolute;
  top: 62px;
  right: 20px;
  display: flex;
  gap: 10px;
}

.dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  cursor: pointer;
}

.color-switch .dot:hover {
  transform: scale(1.2);
}

.dot.red {
  background: red;
}
.dot.yellow {
  background: yellow;
}
.dot.green {
  background: limegreen;
}

@media (max-width: 600px) {
  .color-switch {
    top: 10px; /* masuk frame */
    right: 20px; /* mepet kanan atas frame */
  }
  .dot {
    width: 24px;
    height: 24px;
  }
}
