/* ── Home Hub — bright adventure lobby ── */

:root {
  --hub-bg: #e8f2fc;
  --hub-bg-2: #d4e8f8;
  --hub-surface: rgba(255, 255, 255, 0.72);
  --hub-surface-strong: rgba(255, 255, 255, 0.9);
  --hub-line: rgba(72, 120, 168, 0.18);
  --hub-ink: #1a2d42;
  --hub-muted: #5a7490;
  --hub-accent: #2db8e8;
  --hub-accent-2: #6ee7c8;
  --hub-gold: #e8a830;
  --hub-violet: #8b7cf6;
  --hub-shadow: 0 12px 40px rgba(42, 88, 140, 0.12);
  --hub-glow: 0 0 24px rgba(45, 184, 232, 0.28);
}

.hub-overlay {
  display: block;
  padding: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(142, 228, 255, 0.45), transparent 55%),
    radial-gradient(circle at 88% 72%, rgba(110, 231, 200, 0.22), transparent 40%),
    radial-gradient(circle at 12% 80%, rgba(232, 168, 48, 0.14), transparent 38%),
    linear-gradient(165deg, var(--hub-bg) 0%, var(--hub-bg-2) 52%, #c8dff5 100%);
  backdrop-filter: none;
}

.hub-overlay.hub-pause-mode,
.hub-overlay.hub-result-mode {
  background: rgba(232, 242, 252, 0.92);
  backdrop-filter: blur(14px);
}

.hub-shell {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  width: 100%;
  height: 100%;
  max-height: none;
  overflow: hidden;
  border: none;
  border-radius: 0;
  background: transparent;
  padding: 0;
  text-align: left;
  box-shadow: none;
}

.hub-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.hub-bg-glow {
  position: absolute;
  top: 18%;
  left: 50%;
  width: min(520px, 70vw);
  height: min(520px, 70vw);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(110, 231, 255, 0.35), transparent 68%);
  animation: hubGlowPulse 6s ease-in-out infinite;
}

.hub-bg-ring {
  position: absolute;
  top: 22%;
  left: 50%;
  width: min(380px, 55vw);
  height: min(380px, 55vw);
  transform: translate(-50%, -50%);
  border: 1px solid rgba(45, 184, 232, 0.22);
  border-radius: 50%;
  animation: hubRingSpin 24s linear infinite;
}

.hub-bg-particles {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(45, 184, 232, 0.12) 1px, transparent 1px),
    radial-gradient(circle at 70% 60%, rgba(110, 231, 200, 0.1) 1px, transparent 1px),
    radial-gradient(circle at 45% 85%, rgba(232, 168, 48, 0.08) 1px, transparent 1px);
  background-size: 120px 120px, 160px 160px, 200px 200px;
  opacity: 0.6;
}

@keyframes hubGlowPulse {
  0%, 100% { opacity: 0.7; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.06); }
}

@keyframes hubRingSpin {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ── Top bar ── */
.hub-topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--hub-line);
  background: var(--hub-surface-strong);
  backdrop-filter: blur(16px);
}

.hub-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.hub-avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 22px;
  background: linear-gradient(135deg, rgba(45, 184, 232, 0.25), rgba(110, 231, 200, 0.2));
  border: 1px solid rgba(45, 184, 232, 0.35);
  box-shadow: var(--hub-glow);
  flex-shrink: 0;
}

.hub-profile-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.hub-profile-meta strong {
  font-size: 14px;
  color: var(--hub-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hub-profile-meta span {
  font-size: 11px;
  color: var(--hub-muted);
  font-weight: 700;
}

.hub-resources {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
  justify-content: center;
}

.hub-res-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--hub-line);
  background: rgba(255, 255, 255, 0.65);
  color: var(--hub-ink);
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.hub-res-chip b {
  color: var(--hub-accent);
}

.hub-top-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.hub-icon-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid var(--hub-line);
  background: rgba(255, 255, 255, 0.7);
  color: var(--hub-ink);
  font-size: 16px;
  line-height: 1;
  position: relative;
}

.hub-icon-btn.has-badge::after {
  content: "";
  position: absolute;
  top: 5px;
  right: 5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ff6b5a;
  box-shadow: 0 0 6px rgba(255, 107, 90, 0.6);
}

/* ── Body layout ── */
.hub-body {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: auto 1fr;
  min-height: 0;
  overflow: hidden;
}

