:root {
  --bg: #101722;
  --panel: rgba(14, 24, 38, 0.92);
  --panel-2: rgba(22, 38, 58, 0.96);
  --ink: #f8fbff;
  --muted: #b9c7d7;
  --cyan: #22c8f4;
  --blue: #087bdc;
  --magenta: #e025d6;
  --yellow: #ffd313;
  --red: #f33145;
  --green: #22cfb4;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

body {
  touch-action: none;
}

.portalpi-shell {
  position: fixed;
  inset: 0;
  min-width: 100vw;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 12%, rgba(34, 200, 244, 0.28), transparent 28%),
    radial-gradient(circle at 82% 18%, rgba(224, 37, 214, 0.24), transparent 30%),
    linear-gradient(135deg, #101722 0%, #1e3347 52%, #111927 100%);
}

.portalpi-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.055) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, transparent 0%, black 18%, black 82%, transparent 100%);
  pointer-events: none;
}

#unity-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: transparent;
  outline: none;
  opacity: 0;
  transition: opacity 220ms ease;
}

body.unity-ready #unity-canvas {
  opacity: 1;
}

.loading-screen,
.login-error {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
  background:
    radial-gradient(circle at 50% 36%, rgba(255, 255, 255, 0.13), transparent 32%),
    rgba(9, 13, 20, 0.42);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.loading-screen.hidden {
  display: none;
}

.loader-card,
.error-card {
  position: relative;
  width: min(560px, 88vw);
  padding: 26px;
  border-radius: 26px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  box-shadow: 0 28px 72px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  border: 5px solid #111923;
}

.loader-card::before,
.error-card::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  pointer-events: none;
}

.brand-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 18px;
}

.app-icon {
  position: relative;
  width: 92px;
  height: 92px;
  flex: 0 0 auto;
  border-radius: 24px;
  background: linear-gradient(180deg, #37d5ff 0%, #0785dc 100%);
  border: 9px solid #101923;
  box-shadow: inset 0 8px 16px rgba(255, 255, 255, 0.23), 0 12px 26px rgba(0, 0, 0, 0.34);
}

.app-icon::before,
.app-icon::after {
  content: "";
  position: absolute;
  background: var(--magenta);
}

.app-icon::before {
  top: -9px;
  left: 30px;
  right: 30px;
  height: 9px;
}

.app-icon::after {
  bottom: -9px;
  left: 26px;
  right: 26px;
  height: 9px;
  background: var(--yellow);
}

.stud {
  position: absolute;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(3, 91, 151, 0.26);
}

.stud-a { left: 17px; top: 17px; }
.stud-b { right: 17px; top: 17px; }
.stud-c { left: 17px; bottom: 17px; }
.stud-d { right: 17px; bottom: 17px; }

.eyebrow {
  margin: 0 0 4px;
  color: #7eeaff;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1;
  font-weight: 950;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(34px, 7vw, 56px);
}

h2 {
  font-size: clamp(28px, 6vw, 46px);
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 26px 0 12px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 800;
}

.status-row strong {
  color: var(--ink);
}

.progress-track {
  width: 100%;
  height: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.32);
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--magenta), var(--yellow));
  box-shadow: 0 0 18px rgba(34, 200, 244, 0.5);
  transition: width 180ms ease;
}

.loading-detail,
.error-card p:not(.eyebrow) {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.45;
}

.chrome {
  position: fixed;
  left: 50%;
  width: min(720px, 92vw);
  height: 30px;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 8px;
  pointer-events: none;
}

.chrome-top {
  top: max(16px, env(safe-area-inset-top));
}

.chrome-bottom {
  bottom: max(16px, env(safe-area-inset-bottom));
}

.chrome span {
  border-radius: 8px;
  background: #101923;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.chrome span:nth-child(1) { box-shadow: inset 0 -8px 0 var(--red); }
.chrome span:nth-child(2) { box-shadow: inset 0 -8px 0 var(--cyan); }
.chrome span:nth-child(3) { box-shadow: inset 0 -8px 0 var(--yellow); }
.chrome span:nth-child(4) { box-shadow: inset 0 -8px 0 var(--green); }

.login-error[hidden] {
  display: none;
}

.login-error {
  z-index: 30;
}

.error-card {
  text-align: center;
}

.error-card button {
  appearance: none;
  margin-top: 22px;
  min-width: 180px;
  height: 52px;
  border: 0;
  border-radius: 16px;
  background: linear-gradient(180deg, #36d4ff, #087bdc);
  color: white;
  font-size: 16px;
  font-weight: 950;
  cursor: pointer;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.error-card button:active {
  transform: translateY(1px);
}

.unity-warning {
  position: fixed;
  z-index: 40;
  left: 12px;
  right: 12px;
  top: calc(12px + env(safe-area-inset-top));
  pointer-events: none;
  display: none;
}

.unity-warning > div {
  max-width: 720px;
  margin: 0 auto 8px;
  padding: 12px 14px;
  border-radius: 14px;
  color: white;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.22);
}

@media (max-width: 520px) {
  .loader-card,
  .error-card {
    padding: 22px;
    border-radius: 22px;
  }

  .app-icon {
    width: 78px;
    height: 78px;
    border-radius: 21px;
  }
}
