:root {
  --miku-main: #00d0ff;
  --furina-main: #6f8dff;
  --bg-dark: #050818;
  --card-bg: rgba(8, 16, 40, 0.9);
  --border-soft: rgba(255, 255, 255, 0.16);
  --text-main: #f5f7ff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text-main);
  background-color: var(--bg-dark);
  overflow-x: hidden;
  overscroll-behavior: contain;
}

/* 背景图 */
body.theme-furina {
  background-image: url("assets/bg-furina.jpg");
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
}

body.theme-miku {
  background-image: url("assets/bg-miku.jpg");
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
}

body.locked { overflow: hidden; }

/* 入口问答 */
.gate-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.gate-dialog {
  width: min(420px, 92vw);
  background: #070b1e;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.85);
  padding: 18px 18px 16px;
}

.gate-title {
  font-size: 1.05rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.gate-sub {
  font-size: 0.84rem;
  color: #c4d0ff;
  margin-bottom: 12px;
}

.gate-label {
  font-size: 0.82rem;
  margin-bottom: 6px;
}

.gate-input {
  width: 100%;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid rgba(180, 195, 255, 0.7);
  background: rgba(3, 8, 25, 0.95);
  color: #f5f7ff;
  font-size: 0.9rem;
  outline: none;
}

.gate-input:focus {
  border-color: #00d0ff;
  box-shadow: 0 0 0 1px rgba(0, 208, 255, 0.55);
}

.gate-actions {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
}

.gate-btn {
  border-radius: 999px;
  border: none;
  padding: 7px 16px;
  font-size: 0.9rem;
  cursor: pointer;
  background: linear-gradient(135deg, #00d0ff, #6f8dff);
  color: #020515;
  font-weight: 700;
}

.gate-error {
  margin-top: 8px;
  font-size: 0.8rem;
  color: #ff9393;
  min-height: 1em;
}

/* 背景光晕 */
.bg-orbit {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
}

.bg-orbit::before,
.bg-orbit::after {
  content: "";
  position: absolute;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 208, 255, 0.32), transparent 70%);
  filter: blur(1px);
}

.bg-orbit::before { top: -180px; left: -140px; }

.bg-orbit::after {
  bottom: -200px;
  right: -160px;
  background: radial-gradient(circle, rgba(167, 111, 255, 0.32), transparent 70%);
}

/* 顶部栏 */
header {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(16px);
  background: linear-gradient(
    to right,
    rgba(4, 10, 32, 0.9),
    rgba(4, 10, 32, 0.7)
  );
  border-bottom: 1px solid var(--border-soft);
}

/* 顶部小图标按钮基础样式 */
.top-icon-btn {
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  border: none;
  font-size: 13px;
  line-height: 1.4;
  cursor: pointer;
  background: rgba(10, 30, 60, 0.7);
  color: #e8f0ff;
  transition: background 0.15s ease, transform 0.1s ease;
}

.top-icon-btn:hover {
  transform: translateY(-1px);
}

/* 桌宠切换按钮：根据当前模式变色 */
.pet-toggle-btn.pet-style-na {
  background: rgba(120, 210, 150, 0.8); /* 浅绿色 */
  color: #022;
}

.pet-toggle-btn.pet-style-fu {
  background: rgba(120, 180, 255, 0.9); /* 浅蓝色 */
  color: #021833;
}

