:root {
  --bg: #0a0c16;
  --bg-panel: #12142280;
  --border: #3a2f52;
  --text: #f1eef9;
  --text-dim: #a6a1bd;
  --accent-warm: #ffb35c;
  --accent-warm-2: #ff7a3d;
  --accent-cool: #7c6cf0;
  --success: #5be08c;
  --fail: #ff6b6b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(ellipse at 50% 38%, #100c17 0%, #050508 55%, #030304 100%);
  color: var(--text);
  font-family: -apple-system, "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", sans-serif;
  overflow-x: hidden;
}

.stars {
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 20% 30%, white, transparent),
    radial-gradient(1px 1px at 70% 60%, white, transparent),
    radial-gradient(1px 1px at 40% 80%, white, transparent),
    radial-gradient(1.5px 1.5px at 85% 20%, white, transparent),
    radial-gradient(1px 1px at 10% 70%, white, transparent),
    radial-gradient(1px 1px at 55% 15%, white, transparent),
    radial-gradient(1.5px 1.5px at 90% 85%, white, transparent),
    radial-gradient(1px 1px at 30% 50%, white, transparent);
  background-repeat: repeat;
  background-size: 400px 400px;
  opacity: 0.35;
  z-index: 0;
}

/* 藍圖網格背景（只在遊戲畫面顯示,營造任務儀表板感） */
.blueprint-grid {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 4rem 4rem;
}

/* 四角準星裝飾 */
.crosshair {
  position: fixed;
  width: 28px;
  height: 28px;
  z-index: 2;
  pointer-events: none;
  opacity: 0.55;
}
.crosshair::before,
.crosshair::after {
  content: '';
  position: absolute;
  background: var(--accent-warm);
}
.crosshair::before { width: 1.5px; height: 100%; left: 0; top: 0; }
.crosshair::after { width: 100%; height: 1.5px; left: 0; top: 0; }
.crosshair-tl { top: 1.25rem; left: 1.25rem; }
.crosshair-tr { top: 1.25rem; right: 1.25rem; }
.crosshair-tr::before { left: auto; right: 0; }
.crosshair-bl { bottom: 1.25rem; left: 1.25rem; }
.crosshair-bl::after { top: auto; bottom: 0; }
.crosshair-br { bottom: 1.25rem; right: 1.25rem; }
.crosshair-br::before { left: auto; right: 0; }
.crosshair-br::after { top: auto; bottom: 0; }

.brand-mark {
  position: fixed;
  z-index: 2;
  opacity: 0.92;
  pointer-events: none;
}
.brand-mark-left {
  bottom: 1.5rem;
  left: 1.75rem;
  height: 13vh;
  width: auto;
}
.brand-mark-right {
  bottom: 1.4rem;
  right: 1.9rem;
  height: 13vh;
  width: auto;
}
.brand-mark-spin {
  animation: brand-spin 6s linear infinite;
}
@keyframes brand-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .brand-mark-spin { animation: none; }
}

.hud-title-block {
  position: fixed;
  top: 1.5rem;
  left: 1.75rem;
  z-index: 2;
  max-width: 260px;
}
.hud-title {
  font-size: 1.05rem;
  font-weight: 900;
  color: white;
  letter-spacing: -0.02em;
  text-shadow: 0 0 20px rgba(255, 179, 92, 0.35);
}
.hud-subtitle {
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.45);
  letter-spacing: 0.15em;
  margin-top: 0.2rem;
}
.hud-lore {
  font-size: 0.75rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.6);
  margin: 0.6rem 0 0;
}

.screen {
  position: relative;
  z-index: 1;
  display: none;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 14px;
}

.screen.active { display: flex; }

.panel {
  background: var(--bg-panel);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px 36px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.logo {
  font-size: 28px;
  margin: 0 0 8px;
  background: linear-gradient(90deg, var(--accent-warm), var(--accent-cool));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.sub {
  color: var(--text-dim);
  font-size: 14px;
  margin: 0 0 24px;
}

.sub strong { color: var(--accent-warm); }

form, #voucher-form-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

input {
  background: #1a1826;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 14px;
  outline: none;
}

input:focus { border-color: var(--accent-cool); }

.btn {
  border: none;
  border-radius: 12px;
  padding: 13px 20px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(90deg, var(--accent-warm-2), var(--accent-warm));
  color: #1a0f00;
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  margin-top: 16px;
}

.btn-launch {
  background: linear-gradient(90deg, var(--accent-cool), #a78bfa);
  color: #14092e;
  font-size: 18px;
  padding: 16px 48px;
  border-radius: 999px;
  box-shadow: 0 8px 30px rgba(124, 108, 240, 0.4);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.note {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 14px;
}

.hidden { display: none !important; }

/* Game stage */
.game-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.portal-wrap {
  position: relative;
  width: min(900px, 90vw, calc(100vh - 190px));
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

#portal-canvas {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 40px rgba(255, 140, 60, 0.35));
}

.ship {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 46px;
  height: 46px;
  object-fit: contain;
  filter: drop-shadow(0 4px 14px rgba(124, 108, 240, 0.5));
  will-change: transform, opacity;
  transform: translate(calc(-50% + var(--orbit-r, 150px)), -50%);
}

.ship.idle {
  animation: idle-bob 3.2s ease-in-out infinite;
}

@keyframes idle-bob {
  0%, 100% { transform: translate(calc(-50% + var(--orbit-r, 150px)), -50%) rotate(-4deg); }
  50% { transform: translate(calc(-50% + var(--orbit-r, 150px)), -58%) rotate(4deg); }
}

@media (prefers-reduced-motion: reduce) {
  .ship.idle { animation: none; }
}

.timer-display {
  font-family: "JetBrains Mono", "SF Mono", monospace;
  font-size: 60px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -1px;
  color: white;
  text-shadow: 0 0 24px rgba(255, 179, 92, 0.5);
}

.timer-unit {
  font-size: 28px;
  color: var(--text-dim);
  margin-left: 2px;
  text-shadow: none;
}

.target-hint {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: -20px;
}

#result-title.success { color: var(--success); }
#result-title.fail { color: var(--fail); }

/* 手機版：縮小字級與間距,避免內容超出小螢幕高度 */
@media (max-width: 480px) {
  .hud-title { font-size: 0.9rem; }
  .hud-subtitle { font-size: 0.6rem; }
  .hud-title-block { max-width: 190px; }
  .hud-lore { font-size: 0.62rem; line-height: 1.4; }
  .game-stage { gap: 18px; }
  .timer-display { font-size: 44px; }
  .timer-unit { font-size: 20px; }
  .target-hint { margin-top: -12px; }
  .btn-launch { font-size: 16px; padding: 14px 36px; }
  .screen { padding: 16px; }
  .brand-mark-left { left: 1.1rem; }
  .brand-mark-right { right: 1.2rem; }
}
