:root {
  color-scheme: dark;
  --mint: #b8f5d6;
  --cyan: #8ce8ff;
  --sans: "Inter", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: "Baskervville", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --mono: "IBM Plex Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
  background: linear-gradient(180deg, #4884c6 0%, #7cb4e8 52%, #d6e7e3 100%);
  font-family: var(--sans);
  color: #f8fbfa;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

button:focus-visible, a:focus-visible {
  outline: 2px solid var(--mint);
  outline-offset: 4px;
  border-radius: 10px;
}

.symbols {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.plane-top { transform: translateY(var(--plane-top, 0px)); transition: transform .38s var(--ease-out); }
.plane-bot { transform: translateY(var(--plane-bot, 0px)); transition: transform .38s var(--ease-out); }

/* --- Live 3D Background Layer --- */
#app {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  z-index: 0;
  cursor: grab;
}
#app:active {
  cursor: grabbing;
}
#app canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Whisper-light top & center atmospheric contrast veil */
.sky-scrim {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(18, 48, 86, 0.22) 0%, rgba(22, 58, 98, 0.05) 24%, transparent 46%),
    radial-gradient(54% 36% at 50% 44%, rgba(16, 44, 72, 0.16) 0%, transparent 100%);
}

/* --- Minimal Top Bar --- */
.portal-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: max(18px, env(safe-area-inset-top)) clamp(20px, 4.5vw, 56px) 14px;
  pointer-events: none;
}

.portal-brand {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 6px 12px 6px 9px;
  border-radius: 999px;
  background: rgba(14, 30, 38, 0.28);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 6px 20px -8px rgba(12, 30, 48, 0.28);
  transition: background .25s ease, border-color .25s ease, transform .28s var(--ease-out);
}
.portal-brand:hover, .portal-brand:focus-visible {
  --plane-top: -1.8px;
  --plane-bot: 1.8px;
  background: rgba(14, 30, 38, 0.42);
  border-color: rgba(255, 255, 255, 0.38);
}
.portal-brand svg {
  width: 24px;
  height: 26px;
  color: var(--mint);
}
.portal-brand b {
  font-size: 1.04rem;
  font-weight: 650;
  letter-spacing: -.035em;
  color: #ffffff;
}

.portal-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}

.glass-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 36px;
  padding: 4px 11px;
  border-radius: 999px;
  background: rgba(14, 30, 38, 0.32);
  backdrop-filter: blur(14px) saturate(145%);
  -webkit-backdrop-filter: blur(14px) saturate(145%);
  border: 1px solid rgba(255, 255, 255, 0.24);
  box-shadow: 0 6px 20px -8px rgba(12, 30, 48, 0.28);
  color: rgba(246, 251, 250, 0.92);
  font-size: .82rem;
}

.reset-btn {
  gap: 6px;
  padding-inline: 12px;
  font-weight: 540;
  transition: background .22s ease, border-color .22s ease, transform .25s var(--ease-out);
  animation: pillPop .3s var(--ease-out) both;
}
.reset-btn svg {
  width: 14px;
  height: 14px;
  color: var(--mint);
}
.reset-btn:hover {
  background: rgba(16, 36, 42, 0.52);
  border-color: rgba(184, 245, 214, 0.5);
  transform: translateY(-1px);
}

.sound-btn {
  justify-content: center;
  gap: 7px;
  min-width: 38px;
  padding-inline: 11px;
  transition: background .22s ease, border-color .22s ease, transform .25s var(--ease-out);
}
.sound-btn:hover {
  background: rgba(16, 36, 42, 0.48);
  border-color: rgba(255, 255, 255, 0.4);
  transform: translateY(-1px);
}
.sound-btn.is-playing,
.sound-btn.is-armed {
  border-color: rgba(184, 245, 214, 0.52);
}
.sound-btn.is-armed .eq-bars i {
  background: var(--mint);
}
.sound-btn.is-armed::after {
  content: attr(data-unlock-hint);
  font-size: .76rem;
  font-weight: 560;
  color: var(--mint);
  white-space: nowrap;
  animation: armedPulse 2.2s ease-in-out infinite;
}
@keyframes armedPulse {
  0%, 100% { opacity: .72; }
  50% { opacity: 1; }
}

