: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; }

/* ---- floating chrome: hamburger + shadow-QA button + their panels ---- */
#btn-menu, #btn-shadowqa {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(23, 26, 33, 0.72);
  color: var(--text);
  border-radius: 12px;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  z-index: 30;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

#btn-menu { right: calc(12px + env(safe-area-inset-right)); }
#btn-shadowqa { right: calc(64px + env(safe-area-inset-right)); }
#btn-menu:active, #btn-shadowqa:active { transform: translateY(1px); }

#menu[hidden], #shadowqa[hidden] { display: none; }

#menu, #shadowqa {
  position: fixed;
  top: calc(60px + env(safe-area-inset-top));
  right: calc(12px + env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  background: rgba(23, 26, 33, 0.95);
  border: 1px solid #2a2e37;
  border-radius: 14px;
  z-index: 29;
  max-height: calc(100dvh - 80px);
  overflow-y: auto;
}

#menu 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;
  text-align: left;
}

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

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

#menu .menu-link {
  color: #8ab4ff;
  text-decoration: none;
  font-size: 13px;
  padding: 8px 14px;
}

#menu .menu-sep {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 8px 14px 2px;
}

#menu .kbd {
  float: right;
  color: var(--muted);
  border: 1px solid #2a2e37;
  border-radius: 4px;
  padding: 0 6px;
  font-size: 12px;
  margin-left: 10px;
}

#shadowqa { width: 230px; font-size: 13px; }

.qa-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  user-select: none;
  -webkit-user-select: none;
}

.qa-row input[type="range"] { flex: 1; min-width: 0; }
.qa-row span { min-width: 34px; text-align: right; color: var(--accent-2); }

/* status is a transient toast now — hidden when empty */
#status {
  position: fixed;
  left: 50%;
  bottom: calc(14px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: min(92vw, 560px);
  padding: 8px 14px;
  border-radius: 10px;
  background: rgba(23, 26, 33, 0.92);
  border: 1px solid #2a2e37;
  text-align: center;
  font-size: 13px;
  color: var(--accent-2);
  z-index: 40;
  pointer-events: none;
}

#status:empty { display: none; }

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; }
}

/* phones: the game gets every pixel — chrome floats over the stage */
@media (max-width: 700px) {
  footer { display: none; }
}

/* landscape phones: same, keyed on height (a landscape iPhone is ~390-430
   tall but >700 wide, so the width query alone misses it) */
@media (orientation: landscape) and (max-height: 500px) {
  footer { display: none; }
  #status { font-size: 12px; }
}
