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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Segoe UI', sans-serif;
  background: #0d0d0d;
}

/* ─── PHASES ─────────────────────────────────────────── */

#phase-scanner,
#phase-terminal,
#phase-error,
#phase-reveal {
  position: fixed;
  inset: 0;
  display: none;
}

#phase-scanner.active  { display: flex; flex-direction: column; align-items: center; justify-content: center; }
#phase-terminal.active { display: flex; flex-direction: column; }
#phase-error.active    { display: flex; align-items: center; justify-content: center; }
#phase-reveal.active   { display: flex; align-items: center; justify-content: center; }

/* ─── PHASE 0: QR SCANNER ────────────────────────────── */

#phase-scanner {
  background: #0d0d0d;
  font-family: 'Segoe UI', sans-serif;
  color: #ffffff;
  padding: 32px 24px;
  text-align: center;
  gap: 18px;
}

#scanner-title {
  font-size: clamp(20px, 5vw, 28px);
  font-weight: 700;
  color: #ffffff;
}

#scanner-sub {
  font-size: clamp(13px, 3vw, 15px);
  color: #cbd5e1;
  max-width: 300px;
  line-height: 1.6;
}

#scanner-frame {
  position: relative;
  width: min(280px, 80vw);
  height: min(280px, 80vw);
  background: #111;
  border: 2px solid #ffffff;
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

#scanner-placeholder {
  font-size: 52px;
  opacity: 0.3;
}

#scanner-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

#scanner-video.active { display: block; }

#scanner-corners { position: absolute; inset: 0; pointer-events: none; }

.sc-corner {
  position: absolute;
  width: 24px;
  height: 24px;
  border-color: #00ff41;
  border-style: solid;
}

.sc-tl { top: 0;    left: 0;  border-width: 3px 0 0 3px; border-color: #ffffff; }
.sc-tr { top: 0;    right: 0; border-width: 3px 3px 0 0; border-color: #ffffff; }
.sc-bl { bottom: 0; left: 0;  border-width: 0 0 3px 3px; border-color: #ffffff; }
.sc-br { bottom: 0; right: 0; border-width: 0 3px 3px 0; border-color: #ffffff; }

#scanner-line {
  position: absolute;
  left: 0; right: 0;
  height: 2px;
  background: #ffffff;
  box-shadow: 0 0 8px #ffffff;
  display: none;
  animation: scan-line 2s linear infinite;
}

#scanner-line.active { display: block; }

@keyframes scan-line {
  0%   { top: 0; }
  100% { top: 100%; }
}

#scanner-detected {
  display: none;
  font-size: clamp(16px, 4vw, 20px);
  font-weight: 700;
  color: #00ff41;
}

#scanner-error {
  display: none;
  font-size: clamp(13px, 3vw, 15px);
  color: #ef4444;
  line-height: 1.6;
  max-width: 260px;
  text-align: center;
}

#scanner-btn {
  background: #ffffff;
  color: #0d0d0d;
  border: none;
  padding: 14px 32px;
  font-family: 'Segoe UI', sans-serif;
  font-size: 16px;
  font-weight: 700;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

#scanner-btn:hover { background: #e2e8f0; }

/* ─── PHASE 1: TERMINAL ──────────────────────────────── */

#phase-terminal {
  background: #0d0d0d;
  color: #00ff41;
  font-family: 'Courier New', Courier, monospace;
  font-size: clamp(13px, 2.2vw, 16px);
  padding: 0;
}

#terminal-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #1e1e1e;
  padding: 8px 14px;
  flex-shrink: 0;
}

