/* ============================================================
 * 末世商戰 365 · Retro-Cyber Apocalyptic
 * 主色：#c2410c amber · #15803d moss · #0a0a0a void · #c9a86b old paper
 * 風格：CRT scanline + Terminal serif + 廢墟氛圍
 * ============================================================ */

:root {
  --void: #0a0a0a;
  --ash: #1a1815;
  --paper: #1f1c17;
  --amber: #f5a04b;
  --amber-deep: #c2410c;
  --moss: #4ade80;
  --moss-deep: #15803d;
  --cyan: #22d3ee;
  --red: #ef4444;
  --ink: #e8e0d0;
  --ink-soft: #a89e8c;
  --ink-faint: #6d6659;
  --rule: rgba(232, 224, 208, 0.12);
  --scanline: rgba(245, 160, 75, 0.03);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  background: var(--void);
  color: var(--ink);
  font-family: "Noto Sans TC", -apple-system, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  overscroll-behavior: none;
}

body::before {
  content: '';
  position: fixed; inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent 0,
    transparent 2px,
    var(--scanline) 2px,
    var(--scanline) 3px
  );
  pointer-events: none;
  z-index: 999;
  mix-blend-mode: overlay;
}

#app { min-height: 100vh; position: relative; }

/* ==================== 開始畫面 ==================== */
.menu-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(10,10,10,0.85) 0%, rgba(10,10,10,0.6) 40%, rgba(10,10,10,0.95) 100%),
    url('/apocalypse/game-365/img/apoc-bg-ruins.png') center/cover no-repeat;
}
.menu-glow {
  position: absolute;
  top: -30%; left: 50%;
  transform: translateX(-50%);
  width: 800px; height: 800px;
  background: radial-gradient(circle, rgba(194, 65, 12, 0.35) 0%, transparent 60%);
  filter: blur(40px);
  pointer-events: none;
  animation: pulse-glow 8s ease-in-out infinite;
}
@keyframes pulse-glow {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}
.menu-inner {
  position: relative;
  z-index: 1;
  max-width: 480px;
  width: 100%;
  text-align: center;
}
.menu-eyebrow {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.3em;
  color: var(--amber);
  margin-bottom: 20px;
  text-transform: uppercase;
}
.menu-title {
  font-family: "Fraunces", serif;
  font-weight: 900;
  font-size: clamp(52px, 12vw, 88px);
  line-height: 0.95;
  color: var(--ink);
  text-shadow: 0 0 30px rgba(245, 160, 75, 0.3);
  margin-bottom: 8px;
}
.menu-title-em {
  color: var(--amber);
  font-style: italic;
  margin-left: 0.1em;
}
.menu-tagline {
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 1.9;
  margin: 20px auto 24px;
  max-width: 320px;
}
.menu-tagline em {
  color: var(--amber);
  font-style: italic;
  font-weight: 700;
}
.menu-meta {
  color: var(--ink-faint);
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.1em;
  margin-bottom: 32px;
}
.menu-btns {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 300px;
  margin: 0 auto 24px;
}
.btn-primary, .btn-secondary, .btn-ghost {
  font-family: "Noto Sans TC", sans-serif;
  font-weight: 700;
  font-size: 15px;
  padding: 14px 20px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.05em;
}
.btn-primary {
  background: var(--amber-deep);
  color: var(--void);
  border: none;
  box-shadow: 0 4px 20px rgba(194, 65, 12, 0.4);
}
.btn-primary:hover, .btn-primary:active {
  background: var(--amber);
  transform: translateY(-1px);
}
.btn-secondary {
  background: transparent;
  color: var(--amber);
  border: 1px solid var(--amber-deep);
}
.btn-secondary:hover { background: rgba(194, 65, 12, 0.1); }
.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--rule);
  font-size: 13px;
  padding: 10px 16px;
}
.btn-ghost:hover { color: var(--ink); border-color: var(--ink-soft); }
.menu-foot {
  color: var(--ink-faint);
  font-size: 11px;
  font-family: "JetBrains Mono", monospace;
  letter-spacing: 0.1em;
}
.menu-foot a { color: var(--amber); text-decoration: none; }