.eq-bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 2.5px;
  height: 13px;
}
.eq-bars i {
  display: block;
  width: 2px;
  border-radius: 2px;
  background: rgba(238, 248, 245, 0.82);
  transition: height .24s ease, background .24s ease, opacity .24s ease;
}
.eq-bars i:nth-child(1) { height: 5px; }
.eq-bars i:nth-child(2) { height: 11px; }
.eq-bars i:nth-child(3) { height: 7px; }
.eq-bars i:nth-child(4) { height: 9px; }

.sound-btn.is-playing .eq-bars i {
  background: var(--mint);
  animation: eqWave .92s ease-in-out infinite alternate;
}
.sound-btn.is-playing .eq-bars i:nth-child(1) { animation-duration: .86s; animation-delay: 0ms; }
.sound-btn.is-playing .eq-bars i:nth-child(2) { animation-duration: .68s; animation-delay: -220ms; }
.sound-btn.is-playing .eq-bars i:nth-child(3) { animation-duration: .98s; animation-delay: -410ms; }
.sound-btn.is-playing .eq-bars i:nth-child(4) { animation-duration: .76s; animation-delay: -130ms; }

.sound-btn.is-muted .eq-bars i {
  height: 2.5px;
  opacity: .45;
  animation: none;
}

@keyframes eqWave {
  0% { height: 3.5px; }
  100% { height: 13px; }
}

.lang-switch svg {
  width: 15px;
  height: 15px;
  margin-right: 3px;
  color: rgba(235, 247, 245, 0.8);
}
.lang-switch button {
  padding: 4px 6px;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 540;
  color: rgba(232, 244, 242, 0.76);
  transition: color .2s ease, background .2s ease;
}
.lang-switch button:hover {
  color: #ffffff;
}
.lang-switch button[aria-pressed="true"] {
  color: #0e241b;
  font-weight: 700;
  background: var(--mint);
}
.lang-switch span {
  color: rgba(255, 255, 255, 0.34);
  font-size: .74rem;
  user-select: none;
}

/* --- Central Stage --- */
.portal-stage {
  position: relative;
  z-index: 3;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 84px 20px 64px;
  text-align: center;
  pointer-events: none;
}

.hero-block {
  max-width: min(1280px, 94vw);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.portal-title {
  font-size: clamp(3.15rem, 6.8vw, 6.2rem);
  line-height: 1.06;
  letter-spacing: -.042em;
  color: #ffffff;
  text-shadow:
    0 2px 20px rgba(18, 48, 82, 0.38),
    0 12px 46px rgba(14, 38, 66, 0.28);
  text-wrap: balance;
}
.title-welcome {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  letter-spacing: -.02em;
  margin-right: .14em;
  color: #f9fcff;
}
.title-name {
  font-family: var(--sans);
  font-weight: 700;
  letter-spacing: -.048em;
  color: #ffffff;
}

/* --- Center Selectable Destination Tab Card Deck --- */
.tab-deck {
  margin-top: clamp(30px, 4.6vh, 48px);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px;
  width: 100%;
  max-width: 940px;
  pointer-events: none;
}

.tab-card {
  pointer-events: auto;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 15px;
  width: min(336px, calc(100vw - 40px));
  padding: 15px 18px 15px 16px;
  text-align: left;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(15, 31, 34, 0.56) 0%, rgba(13, 25, 27, 0.72) 100%);
  backdrop-filter: blur(22px) saturate(165%);
  -webkit-backdrop-filter: blur(22px) saturate(165%);
  border: 1px solid rgba(255, 255, 255, 0.32);
  box-shadow:
    0 22px 50px -14px rgba(9, 24, 34, 0.46),
    inset 0 1px 0 rgba(255, 255, 255, 0.36);
  transform: translate3d(0, 0, 0) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition:
    transform .36s var(--ease-out),
    border-color .28s ease,
    box-shadow .36s var(--ease-out),
    background .28s ease;
}