.bar-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}
.bar-dot.red    { background: #ff5f57; }
.bar-dot.yellow { background: #febc2e; }
.bar-dot.green  { background: #28c840; }

.bar-title {
  color: #888;
  font-size: 12px;
  margin-left: 8px;
  font-family: 'Courier New', Courier, monospace;
}

#terminal-output {
  flex: 1;
  padding: 20px;
  overflow: hidden;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-all;
}

#terminal-cursor {
  display: inline-block;
  width: 10px;
  height: 1.2em;
  background: #00ff41;
  margin-left: 20px;
  margin-bottom: 20px;
  animation: blink 0.7s step-end infinite;
  flex-shrink: 0;
}

@keyframes blink {
  50% { opacity: 0; }
}

.line-prompt  { color: #00ff41; }
.line-info    { color: #aaffaa; }
.line-warn    { color: #ffcc00; }
.line-danger  { color: #ff4444; }
.line-success { color: #00ffcc; }
.line-dim     { color: #555; }

/* progress bar */
.progress-wrap { color: #00ff41; }

/* ─── PHASE 2: ERROR ─────────────────────────────────── */

#phase-error {
  background: #cc0000;
}

#error-content {
  text-align: center;
  color: #fff;
  animation: shake 0.4s ease;
}

#error-icon {
  font-size: clamp(60px, 15vw, 120px);
  font-weight: 900;
  line-height: 1;
}

#error-text {
  font-size: clamp(28px, 7vw, 64px);
  font-weight: 900;
  letter-spacing: 0.15em;
  margin-top: 10px;
  font-family: 'Courier New', Courier, monospace;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-12px); }
  40%       { transform: translateX(12px); }
  60%       { transform: translateX(-8px); }
  80%       { transform: translateX(8px); }
}

/* ─── PHASE 3: REVEAL ────────────────────────────────── */

#phase-reveal {
  background: #07090f;
  overflow-y: auto;
}

#stars {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

#reveal-content {
  position: relative;
  z-index: 1;
  text-align: center;
  color: #fff;
  padding: 48px 24px;
  max-width: 560px;
  width: 100%;
  animation: fadeUp 0.8s ease both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}

#reveal-emoji {
  font-size: clamp(48px, 12vw, 72px);
  line-height: 1;
  margin-bottom: 12px;
}

#reveal-title {
  font-size: clamp(36px, 10vw, 64px);
  font-weight: 900;
  letter-spacing: 0.05em;
  color: #38bdf8;
  margin-bottom: 20px;
}

#reveal-sub {
  font-size: clamp(18px, 4vw, 22px);
  font-weight: 600;
  color: #fff;
  margin-bottom: 8px;
}

#reveal-body {
  font-size: clamp(15px, 3.5vw, 18px);
  color: #94a3b8;
  line-height: 1.7;
  margin-bottom: 28px;
}

#reveal-warning {
  font-size: clamp(15px, 3.5vw, 18px);
  font-weight: 700;
  color: #f87171;
  margin-bottom: 24px;
}

#reveal-photo-wrap {
  margin-bottom: 28px;
}

#reveal-photo-label {
  font-size: clamp(14px, 3.5vw, 17px);
  color: #94a3b8;
  margin-bottom: 12px;
}

#reveal-photo {
  width: min(220px, 60vw);
  height: min(220px, 60vw);
  object-fit: cover;
  border-radius: 50%;
  border: 3px solid #38bdf8;
  box-shadow: 0 0 24px rgba(56,189,248,0.35);
  animation: fadeUp 0.6s ease both;
}

#reveal-divider {
  width: 60px;
  height: 3px;
  background: #38bdf8;
  border-radius: 2px;
  margin: 0 auto 24px;
}

#reveal-cta-text {
  font-size: clamp(14px, 3.5vw, 17px);
  color: #cbd5e1;
  margin-bottom: 32px;
  font-style: italic;
}

#reveal-logo-link {
  display: block;
  margin-bottom: 28px;
}

#reveal-logo {
  max-width: min(280px, 70vw);
  height: auto;
  filter: drop-shadow(0 0 16px rgba(56,189,248,0.25));
  transition: filter 0.3s ease;
}

#reveal-logo:hover {
  filter: drop-shadow(0 0 24px rgba(56,189,248,0.5));
}

#reveal-btn {
  display: inline-block;
  padding: 14px 36px;
  background: #38bdf8;
  color: #07090f;
  font-weight: 700;
  font-size: clamp(15px, 3.5vw, 18px);
  border-radius: 8px;
  text-decoration: none;
  letter-spacing: 0.03em;
  transition: background 0.2s ease, transform 0.2s ease;
}

#reveal-btn:hover {
  background: #7dd3fc;
  transform: translateY(-2px);
}

