/* ==========================================================================
   Demo Portal — styles. No inline styles anywhere (strict CSP).
   ========================================================================== */

:root {
  --bg-0: #07051a;
  --bg-1: #120c35;
  --ink: #f5f3ff;
  --ink-dim: #b9b3dc;
  --ink-faint: #8a84b3;
  --violet: #7c5cff;
  --pink: #ff4fd8;
  --amber: #ffb84f;
  --gold: #ffd23f;
  --danger: #ff2e4d;
  --danger-deep: #6d0014;
  --card-bg: rgba(20, 14, 52, 0.66);
  --card-border: rgba(255, 255, 255, 0.12);
  --field-bg: rgba(255, 255, 255, 0.06);
  --field-border: rgba(255, 255, 255, 0.18);
  --focus: #ffe066;
  --radius: 18px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-display: "SF Pro Display", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

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

html {
  /* scales smoothly from phone to 1080p projector */
  font-size: clamp(15px, 0.55vw + 11px, 21px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--ink);
  background: radial-gradient(120% 90% at 50% 0%, var(--bg-1) 0%, var(--bg-0) 60%) fixed, var(--bg-0);
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

body.result-open { overflow: hidden; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

[hidden] { display: none !important; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.skip-link {
  position: absolute;
  left: 1rem; top: -4rem;
  z-index: 100;
  padding: 0.6rem 1rem;
  background: var(--focus);
  color: #1a1030;
  font-weight: 700;
  border-radius: 10px;
  text-decoration: none;
}
.skip-link:focus { top: 1rem; }

/* ---------- animated backdrop ---------- */
.backdrop {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}
.blob {
  position: absolute;
  width: 55vmax; height: 55vmax;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.45;
  mix-blend-mode: screen;
}
.blob-a { background: radial-gradient(circle, var(--violet), transparent 65%); top: -20vmax; left: -15vmax; animation: drift-a 22s ease-in-out infinite alternate; }
.blob-b { background: radial-gradient(circle, var(--pink), transparent 65%); bottom: -25vmax; right: -18vmax; animation: drift-b 26s ease-in-out infinite alternate; }
.blob-c { background: radial-gradient(circle, #2fd5ff, transparent 65%); top: 30%; left: 45%; width: 35vmax; height: 35vmax; opacity: 0.25; animation: drift-c 30s ease-in-out infinite alternate; }

@keyframes drift-a { to { transform: translate(18vw, 14vh) scale(1.15); } }
@keyframes drift-b { to { transform: translate(-16vw, -12vh) scale(1.1); } }
@keyframes drift-c { to { transform: translate(-30vw, 10vh) scale(0.8); } }

.grid-floor {
  position: absolute;
  left: -50%; right: -50%;
  bottom: -10vh;
  height: 55vh;
  background-image:
    linear-gradient(rgba(124, 92, 255, 0.35) 1px, transparent 1px),
    linear-gradient(90deg, rgba(124, 92, 255, 0.35) 1px, transparent 1px);
  background-size: 60px 60px;
  transform: perspective(500px) rotateX(62deg);
  transform-origin: 50% 100%;
  mask-image: linear-gradient(to top, #000 10%, transparent 85%);
  -webkit-mask-image: linear-gradient(to top, #000 10%, transparent 85%);
  animation: grid-scroll 3.5s linear infinite;
}
@keyframes grid-scroll { to { background-position: 0 60px, 0 0; } }

/* ---------- demo banner ---------- */
.demo-banner {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.65rem 1rem;
  font-size: 0.95rem;
  text-align: center;
  color: #1f1300;
  background: repeating-linear-gradient(-45deg, #ffc93c 0 22px, #ffbe1a 22px 44px);
  border-bottom: 2px solid rgba(0, 0, 0, 0.25);
  box-shadow: 0 4px 24px rgba(255, 190, 26, 0.25);
}
.demo-banner strong { font-weight: 800; letter-spacing: 0.01em; }
.demo-banner-icon { width: 1.3em; height: 1.3em; flex: none; }

/* ---------- login ---------- */
.login-view {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  min-height: calc(100vh - 3rem);
  min-height: calc(100dvh - 3rem);
  padding: clamp(1rem, 4vw, 3rem) 1rem 3rem;
}

.card {
  width: min(100%, 27rem);
  padding: clamp(1.5rem, 4vw, 2.5rem);
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: calc(var(--radius) + 6px);
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(124, 92, 255, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  animation: card-in 700ms cubic-bezier(.2, .9, .25, 1.15) both;
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.brand-mark { width: 2.75rem; height: 2.75rem; flex: none; filter: drop-shadow(0 6px 16px rgba(255, 79, 216, 0.4)); }
.brand-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  background: linear-gradient(90deg, #fff, #d9ccff 60%, #ffc6f1);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.card-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3vw + 0.6rem, 2.1rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.card-sub { margin: 0.35rem 0 1.5rem; color: var(--ink-dim); }

.login-form { display: grid; gap: 1.1rem; }

.field { display: grid; gap: 0.4rem; }
.field label { font-weight: 650; font-size: 0.95rem; }

.field input {
  width: 100%;
  font: inherit;
  font-size: 1.05rem;
  color: var(--ink);
  background: var(--field-bg);
  border: 1.5px solid var(--field-border);
  border-radius: 12px;
  padding: 0.8rem 0.95rem;
  min-height: 3rem;
  transition: border-color 160ms, box-shadow 160ms, background 160ms;
}
.field input:hover { border-color: rgba(255, 255, 255, 0.32); }
.field input:focus {
  outline: none;
  border-color: var(--violet);
  background: rgba(124, 92, 255, 0.1);
  box-shadow: 0 0 0 4px rgba(124, 92, 255, 0.35);
}
.field input:focus-visible { outline: none; }
.field input[aria-invalid="true"] { border-color: var(--danger); }

.password-wrap { position: relative; }
.password-wrap input { padding-right: 5rem; }
.reveal-btn {
  position: absolute;
  right: 0.4rem; top: 50%;
  transform: translateY(-50%);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink-dim);
  background: transparent;
  border: 0;
  border-radius: 8px;
  padding: 0.45rem 0.7rem;
  min-height: 2.2rem;
  cursor: pointer;
}
.reveal-btn:hover { color: var(--ink); background: rgba(255, 255, 255, 0.08); }

.form-error {
  margin: 0;
  padding: 0.7rem 0.9rem;
  border-radius: 12px;
  background: rgba(255, 46, 77, 0.14);
  border: 1px solid rgba(255, 46, 77, 0.5);
  color: #ffd2d9;
  font-weight: 600;
  animation: nudge 360ms ease;
}
@keyframes nudge {
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.card-foot { margin: 1.4rem 0 0; font-size: 0.85rem; color: var(--ink-faint); text-align: center; }

/* ---------- buttons ---------- */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  min-height: 3.1rem;
  padding: 0.8rem 1.6rem;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 200ms ease, filter 200ms ease;
}
.btn:active { transform: translateY(1px) scale(0.99); }

.btn-primary {
  width: 100%;
  margin-top: 0.3rem;
  color: #fff;
  background: linear-gradient(95deg, var(--violet), var(--pink) 60%, var(--amber));
  background-size: 200% 100%;
  box-shadow: 0 10px 30px rgba(255, 79, 216, 0.35);
  animation: sheen 6s ease-in-out infinite;
}
.btn-primary:hover { filter: brightness(1.08); box-shadow: 0 14px 36px rgba(255, 79, 216, 0.5); }
@keyframes sheen { 50% { background-position: 100% 0; } }

.btn[disabled] { cursor: progress; filter: saturate(0.7) brightness(0.9); }

.btn-spinner {
  display: none;
  width: 1.15em; height: 1.15em;
  border: 3px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.btn.is-loading .btn-spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.btn-party {
  color: #2a1400;
  background: linear-gradient(180deg, #fff09a, var(--gold) 45%, #ff9f1a);
  box-shadow: 0 10px 34px rgba(255, 190, 40, 0.5), inset 0 -3px 0 rgba(0, 0, 0, 0.15);
}
.btn-party:hover { filter: brightness(1.06); }

.btn-danger {
  color: #fff;
  background: linear-gradient(180deg, #ff4d64, #c1001c);
  box-shadow: 0 10px 34px rgba(255, 0, 40, 0.45), inset 0 -3px 0 rgba(0, 0, 0, 0.25);
}
.btn-danger:hover { filter: brightness(1.1); }

.result .btn { margin-top: 1.8rem; min-width: 12rem; font-size: 1.15rem; }

/* ---------- result overlays (shared) ---------- */
.result {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  overflow: hidden auto;
  text-align: center;
}
.result-inner {
  position: relative;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 64rem;
}
.result-title {
  margin: 0.6rem 0 0;
  font-family: var(--font-display);
  font-weight: 900;
  line-height: 1.02;
  letter-spacing: -0.02em;
  outline: none;
}
.result-sub {
  margin: 0.9rem 0 0;
  font-size: clamp(1rem, 1vw + 0.7rem, 1.35rem);
  color: var(--ink-dim);
}

/* ---------- SUCCESS ---------- */
.result-success {
  background:
    radial-gradient(circle at 50% 40%, rgba(255, 210, 63, 0.35), transparent 55%),
    linear-gradient(160deg, #3b0fa8 0%, #b1128a 55%, #ff7a1a 100%);
  animation: fade-in 300ms ease both;
}
@keyframes fade-in { from { opacity: 0; } }

.confetti {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 4;
  pointer-events: none;
}

.rays {
  position: absolute;
  left: 50%; top: 42%;
  width: 180vmax; height: 180vmax;
  margin: -90vmax 0 0 -90vmax;
  z-index: 1;
  background: repeating-conic-gradient(from 0deg, rgba(255, 255, 255, 0.13) 0deg 9deg, transparent 9deg 22.5deg);
  mask-image: radial-gradient(circle, #000 0%, transparent 55%);
  -webkit-mask-image: radial-gradient(circle, #000 0%, transparent 55%);
  animation: rays-spin 24s linear infinite;
}
@keyframes rays-spin { to { transform: rotate(360deg); } }

.trophy {
  width: clamp(10rem, 26vmin, 20rem);
  height: auto;
  overflow: visible;
  filter: drop-shadow(0 18px 40px rgba(255, 200, 40, 0.55));
  animation: trophy-in 900ms cubic-bezier(.18, 1.6, .4, 1) both, trophy-float 3s ease-in-out 900ms infinite;
  transform-origin: 50% 100%;
}
@keyframes trophy-in {
  0%   { transform: translateY(60vh) scale(0.3) rotate(-25deg); opacity: 0; }
  60%  { opacity: 1; }
  100% { transform: none; }
}
@keyframes trophy-float {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50%      { transform: translateY(-12px) rotate(2deg); }
}
.shine { animation: shine 2.6s ease-in-out 1s infinite; }
@keyframes shine {
  0%        { transform: translateX(-80px) rotate(18deg); }
  60%, 100% { transform: translateX(200px) rotate(18deg); }
}
.trophy-star { transform-box: fill-box; transform-origin: center; animation: star-pulse 1.6s ease-in-out infinite; }
@keyframes star-pulse { 50% { transform: scale(1.12); } }
.sparkle { transform-box: fill-box; transform-origin: center; animation: twinkle 1.8s ease-in-out infinite; }
.sparkle.s2 { animation-delay: 0.45s; }
.sparkle.s3 { animation-delay: 0.9s; }
.sparkle.s4 { animation-delay: 1.35s; }
@keyframes twinkle {
  0%, 100% { transform: scale(0.3) rotate(0deg); opacity: 0.2; }
  50%      { transform: scale(1.2) rotate(45deg); opacity: 1; }
}

.success-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: clamp(2.2rem, 8vw, 6.5rem);
  color: #fff;
  text-shadow: 0 4px 0 #7a1f9c, 0 8px 0 rgba(60, 10, 90, 0.6), 0 16px 40px rgba(0, 0, 0, 0.4);
}
.yay { display: block; }
.yay .ch {
  display: inline-block;
  animation: letter-pop 700ms cubic-bezier(.2, 1.8, .4, 1) both, letter-bounce 1.6s ease-in-out infinite;
  animation-delay: calc(var(--i, 0) * 55ms + 250ms), calc(var(--i, 0) * 90ms + 1.2s);
}
.yay .sp { display: inline-block; width: 0.3em; }
@keyframes letter-pop {
  from { transform: translateY(1.2em) scale(0.2) rotate(-30deg); opacity: 0; }
  to   { transform: none; opacity: 1; }
}
@keyframes letter-bounce {
  0%, 100% { transform: translateY(0); }
  30%      { transform: translateY(-0.12em) rotate(-3deg); }
}
.success-name {
  display: block;
  max-width: 100%;
  margin-top: 0.1em;
  padding: 0 0.1em;
  font-size: 0.8em;
  overflow-wrap: anywhere;
  background: linear-gradient(90deg, #fff59a, #ffd23f, #fff, #ffd23f, #fff59a);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: none;
  filter: drop-shadow(0 4px 0 #7a1f9c) drop-shadow(0 10px 24px rgba(0, 0, 0, 0.35));
  animation: letter-pop 800ms cubic-bezier(.2, 1.6, .4, 1) 900ms both, gold-flow 2.5s linear infinite;
}
@keyframes gold-flow { to { background-position: -200% 0; } }
.result-success .result-sub { color: #ffe9fb; font-weight: 600; }

/* ---------- FAILURE ---------- */
.result-failure {
  background:
    radial-gradient(circle at 50% 38%, rgba(255, 0, 40, 0.35), transparent 55%),
    radial-gradient(circle at 50% 50%, #2a0008 0%, #0a0003 70%);
  color: #ffe5e9;
  animation: fade-in 150ms ease both, shake 600ms cubic-bezier(.36, .07, .19, .97) 150ms both;
}
@keyframes shake {
  10%, 90% { transform: translate(-2px, 1px); }
  20%, 80% { transform: translate(5px, -2px); }
  30%, 50%, 70% { transform: translate(-10px, 3px) rotate(-0.4deg); }
  40%, 60% { transform: translate(10px, -3px) rotate(0.4deg); }
}

.scanlines {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.28) 0 2px, transparent 2px 4px);
  animation: scan-flicker 4s steps(1) infinite;
}
@keyframes scan-flicker { 0%, 100% { opacity: 0.7; } 47% { opacity: 1; } 48% { opacity: 0.5; } 50% { opacity: 0.85; } }

.alarm {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  box-shadow: inset 0 0 18vmin rgba(255, 0, 30, 0.75);
  animation: alarm 1.6s ease-in-out infinite;
}
@keyframes alarm { 50% { opacity: 0.25; } }

.skull {
  width: clamp(11rem, 32vmin, 22rem);
  height: auto;
  overflow: visible;
  filter: drop-shadow(0 0 28px rgba(255, 30, 60, 0.55)) drop-shadow(0 16px 30px rgba(0, 0, 0, 0.8));
  animation: skull-slam 700ms cubic-bezier(.2, 1.4, .4, 1) both, skull-hover 3.2s ease-in-out 700ms infinite;
}
@keyframes skull-slam {
  0%   { transform: scale(3) rotate(-12deg); opacity: 0; filter: blur(10px); }
  55%  { opacity: 1; filter: none; }
  100% { transform: none; }
}
@keyframes skull-hover {
  0%, 100% { transform: translateY(0) rotate(-1.5deg); }
  50%      { transform: translateY(-10px) rotate(1.5deg); }
}
.skull-jaw { animation: chatter 0.34s ease-in-out 0.8s 6 alternate; }
@keyframes chatter { to { transform: translateY(7px); } }
.skull .eye { transform-box: fill-box; transform-origin: center; animation: eye-glow 1.2s ease-in-out infinite; }
@keyframes eye-glow {
  0%, 100% { opacity: 0.55; transform: scale(0.8); }
  50%      { opacity: 1; transform: scale(1.1); }
}
.bones { transform-origin: 120px 208px; animation: bones-in 700ms cubic-bezier(.2, 1.4, .4, 1) 150ms both; }
@keyframes bones-in { from { transform: scale(0.4) rotate(90deg); opacity: 0; } }

.glitch {
  position: relative;
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 9vw, 7rem);
  letter-spacing: 0.04em;
  color: #fff;
  text-shadow: 0 0 18px rgba(255, 30, 60, 0.9), 0 0 50px rgba(255, 0, 40, 0.6);
  animation: glitch-skew 2.5s steps(1) infinite;
}
.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.glitch::before {
  color: #ff1744;
  text-shadow: -3px 0 #ff1744;
  transform: translateX(-4px);
  mix-blend-mode: screen;
  animation: glitch-a 1.9s steps(1) infinite;
}
.glitch::after {
  color: #00e5ff;
  text-shadow: 3px 0 #00e5ff;
  transform: translateX(4px);
  mix-blend-mode: screen;
  animation: glitch-b 2.3s steps(1) infinite;
}
@keyframes glitch-a {
  0%   { clip-path: inset(0 0 85% 0); }
  15%  { clip-path: inset(40% 0 35% 0); transform: translateX(-8px); }
  30%  { clip-path: inset(75% 0 5% 0); }
  45%  { clip-path: inset(10% 0 70% 0); transform: translateX(6px); }
  60%  { clip-path: inset(55% 0 25% 0); }
  75%  { clip-path: inset(0 0 100% 0); }
  100% { clip-path: inset(0 0 100% 0); }
}
@keyframes glitch-b {
  0%   { clip-path: inset(80% 0 0 0); }
  20%  { clip-path: inset(20% 0 60% 0); transform: translateX(8px); }
  40%  { clip-path: inset(60% 0 20% 0); }
  55%  { clip-path: inset(5% 0 80% 0); transform: translateX(-5px); }
  70%  { clip-path: inset(100% 0 0 0); }
  100% { clip-path: inset(100% 0 0 0); }
}
@keyframes glitch-skew {
  0%, 100% { transform: none; }
  92% { transform: skewX(-8deg) translateX(3px); }
  94% { transform: skewX(6deg); }
  96% { transform: none; }
}

.failure-sub {
  max-width: 36rem;
  color: #ffb3bf;
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.failure-sub::before { content: "> "; color: var(--danger); }

.noscript {
  position: relative;
  z-index: 10;
  text-align: center;
  padding: 1rem;
  background: var(--danger-deep);
}

/* ---------- responsive ---------- */
@media (max-width: 480px) {
  .demo-banner { font-size: 0.85rem; justify-content: flex-start; text-align: left; }
  .result .btn { width: 100%; }
  .blob { filter: blur(50px); }
}

@media (max-height: 560px) {
  .trophy, .skull { width: clamp(7rem, 30vmin, 12rem); }
}

/* ---------- reduced motion: keep the drama, lose the movement ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0ms !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
  .blob, .grid-floor, .rays, .scanlines, .alarm, .shine,
  .glitch, .glitch::before, .glitch::after, .btn-primary { animation: none !important; }
  .glitch::before, .glitch::after { display: none; }
  .confetti { display: none; }
}
