:root {
  --primary-font: 'Zen Maru Gothic', 'Noto Sans TC', -apple-system, BlinkMacSystemFont, sans-serif;
  --eevee-gold: #c89454;
  --flareon-flame: #ff6b35;
  --flareon-glow: #ffd166;
  --flareon-red: #d90429;
  --umbreon-dark: #2b3a4a;
  --sylveon-pink: #ff85a2;
  --bg-grass: #52b788;
  --bg-sky: #90e0ef;
  --text-dark: #1f2421;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  position: fixed;
  inset: 0;
  font-family: var(--primary-font);
  background: #14171a;
  color: var(--text-dark);
}

/* ============================================================
   1. 電影級橫掃過場布幕 (100% 命運之路原廠標準 wipe-mask)
   ============================================================ */
.wipe-mask {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 9999;
}

.wipe-mask.show {
  opacity: 1;
  pointer-events: auto;
}

.wipe-mask:before {
  content: "";
  display: block;
  position: absolute;
  left: 0;
  top: 0;
  width: 300%;
  height: 100%;
  background-image: linear-gradient(
    to right,
    transparent 0%,
    rgba(255, 222, 179, 0.9) 18%,
    rgb(255, 183, 3) 35%,
    rgb(244, 140, 6) 50%,
    rgb(255, 183, 3) 65%,
    rgba(255, 222, 179, 0.9) 82%,
    transparent 100%
  );
  transform: translate(-100%);
}

.wipe-mask.show:before {
  animation: wipe-out-anim 2.8s linear 1;
}

@keyframes wipe-out-anim {
  0% { transform: translate(-100%); }
  100% { transform: translate(100%); }
}

/* 直向旋轉提示遮罩 */
.orientation-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: #1e1e24;
  color: #ffffff;
  z-index: 9999;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 24px;
}

@media screen and (orientation: portrait), (max-aspect-ratio: 1/1) {
  .orientation-overlay {
    display: flex;
  }
}

.orientation-card {
  background: #2b2d42;
  border: 3px solid #ffbe86;
  border-radius: 24px;
  padding: 30px;
  max-width: 380px;
}

.rotate-phone-icon {
  font-size: 4rem;
  margin-bottom: 16px;
  display: inline-block;
  animation: rotatePrompt 1.8s infinite ease-in-out;
}

@keyframes rotatePrompt {
  0% { transform: rotate(0deg); }
  50% { transform: rotate(-90deg); }
  100% { transform: rotate(0deg); }
}

.orientation-card h2 {
  font-size: 1.4rem;
  color: #ffd166;
  margin-bottom: 10px;
}

.orientation-card p {
  font-size: 1rem;
  line-height: 1.6;
  color: #e0e1dd;
}

/* ============================================================
   2. 16:9 全螢幕遊戲視窗 (滿版背景 + 懸浮 HUD)
   ============================================================ */
#game-viewport {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* 頂部懸浮 HUD */
.hud-floating-top {
  position: absolute;
  top: 12px;
  left: 18px;
  right: 18px;
  height: 46px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 25;
  pointer-events: none;
}

.hud-left, .hud-center, .hud-right {
  pointer-events: auto;
}

.hud-left {
  display: flex;
  gap: 8px;
  align-items: center;
}

.unit-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 900;
  font-size: 0.9rem;
  color: #8c4200;
  background: rgba(255, 235, 214, 0.94);
  backdrop-filter: blur(8px);
  padding: 4px 14px;
  border-radius: 20px;
  border: 2px solid #ffbe86;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.scene-pill {
  font-weight: 800;
  font-size: 0.85rem;
  color: #1b4332;
  background: rgba(216, 243, 220, 0.94);
  backdrop-filter: blur(8px);
  padding: 4px 12px;
  border-radius: 20px;
  border: 2px solid #95d5b2;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.flame-meter-card {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  padding: 4px 14px;
  border-radius: 20px;
  border: 2px solid #ffbe86;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.flame-label {
  font-size: 0.85rem;
  font-weight: 900;
  color: #b84a00;
}

.flame-icons {
  display: flex;
  gap: 2px;
}

