*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --lavender: rgba(184, 164, 255, 0.18);
  --orange: rgba(255, 202, 143, 0.12);
  --bg-color: #1a1a1d;
  --card-bg: rgba(36, 36, 40, 0.65);
  --card-border: rgba(255, 255, 255, 0.12);
  --text-primary: #f0e8ff;
  --text-secondary: #d1c3e8;
  --btn-bg: linear-gradient(135deg, #e8c7ff, #c5a6ff);
  --btn-text: #120a1b;
  --btn-shadow: 0 12px 30px rgba(197, 166, 255, 0.45);
  --btn-hover-shadow: 0 16px 40px rgba(197, 166, 255, 0.55);
  --tg-top-inset: 0px;
}

@keyframes liquid-move-1 {
  0% { transform: translate(0, 0); }
  50% { transform: translate(40px, 60px) scale(1.1); }
  100% { transform: translate(0, 0); }
}

@keyframes liquid-move-2 {
  0% { transform: translate(0, 0); }
  50% { transform: translate(-50px, -70px) scale(0.9); }
  100% { transform: translate(0, 0); }
}

@keyframes button-pop {
  0% { transform: translateY(-1px) scale(1); }
  50% { transform: translateY(-3px) scale(1.05); }
  100% { transform: translateY(-1px) scale(1); }
}

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  background-color: var(--bg-color);
  background-image: radial-gradient(circle at 50% 50%, rgba(100, 100, 110, 0.12) 0%, transparent 70%);
  background-attachment: fixed;
  color: var(--text-primary);
  position: relative;
  overflow-x: hidden;
  font-size: 16px;
  line-height: 1.5;
  padding-top: var(--tg-top-inset);
}

#snow-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.85;
}

.liquid-glow {
  position: fixed;
  pointer-events: none;
  z-index: -1;
  filter: blur(150px);
  opacity: 0.8;
  will-change: transform;
}

.liquid-glow.lavender {
  width: 900px;
  height: 900px;
  border-radius: 50%;
  background: var(--lavender);
  top: -250px;
  left: -250px;
  animation: liquid-move-1 30s ease-in-out infinite;
}

.liquid-glow.orange {
  width: 700px;
  height: 700px;
  border-radius: 50%;
  background: var(--orange);
  bottom: -250px;
  right: -250px;
  animation: liquid-move-2 35s ease-in-out infinite;
}

.page-shell {
  position: relative;
  max-width: 960px;
  margin: 0 auto;
  padding: 1.75rem 1rem 3rem;
  z-index: 1;
}

.device-picker,
.instruction-card {
  position: relative;
  z-index: 1;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 1.5rem;
  padding: 1.5rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  overflow: hidden;
  transition: all 0.3s ease-in-out;
}

.device-picker {
  margin-bottom: 1rem;
}

.instruction-card {
  display: none;
  opacity: 0;
}

.instruction-card.active {
  display: block;
  opacity: 1;
  animation: card-fade 0.6s ease, card-rise 0.65s ease;
}

.instruction-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.08), transparent 50%);
  pointer-events: none;
}

.picker-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.picker-detected {
  font-weight: 700;
  color: var(--text-primary);
}

.picker-buttons {
  margin-top: 0.75rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 0.75rem;
  position: relative;
  isolation: isolate;
}

.picker-buttons button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease;
  position: relative;
  z-index: 1;
}

.picker-buttons button .icon {
  width: 20px;
  height: 20px;
  filter: grayscale(1) brightness(1.5);
  opacity: 0.7;
  transition: all 0.2s ease;
}

.picker-buttons button:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.15);
  box-shadow: 0 8px 20px rgba(197, 166, 255, 0.2);
}

.picker-buttons button.active {
  background: var(--btn-bg);
  color: var(--btn-text);
  border-color: transparent;
  box-shadow: var(--btn-shadow);
  transform: translateY(-1px);
  animation: button-pop 0.5s ease-in-out;
}

.picker-buttons button.active .icon {
  filter: none;
  opacity: 1;
}