.hub-side-dock {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 8px;
  border-right: 1px solid var(--hub-line);
  background: rgba(255, 255, 255, 0.35);
}

.hub-dock-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 12px;
  border: 1px solid var(--hub-line);
  background: rgba(255, 255, 255, 0.72);
  color: var(--hub-ink);
  font-size: 18px;
  position: relative;
}

.hub-dock-btn span.dock-label {
  display: none;
}

.hub-dock-btn.has-badge::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ff6b5a;
}

.hub-main {
  min-height: 0;
  overflow: auto;
  padding: 12px 14px 8px;
  -webkit-overflow-scrolling: touch;
}

/* ── Views ── */
.hub-view {
  display: none;
  animation: hubFadeIn 0.28s ease;
}

.hub-view.is-active {
  display: block;
}

@keyframes hubFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.hub-view-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.hub-view-head h2 {
  margin: 0;
  font-family: Orbitron, "Noto Sans SC", sans-serif;
  font-size: 18px;
  color: var(--hub-ink);
  letter-spacing: 0.04em;
}

.hub-view-head p {
  margin: 0;
  font-size: 12px;
  color: var(--hub-muted);
}

/* ── Home center ── */
.hub-home-center {
  display: grid;
  grid-template-columns: 1fr minmax(200px, 280px);
  gap: 16px;
  align-items: center;
  max-width: 920px;
  margin: 0 auto;
}

.hub-hero-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 16px 12px;
}

.hub-hero-portrait {
  width: min(200px, 42vw);
  height: min(200px, 42vw);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: clamp(64px, 12vw, 96px);
  background:
    radial-gradient(circle at 50% 35%, rgba(255, 255, 255, 0.9), rgba(200, 230, 255, 0.4)),
    linear-gradient(160deg, rgba(45, 184, 232, 0.2), rgba(110, 231, 200, 0.15));
  border: 2px solid rgba(45, 184, 232, 0.35);
  box-shadow: var(--hub-shadow), var(--hub-glow);
  animation: hubHeroFloat 4s ease-in-out infinite;
}

@keyframes hubHeroFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.hub-hero-name {
  margin: 14px 0 4px;
  font-family: Orbitron, "Noto Sans SC", sans-serif;
  font-size: clamp(20px, 3.5vw, 26px);
  color: var(--hub-ink);
  text-align: center;
}

.hub-hero-flavor {
  margin: 0;
  max-width: 32ch;
  text-align: center;
  font-size: 13px;
  color: var(--hub-muted);
  line-height: 1.5;
}

.hub-play-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hub-recommend-card {
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--hub-line);
  background: var(--hub-surface-strong);
  box-shadow: var(--hub-shadow);
}

.hub-recommend-card .eyebrow {
  color: var(--hub-accent);
  font-size: 11px;
  margin-bottom: 4px;
}

.hub-recommend-card strong {
  display: block;
  font-size: 16px;
  color: var(--hub-ink);
  margin-bottom: 4px;
}

.hub-recommend-card span {
  font-size: 12px;
  color: var(--hub-muted);
  line-height: 1.45;
}

.hub-cta-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hub-start-btn {
  width: 100%;
  min-height: 54px;
  padding: 14px 24px;
  border: none;
  border-radius: 16px;
  background: linear-gradient(135deg, #2db8e8 0%, #6ee7c8 55%, #5ed4ff 100%);
  color: #0a2840;
  font-family: Orbitron, "Noto Sans SC", sans-serif;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.06em;
  box-shadow: 0 12px 32px rgba(45, 184, 232, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.45);
  animation: hubStartPulse 3s ease-in-out infinite;
}

@keyframes hubStartPulse {
  0%, 100% { box-shadow: 0 12px 32px rgba(45, 184, 232, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.45); }
  50% { box-shadow: 0 16px 40px rgba(45, 184, 232, 0.5), 0 0 20px rgba(110, 231, 200, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.5); }
}

.hub-start-btn:hover {
  transform: translateY(-2px) scale(1.01);
  background: linear-gradient(135deg, #3cc8f8 0%, #7ef7d8 55%, #6ee4ff 100%);
}

.hub-secondary-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.hub-secondary-btn {
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--hub-line);
  background: rgba(255, 255, 255, 0.82);
  color: var(--hub-ink);
  font-size: 13px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.hub-secondary-btn.is-mp {
  border-color: rgba(45, 184, 232, 0.4);
  background: linear-gradient(135deg, rgba(45, 184, 232, 0.12), rgba(110, 231, 200, 0.1));
}

.hub-quick-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 14px;
  max-width: 920px;
  margin-left: auto;
  margin-right: auto;
}

.hub-quick-card {
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--hub-line);
  background: var(--hub-surface);
  text-align: left;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.hub-quick-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--hub-shadow);
}

