@font-face {
  font-family: "Google Sans Code Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 300 800;
  src: url("https://cdn.jsdelivr.net/fontsource/fonts/google-sans-code:vf@latest/latin-wght-normal.woff2")
    format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
    U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
    U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Google Sans Flex Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 300 1000;
  src: url("https://cdn.jsdelivr.net/fontsource/fonts/google-sans-flex:vf@latest/latin-wght-normal.woff2")
    format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
    U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
    U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light;
  --bg: #f4f5f2;
  --ink: #171b22;
  --muted: #6a707a;
  --line: rgba(23, 27, 34, 0.1);
  --panel: rgba(255, 255, 255, 0.82);
  --shadow: 0 18px 42px rgba(23, 27, 34, 0.12);
  --danger: #ef4444;
  --success: #22c55e;
  --quest-bg: url("https://s3.us-east-1.amazonaws.com/0rbit.life/quests_background_+v2.svg");
  --knowledge-bg: url("https://s3.us-east-1.amazonaws.com/0rbit.life/knowledge_background.svg");
  --shop-bg: url("https://s3.us-east-1.amazonaws.com/0rbit.life/illustration-small-bar-with-full-moon-background-generative-ai.jpg");
  --customize-bg: url("https://s3.us-east-1.amazonaws.com/0rbit.life/high-fantasy-books.png");
}

* {
  box-sizing: border-box;
  font-family: "Google Sans Flex Variable", "IBM Plex Sans", "Inter",
    "Segoe UI", system-ui, -apple-system, sans-serif;
  font-variant-numeric: slashed-zero;
  font-feature-settings: "zero" 1;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 18% 0%, rgba(63, 109, 240, 0.18), transparent 26rem),
    linear-gradient(145deg, #f7f4ed 0%, #eef4f2 52%, #f5f6fb 100%);
  color: var(--ink);
}

body.signed-out,
body.recovering {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 1rem;
  padding: 1rem;
}

body.signed-out .login-brand,
body.recovering .login-brand {
  font-family: "Google Sans Code Variable", "Google Sans Flex Variable",
    "IBM Plex Sans", "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: clamp(2rem, 8vw, 3.5rem);
  font-weight: 800;
  line-height: 1;
  text-align: center;
}

body.authenticated .login-brand {
  display: none;
}

body.recovering .login-brand {
  display: block;
}

body:not(.authenticated) #appView {
  display: none !important;
}

body:not(.recovering) #resetPasswordView {
  display: none !important;
}

body.recovering #authView,
body.recovering #appView {
  display: none !important;
}

.card {
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.auth-card {
  width: min(100%, 420px);
  padding: 1.5rem;
}

.auth-card h2 {
  margin: 0 0 1rem;
}

.form-grid {
  display: grid;
  gap: 1rem;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-weight: 700;
}

.form-grid input {
  min-height: 2.75rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  padding: 0 0.85rem;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  font-size: 1rem;
}

.pill {
  min-height: 2.8rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  padding: 0 1.25rem;
  background: #171b22;
  color: #ffffff;
  font-weight: 800;
  cursor: pointer;
}

.helper {
  margin: 0;
  color: var(--muted);
}

.helper[data-state="error"] {
  color: var(--danger);
}

.helper[data-state="success"] {
  color: var(--success);
}

.child-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}

.child-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(1rem + env(safe-area-inset-top)) 1rem 0.75rem;
  position: sticky;
  top: 0;
  z-index: 2;
  backdrop-filter: blur(18px);
}

.child-brand {
  margin: 0;
  font-family: "Google Sans Code Variable", "Google Sans Flex Variable",
    "IBM Plex Sans", "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 1.1rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
}

.top-actions {
  position: relative;
  z-index: 3;
  isolation: isolate;
}

.top-actions::before {
  content: "";
  width: 18rem;
  height: 18rem;
  position: fixed;
  top: 0;
  right: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 26px 70px rgba(23, 27, 34, 0.18);
  backdrop-filter: blur(18px);
  transform: translate(50%, -50%) scale(0);
  transform-origin: center;
  transition: transform 360ms cubic-bezier(0.2, 0.9, 0.2, 1);
  z-index: -1;
}

.top-actions.is-open::before {
  transform: translate(50%, -50%) scale(1);
}

