/* 008-makefriends — 8-bit RPG style */

:root {
  --bg: #0f0e17;
  --card-bg: #1a1a2e;
  --border: #a78bfa;
  --border-dim: #4a3f6b;
  --primary: #a78bfa;
  --accent: #34d399;
  --pink: #ff6b9d;
  --yellow: #fbbf24;
  --text: #fffffe;
  --text-dim: #94a1b2;
  --pixel-font: 'Press Start 2P', monospace;
  --body-font: 'Noto Sans TC', -apple-system, sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--body-font);
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--text);
  padding: 1rem;
  position: relative;
  overflow-x: hidden;
}

/* 掃描線 */
.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.08) 2px,
    rgba(0, 0, 0, 0.08) 4px
  );
}

.container {
  width: 100%;
  max-width: 440px;
  position: relative;
  z-index: 1;
}

/* Screens */
.screen {
  display: none;
}

.screen.active {
  display: block;
  animation: screenIn 0.3s ease;
}

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

/* Pixel box — double border RPG style */
.pixel-box {
  background: var(--card-bg);
  border: 3px solid var(--border);
  box-shadow:
    0 0 0 3px var(--card-bg),
    0 0 0 6px var(--border-dim),
    0 0 30px rgba(167, 139, 250, 0.15);
  padding: 1.75rem 1.25rem;
  position: relative;
}

.pixel-box-inner {
  background: rgba(167, 139, 250, 0.08);
  border: 2px solid var(--border-dim);
  padding: 1rem;
}

/* ═══ Start Screen ═══ */
.main-card {
  text-align: center;
  padding: 2.5rem 1.25rem;
}

.title {
  font-family: var(--body-font);
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.5;
  margin-bottom: 1rem;
  color: var(--text);
  text-shadow: 2px 2px 0 var(--border-dim);
}

.hero-image {
  margin: 2rem 0;
  font-size: 3rem;
  animation: float 2s ease-in-out infinite alternate;
}

@keyframes float {
  from { transform: translateY(0); }
  to { transform: translateY(-10px); }
}

/* ═══ Buttons ═══ */
.btn-pixel {
  font-family: var(--pixel-font);
  font-size: 0.7rem;
  padding: 0.9rem 2rem;
  border: 3px solid var(--primary);
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  letter-spacing: 0.15em;
  transition: all 0.1s;
  position: relative;
}

#btn-start {
  font-size: 0.875rem;
  font-weight: 700;
}

.btn-pixel:active {
  background: var(--primary);
  color: var(--bg);
  transform: translate(2px, 2px);
}

.btn-small {
  font-size: 0.55rem;
  padding: 0.65rem 1.5rem;
}

/* ═══ Stars canvas ═══ */
#stars-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

/* ═══ Question Screen ═══ */
.progress-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.progress-bar {
  flex: 1;
  height: 8px;
  background: #0d0d1a;
  border: 2px solid var(--border-dim);
  border-radius: 4px;
  overflow: hidden;
}

.progress-label {
  font-family: var(--pixel-font);
  font-size: 0.45rem;
  color: var(--text-dim);
  white-space: nowrap;
  flex-shrink: 0;
}

.progress-inner {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.3s ease;
}

.quiz-content {
  text-align: left;
}

.question-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.q-num {
  font-family: var(--pixel-font);
  font-size: 0.6rem;
  color: var(--yellow);
}

.btn-prev {
  font-family: var(--pixel-font);
  font-size: 0.5rem;
  padding: 0.4rem 0.75rem;
  border: 2px solid var(--border-dim);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  letter-spacing: 0.1em;
  transition: all 0.15s;
}

