:root {
  /* --- 溫潤深色系 (Human-Centric Dark) --- */
  --bg-deep: #0a0c10;
  --surface-base: rgba(18, 22, 30, 0.7);
  --border-soft: rgba(255, 255, 255, 0.12);
  --text-pure: #ffffff;
  --text-muted: #8b949e;

  /* --- 點綴光芒 --- */
  --light-cyan: #44ccff;
  --light-amber: #ffaa00;
  --light-alert: #ff4444;

  /* --- Typography --- */
  --font-mono: "JetBrains Mono", monospace;
  --font-serif: "Noto Serif TC", serif;
  --font-sans: system-ui, -apple-system, sans-serif;

  /* --- 順滑動畫 --- */
  --ease-snappy: cubic-bezier(0.2, 0.8, 0.2, 1);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

/* 💎 截長補短升級區 1 & 2：系統淡入與戰術座標網格 */
body {
  margin: 0;
  min-height: 100dvh;
  background-color: var(--bg-deep);

  /* 戰術網格暗紋 */
  background-image:
    linear-gradient(rgba(68, 204, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(68, 204, 255, 0.03) 1px, transparent 1px);
  background-size: 30px 30px;
  background-position: center center;

  color: var(--text-pure);
  font-family: var(--font-mono);
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 15px;

  /* 系統啟動動畫 */
  opacity: 0;
  animation: system-boot 1s var(--ease-snappy) forwards;
}

@keyframes system-boot {
  0% {
    opacity: 0;
    transform: scale(0.98);
    filter: blur(5px);
  }
  100% {
    opacity: 1;
    transform: scale(1);
    filter: blur(0);
  }
}

/* --- 雙重環境暖光 --- */
.ambient-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.4;
  pointer-events: none;
  z-index: 0;
}
.cyan-glow {
  width: 60vw;
  height: 60vw;
  background: rgba(68, 204, 255, 0.08);
  top: -10%;
  left: -10%;
}
.amber-glow {
  width: 50vw;
  height: 50vw;
  background: rgba(255, 170, 0, 0.05);
  bottom: -10%;
  right: -10%;
}

/* --- Layout --- */
.oracle-container {
  position: relative;
  z-index: 10;
  text-align: center;
  width: 100%;
  max-width: 380px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* --- Header --- */
header {
  margin-bottom: 4px;
}
.brand-tag {
  font-size: 0.6rem;
  letter-spacing: 0.15em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.oracle-title {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 900;
  margin: 0;
  letter-spacing: 0.05em;
  color: #fff;
  text-shadow: 0 2px 10px rgba(255, 255, 255, 0.2);
}
.subtitle {
  margin-top: 6px;
}
.main-sub {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* --- 玻璃卡片 --- */
.glass-card {
  background: var(--surface-base);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border-soft);
  border-radius: 24px;
  padding: 20px;
  box-shadow:
    0 16px 40px rgba(0, 0, 0, 0.4),
    inset 0 1px 1px rgba(255, 255, 255, 0.1);
  transition: all 0.5s var(--ease-snappy);
  display: flex;
  flex-direction: column;
}
.glass-card.locked {
  border-color: rgba(68, 204, 255, 0.3);
  box-shadow:
    0 16px 40px rgba(0, 0, 0, 0.4),
    0 0 20px rgba(68, 204, 255, 0.1),
    inset 0 1px 1px rgba(255, 255, 255, 0.15);
}

/* --- 狀態列 --- */
.hud-header {
  display: flex;
  justify-content: center;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding-bottom: 12px;
  margin-bottom: 16px;
}
.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 💎 截長補短升級區 3：雷達呼吸燈 */
.led-light {
  width: 8px;
  height: 8px;
  background: #333;
  border-radius: 50%;
  transition: all 0.3s;
}
.glass-card.locked .led-light {
  background: var(--light-cyan);
  box-shadow: 0 0 8px var(--light-cyan);
  animation: led-pulse 1.5s infinite;
}
@keyframes led-pulse {
  0% {
    opacity: 1;
    box-shadow: 0 0 8px var(--light-cyan);
  }
  50% {
    opacity: 0.4;
    box-shadow: 0 0 2px var(--light-cyan);
  }
  100% {
    opacity: 1;
    box-shadow: 0 0 8px var(--light-cyan);
  }
}

.sys-text {
  font-size: 0.65rem;
  color: var(--text-muted);
  letter-spacing: 0.08em;
}

/* --- 終端機日誌 --- */
.terminal-log-zone {
  min-height: 90px;
  text-align: left;
  padding: 12px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  margin-bottom: 16px;
}
.log-line {
  font-size: 0.75rem;
  color: var(--text-muted);
  opacity: 0;
  transform: translateY(2px);
}
.log-line.active {
  opacity: 1;
  transform: translateY(0);
  color: var(--light-cyan);
  transition: all 0.2s;
}

/* --- 結果區 --- */
.result-section {
  position: relative;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  margin-bottom: 20px;
}
.result-halo {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(255, 170, 0, 0.15) 0%,
    transparent 70%
  );
  filter: blur(15px);
  opacity: 0;
  transition: all 0.8s var(--ease-snappy);
  pointer-events: none;
}
.result-section.revealed .result-halo {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1.2);
}

.result-content {
  position: relative;
  z-index: 2;
  width: 100%;
}

/* Emoji 舞台樣式 */
.emoji-stage {
  font-size: 42px;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 10px;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.5));
  animation: float-emoji 3s ease-in-out infinite alternate;
}
.emoji-overlay {
  position: absolute;
  font-size: 22px;
  right: 35%;
  bottom: -4px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.8));
}
@keyframes float-emoji {
  0% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(-4px);
  }
}