.top-bar {
  max-width: 1120px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.logo-icon {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: conic-gradient(from 120deg, #00d0ff, #6f8dff, #ffffff, #00d0ff);
  box-shadow: 0 0 16px rgba(255, 255, 255, 0.45);
}

.logo-text-main {
  font-size: 1.05rem;
  font-weight: 900;
  letter-spacing: 0.03em;
}

.logo-text-sub {
  font-size: 0.72rem;
  opacity: 0.8;
}

.top-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.clock,
.weather-pill {
  font-size: 0.8rem;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: rgba(4, 10, 32, 0.9);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  color: #dde5ff;
  cursor: pointer;
  user-select: none;
}

.clock-icon { font-size: 1rem; }

.lang-btn {
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  padding: 5px 10px;
  font-size: 0.8rem;
  background: rgba(4, 10, 32, 0.9);
  color: #dbe3ff;
  cursor: pointer;
}

.theme-toggle {
  display: flex;
  border-radius: 999px;
  padding: 3px;
  background: rgba(2, 8, 30, 0.9);
  border: 1px solid var(--border-soft);
}

.theme-btn {
  border: none;
  background: transparent;
  padding: 5px 10px;
  font-size: 0.78rem;
  border-radius: 999px;
  color: #d9e4ff;
  cursor: pointer;
  opacity: 0.7;
}

.theme-btn.active {
  background: linear-gradient(135deg, #00d0ff, #6f8dff);
  color: #05101f;
  opacity: 1;
  box-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
}

/* 主布局 */
.layout {
  max-width: 1120px;
  margin: 18px auto 40px;
  padding: 0 16px;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 18px;
}

@media (max-width: 880px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .top-bar {
    flex-direction: column;
    align-items: flex-start;
  }
  .top-right {
    width: 100%;
    justify-content: space-between;
  }
}

/* 侧栏 */
.side-nav {
  background: var(--card-bg);
  border-radius: 18px;
  padding: 14px 14px 16px;
  border: 1px solid var(--border-soft);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.6);
  position: relative;
}

.side-title {
  font-size: 0.86rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #a4b3ff;
  margin-bottom: 8px;
}

.nav-list {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
}

.nav-item { margin-bottom: 6px; }

.nav-btn {
  width: 100%;
  border: none;
  background: transparent;
  color: #dbe1ff;
  font-size: 0.9rem;
  padding: 8px 10px;
  border-radius: 12px;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.nav-link { text-decoration: none; }

.nav-btn .icon { font-size: 1.05rem; }

.nav-btn.active {
  background: rgba(0, 208, 255, 0.16);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.nav-btn:not(.active):hover {
  background: rgba(10, 26, 60, 0.85);
}

.side-mini {
  font-size: 0.8rem;
  color: #99a4d8;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed rgba(153, 164, 216, 0.5);
}

.counter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 5px;
}

.btn-small {
  border-radius: 999px;
  border: none;
  padding: 4px 10px;
  margin-top: 6px;
  font-size: 0.78rem;
  cursor: pointer;
  background: linear-gradient(135deg, #00d0ff, #6f8dff);
  color: #020515;
}

/* 水花特效 */
#wave-fx-container {
  position: absolute;
  right: 10px;
  bottom: 70px;
  pointer-events: none;
}

.wave-fx {
  position: absolute;
  left: 0;
  bottom: 0;
  transform-origin: center;
}

.wave-drop {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #7ad6ff;
  animation: waveDrop 0.75s ease-out forwards;
  box-shadow: 0 0 12px rgba(109, 214, 255, 0.6);
}

.wave-ripple {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(109, 214, 255, 0.8);
  border-radius: 50%;
  animation: waveRipple 0.6s ease-out forwards;
  opacity: 0.9;
  box-shadow: 0 0 16px rgba(109, 214, 255, 0.5);
}

@keyframes waveDrop {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--tx, 0), var(--ty, -50px)) scale(0.5); opacity: 0; }
}

@keyframes waveRipple {
  0% { transform: scale(0.4); opacity: 0.85; }
  100% { transform: scale(2.6); opacity: 0; }
}

/* 内容卡片 */
.content-area {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.card {
  background: var(--card-bg);
  border-radius: 18px;
  padding: 16px 14px 16px;
  border: 1px solid var(--border-soft);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.65);
}

.card-inner { position: relative; z-index: 1; }

.card-header-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px;
  margin-bottom: 4px;
}

.card-title {
  font-size: 1.15rem;
  font-weight: 800;
}

.pill {
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(4, 12, 48, 0.9);
  color: #9cb4ff;
}

.card-subtitle {
  font-size: 0.88rem;
  color: #cad4ff;
  margin-bottom: 10px;
}

.mini-grid {
  margin-top: 6px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}

.mini-card {
  border-radius: 14px;
  padding: 10px 10px 9px;
  border: 1px solid rgba(116, 170, 255, 0.4);
  background: rgba(5, 16, 48, 0.96);
  font-size: 0.8rem;
}

.mini-label {
  font-size: 0.74rem;
  color: #8ea6ff;
  margin-bottom: 3px;
}

.mini-value {
  font-size: 0.86rem;
}

/* 视频区 + 占位 */
.video-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}