.menu-button {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.menu-button svg {
  width: 24px;
  height: 24px;
  display: block;
}

.menu-panel {
  width: 7.75rem;
  position: absolute;
  top: calc(100% + 0.1rem);
  right: 0;
  display: grid;
  gap: 0.05rem;
  padding: 0;
  border: 0;
  background: transparent;
  pointer-events: none;
}

.menu-panel.is-open {
  pointer-events: auto;
}

.menu-item {
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  border: 0;
  border-radius: 13px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 760;
  text-align: right;
  text-decoration: none;
  padding: 0 0.35rem;
  opacity: 0;
  transform: translateY(-0.35rem);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
  -webkit-tap-highlight-color: transparent;
}

.menu-item[hidden] {
  display: none;
}

.menu-panel.is-open .menu-item {
  opacity: 1;
  transform: translateY(0);
  transition-delay: 130ms;
}

.menu-item:active {
  background: rgba(23, 27, 34, 0.06);
}

.child-main {
  width: 100%;
  padding: 1rem 0 0;
}

.user-card {
  margin: 0 1rem 1rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
}

.user-name {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 850;
  line-height: 1.1;
}

.user-date {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
}

.point-row {
  margin-top: 1rem;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
}

.point-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  text-transform: uppercase;
}

.point-value {
  font-family: "Google Sans Code Variable", "Google Sans Flex Variable",
    "IBM Plex Sans", "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 2.35rem;
  font-weight: 800;
  line-height: 0.9;
}

.point-unit {
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 700;
}

.action-stack {
  display: grid;
  gap: 0.85rem;
  padding: 0 1rem 1rem;
}

.action-card {
  width: 100%;
  min-height: 148px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 1.3rem;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  text-align: left;
  padding: 1rem;
  box-shadow: var(--shadow);
  cursor: pointer;
  overflow: hidden;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  outline: none;
  user-select: none;
  touch-action: manipulation;
}

.action-card::before {
  content: "";
  width: 4.5rem;
  height: 4.5rem;
  position: absolute;
  right: -1.8rem;
  top: -1.8rem;
  border-radius: 999px;
  background: var(--card-accent);
  opacity: 0.18;
}

.action-card:active {
  transform: none;
  filter: none;
}

.action-card-title {
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.1;
}

.action-card-copy {
  display: grid;
  gap: 0.75rem;
  align-content: end;
  min-width: 0;
  position: relative;
  z-index: 1;
}

.action-card-icon {
  width: 58px;
  height: 58px;
  object-fit: contain;
  justify-self: start;
  position: relative;
  z-index: 1;
}

.action-card:nth-child(1) {
  --card-accent: #3f6df0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.62)),
    var(--quest-bg) center / cover no-repeat;
}

.action-card:nth-child(2) {
  --card-accent: #0f766e;
  background:
    linear-gradient(rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.68)),
    var(--knowledge-bg) center / cover no-repeat;
}

.action-card:nth-child(3) {
  --card-accent: #d89b16;
  background:
    linear-gradient(rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.66)),
    var(--shop-bg) center / cover no-repeat;
}

.action-card:nth-child(4) {
  --card-accent: #9d5bd2;
  background:
    linear-gradient(rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.66)),
    var(--customize-bg) center / cover no-repeat;
}

.portal-page {
  position: fixed;
  left: var(--portal-start-left, 0);
  top: var(--portal-start-top, 0);
  width: var(--portal-start-width, 100vw);
  height: var(--portal-start-height, 100vh);
  z-index: 10;
  border-radius: 22px;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.18)),
    var(--quest-bg) center / cover no-repeat;
  box-shadow: 0 24px 70px rgba(23, 27, 34, 0.24);
}

.knowledge-page {
  background:
    linear-gradient(rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.18)),
    var(--knowledge-bg) calc(50% - 200px) center / cover no-repeat;
}

.shop-page {
  background:
    linear-gradient(rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.18)),
    var(--shop-bg) center / cover no-repeat;
}

.customize-page {
  background:
    linear-gradient(rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.18)),
    var(--customize-bg) center / cover no-repeat;
}

.portal-page.is-open {
  pointer-events: auto;
  animation: portal-enter 560ms cubic-bezier(0.2, 0.9, 0.2, 1) forwards;
}

.portal-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(1rem + env(safe-area-inset-top)) 1rem 1rem;
  color: #ffffff;
}

.portal-page-title {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 900;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.28);
}

.portal-close {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
  font: inherit;
  font-size: 1.4rem;
  line-height: 1;
}

@keyframes portal-enter {
  from {
    left: var(--portal-start-left);
    top: var(--portal-start-top);
    width: var(--portal-start-width);
    height: var(--portal-start-height);
    border-radius: 22px;
    opacity: 1;
  }
  to {
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .portal-page.is-open {
    animation-duration: 1ms;
  }
}