.f-dot {
  font-size: 1rem;
  filter: grayscale(100%) opacity(0.25);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.f-dot.active {
  filter: grayscale(0%) opacity(1);
  transform: scale(1.25);
  animation: flameBounce 0.9s infinite alternate;
}

@keyframes flameBounce {
  0% { transform: scale(1.1) rotate(-4deg); }
  100% { transform: scale(1.35) rotate(5deg); }
}

.f-status {
  font-size: 0.85rem;
  font-weight: 900;
  color: #d90429;
}

.hud-right {
  display: flex;
  gap: 8px;
}

.hud-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  border: 2px solid #ffbe86;
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 0.85rem;
  font-weight: 900;
  color: #9c4700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  transition: all 0.2s ease;
}

.hud-btn:hover {
  background: #fff3e6;
  transform: translateY(-2px);
}

.hud-btn.active {
  background: #ffbe86;
  color: #5c2c00;
}

.hud-btn.secondary {
  border-color: #ced4da;
  color: #6c757d;
}

/* ============================================================
   3. 100% 滿版全景背景層與角色立繪舞台
   ============================================================ */
.viewport-bg {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: #2b2d42;
}

/* 心智透視鏡星空氛圍遮罩 */
.mind-lens-dimmer {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: radial-gradient(circle at 50% 30%, rgba(67, 97, 238, 0.2) 0%, rgba(11, 9, 26, 0.6) 80%);
  animation: fadeIn 0.4s ease;
}

.mind-lens-title-badge {
  position: absolute;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #4361ee 0%, #7209b7 100%);
  color: #ffffff;
  font-weight: 900;
  font-size: 1.05rem;
  padding: 8px 24px;
  border-radius: 30px;
  border: 2px solid #ffd166;
  box-shadow: 0 0 25px rgba(67, 97, 238, 0.8);
  animation: pulseGlow 1.5s infinite alternate;
}

@keyframes pulseGlow {
  0% { transform: translateX(-50%) scale(0.97); }
  100% { transform: translateX(-50%) scale(1.03); }
}

/* 角色立繪舞台 */
.stage-actors-layer {
  position: absolute;
  inset: 0;
  bottom: 120px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 100px 20px 100px;
  z-index: 2;
  pointer-events: none;
}

.actor-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.sprite-box {
  width: clamp(160px, 25vh, 240px);
  height: clamp(160px, 25vh, 240px);
  display: flex;
  justify-content: center;
  align-items: center;
  filter: drop-shadow(0 12px 24px rgba(0,0,0,0.3));
}

.breathing-anim {
  animation: breathingFloat 2.6s infinite ease-in-out;
}

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

.screen-shake {
  animation: shakeAnim 0.35s ease-in-out;
}

@keyframes shakeAnim {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-8px, 6px); }
  40% { transform: translate(8px, -6px); }
  60% { transform: translate(-6px, -3px); }
  80% { transform: translate(6px, 3px); }
}

.flame-halo {
  position: absolute;
  top: 15px;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,107,53,0.55) 0%, rgba(255,209,102,0.25) 50%, transparent 70%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.flame-halo.active-high {
  opacity: 1;
  animation: fireGlow 1s infinite alternate;
}

@keyframes fireGlow {
  0% { transform: scale(0.95); }
  100% { transform: scale(1.3); }
}

.actor-nametag {
  background: rgba(255, 255, 255, 0.96);
  border: 2px solid #e0be9c;
  border-radius: 14px;
  padding: 3px 14px;
  font-size: 0.88rem;
  font-weight: 900;
  color: #3d405b;
  box-shadow: 0 4px 10px rgba(0,0,0,0.12);
  margin-top: -6px;
}

/* ============================================================
   4. 經典懸浮式視覺小說對話框 (Floating Dialogue Box)
   ============================================================ */
.floating-dialogue-box {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 48px);
  max-width: 980px;
  min-height: 135px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  border: 3.5px solid #ffbe86;
  border-radius: 22px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.22);
  padding: 14px 22px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  transition: border-color 0.3s ease;
}

.floating-dialogue-box:hover {
  border-color: #ff9f43;
}

.dialogue-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.speaker-tag {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #ffebd2;
  border: 2px solid #ffbe86;
  border-radius: 16px;
  padding: 3px 14px;
  font-weight: 900;
  font-size: 1rem;
  color: #9c4700;
}

.btn-read-dialogue {
  background: #eef8ff;
  border: 1.5px solid #90e0ef;
  border-radius: 14px;
  padding: 3px 12px;
  font-size: 0.85rem;
  font-weight: 800;
  color: #0077b6;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-read-dialogue:hover {
  background: #caf0f8;
  transform: scale(1.04);
}