/* ==================== 說明 / 收藏畫面 ==================== */
.how-screen {
  min-height: 100vh;
  padding: 20px;
  max-width: 640px;
  margin: 0 auto;
}
.btn-close {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--rule);
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  margin-bottom: 24px;
}
.btn-close:hover { color: var(--amber); }
.how-inner h2 {
  font-family: "Fraunces", serif;
  font-weight: 900;
  font-size: 32px;
  margin-bottom: 20px;
}
.how-inner h3 {
  font-family: "Fraunces", serif;
  font-weight: 700;
  font-size: 20px;
  margin-bottom: 14px;
}
.how-list {
  padding-left: 24px;
  color: var(--ink-soft);
  line-height: 1.85;
  font-size: 14px;
}
.how-list li { margin-bottom: 8px; }
.how-list strong { color: var(--ink); }
.how-tip {
  margin-top: 24px;
  padding: 16px 20px;
  background: var(--paper);
  border-left: 3px solid var(--moss);
  border-radius: 4px;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.7;
}
.how-tip strong { color: var(--moss); }

.endings-grid, .principles-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 12px;
}
.ending-card, .principle-card {
  padding: 12px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 6px;
  font-size: 12px;
}
.ending-card.locked, .principle-card.locked {
  opacity: 0.35;
}
.ending-card .rarity {
  display: inline-block;
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 999px;
  letter-spacing: 0.1em;
  margin-bottom: 6px;
}
.rarity-legendary { background: rgba(245, 160, 75, 0.2); color: var(--amber); }
.rarity-epic { background: rgba(74, 222, 128, 0.15); color: var(--moss); }
.rarity-rare { background: rgba(34, 211, 238, 0.15); color: var(--cyan); }
.rarity-common { background: rgba(168, 158, 140, 0.1); color: var(--ink-soft); }
.principle-card .p-icon {
  font-size: 20px;
  margin-bottom: 4px;
}
.principle-card strong { color: var(--ink); display: block; margin-bottom: 4px; }
.principle-card .p-count { color: var(--ink-faint); font-size: 10px; }

/* ==================== 遊戲主畫面 ==================== */
.play-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 0;
}

.hud {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  padding: 12px 16px;
  align-items: center;
  border-bottom: 1px solid var(--rule);
  background: rgba(10, 10, 10, 0.95);
  backdrop-filter: blur(8px);
}
.hud-day {
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--amber);
}
.hud-day span { color: var(--ink); font-size: 14px; font-weight: 700; }
.hud-mid { max-width: 260px; }
.hud-oracle-label {
  font-family: "JetBrains Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.2em;
  color: var(--red);
  margin-bottom: 4px;
  text-align: center;
  opacity: 0.7;
}
.hud-oracle-bar {
  width: 100%;
  height: 6px;
  background: var(--paper);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--rule);
}
.hud-oracle-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--moss), var(--amber), var(--red));
  transition: width 0.6s ease;
}
.btn-icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 16px;
}
.btn-icon:hover { color: var(--amber); border-color: var(--amber); }