.video-item .video-title {
  font-size: 0.86rem;
  margin-bottom: 4px;
}

.video-wrapper {
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.9);
}

.video-wrapper iframe {
  display: block;
  width: 100%;
    /* 高度跟随宽度，保持 16:9，比固定像素好 */
  height: auto;
  aspect-ratio: 16 / 9;
  background: #000814;
}

.video-placeholder {
  width: 100%;
  height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #d0ddff;
  font-size: 0.9rem;
  background: radial-gradient(circle at top, #152040, #050814);
  cursor: pointer;
}

.video-placeholder:hover {
  background: radial-gradient(circle at top, #203060, #050814);
}

/* 修复视频比例问题：删除强制高度 */
 /*
@media (max-width: 640px) {
  .video-wrapper iframe,
  .video-placeholder {
    height: 210px;
  }
}
*/

/* 不能删除，这段必须保留 */
.fantasy-entry { 
  margin-top: 12px; 
}

/* 画廊 */
.gallery-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

.gallery-item {
  border-radius: 12px;
  padding: 10px 11px;
  font-size: 0.86rem;
  background: rgba(10, 22, 60, 0.96);
  border: 1px solid rgba(120, 170, 255, 0.4);
}

/* 游戏区：上方游戏选单按钮 */
.game-tabs {
  margin-top: 14px;
  margin-bottom: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.game-tab-btn {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(120, 170, 255, 0.6);
  background: rgba(5, 15, 40, 0.8);
  color: #e3ebff;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.08s ease;
}

.game-tab-btn:hover {
  transform: translateY(-1px);
  background: rgba(25, 60, 110, 0.95);
}

.game-tab-btn.active {
  background: linear-gradient(135deg, #5fc3ff, #9b7bff);
  color: #020617;
  border-color: transparent;
}

.game-frame-area .video-wrapper {
  margin-top: 4px;
}


/* 文字角落 */
.words-block {
  margin-top: 8px;
  font-size: 0.9rem;
  line-height: 1.6;
  color: #dde4ff;
}

/* 幻想乡房间布局 */
.single-page-main {
  max-width: 1120px;
  margin: 18px auto 40px;
  padding: 0 16px;
}

.fantasy-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}

/* 游戏区：默认按 16:9 比例显示游戏 */
.game-frame {
  position: relative;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  background: transparent;
}

.game-frame iframe {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  display: block;
  background: #000; /* 没加载内容时是黑底，看起来比较像游戏 */
  min-height: 260px;
}

.game-frame .video-placeholder {
  width: 100%;
  min-height: 260px;
}

.game-frame.game-orientation-portrait iframe,
.game-frame.game-orientation-portrait .video-placeholder {
  aspect-ratio: 9 / 16;
  min-height: 420px;
}

@media (max-width: 768px) {
  .game-frame.game-orientation-portrait iframe,
  .game-frame.game-orientation-portrait .video-placeholder {
    min-height: 360px;
    max-height: 640px;
  }
}

/* 当游戏区域进入全屏时，让它铺满整个屏幕 */
.game-frame:fullscreen,
.game-frame:-webkit-full-screen {
  width: 100vw;
  height: 100dvh;
  min-height: 100vh;
  max-width: none;
  padding-top: 0;
  box-sizing: border-box;
}

/* 全屏状态下，让里面的 iframe 跟容器一起铺满 */
.game-frame:fullscreen iframe,
.game-frame:-webkit-full-screen iframe {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  min-height: 0;
}

.game-frame.game-frame-fallback {
  position: fixed;

  /* 先给个 0 兜底 */
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;

  /* 然后用安全区把内容往里缩，避免被 iPhone 顶部 / 底部遮挡 */
  top: env(safe-area-inset-top);
  left: env(safe-area-inset-left);
  right: env(safe-area-inset-right);
  bottom: env(safe-area-inset-bottom);

  width: auto;
  height: auto;
  min-height: 0;
  max-width: none;
  max-height: none;
  z-index: 1000;
  margin: 0;
  background: #000;
  padding-top: 0;
  box-sizing: border-box;
}


.game-frame.game-frame-fallback iframe,
.game-frame.game-frame-fallback .video-placeholder {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  min-height: 0;
}

/* 让全屏容器把里面的游戏画面居中显示 */
.game-frame:fullscreen,
.game-frame:-webkit-full-screen,
.game-frame.game-frame-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 竖屏游戏（比如合成大西瓜）在全屏时保持 9:16，比率不能乱 */
.game-frame.game-orientation-portrait:fullscreen iframe,
.game-frame.game-orientation-portrait:-webkit-full-screen iframe,
.game-frame.game-orientation-portrait.game-frame-fallback iframe {
  /* 宽度在「屏幕宽度」和「按 9:16 算出的最大宽度」之间取较小值 */
  width: min(100vw, calc(100vh * 9 / 16));
  height: auto;          /* 覆盖掉上面 fallback 里的 height:100%，防止被拉高裁切 */
  max-height: 100vh;
  aspect-ratio: 9 / 16;  /* 明确告诉浏览器保持 9:16 */
}



body.game-fullscreen-fallback {
  overflow: hidden;
}

.game-fullscreen-exit {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  right: calc(10px + env(safe-area-inset-right));
  z-index: 1100;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(10, 15, 25, 0.85);
  color: #fff;
  font-size: 0.9rem;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.game-fullscreen-exit.edge-left:not(.dragging) {
  left: 8px;
  right: auto;
  transform: translateX(-90%);
  opacity: 0.6;
}

.game-fullscreen-exit.edge-right:not(.dragging) {
  right: 8px;
  left: auto;
  transform: translateX(90%);
  opacity: 0.6;
}

.game-fullscreen-exit.dragging {
  transition: none;
  opacity: 1;
}

body.game-hide-header header {
  display: none;
}


.back-links { margin-top: 12px; }

/* section 切换 */
.section-panel { display: none; }
.section-panel.active { display: block; }

/* 底部 */
footer {
  text-align: center;
  padding: 10px 10px 20px;
  font-size: 0.76rem;
  color: #8d9ad3;
}

/* 桌宠：可拖动 + 轻微跟随鼠标 */
#umaru-helper {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 120px;
  height: 120px;
  z-index: 999;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: auto;   /* 允许接收鼠标事件 */
  cursor: grab;
  touch-action: none;
}

#umaru-helper.dragging {
  cursor: grabbing;
}

/* 折叠状态：只显示“呐呐”按钮 */
#umaru-helper.umaru-collapsed .umaru-body {
  display: none;
}

#umaru-helper.umaru-collapsed .umaru-restore {
  display: inline-flex;
}