.btn-prev:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.dialog-box {
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid var(--border-dim);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.question-text {
  font-size: 1.125rem;
  line-height: 1.7;
  font-weight: 700;
}

.options {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.option-btn {
  padding: 1rem;
  background: rgba(167, 139, 250, 0.05);
  border: 2px solid var(--border-dim);
  color: var(--text-dim);
  text-align: left;
  cursor: pointer;
  font-family: var(--body-font);
  font-size: 1.025rem;
  transition: all 0.2s;
}

.option-btn:hover {
  background: rgba(167, 139, 250, 0.15);
  border-color: var(--primary);
  color: var(--text);
  transform: translateX(5px);
}

.option-btn.selected {
  background: rgba(167, 139, 250, 0.35);
  border-color: var(--primary);
  color: var(--text);
  animation: optionPop 0.2s ease;
}

@keyframes optionPop {
  0%   { transform: translateX(5px) scale(1); }
  50%  { transform: translateX(5px) scale(1.02); }
  100% { transform: translateX(5px) scale(1); }
}

/* ═══ Result Screen ═══ */
.result-card {
  text-align: center;
}

.result-label {
  font-family: var(--pixel-font);
  font-size: 0.5rem;
  color: var(--yellow);
  letter-spacing: 0.2em;
  margin-bottom: 1rem;
}

.result-title-box h2 {
  font-size: 1.8rem;
  color: var(--primary);
  margin-bottom: 0.5rem;
  text-shadow: 2px 2px 0 var(--border-dim);
}

.tagline {
  font-size: 0.85rem;
  color: var(--pink);
  font-style: italic;
  margin-bottom: 1.5rem;
}

.stats-section {
  margin: 1.5rem 0;
  text-align: left;
}

.stats-label {
  font-family: var(--pixel-font);
  font-size: 0.65rem;
  color: var(--yellow);
  margin-bottom: 0.5rem;
}

.typical-text {
  font-size: 0.8rem;
  color: var(--text-dim);
  line-height: 1.6;
}

.apps-section {
  margin-bottom: 1.5rem;
  text-align: left;
}

.apps-label {
  font-family: var(--pixel-font);
  font-size: 0.65rem;
  color: var(--accent);
  margin-bottom: 0.75rem;
}

.app-rec {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.app-icon-wrap {
  position: relative;
  flex-shrink: 0;
}

.app-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: block;
  border: 2px solid var(--border-dim);
  background: #fff;
  object-fit: cover;
}

.app-icon-wrap:hover::after {
  content: attr(data-name);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--card-bg);
  border: 1px solid var(--border-dim);
  color: var(--text);
  font-size: 0.7rem;
  padding: 3px 8px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 10;
}

.app-text {
  flex: 1;
  min-width: 0;
}

.app-rec strong {
  display: block;
  font-size: 0.95rem;
  color: var(--primary);
}

.app-rec span {
  font-size: 0.8rem;
  color: var(--text-dim);
  line-height: 1.5;
}

.result-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 2rem;
}

#btn-save {
  background: var(--pink);
  border-color: #ff4d8d;
  color: #fff;
}

#btn-save:hover {
  background: #ff4d8d;
}

/* ═══ Mobile tweaks ═══ */
@media (max-width: 380px) {
  .pixel-box {
    padding: 1.25rem 1rem;
  }
  .result-actions {
    flex-direction: column;
  }
}

/* iOS safe area */
.result-actions {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* ═══ 下載快照專用深色 ═══ */
.screen.snapshot-mode .pixel-box {
  background: #1a1a2e;
  box-shadow:
    0 0 0 3px #1a1a2e,
    0 0 0 6px #4a3f6b;
}
.screen.snapshot-mode .pixel-box-inner {
  background: rgba(167, 139, 250, 0.08);
}
.screen.snapshot-mode,
.screen.snapshot-mode .tagline,
.screen.snapshot-mode .typical-text,
.screen.snapshot-mode .app-rec span {
  color: #fffffe;
}
.screen.snapshot-mode .result-title-box h2,
.screen.snapshot-mode .app-rec strong {
  color: #a78bfa;
}
.screen.snapshot-mode .result-actions {
  display: none;
}
.screen.snapshot-mode .app-icon {
  border-color: #4a3f6b;
}
