:root {
  color-scheme: dark;
  --bg: #0b0f14;
  --fg: #e6eef7;
  --muted: #8aa0b4;
  --accent: #4cc2ff;
  --accent-2: #2a90ff;
  --track: rgba(255, 255, 255, 0.08);
  --danger: #ff7a7a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100vh;
  /* dvh — dynamic viewport height: учитывает адрес-бар iOS/Android, */
  /* чтобы Unity не резало нижнюю полоску при его появлении. */
  height: 100dvh;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: block;
}

#unity-canvas {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
  outline: none;
  touch-action: none;
  image-rendering: auto;
}

#loader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: radial-gradient(1200px 700px at 50% 30%, #10202e 0%, #0b0f14 70%);
  transition: opacity 280ms ease;
}
#loader.done { opacity: 0; pointer-events: none; }

#loader-title {
  font-size: clamp(20px, 3vw, 32px);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--fg);
  text-align: center;
  padding: 0 24px;
}

#loader-bar {
  width: min(360px, 60vw);
  height: 6px;
  border-radius: 999px;
  background: var(--track);
  overflow: hidden;
}
#loader-fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 120ms linear;
}

#loader-hint {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

#error {
  position: absolute;
  inset: 0;
  margin: auto;
  max-width: 520px;
  height: fit-content;
  padding: 28px 28px 24px;
  text-align: center;
  background: rgba(20, 26, 34, 0.95);
  border: 1px solid rgba(255, 122, 122, 0.25);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  justify-content: center;
}
#error h2 { margin: 0; color: var(--danger); font-size: 18px; }
#error p { margin: 0; color: var(--muted); font-size: 14px; word-break: break-word; }

#error .error-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
#error .error-actions button {
  padding: 10px 18px;
  background: var(--accent);
  color: #001220;
  border: 0;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}
#error .error-actions button:hover { background: var(--accent-2); color: #fff; }
#error .error-actions button.secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
#error .error-actions button.secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #e8edf5;
}

#error-close {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 28px;
  height: 28px;
  padding: 0;
  background: transparent;
  color: var(--muted);
  border: 0;
  border-radius: 6px;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
#error-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