.tab-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(
    240px circle at var(--mx, 50%) var(--my, 20%),
    rgba(184, 245, 214, 0.18),
    transparent 70%
  );
  opacity: .75;
  transition: opacity .3s ease;
}

.tab-card:hover, .tab-card:focus-visible {
  --plane-top: -2px;
  --plane-bot: 2px;
  transform: translate3d(0, -4px, 0) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  border-color: rgba(184, 245, 214, 0.62);
  background: linear-gradient(135deg, rgba(16, 35, 37, 0.64) 0%, rgba(13, 27, 28, 0.78) 100%);
  box-shadow:
    0 28px 60px -14px rgba(8, 22, 32, 0.56),
    0 0 28px -8px rgba(184, 245, 214, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.48);
}
.tab-card:hover::before {
  opacity: 1;
}

.tab-icon {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: rgba(184, 245, 214, 0.13);
  border: 1px solid rgba(184, 245, 214, 0.34);
  color: var(--mint);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transition: background .28s ease, transform .34s var(--ease-out);
}
.tab-icon svg {
  width: 24px;
  height: 26px;
}
.tab-card:hover .tab-icon {
  background: rgba(184, 245, 214, 0.22);
  transform: scale(1.04);
}

.tab-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.tab-kicker {
  font-family: var(--mono);
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .11em;
  color: var(--mint);
}

.tab-title {
  font-size: 1.2rem;
  font-weight: 660;
  letter-spacing: -.03em;
  color: #ffffff;
  line-height: 1.2;
}

.tab-arrow {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.26);
  color: #f4fbf8;
  transition:
    background .24s ease,
    border-color .24s ease,
    color .24s ease,
    transform .32s var(--ease-out);
}
.tab-arrow svg {
  width: 17px;
  height: 17px;
}
.tab-card:hover .tab-arrow, .tab-card:focus-visible .tab-arrow {
  background: var(--mint);
  border-color: var(--mint);
  color: #0e251a;
  transform: translateX(3px) scale(1.06);
}

/* --- Coordinated Entrance & Exit Animations --- */
@keyframes pillPop {
  from { opacity: 0; transform: translateY(-4px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes barSlideDown {
  from { opacity: 0; transform: translate3d(0, -14px, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}
@keyframes portalFloatIn {
  from {
    opacity: 0;
    transform: translate3d(0, 24px, 0) scale(0.975);
    filter: blur(7px);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
    filter: blur(0);
  }
}

html.motion-ready .portal-bar {
  animation: barSlideDown .85s var(--ease-out) 280ms both;
}
html.motion-ready .anim-in {
  animation: portalFloatIn 1s var(--ease-out) var(--d, 480ms) both;
}

body.is-leaving {
  opacity: 0;
  transition: opacity .24s ease-out;
}
body.is-leaving .portal-stage {
  transform: scale(1.02) translateY(-6px);
  transition: transform .26s ease-out;
}

.lang-fade [data-i] {
  animation: pillPop .2s ease-out;
}

/* --- Mobile Adaptations --- */
@media (max-width: 640px) {
  .portal-bar {
    padding: max(14px, env(safe-area-inset-top)) 16px 10px;
  }
  .portal-brand b {
    font-size: .95rem;
  }
  .portal-stage {
    padding: 76px 16px 56px;
  }
  .title-welcome {
    display: block;
    margin-right: 0;
    font-size: .76em;
    margin-bottom: 2px;
  }
  .portal-title {
    font-size: clamp(2.85rem, 12.8vw, 4.1rem);
  }
  .tab-card {
    padding: 14px 16px;
    gap: 13px;
    border-radius: 16px;
  }
  .tab-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
  }
  .tab-title {
    font-size: 1.1rem;
  }
  .tab-arrow {
    width: 34px;
    height: 34px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