.hub-quick-card .icon {
  font-size: 20px;
  margin-bottom: 6px;
}

.hub-quick-card strong {
  display: block;
  font-size: 13px;
  color: var(--hub-ink);
  margin-bottom: 2px;
}

.hub-quick-card span {
  font-size: 11px;
  color: var(--hub-muted);
}

/* ── Bottom nav ── */
.hub-bottom-nav {
  position: relative;
  z-index: 2;
  display: flex;
  gap: 4px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--hub-line);
  background: var(--hub-surface-strong);
  backdrop-filter: blur(16px);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.hub-nav-btn {
  flex: 1;
  min-width: 56px;
  max-width: 88px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 4px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--hub-muted);
  font-size: 10px;
  font-weight: 800;
}

.hub-nav-btn .nav-icon {
  font-size: 20px;
  line-height: 1;
}

.hub-nav-btn.is-active {
  color: var(--hub-accent);
  background: rgba(45, 184, 232, 0.12);
  box-shadow: inset 0 0 0 1px rgba(45, 184, 232, 0.25);
}

/* ── Sub-tabs (profile/codex) ── */
.hub-subtabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.hub-subtabs .menu-tab {
  flex: 1;
  min-width: 72px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--hub-line);
  background: rgba(255, 255, 255, 0.6);
  color: var(--hub-muted);
  font-size: 12px;
}

.hub-subtabs .menu-tab.is-active {
  color: var(--hub-accent);
  border-color: rgba(45, 184, 232, 0.45);
  background: rgba(45, 184, 232, 0.12);
}

/* ── Hub panels inherit bright cards ── */
.hub-main .save-card,
.hub-main .help-card,
.hub-main .settings-card,
.hub-main .season-card,
.hub-main .leaderboard-card,
.hub-main .achievement-card,
.hub-main .activity-card,
.hub-main .arsenal-card {
  border-color: var(--hub-line);
  background: var(--hub-surface-strong);
  color: var(--hub-muted);
}

.hub-main .save-card strong,
.hub-main .help-card strong,
.hub-main .settings-card strong,
.hub-main .season-card strong,
.hub-main .leaderboard-card strong,
.hub-main .achievement-card strong,
.hub-main .activity-card strong {
  color: var(--hub-ink);
}

.hub-main .section-label {
  color: var(--hub-muted);
  font-size: 12px;
  font-weight: 800;
  margin: 12px 0 8px;
  text-align: left;
}

.hub-main .hero-choices,
.hub-main .mode-choices,
.hub-main .pet-choices,
.hub-main .device-choices {
  margin-bottom: 12px;
}

.hub-main .hero-choice,
.hub-main .mode-choice,
.hub-main .pet-choice,
.hub-main .device-choice {
  border-color: var(--hub-line);
  background: rgba(255, 255, 255, 0.75);
  color: var(--hub-ink);
}

.hub-main .hero-choice strong,
.hub-main .mode-choice strong,
.hub-main .pet-choice strong {
  color: var(--hub-ink);
}

.hub-main .hero-choice span,
.hub-main .mode-choice span,
.hub-main .pet-choice span {
  color: var(--hub-muted);
}

/* ── Drawers (settings / help / account) ── */
.hub-drawer-backdrop {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: rgba(26, 45, 66, 0.25);
  backdrop-filter: blur(4px);
}

.hub-drawer-backdrop.is-hidden {
  display: none;
}

.hub-drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 21;
  width: min(360px, 92vw);
  padding: 16px;
  overflow: auto;
  background: var(--hub-surface-strong);
  border-left: 1px solid var(--hub-line);
  box-shadow: -12px 0 40px rgba(42, 88, 140, 0.15);
  transform: translateX(100%);
  transition: transform 0.28s ease;
}

.hub-drawer.is-open {
  transform: translateX(0);
}

