/* Portal chooser — calm liquid glass (no neon / cyber) */
body.portal-mode::after,
html.portal-host body::after {
    opacity: 0.45;
    animation-duration: 28s;
}

#portal-home.portal-home {
    width: min(92vw, 420px);
    max-width: 420px;
    gap: 14px;
    padding: 28px 22px 24px !important;
    display: none;
    flex-direction: column;
    align-items: stretch;
    text-align: center;
}

#portal-home.portal-home.active-view {
    display: flex !important;
}

.portal-brand {
    margin: 0;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--text-main);
    background: none !important;
    -webkit-text-fill-color: unset !important;
    animation: none !important;
    filter: none !important;
}

.portal-subtitle {
    margin: -4px 0 8px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 400;
    letter-spacing: 0.02em;
}

.portal-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 6px;
}

.portal-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    width: 100%;
    padding: 20px 22px;
    text-align: left;
    text-decoration: none;
    color: var(--text-main);
    cursor: pointer;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-top: 1px solid rgba(255, 255, 255, 0.38);
    backdrop-filter: blur(22px) saturate(160%);
    -webkit-backdrop-filter: blur(22px) saturate(160%);
    box-shadow:
        0 8px 24px rgba(0, 0, 0, 0.16),
        inset 0 1px 1px rgba(255, 255, 255, 0.22);
    transition: transform 0.25s ease, background 0.25s ease, border-color 0.25s ease;
}

.portal-card:hover {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.32);
    transform: translateY(-2px);
}

.portal-card:active {
    transform: scale(0.98);
}

.portal-card-title {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.portal-card-desc {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 400;
}

.portal-card-arrow {
    align-self: flex-end;
    margin-top: -4px;
    font-size: 18px;
    opacity: 0.55;
}

body:has(#portal-home.active-view) .system-controls {
    display: none !important;
}

/* Soften cyber-title shimmer on gme lobby when still using class name */
body:not(.portal-mode) .cyber-title {
    filter: drop-shadow(0px 1px 2px rgba(255, 255, 255, 0.06));
}

body.no-glass #portal-home.portal-home,
body.no-glass .portal-card {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: #1c1c1e !important;
}


/* Legacy-site one-click migrate */
.portal-migrate-btn {
    margin-top: 14px;
    width: 100%;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 14px;
    background: rgba(255, 204, 0, 0.12);
    color: #ffcc00;
    border: 1px solid rgba(255, 204, 0, 0.45);
    cursor: pointer;
}
.portal-migrate-btn:hover {
    background: rgba(255, 204, 0, 0.2);
}
.portal-migrate-btn--home {
    margin-top: 16px;
}
.portal-migrate-hint {
    margin: 6px 0 0;
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.4;
}
#login-gate .portal-migrate-btn {
    margin-top: 12px;
}


.portal-gmes-block {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.portal-gmes-fallback {
    align-self: stretch;
    margin: 0;
    padding: 8px 10px;
    font-size: 11px;
    line-height: 1.35;
    font-weight: 500;
    text-align: left;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.04);
    border: 1px dashed rgba(255, 255, 255, 0.22);
    border-radius: 12px;
    cursor: pointer;
}
.portal-gmes-fallback:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.35);
}


/* ——— Wusper 桌面模式 MVP ——— */
#wusper-desktop {
  position: fixed;
  inset: 0;
  z-index: 50000;
  display: flex;
  flex-direction: column;
  pointer-events: auto;
  /* 背景輪換仍由 #bg-root 提供，這裡只鋪一層極淡遮罩讓圖示可讀 */
  background: rgba(0, 0, 0, 0.18);
}
#wusper-desktop[hidden],
#wusper-desktop.wd-gone {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.wd-topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  margin: 10px 12px 0;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-top: 1px solid rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(32px) saturate(180%);
  box-shadow:
    0 10px 28px rgba(0, 0, 0, 0.16),
    inset 0 1px 1px rgba(255, 255, 255, 0.35);
}

.wd-topbar-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-main);
}

.wd-topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.wd-prefer {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  user-select: none;
  cursor: pointer;
}

.wd-btn {
  margin: 0;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 12px;
  cursor: pointer;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.28);
}
.wd-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}
.wd-btn-exit {
  color: #ffcc00;
  border-color: rgba(255, 204, 0, 0.45);
  background: rgba(255, 204, 0, 0.1);
}

.wd-icons {
  flex: 1 1 auto;
  overflow: auto;
  padding: 18px 16px 28px;
  -webkit-overflow-scrolling: touch;
}

.wd-section {
  margin-bottom: 22px;
}
.wd-section-title {
  margin: 0 0 10px 6px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.wd-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 14px 10px;
  max-width: 920px;
}

.wd-icon {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--text-main);
  border-radius: 16px;
  transition: transform 0.2s ease, background 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.wd-icon:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-2px);
}
.wd-icon:active {
  transform: scale(0.96);
}

.wd-icon-badge {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-top: 1px solid rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(18px) saturate(170%);
  -webkit-backdrop-filter: blur(20px) saturate(170%);
  box-shadow:
    0 8px 20px rgba(0, 0, 0, 0.18),
    inset 0 1px 1px rgba(255, 255, 255, 0.35),
    0 0 0 1px color-mix(in srgb, var(--wd-accent, #fff) 35%, transparent);
}
.wd-icon-emoji {
  font-size: 22px;
  line-height: 1;
  font-weight: 700;
}
.wd-icon-label {
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  max-width: 88px;
  line-height: 1.25;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}

.wd-windows {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}
.wd-window {
  pointer-events: auto;
  position: absolute;
  width: min(92vw, 720px);
  height: min(78vh, 560px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 18px !important;
  padding: 0 !important;
}
.wd-window-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  cursor: grab;
  background: rgba(255, 255, 255, 0.08);
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
  user-select: none;
  touch-action: none;
}
.wd-window-bar:active {
  cursor: grabbing;
}
.wd-window-title {
  font-size: 13px;
  font-weight: 650;
}
.wd-window-close {
  appearance: none;
  border: 0;
  background: rgba(255, 59, 48, 0.2);
  color: #ff8a80;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13px;
}
.wd-window-frame {
  flex: 1 1 auto;
  width: 100%;
  border: 0;
  background: rgba(0, 0, 0, 0.35);
}

.wd-ctx {
  position: fixed;
  z-index: 50010;
  min-width: 140px;
  padding: 6px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.3);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
}
.wd-ctx[hidden] {
  display: none !important;
}
.wd-ctx button {
  display: block;
  width: 100%;
  text-align: left;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-main);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.wd-ctx button:hover {
  background: rgba(255, 255, 255, 0.12);
}

.portal-desktop-entry {
  margin-top: 10px;
  width: 100%;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 12px;
  cursor: pointer;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.16);
}
.portal-desktop-entry:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.28);
}

body.wusper-desktop-on .system-controls,
body.wusper-desktop-on .circle-btn,
body.wusper-desktop-on #cyber-cookie-banner {
  display: none !important;
}
body.wusper-desktop-on #lobby-container,
body.wusper-desktop-on #portal-home {
  visibility: hidden !important;
  pointer-events: none !important;
}

body.no-glass .wd-topbar,
body.no-glass .wd-icon-badge,
body.no-glass .wd-window,
body.no-glass .wd-ctx {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  background: #1c1c1e !important;
}

@media (max-width: 520px) {
  .wd-grid {
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 12px 6px;
  }
  .wd-icon-badge {
    width: 50px;
    height: 50px;
    border-radius: 14px;
  }
  .wd-window {
    width: 96vw;
    height: 72vh;
    left: 2vw !important;
  }
}
