:root {
  color-scheme: dark;
  --sb-accent: #ccff00;
  --sb-accent-rgb: 204, 255, 0;
  --sb-muted: rgba(236, 241, 255, 0.65);
  --sb-stroke: rgba(255, 255, 255, 0.12);
  --sb-bg: #07090e;
}

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

html, body {
  background: var(--sb-bg) !important;
  color: #ecf1ff !important;
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif !important;
  user-select: none;
}

/* ── Loading Overlay ── */
#loading-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at center, #111622 0%, #06080c 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.6s ease;
  padding: 24px;
  text-align: center;
}

body.sb-running #loading-overlay {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-card {
  max-width: 480px;
  width: 100%;
  background: rgba(18, 24, 38, 0.7);
  border: 1px solid var(--sb-stroke);
  border-radius: 20px;
  padding: 36px 32px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7), 0 0 30px rgba(204, 255, 0, 0.05);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.loader-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: rgba(204, 255, 0, 0.12);
  border: 1px solid rgba(204, 255, 0, 0.25);
  border-radius: 999px;
  color: var(--sb-accent);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 16px;
}

.loader-icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.loader-title {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
  margin-bottom: 6px;
}

.loader-subtitle {
  font-size: 0.88rem;
  color: var(--sb-muted);
  margin-bottom: 24px;
}

/* Spinner & Progress */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--sb-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 18px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#status {
  font-size: 0.86rem;
  font-weight: 600;
  color: #e2e8f0;
  margin-bottom: 12px;
  min-height: 1.3em;
  letter-spacing: 0.01em;
}

.progress-wrap {
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  height: 6px;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 20px;
}

progress#progress {
  width: 100%;
  height: 100%;
  display: block;
  appearance: none;
  border: none;
  background: transparent;
}
progress#progress::-webkit-progress-bar {
  background: transparent;
}
progress#progress::-webkit-progress-value {
  background: linear-gradient(90deg, #99cc00, var(--sb-accent));
  border-radius: 999px;
  transition: width 0.3s ease;
}
progress#progress::-moz-progress-bar {
  background: linear-gradient(90deg, #99cc00, var(--sb-accent));
  border-radius: 999px;
}

.loader-tips {
  font-size: 0.76rem;
  color: rgba(236, 241, 255, 0.45);
  line-height: 1.45;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 16px;
  width: 100%;
}

/* ── Game Canvas & Dropzone ── */
#app {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #000;
  position: relative;
}

#dropzone {
  flex: 1;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  overflow: hidden;
}

.emscripten_border {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  border: none !important;
}

canvas.emscripten {
  max-width: 100vw;
  max-height: 100vh;
  width: auto;
  height: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background: #000;
  display: block;
  cursor: default;
}

canvas.boxedwine-webgl-canvas {
  position: absolute;
}

/* Controls Header (minimal float in bottom-right) */
#controls {
  position: fixed;
  bottom: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 100;
  background: rgba(10, 14, 20, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--sb-stroke);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  color: var(--sb-muted);
  opacity: 0.3;
  transition: opacity 0.25s ease;
}
#controls:hover {
  opacity: 1;
}

#controls label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}

#controls input[type="checkbox"] {
  accent-color: var(--sb-accent);
}

#startbtn, #downloadbtn, #savejitbtn, #modalLink, #modalLinkExe {
  display: none !important;
}

/* Console Drawer */
#console {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: rgba(5, 7, 10, 0.95);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--sb-stroke);
  padding: 12px;
  display: none;
}
#console textarea {
  width: 100%;
  height: 160px;
  background: #000;
  color: #38bdf8;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 8px;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 11px;
  resize: vertical;
}

hr { display: none; }
