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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
}

@supports (height: 100dvh) {
  html,
  body {
    height: 100dvh;
  }
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
}

.stage {
  position: relative;
  width: min(100vw, calc(100vh * 1080 / 1920), calc(100dvh * 1080 / 1920));
  height: min(100vh, calc(100vw * 1920 / 1080), calc(100dvh * 1920 / 1080));
  aspect-ratio: 1080 / 1920;
  background: #000;
  flex-shrink: 0;
  touch-action: manipulation;
  -webkit-touch-callout: none;
  user-select: none;
}

#canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.touch-tap {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.touch-tap[hidden],
.touch-back[hidden] {
  display: none;
}

.touch-back {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  display: block;
  width: 100%;
  height: 26%;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.boot-loading {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  color: rgba(255, 255, 255, 0.6);
  font: 16px/1.4 system-ui, sans-serif;
  pointer-events: none;
}

.boot-loading[hidden] {
  display: none;
}

.boot-error {
  position: fixed;
  inset: auto 12px 12px 12px;
  z-index: 200;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(180, 40, 40, 0.95);
  color: #fff;
  font: 14px/1.4 system-ui, sans-serif;
}

/* ——— Admin ——— */
.admin-fab {
  display: none !important;
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 100;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  background: rgba(22, 22, 28, 0.9);
  color: #eee;
  font-size: 1.2rem;
  cursor: pointer;
}

.admin-panel {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 101;
  width: min(300px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  padding: 0;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(18, 18, 24, 0.95);
  color: #e4e4ea;
  font: 13px/1.4 system-ui, sans-serif;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}

.admin-panel[hidden] {
  display: none;
}

.admin-panel__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.admin-panel__head h2 {
  font-size: 0.95rem;
  font-weight: 600;
}

.admin-panel__close {
  border: none;
  background: none;
  color: #999;
  font-size: 1.4rem;
  cursor: pointer;
}

.admin-section {
  margin: 0.75rem 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
}

.admin-section:first-child {
  margin-top: 0;
}

.admin-panel__body {
  padding: 10px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 8px;
}

.admin-row span:first-child {
  color: #a8a8b4;
  font-size: 0.82rem;
}

.admin-row output {
  font-size: 0.78rem;
  color: #7eb8ff;
  font-variant-numeric: tabular-nums;
}

.admin-row input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  accent-color: #6eb0ff;
}

.admin-panel__foot {
  padding: 0 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-panel__foot button {
  width: 100%;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: transparent;
  color: #aaa;
  cursor: pointer;
  font-size: 0.82rem;
}

#admin-save-defaults {
  color: #c8e0ff;
  border-color: rgba(110, 176, 255, 0.35);
}

.admin-panel__foot button:hover {
  color: #fff;
}
