:root {
  --bg: #0a0a1a;
  --surface: rgba(255, 255, 255, 0.05);
  --surface-solid: #111;
  --border: rgba(255, 255, 255, 0.1);
  --accent: #00d4ff;
  --accent-hover: #00e5ff;
  --accent-bg: rgba(0, 212, 255, 0.15);
  --accent-border: rgba(0, 212, 255, 0.3);
  --text: #e0e0e0;
  --text-muted: #888;
  --text-dim: #bbb;
  --success: #00ffcc;
  --warn: #ffcc66;
  --danger: #ff4d7d;
  --radius: 20px;
  --radius-sm: 12px;
  --pad: 30px;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---- Layout ---- */
.container {
  width: 100%;
  max-width: 500px;
  padding: 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--pad) 30px;
  text-align: center;
  backdrop-filter: blur(10px);
}

h1 {
  font-size: 1.6rem;
  margin: 20px 0 10px;
  color: #fff;
  font-weight: 700;
}

.sub-text {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 20px;
}

/* ---- Buttons ---- */
button {
  margin-top: 15px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  padding: 12px 30px;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 44px;
}

button:hover {
  background: var(--accent-hover);
}

button:disabled {
  opacity: 0.4;
  cursor: default;
}

/* ---- QR Box (index.html) ---- */
#qrBox {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 180px;
}

#qrBox img {
  border-radius: var(--radius-sm);
}

/* ---- Scanner (scan.html — fullscreen) ---- */
body.no-scroll {
  overflow: hidden;
}

.scanner-area {
  position: fixed;
  inset: 0;
  background: var(--surface-solid);
  overflow: hidden;
}

.scanner-area video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* AR overlay (three.js canvas transparan) */
#overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
}

.scanner-area.ar-active .scanner-frame {
  visibility: hidden;
}

/* Scanner frame (satu-satunya isyarat visual di idle) */
.scanner-frame {
  position: absolute;
  inset: 15%;
  border: 2px solid var(--accent-border);
  border-radius: var(--radius-sm);
  pointer-events: none;
  animation: scanPulse 2s ease-in-out infinite;
}

.scanner-frame::before,
.scanner-frame::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border-color: var(--accent);
  border-style: solid;
}

.scanner-frame::before {
  top: -2px;
  left: -2px;
  border-width: 3px 0 0 3px;
  border-radius: 4px 0 0 0;
}

.scanner-frame::after {
  bottom: -2px;
  right: -2px;
  border-width: 0 3px 3px 0;
  border-radius: 0 0 4px 0;
}

@keyframes scanPulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

/* ---- Status Badge ---- */
.scan-feedback {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  padding: 8px 18px;
  border-radius: 30px;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  background: rgba(10, 10, 26, 0.85);
  color: var(--accent);
  border: 1px solid var(--accent-border);
  backdrop-filter: blur(6px);
  display: none;
  pointer-events: none;
}

.scan-feedback.info {
  display: block;
}

.scan-feedback.success {
  display: block;
  color: var(--bg);
  background: var(--success);
  border-color: var(--success);
}

.scan-feedback.warn {
  display: block;
  color: var(--warn);
}

/* ---- Tap Layer ---- */
.tap-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* ---- Pet HUD (inside scanner-area) ---- */
.pet-hud {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 24px;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.pet-hud button {
  pointer-events: auto;
  margin-top: 0;
  padding: 12px 20px;
  font-size: 1.3rem;
  min-height: 44px;
  min-width: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pet-hint {
  display: flex;
  gap: 8px;
  background: rgba(10, 10, 26, 0.75);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 1rem;
  color: var(--text-dim);
  border: 1px solid var(--border);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.pet-hint.visible {
  opacity: 1;
}

/* ---- Error / Camera States ---- */
.camera-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: var(--bg);
  padding: 40px;
  text-align: center;
}

.camera-screen .cam-icon {
  font-size: 3rem;
  margin-bottom: 8px;
}

.camera-screen .cam-msg {
  font-size: 1rem;
  color: var(--text);
  font-weight: 600;
}

.camera-screen .cam-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.camera-screen button {
  margin-top: 8px;
}

/* ---- Onboarding (first-run) ---- */
.onboarding {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 26, 0.95);
  backdrop-filter: blur(12px);
}

.onboarding-track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  width: 100%;
  height: 100%;
  scrollbar-width: none;
}

.onboarding-track::-webkit-scrollbar {
  display: none;
}

.onboarding-card {
  flex: 0 0 100%;
  scroll-snap-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 40px;
  text-align: center;
}

.onboarding-card .ob-icon {
  font-size: 4rem;
}

.onboarding-card .ob-text {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
}

.onboarding-dots {
  position: absolute;
  bottom: 40px;
  display: flex;
  gap: 8px;
}

.onboarding-dots .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background 0.3s;
}

.onboarding-dots .dot.active {
  background: var(--accent);
  width: 24px;
  border-radius: 4px;
}

/* ---- Fallback (legacy, kept for compat) ---- */
.fallback {
  margin-top: 15px;
  font-size: 0.85rem;
}

.fallback a {
  color: var(--accent);
  text-decoration: underline;
}

/* ---- Canvas fullscreen (animation.html) ---- */
#canvas3d {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.overlay .card {
  pointer-events: auto;
}