#umaru-helper .umaru-body {
  position: relative;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background-image: url("assets/umaru.gif");
  background-size: cover;
  background-position: center;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
  transition: transform 0.06s linear;
}

/* “呐呐” 按钮，跟随桌宠一起移动 */
#umaru-helper .umaru-restore {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  padding: 6px 12px;
  font-size: 13px;
  min-width: 54px;
  border-radius: 999px;
  border: none;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  cursor: pointer;
  display: none;          /* 默认不显示，折叠时才显示 */
  pointer-events: auto;
}



#umaru-helper.umaru-hidden { display: none; }

/* 桌宠召回按钮：呐呐 */
#umaru-return-btn {
  position: fixed;
  right: 20px;
  bottom: 130px; /* 在桌宠上方一点 */
  z-index: 81;
  padding: 6px 14px;
  border-radius: 999px;
  border: none;
  background: rgba(15, 23, 42, 0.85);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

#umaru-return-btn.umaru-return-hidden {
  display: none;
}

#umaru-helper .umaru-body {
  position: relative;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background-image: url("assets/umaru.gif");
  background-size: cover;
  background-position: center;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
  transition: transform 0.06s linear;
}

#umaru-close-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: none;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  pointer-events: auto;
}

/* 右上角「呐呐」按钮 */
.pet-return-btn {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 1000;
  padding: 6px 14px;
  border-radius: 999px;
  border: none;
  font-size: 14px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  backdrop-filter: blur(10px);
  transition: background 0.2s, transform 0.2s;
}

.pet-return-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

/* 桌宠容器（如果你已经有，就不要重复定义，只是确认有类似 position / 右下角固定） */
.desk-pet {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 999;
}

.desk-pet-img {
  width: 120px;        /* 根据你的 gif 大小自己调 */
  height: auto;
  pointer-events: none; /* 避免误点 */
}

.desk-pet-close {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-size: 14px;
  line-height: 20px;
}