.dialogue-body {
  flex-grow: 1;
}

.situation-pill {
  background: #fff3cd;
  color: #856404;
  font-size: 0.85rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 6px;
  margin-bottom: 4px;
  display: inline-block;
  border-left: 3px solid #ffc107;
}

.dialogue-text-stream {
  font-size: 1.22rem;
  line-height: 1.55;
  font-weight: 700;
  color: #1e2229;
  white-space: pre-line;
}

.dialogue-advance-arrow {
  position: absolute;
  bottom: 12px;
  right: 18px;
  color: #ff8c42;
  font-size: 1.1rem;
  font-weight: 900;
  animation: bounceArrow 1s infinite alternate ease-in-out;
}

@keyframes bounceArrow {
  0% { transform: translateY(0); opacity: 0.5; }
  100% { transform: translateY(6px); opacity: 1; }
}

.coaching-float-banner {
  background: #eef8ff;
  border: 2px dashed #48cae4;
  border-radius: 10px;
  padding: 6px 12px;
  margin-top: 6px;
  font-size: 0.9rem;
  color: #023e8a;
  line-height: 1.4;
}

.coach-head {
  font-weight: 900;
  color: #0077b6;
  margin-bottom: 2px;
}

/* ============================================================
   5. 抉擇時刻：中央浮現選項面板 (Choice Mode)
   ============================================================ */
.floating-choices-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 40;
  background: rgba(15, 20, 28, 0.45);
  backdrop-filter: blur(3px);
  animation: fadeIn 0.25s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.choices-dialog-card {
  background: #ffffff;
  border: 4px solid #ffd166;
  border-radius: 24px;
  padding: 20px 24px;
  width: 90%;
  max-width: 680px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.35);
  animation: slideUpChoice 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes slideUpChoice {
  0% { transform: translateY(30px) scale(0.9); opacity: 0; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

.choices-prompt-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1rem;
  font-weight: 900;
  color: #5c677d;
  margin-bottom: 12px;
}

.btn-read-choices {
  background: #f0f7ff;
  border: 1.5px solid #bde0fe;
  border-radius: 14px;
  padding: 3px 12px;
  font-size: 0.82rem;
  font-weight: 800;
  color: #0288d1;
  cursor: pointer;
}

.choices-buttons-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.opt-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #ffffff;
  border: 2.5px solid #dee2e6;
  border-radius: 16px;
  padding: 10px 14px;
  font-size: 1.05rem;
  font-weight: 800;
  color: #2b2d42;
  cursor: pointer;
  text-align: left;
  line-height: 1.4;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 4px 10px rgba(0,0,0,0.04);
}

.opt-btn:hover, .opt-btn:focus {
  transform: translateX(6px) scale(1.01);
  box-shadow: 0 8px 18px rgba(0,0,0,0.1);
}

.opt-btn.opt-danger {
  border-color: #ffb4a2;
  background: #fffafa;
}
.opt-btn.opt-danger:hover {
  border-color: #e63946;
  background: #ffebee;
}

.opt-btn.opt-impulsive {
  border-color: #ffd166;
  background: #fffef8;
}
.opt-btn.opt-impulsive:hover {
  border-color: #ffb703;
  background: #fff8e1;
}

.opt-btn.opt-success {
  border-color: #b7e4c7;
  background: #fbfdfc;
}
.opt-btn.opt-success:hover {
  border-color: #52b788;
  background: #e8f5e9;
}

.opt-btn.opt-perspective {
  border-color: #a0c4ff;
  background: #f0f7ff;
}
.opt-btn.opt-perspective:hover {
  border-color: #4361ee;
  background: #e0edff;
}

.opt-badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #edf2f4;
  color: #495057;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 0.95rem;
  font-weight: 900;
  flex-shrink: 0;
}

.opt-btn.opt-success .opt-badge {
  background: #52b788;
  color: #ffffff;
}

.opt-btn.opt-danger .opt-badge {
  background: #e63946;
  color: #ffffff;
}

.opt-btn.opt-impulsive .opt-badge {
  background: #f4a261;
  color: #ffffff;
}

.opt-btn.opt-perspective .opt-badge {
  background: #4361ee;
  color: #ffffff;
}

.opt-label {
  flex-grow: 1;
}

.opt-speak-btn {
  background: #eef8ff;
  border: 1.5px solid #90e0ef;
  border-radius: 12px;
  width: 34px;
  height: 34px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1rem;
  color: #0077b6;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.opt-speak-btn:hover {
  background: #caf0f8;
  transform: scale(1.15);
}