.picker-blob {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  border-radius: 12px;
  background:
    radial-gradient(120% 120% at 25% 25%, rgba(232, 199, 255, 0.7), transparent 65%),
    radial-gradient(120% 120% at 75% 75%, rgba(255, 202, 143, 0.6), transparent 70%),
    rgba(197, 166, 255, 0.22);
  filter: blur(10px);
  mix-blend-mode: screen;
  opacity: 0.95;
  transform: translate(0, 0);
  transition: transform 0.55s cubic-bezier(0.2, 0.8, 0.2, 1.1), width 0.55s ease, height 0.55s ease, filter 0.55s ease;
  pointer-events: none;
  z-index: 0;
}

.picker-buttons:hover .picker-blob {
  filter: blur(14px);
}

.card-title {
  margin: 0 0 1rem;
  font-size: 1.375rem;
  font-weight: 700;
  color: #fff;
}

.instruction-card ol, .instruction-card ul {
  margin: 0 0 0.75rem 1.25rem;
  color: var(--text-secondary);
  line-height: 1.6;
  padding: 0;
}

.instruction-card li {
  margin-bottom: 0.5rem;
}

.step-image {
  width: 100%;
  max-width: 520px;
  border-radius: 0.875rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
  display: block;
  margin: 0.75rem 0;
  cursor: zoom-in;
}

.note, .alert, .tip {
  margin: 1rem 0;
  border-radius: 0.75rem;
  padding: 0.875rem 1rem;
  font-size: 0.9375rem;
  line-height: 1.5;
}

.note {
  background: rgba(184, 164, 255, 0.1);
  border: 1px solid rgba(184, 164, 255, 0.2);
  color: #e3d9f8;
}

.alert {
  background: rgba(255, 200, 120, 0.1);
  border: 1px solid rgba(255, 200, 120, 0.25);
  color: #fdeccf;
}

.alert p { margin: 0; }
.alert p:not(:last-child) { margin-bottom: 0.375rem; }
.alert a { color: #fdeccf; font-weight: 600; }

.tip p { margin: 0; }

.actions {
  display: flex;
  gap: 0.75rem;
  margin: 1rem 0;
  flex-wrap: wrap;
}

.solid {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.75rem 1.125rem;
  border-radius: 0.75rem;
  border: none;
  font-weight: 700;
  background: var(--btn-bg);
  color: var(--btn-text);
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.solid[aria-disabled="true"] {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

.solid:not([aria-disabled="true"]):hover {
  transform: translateY(-3px);
  box-shadow: var(--btn-hover-shadow);
}

.step {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--card-border);
}

.step:first-of-type {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.step-title {
  margin: 0 0 0.75rem;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
}

.code-block {
  position: relative;
  background: rgba(0,0,0,0.2);
  border-radius: 6px;
  padding: 8px 12px;
  user-select: all;
}

.copy-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-secondary);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.copy-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.copy-btn.copied {
  background: #86efac; /* Tailwind green-300 */
  color: #000;
}

/* Deeplink Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 1.5rem;
  padding: 1.5rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  max-width: 400px;
  text-align: center;
  transform: translateY(20px);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.modal-overlay.active .modal-content {
  transform: translateY(0);
  opacity: 1;
}

.modal-content h3 {
  margin-top: 0;
  font-size: 1.25rem;
  color: var(--text-primary);
}

.modal-content p {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.modal-content .solid {
  margin-top: 0;
}


.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 1rem;
}

.lightbox.open {
  display: flex;
}

.lightbox img {
  max-width: 96vw;
  max-height: 96vh;
  border-radius: 1rem;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6);
}

@keyframes card-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes card-rise {
  from { transform: translateY(12px) scale(0.99); }
  to { transform: translateY(0) scale(1); }
}

@media (max-width: 640px) {
  body {
    font-size: 15px;
  }
  .page-shell {
    padding: 1.5rem 0.75rem 2.5rem;
  }
  .instruction-card, .device-picker {
    padding: 1rem;
    border-radius: 1.25rem;
  }
  .card-title {
    font-size: 1.25rem;
  }
  .step-title {
    font-size: 1rem;
  }
  .picker-buttons {
    grid-template-columns: 1fr;
  }
  .solid {
    padding: 0.625rem 1rem;
    font-size: 0.9375rem;
  }
}