.result-title {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  font-weight: 900;
  margin: 0 0 8px 0;
  letter-spacing: 0.05em;
  line-height: 1.2;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}
.result-desc {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: #aaa;
}

/* --- 參數網格 --- */
.filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
  transition: opacity 0.3s;
}

/* --- 💎 戰術載具選擇器 (Transit Selector) --- */
.transit-selector {
  margin-bottom: 20px;
  width: 100%;
  transition: opacity 0.3s;
}
.transit-title {
  font-size: 0.55rem;
  color: var(--text-muted);
  letter-spacing: 0.15em;
  margin-bottom: 8px;
  text-align: left;
  padding-left: 4px;
}
.transit-options {
  display: flex;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.5);
}
.transit-btn {
  flex: 1;
  cursor: pointer;
  position: relative;
}
.transit-btn input {
  display: none; /* 隱藏醜醜的圓圈 */
}
.transit-btn .t-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 4px;
  color: var(--text-muted);
  border-radius: 8px;
  transition: all 0.3s var(--ease-snappy);
  user-select: none;
}
.t-icon {
  font-size: 1.1rem;
  margin-bottom: 2px;
  filter: grayscale(1);
  opacity: 0.5;
  transition: all 0.3s var(--ease-snappy);
}
.t-text {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 700;
}

/* 載具選中狀態 (Active State) */
.transit-btn input:checked ~ .t-content {
  background: rgba(68, 204, 255, 0.15);
  color: var(--light-cyan);
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.1),
    0 2px 8px rgba(0, 0, 0, 0.2);
}
.transit-btn input:checked ~ .t-content .t-icon {
  filter: grayscale(0);
  opacity: 1;
  filter: drop-shadow(0 0 5px rgba(68, 204, 255, 0.4));
  transform: translateY(-2px); /* 微微浮起 */
}

.toggle-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid transparent;
  transition: background 0.2s;
  user-select: none;
}
.toggle-switch:active {
  background: rgba(255, 255, 255, 0.06);
}
.toggle-switch input {
  display: none;
}

.slider {
  width: 32px;
  height: 16px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 20px;
  position: relative;
  transition: all 0.3s;
  flex-shrink: 0;
}
.slider::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  background: #666;
  border-radius: 50%;
  transition: all 0.3s;
}
input:checked + .slider {
  background: rgba(255, 170, 0, 0.2);
}
input:checked + .slider::after {
  transform: translateX(16px);
  background: var(--light-amber);
  box-shadow: 0 0 6px var(--light-amber);
}