.hub-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.hub-drawer-head strong {
  font-size: 16px;
  color: var(--hub-ink);
}

.hub-drawer-close {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 8px;
  font-size: 18px;
}

/* ── Result / pause overlays ── */
.hub-result-banner {
  text-align: center;
  padding: 16px;
  margin-bottom: 12px;
  border-radius: 16px;
  border: 1px solid var(--hub-line);
  background: var(--hub-surface-strong);
}

.hub-result-banner h1 {
  font-size: clamp(28px, 5vw, 40px);
  margin: 0 0 8px;
  background: linear-gradient(135deg, #2db8e8, #6ee7c8, #e8a830);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hub-result-banner #modalCopy {
  margin: 0 auto;
  color: var(--hub-muted);
}

.hub-overlay.hub-pause-mode .hub-side-dock,
.hub-overlay.hub-pause-mode .hub-bottom-nav,
.hub-overlay.hub-pause-mode .hub-quick-cards,
.hub-overlay.hub-pause-mode .hub-home-center,
.hub-overlay.hub-pause-mode .hub-view:not(#hubViewPause) {
  display: none !important;
}

.hub-overlay.hub-pause-mode #hubViewPause {
  display: block !important;
}

.hub-overlay.hub-result-mode .hub-side-dock,
.hub-overlay.hub-result-mode .hub-bottom-nav {
  display: none;
}

.hub-overlay.hub-result-mode .hub-home-center {
  display: none;
}

.hub-overlay.hub-result-mode #hubViewHome {
  display: block !important;
}

.hub-pause-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 320px;
  margin: 24px auto;
}

/* Hidden legacy triggers */
.hub-hidden-triggers {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

/* Hide old topbar when hub visible */
.game-stage:has(#overlay.hub-overlay:not(.is-hidden)) > .topbar {
  opacity: 0;
  pointer-events: none;
}

.game-stage:has(#overlay.hub-overlay:not(.is-hidden)) > .topbar .buttons {
  pointer-events: none;
}

/* Mobile */
@media (max-width: 760px) {
  .hub-home-center {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .hub-hero-stage {
    padding-top: 8px;
  }

  .hub-hero-portrait {
    width: min(140px, 36vw);
    height: min(140px, 36vw);
    font-size: 56px;
  }

  .hub-quick-cards {
    grid-template-columns: 1fr 1fr;
  }

  .hub-resources {
    display: none;
  }

  .hub-topbar {
    padding: 8px 10px;
  }

  .hub-side-dock {
    flex-direction: row;
    flex-wrap: wrap;
    border-right: none;
    border-bottom: 1px solid var(--hub-line);
    padding: 6px 8px;
    justify-content: center;
  }

  .hub-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .hub-dock-btn {
    width: 40px;
    height: 40px;
    font-size: 16px;
  }

  .hub-nav-btn {
    min-width: 48px;
    font-size: 9px;
  }

  .hub-nav-btn .nav-icon {
    font-size: 18px;
  }
}

.device-effective-mobile .hub-home-center {
  grid-template-columns: 1fr;
}

.device-effective-mobile .hub-quick-cards {
  grid-template-columns: 1fr 1fr;
}

.hub-shell button {
  color: var(--hub-ink);
  border-color: var(--hub-line);
}

.hub-shell button:hover,
.hub-shell button:focus-visible {
  background: rgba(45, 184, 232, 0.12);
  border-color: rgba(45, 184, 232, 0.35);
}

.hub-overlay .account-form {
  grid-template-columns: 1fr;
}

.hub-overlay .account-form button {
  width: 100%;
}

.hub-overlay #hubResultBanner.is-hidden {
  display: none !important;
}

.hub-tutorial-tip {
  max-width: 920px;
  margin: 12px auto 0;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(45, 184, 232, 0.35);
  background: rgba(255, 255, 255, 0.88);
  color: var(--hub-muted);
  font-size: 13px;
  line-height: 1.5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.hub-tutorial-tip p {
  margin: 0;
  flex: 1;
  min-width: 200px;
}

.hub-tutorial-tip b {
  color: var(--hub-ink);
}

.hub-tutorial-tip button {
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--hub-line);
  background: rgba(45, 184, 232, 0.12);
  color: var(--hub-ink);
  font-weight: 800;
  cursor: pointer;
}

.hub-overlay.hub-result-mode .hub-quick-cards {
  margin-top: 0;
}