/* ============================================================
   6. 3D 翻牌機會卡與結局彈窗
   ============================================================ */
.chance-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 50;
  backdrop-filter: blur(4px);
}

.chance-card-3d-scene {
  perspective: 1000px;
}

.chance-card-flip-box {
  background: #ffffff;
  border: 4px solid #ffd166;
  border-radius: 24px;
  padding: 22px 28px;
  max-width: 460px;
  text-align: center;
  box-shadow: 0 16px 36px rgba(0,0,0,0.35);
  animation: flipCardIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes flipCardIn {
  0% { transform: rotateY(90deg) scale(0.6); opacity: 0; }
  100% { transform: rotateY(0deg) scale(1); opacity: 1; }
}

.card-badge {
  display: inline-block;
  background: #e63946;
  color: #ffffff;
  padding: 4px 16px;
  border-radius: 18px;
  font-size: 0.95rem;
  font-weight: 900;
  margin-bottom: 12px;
}

.chance-content-text h3 {
  font-size: 1.25rem;
  color: #d90429;
  margin-bottom: 8px;
}

.chance-content-text p {
  font-size: 1.05rem;
  line-height: 1.55;
  color: #2b2d42;
  margin-bottom: 12px;
}

.chance-next-btn {
  background: #ffb703;
  color: #4a2c00;
  border: none;
  border-radius: 26px;
  padding: 10px 26px;
  font-size: 1rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(255, 183, 3, 0.4);
}

.ending-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 60;
  backdrop-filter: blur(6px);
}

.ending-card-box {
  background: #ffffff;
  border: 5px solid #ffbe86;
  border-radius: 26px;
  padding: 24px 32px;
  max-width: 520px;
  width: 90%;
  text-align: center;
  animation: slideUpChoice 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.trophy-glow {
  font-size: 3.5rem;
  margin-bottom: 2px;
}

.ending-card-box h2 {
  font-size: 1.5rem;
  color: #a05a2c;
  margin-bottom: 4px;
}

.badge-headline {
  font-size: 1.15rem;
  font-weight: 900;
  color: #52b788;
  margin-bottom: 12px;
}

.summary-card-inner {
  background: #f8f9fa;
  border-radius: 14px;
  padding: 12px 16px;
  text-align: left;
  border: 2px solid #e9ecef;
  margin-bottom: 16px;
}

.summary-title {
  font-weight: 900;
  color: #2b2d42;
  margin-bottom: 6px;
  font-size: 0.92rem;
}

.summary-card-inner ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.summary-card-inner li {
  font-size: 0.88rem;
  line-height: 1.45;
  color: #495057;
}

.btn-play-again-hero {
  background: #52b788;
  color: #ffffff;
  border: none;
  border-radius: 28px;
  padding: 12px 30px;
  font-size: 1.15rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(82, 183, 136, 0.4);
  transition: transform 0.2s ease;
}

.btn-play-again-hero:hover {
  transform: scale(1.05);
}

/* ============================================================
   7. 章節快速選關彈窗 (微課堂專題演練)
   ============================================================ */
.chapter-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 20, 28, 0.78);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 70;
  backdrop-filter: blur(6px);
}