.label-text {
  display: flex;
  flex-direction: column;
  text-align: left;
  line-height: 1.2;
}
.label-text .zh {
  font-size: 0.9rem;
  font-weight: 700;
  color: #bbb;
  transition: color 0.2s;
}
.label-text .en {
  font-size: 0.55rem;
  color: #666;
}
input:checked + .slider + .label-text .zh {
  color: #fff;
}

/* --- 動作島 --- */
.action-island {
  display: flex;
  gap: 12px;
  width: 100%;
}
.cyber-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  color: #fff;
  padding: 14px 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex: 1;
  transition: all 0.2s var(--ease-snappy);
  user-select: none;
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.05),
    0 4px 12px rgba(0, 0, 0, 0.2);
}
.cyber-btn:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: none;
  background: rgba(255, 255, 255, 0.08);
}
.cyber-btn:disabled {
  opacity: 0.4;
  border-style: dashed;
  pointer-events: none;
}

.zh-btn {
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}
.en-btn {
  font-size: 0.55rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
}

.cyber-btn.primary {
  background: rgba(68, 204, 255, 0.08);
  border-color: rgba(68, 204, 255, 0.3);
}
.cyber-btn.primary:active:not(:disabled) {
  background: rgba(68, 204, 255, 0.15);
}
.cyber-btn.tertiary {
  background: var(--light-amber);
  color: #000;
  border: none;
}
.cyber-btn.tertiary .zh-btn {
  color: #000;
}
.cyber-btn.tertiary .en-btn {
  color: rgba(0, 0, 0, 0.6);
}

@keyframes soft-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 rgba(68, 204, 255, 0);
  }
  50% {
    box-shadow: 0 0 15px rgba(68, 204, 255, 0.3);
  }
}
.cyber-btn.pulse-active {
  animation: soft-pulse 2s infinite ease-in-out;
}

/* --- Footer & Links --- */
footer {
  margin-top: 1rem;
  font-size: 0.6rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.footer-line,
.footer-links {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}
.footer-link {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: bold;
  margin: 0 4px;
  transition: all 0.3s var(--ease-snappy);
}
.footer-link:hover {
  color: var(--light-cyan);
  text-shadow: 0 0 8px rgba(68, 204, 255, 0.5);
}

/* 小螢幕微調 */
@media (max-height: 700px) {
  .glass-card {
    padding: 16px;
    border-radius: 20px;
  }
  .result-section {
    min-height: 100px;
    margin-bottom: 12px;
  }
  .terminal-log-zone {
    min-height: 80px;
    margin-bottom: 12px;
  }
  .filter-grid {
    margin-bottom: 16px;
    gap: 8px;
  }
  .cyber-btn {
    padding: 12px 8px;
  }
}

/* --- 💎 截長補短加強版：致命故障特效 (Glitch Shake) --- */
@keyframes glitch-shake {
  0% {
    transform: translate(0);
  }
  20% {
    transform: translate(-4px, 2px);
  }
  40% {
    transform: translate(4px, -2px);
  }
  60% {
    transform: translate(-4px, -2px);
  }
  80% {
    transform: translate(4px, 2px);
  }
  100% {
    transform: translate(0);
  }
}

.glass-card.critical-error {
  animation: glitch-shake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
  border-color: var(--light-alert) !important;
  box-shadow:
    0 16px 40px rgba(0, 0, 0, 0.6),
    0 0 30px rgba(255, 68, 68, 0.2),
    inset 0 1px 1px rgba(255, 68, 68, 0.3) !important;
}

/* 讓系統指示燈在故障時狂閃紅燈 */
.glass-card.critical-error .led-light {
  background: var(--light-alert) !important;
  box-shadow: 0 0 10px var(--light-alert) !important;
  animation: led-pulse 0.2s infinite !important;
}
