:root {
  --bg-color: #0f172a;
  --card-bg: #1e293b;
  --primary: #38bdf8;
  --primary-hover: #0ea5e9;
  --secondary: #64748b;
  --accent: #fbbf24;
  --text-main: #f8fafc;
  --text-dim: #94a3b8;
}

body {
  margin: 0;
  background-color: var(--bg-color);
  background-image: radial-gradient(circle at top right, #1e293b, #0f172a);
  font-family: "Poppins", sans-serif;
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
}

.app-container {
  width: 100%;
  max-width: 600px; /* Dipersempit agar fokus di tengah */
  padding: 40px 20px;
}

header {
  text-align: center;
  margin-bottom: 30px;
}

header h1 {
  font-size: 2.2rem;
  font-weight: 700;
  margin: 0;
}

header h1 span {
  color: var(--primary);
}

.subtitle {
  color: var(--text-dim);
  font-size: 0.9rem;
}

/* Main Layout Centering */
.main-content {
  display: flex;
  justify-content: center;
  width: 100%;
}

.game-section {
  background: var(--card-bg);
  padding: 25px;
  border-radius: 28px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.05);
  width: 100%;
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.level-badge {
  background: #0f172a;
  padding: 8px 15px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--primary);
}

select {
  background: transparent;
  border: none;
  color: var(--accent);
  font-family: inherit;
  font-weight: 600;
  outline: none;
  cursor: pointer;
}

/* Canvas Area */
.canvas-area {
  background: #000;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
  line-height: 0; /* Menghilangkan gap bawah canvas */
}

canvas {
  width: 100%;
  height: auto;
  image-rendering: pixelated;
}

/* Buttons */
.game-actions {
  display: flex;
  gap: 10px;
}

button {
  font-family: "Poppins", sans-serif;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  transition: all 0.3s ease;
  cursor: pointer;
}

.btn-primary {
  background: var(--primary);
  color: #000;
  padding: 10px 20px;
}

.btn-secondary {
  background: var(--secondary);
  color: white;
  width: 45px;
  height: 45px;
}

/* Swipe Hint */
.swipe-hint {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.75rem;
  margin-top: 15px;
  text-transform: uppercase;
  letter-spacing: 2px;
  display: none; /* Default sembunyi */
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: var(--card-bg);
  padding: 30px;
  border-radius: 32px;
  text-align: center;
  width: 90%;
  max-width: 350px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 20px 0;
}

.stat-item {
  background: #0f172a;
  padding: 10px;
  border-radius: 12px;
}

.btn-run {
  width: 100%;
  padding: 15px;
  background: #10b981;
  color: white;
}

.hidden {
  display: none !important;
}

/* Styling Loading Overlay */
.loading-content {
  text-align: center;
  color: var(--primary);
}

.spinner {
  width: 50px;
  height: 50px;
  border: 5px solid rgba(56, 189, 248, 0.1);
  border-top: 5px solid var(--primary);
  border-radius: 50%;
  margin: 0 auto 20px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.loading-content p {
  font-weight: 600;
  margin: 0;
  font-size: 1.2rem;
}

.loading-content small {
  color: var(--text-dim);
  letter-spacing: 1px;
}

/* === FOOTER STYLING === */
footer {
  margin-top: 40px;
  padding: 20px 0;
  text-align: center;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  width: 100%;
}

footer p {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin: 0;
  letter-spacing: 0.5px;
}

.footer-links {
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--primary);
  opacity: 0.7;
  font-weight: 600;
}

.app-container {
  display: flex;
  flex-direction: column;
  min-height: 90vh; /* Memberi ruang untuk footer */
}

.main-content {
  flex: 1; /* Membuat area game mengambil ruang yang tersedia */
}

/* Responsive */
@media (max-width: 850px) {
  .swipe-hint {
    display: block;
  }
  .app-container {
    padding: 20px 15px;
  }
}
