:root {
  color-scheme: dark;
  --bg: #050a14;
  --panel: rgba(11, 23, 40, 0.94);
  --line: rgba(145, 188, 255, 0.18);
  --text: #f5f9ff;
  --muted: #8fa8c7;
  --cyan: #31e6ff;
  --purple: #9b72ff;
}

* { box-sizing: border-box; }

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

body {
  display: grid;
  grid-template-rows: auto 1fr;
  background:
    radial-gradient(circle at 15% -20%, rgba(49, 230, 255, 0.14), transparent 34rem),
    radial-gradient(circle at 90% -30%, rgba(155, 114, 255, 0.16), transparent 34rem),
    var(--bg);
}

.portal-header {
  min-height: 72px;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 1fr);
  align-items: center;
  gap: 24px;
  padding: 10px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(18px);
  z-index: 2;
}

.portal-brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  width: fit-content;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 43px;
  height: 43px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(49, 230, 255, 0.52);
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(49, 230, 255, 0.22), rgba(155, 114, 255, 0.28));
  color: var(--cyan);
  font-size: 23px;
  font-weight: 900;
  box-shadow: inset 0 0 18px rgba(49, 230, 255, 0.12), 0 0 22px rgba(49, 230, 255, 0.12);
}

.portal-brand strong,
.portal-brand small { display: block; }
.portal-brand strong { font-size: 16px; letter-spacing: 0.01em; }
.portal-brand small { margin-top: 2px; color: var(--muted); font-size: 11px; }

.portal-nav {
  justify-self: center;
  display: flex;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(49, 230, 255, 0.07), rgba(155, 114, 255, 0.1));
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.portal-tab {
  min-width: 160px;
  padding: 11px 22px;
  border: 1px solid rgba(49, 230, 255, 0.42);
  border-radius: 11px;
  background: linear-gradient(120deg, rgba(49, 230, 255, 0.18), rgba(126, 188, 255, 0.16));
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 850;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: 160ms ease;
}

.portal-tab:hover {
  color: #041019;
  border-color: var(--cyan);
  background: linear-gradient(120deg, var(--cyan), #7ebcff);
  box-shadow: 0 5px 22px rgba(49, 230, 255, 0.28);
  transform: translateY(-1px);
}
.portal-tab:focus-visible { outline: 3px solid #a6ff4d; outline-offset: 3px; }
.portal-header-balance { min-width: 220px; }

.portal-main { position: relative; min-height: 0; padding: 8px; }
.portal-frame {
  width: 100%;
  height: 100%;
  display: block;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #080f1c;
}

.loading-state {
  position: absolute;
  inset: 8px;
  display: grid;
  place-content: center;
  gap: 12px;
  justify-items: center;
  border-radius: 14px;
  background: #080f1c;
  color: var(--muted);
  font-size: 13px;
  z-index: 1;
  transition: opacity 180ms ease;
}

.loading-state.hidden { opacity: 0; pointer-events: none; }
.loading-dot {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(49, 230, 255, 0.18);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

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

@media (max-width: 760px) {
  .portal-header {
    min-height: 62px;
    grid-template-columns: auto 1fr;
    gap: 10px;
    padding: 8px 10px;
  }
  .portal-brand small,
  .portal-header-balance { display: none; }
  .portal-brand strong { font-size: 13px; }
  .brand-mark { width: 38px; height: 38px; border-radius: 12px; }
  .portal-nav { justify-self: end; padding: 4px; }
  .portal-tab { min-width: 112px; padding: 9px 14px; font-size: 12px; }
  .portal-main { padding: 4px; }
  .portal-frame,
  .loading-state { border-radius: 9px; }
  .loading-state { inset: 4px; }
}
