:root {
  --bg: #0f1115;
  --panel: #171a21;
  --text: #e8e6e3;
  --muted: #8b8f98;
  --accent: #e3350d;
  --accent-2: #ffcb05;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  overflow: hidden;
}

#canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  visibility: hidden;
  touch-action: none;
}

#loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: var(--bg);
}

#loading .ball {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(to bottom, var(--accent) 0 46%, #1b1d22 46% 54%, #f4f4f4 54% 100%);
  border: 3px solid #1b1d22;
  animation: spin 1.2s linear infinite;
}

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

#loading-text { color: var(--muted); font-size: 14px; }

#toolbar {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px;
  background: var(--panel);
  justify-content: center;
}

#toolbar button {
  appearance: none;
  border: 1px solid #2a2e37;
  background: #20242d;
  color: var(--text);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  min-height: 44px;
  cursor: pointer;
}

#toolbar button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

#toolbar button:active { transform: translateY(1px); }

#status {
  flex: 0 0 auto;
  min-height: 20px;
  padding: 4px 12px;
  text-align: center;
  font-size: 13px;
  color: var(--accent-2);
}

footer {
  flex: 0 0 auto;
  padding: 6px 12px calc(6px + env(safe-area-inset-bottom));
  text-align: center;
  font-size: 11px;
  color: var(--muted);
}

footer a { color: var(--muted); }

@media (display-mode: standalone) {
  footer { display: none; }
}