.chapter-dialog-card {
  background: #ffffff;
  border: 4px solid #ffd166;
  border-radius: 24px;
  padding: 22px 28px;
  max-width: 580px;
  width: 90%;
  box-shadow: 0 16px 40px rgba(0,0,0,0.35);
  animation: slideUpChoice 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.chapter-dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.chapter-dialog-header h3 {
  font-size: 1.3rem;
  color: #a05a2c;
  font-weight: 900;
}

.chapter-close-btn {
  background: #edf2f4;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 1rem;
  font-weight: 900;
  color: #6c757d;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chapter-close-btn:hover {
  background: #dee2e6;
  color: #2b2d42;
}

.chapter-dialog-desc {
  font-size: 0.92rem;
  color: #6c757d;
  margin-bottom: 14px;
}

.chapter-cards-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chapter-item-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fdfaf6;
  border: 2.5px solid #ebd9c8;
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 1.05rem;
  font-weight: 800;
  color: #2b2d42;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.chapter-item-btn:hover {
  background: #fff3e6;
  border-color: #f4a261;
  transform: translateX(6px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

.chapter-num-badge {
  background: #ffd166;
  color: #5c2c00;
  font-size: 0.85rem;
  font-weight: 900;
  padding: 3px 10px;
  border-radius: 12px;
  flex-shrink: 0;
}

/* ============================================================
   8. 遊戲大廳首頁 (Game Home Portal)
   ============================================================ */
.home-portal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: radial-gradient(circle at 50% 25%, #fffdf0 0%, #fefae0 40%, #faedcd 80%, #d4a373 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 18px;
  overflow-y: auto;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.home-portal-overlay.portal-exit {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* 浮動雲朵與亮晶晶動態裝飾 */
.portal-animated-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.cloud-drift {
  position: absolute;
  font-size: 4.5rem;
  opacity: 0.55;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,0.05));
}
.cloud-drift.c1 { top: 8%; left: 8%; animation: driftCloud 18s infinite alternate ease-in-out; }
.cloud-drift.c2 { top: 65%; right: 6%; animation: driftCloud 22s infinite alternate-reverse ease-in-out; }

@keyframes driftCloud {
  0% { transform: translate(0, 0); }
  100% { transform: translate(40px, -20px); }
}

.sparkle-drift {
  position: absolute;
  font-size: 2.2rem;
  animation: floatSparkle 3s infinite alternate ease-in-out;
}
.sparkle-drift.s1 { top: 18%; right: 15%; animation-delay: 0.3s; }
.sparkle-drift.s2 { top: 38%; left: 12%; animation-delay: 0.9s; }
.sparkle-drift.s3 { bottom: 15%; left: 25%; animation-delay: 1.4s; }

@keyframes floatSparkle {
  0% { transform: scale(0.85) rotate(0deg); opacity: 0.5; }
  100% { transform: scale(1.25) rotate(15deg); opacity: 0.95; }
}

.portal-main-content {
  position: relative;
  z-index: 2;
  background: rgba(255, 255, 255, 0.96);
  border: 4.5px solid #ffbe86;
  border-radius: 32px;
  box-shadow: 0 20px 60px rgba(160, 90, 44, 0.22);
  max-width: 860px;
  width: 100%;
  padding: 28px 36px;
  text-align: center;
  animation: popCard 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.portal-brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ffe8d6;
  border: 2px solid #ffbe86;
  border-radius: 20px;
  padding: 4px 16px;
  font-size: 0.92rem;
  font-weight: 900;
  color: #9c4700;
  margin-bottom: 10px;
}

.portal-game-title {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 900;
  color: #5c2c00;
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}

.portal-game-title .title-highlight {
  color: #e65c00;
  text-shadow: 0 2px 0 #ffd166;
}

.portal-game-subtitle {
  font-size: 1.05rem;
  font-weight: 700;
  color: #6c757d;
  margin-bottom: 20px;
  line-height: 1.5;
}

/* 主推單元卡片 */
.featured-unit-card {
  background: #fffbf7;
  border: 2.5px solid #f3d5b5;
  border-radius: 22px;
  padding: 18px 22px;
  text-align: left;
  margin-bottom: 24px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.03);
}

.featured-tag-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.tag-unit-num {
  background: #ffb703;
  color: #5c2c00;
  font-size: 0.82rem;
  font-weight: 900;
  padding: 2px 10px;
  border-radius: 12px;
}

.tag-status-ready {
  font-size: 0.82rem;
  font-weight: 800;
  color: #2b9348;
}

.featured-unit-title {
  font-size: 1.25rem;
  font-weight: 900;
  color: #9c4700;
  margin-bottom: 6px;
}

.featured-unit-desc {
  font-size: 0.95rem;
  line-height: 1.5;
  color: #495057;
  margin-bottom: 12px;
}

.featured-skills-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.skill-chip {
  background: #eef8ff;
  border: 1.5px solid #bde0fe;
  border-radius: 14px;
  padding: 3px 10px;
  font-size: 0.8rem;
  font-weight: 800;
  color: #0277bd;
}

/* 首頁操作按鈕群 (針對大屏與觸控極佳體驗) */
.portal-action-buttons {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.portal-btn-primary {
  background: linear-gradient(135deg, #ff9f43 0%, #ff5400 100%);
  color: #ffffff;
  border: none;
  border-radius: 28px;
  padding: 14px 34px;
  font-size: 1.18rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(255, 107, 53, 0.4);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.portal-btn-primary:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 12px 28px rgba(255, 107, 53, 0.5);
}

.portal-btn-secondary {
  background: #ffffff;
  border: 2.5px solid #ffbe86;
  color: #9c4700;
  border-radius: 28px;
  padding: 12px 26px;
  font-size: 1.1rem;
  font-weight: 900;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.06);
  transition: all 0.2s ease;
}

.portal-btn-secondary:hover {
  background: #fff7ed;
  border-color: #ff9f43;
  transform: translateY(-2px);
}

.portal-btn-ghost {
  background: #eef8ff;
  border: 2px dashed #90e0ef;
  color: #0077b6;
  border-radius: 28px;
  padding: 12px 22px;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.portal-btn-ghost:hover {
  background: #caf0f8;
  transform: translateY(-2px);
}

.portal-footer-hint {
  font-size: 0.85rem;
  color: #8c7851;
  font-weight: 700;
}

/* ============================================================
   9. 社交單元全覽選單 (Curriculum Units Catalog)
   ============================================================ */
.units-catalog-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(15, 20, 28, 0.8);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.units-catalog-card {
  background: #ffffff;
  border: 4.5px solid #ffbe86;
  border-radius: 30px;
  width: 100%;
  max-width: 920px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  padding: 24px 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  animation: popCard 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.catalog-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  border-bottom: 2px solid #f1f3f5;
  padding-bottom: 12px;
}

.catalog-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.catalog-title-group .catalog-icon {
  font-size: 2.2rem;
}

.catalog-title-group h2 {
  font-size: 1.4rem;
  color: #5c2c00;
  font-weight: 900;
}

.catalog-title-group p {
  font-size: 0.9rem;
  color: #6c757d;
  font-weight: 700;
}

.catalog-close-btn {
  background: #edf2f4;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 1.1rem;
  font-weight: 900;
  color: #6c757d;
  cursor: pointer;
  transition: all 0.2s ease;
}

.catalog-close-btn:hover {
  background: #dee2e6;
  color: #2b2d42;
}

.units-grid-container {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-right: 4px;
}

/* 個別單元項目卡片 */
.unit-item-card {
  background: #fdfaf6;
  border: 2.5px solid #ebd9c8;
  border-radius: 20px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 18px;
  transition: all 0.2s ease;
}

.unit-item-card:hover {
  border-color: #f4a261;
  background: #fff8f0;
  transform: translateX(4px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.06);
}

.unit-item-card.is-locked {
  opacity: 0.75;
  background: #f8f9fa;
  border-color: #dee2e6;
}

.unit-item-card.is-locked:hover {
  transform: none;
  box-shadow: none;
}

.unit-item-icon-box {
  width: 60px;
  height: 60px;
  border-radius: 18px;
  background: #ffe8d6;
  border: 2px solid #ffbe86;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 2rem;
  flex-shrink: 0;
}

.unit-item-card.is-locked .unit-item-icon-box {
  background: #e9ecef;
  border-color: #ced4da;
  filter: grayscale(80%);
}

.unit-item-info {
  flex-grow: 1;
}

.unit-item-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.unit-badge-pill {
  background: #ffd166;
  color: #5c2c00;
  font-size: 0.8rem;
  font-weight: 900;
  padding: 2px 8px;
  border-radius: 10px;
}

.unit-theme-text {
  font-size: 0.85rem;
  font-weight: 800;
  color: #6c757d;
}

.unit-item-title {
  font-size: 1.15rem;
  font-weight: 900;
  color: #2b2d42;
  margin-bottom: 6px;
}

.unit-item-skills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.unit-skill-tag {
  background: #ffffff;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #495057;
}

.unit-action-btn {
  background: #ff9f43;
  color: #ffffff;
  border: none;
  border-radius: 20px;
  padding: 10px 20px;
  font-size: 0.95rem;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(255, 159, 67, 0.35);
  transition: all 0.2s ease;
}

.unit-action-btn:hover {
  background: #ff851b;
  transform: scale(1.05);
}

.unit-action-btn.btn-disabled {
  background: #ced4da;
  color: #6c757d;
  box-shadow: none;
  cursor: not-allowed;
}

.unit-action-btn.btn-disabled:hover {
  transform: none;
}

/* 頂部 HUD 首頁按鈕 */
.hud-btn.home-btn {
  background: #ffedd5;
  border-color: #fb923c;
  color: #9a3412;
}

.hud-btn.home-btn:hover {
  background: #fed7aa;
}

.hidden {
  display: none !important;
}