.card-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
  position: relative;
  min-height: 380px;
}
.card {
  position: relative;
  width: 100%;
  max-width: 400px;
  aspect-ratio: 3 / 4;
  background: var(--paper);
  border: 2px solid var(--rule);
  border-radius: 12px;
  overflow: hidden;
  cursor: grab;
  user-select: none;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  touch-action: pan-y;
  will-change: transform;
}
.card.dragging {
  transition: none;
  cursor: grabbing;
}
.card.swiping-out-left {
  transform: translateX(-140vw) rotate(-30deg) !important;
  transition: transform 0.5s ease-in;
}
.card.swiping-out-right {
  transform: translateX(140vw) rotate(30deg) !important;
  transition: transform 0.5s ease-in;
}
.card-inner {
  position: relative;
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  padding: 20px;
}
.card-portrait {
  width: 96px; height: 96px;
  border-radius: 50%;
  background: var(--void) center/cover no-repeat;
  border: 2px solid var(--amber-deep);
  margin: 0 auto 12px;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 4px 20px rgba(194, 65, 12, 0.3);
}
.card-faction {
  text-align: center;
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--amber);
  text-transform: uppercase;
  margin-bottom: 16px;
}
.card-text {
  flex: 1;
  font-family: "Noto Sans TC", serif;
  font-size: 15px;
  line-height: 1.85;
  color: var(--ink);
  overflow-y: auto;
  text-align: justify;
}
.card-principle {
  position: absolute;
  bottom: 12px; right: 14px;
  font-size: 20px;
  opacity: 0.5;
}
.swipe-hint {
  position: absolute;
  top: 40%; transform: translateY(-50%);
  font-family: "JetBrains Mono", monospace;
  font-size: 24px;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 8px;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
.swipe-hint-l { left: 20px; color: var(--red); border: 2px solid var(--red); }
.swipe-hint-r { right: 20px; color: var(--moss); border: 2px solid var(--moss); }
.card.swiping-l .swipe-hint-l { opacity: 1; }
.card.swiping-r .swipe-hint-r { opacity: 1; }

.swipe-choice-preview {
  position: absolute;
  bottom: 40px;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  max-width: 60%;
  text-align: center;
  line-height: 1.4;
}
.swipe-choice-l { left: 12px; background: rgba(239,68,68,0.9); color: white; }
.swipe-choice-r { right: 12px; background: rgba(74,222,128,0.9); color: var(--void); }
.card.swiping-l .swipe-choice-l { opacity: 1; }
.card.swiping-r .swipe-choice-r { opacity: 1; }

.meters {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  padding: 8px 16px 12px;
  border-top: 1px solid var(--rule);
}
.meter {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.meter-icon {
  font-size: 18px;
  filter: grayscale(0.3);
}
.meter-bar {
  width: 100%;
  height: 6px;
  background: var(--paper);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--rule);
}
.meter-fill {
  height: 100%;
  transition: width 0.5s ease, background 0.3s ease;
  background: var(--ink-soft);
}
.meter-value {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  color: var(--ink-soft);
}
.meter.crit .meter-value { color: var(--red); font-weight: 700; }
.meter.high .meter-value { color: var(--moss); font-weight: 700; }

.btn-row {
  display: none;
  gap: 12px;
  padding: 0 16px 24px;
}
.btn-swipe {
  flex: 1;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid;
  background: transparent;
  font-size: 20px;
  cursor: pointer;
  font-weight: 700;
}
.btn-swipe-l { border-color: var(--red); color: var(--red); }
.btn-swipe-r { border-color: var(--moss); color: var(--moss); }
@media (hover: none) and (pointer: coarse) {
  .btn-row { display: none; } /* 手機用滑的 */
}
.no-touch .btn-row { display: flex; }

/* Outcome bubble */
.outcome {
  position: fixed;
  bottom: 90px; left: 16px; right: 16px;
  background: var(--paper);
  border: 1px solid var(--amber-deep);
  border-radius: 8px;
  padding: 12px 16px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.65;
  z-index: 100;
  animation: outcome-in 0.3s ease;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}
@keyframes outcome-in {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.outcome .outcome-hint {
  font-size: 11px;
  color: var(--amber);
  margin-top: 6px;
  font-style: italic;
}

/* ==================== End screen ==================== */
.end-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  text-align: center;
  max-width: 560px;
  margin: 0 auto;
}
.end-eyebrow {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.3em;
  color: var(--amber);
  margin-bottom: 16px;
  text-transform: uppercase;
}
.end-title {
  font-family: "Fraunces", serif;
  font-weight: 900;
  font-size: clamp(28px, 7vw, 44px);
  line-height: 1.1;
  margin-bottom: 20px;
}
.end-day {
  font-family: "JetBrains Mono", monospace;
  color: var(--ink-soft);
  font-size: 14px;
  margin-bottom: 20px;
}
.end-day strong { color: var(--amber); font-size: 18px; }
.end-meters {
  display: flex;
  gap: 12px;
  margin: 12px 0 20px;
  flex-wrap: wrap;
  justify-content: center;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--ink-soft);
}
.end-text {
  font-family: "Noto Sans TC", serif;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.9;
  margin: 20px 0 30px;
  white-space: pre-wrap;
  text-align: left;
}
.end-rewards {
  padding: 14px 18px;
  background: var(--paper);
  border-left: 3px solid var(--amber);
  border-radius: 4px;
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 24px;
  min-height: 40px;
  text-align: left;
}
.end-rewards strong { color: var(--amber); }
.end-btns {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 280px;
}
