/* ==========================================================================
   LPL SCREAM CHALLENGE — KIOSK STYLES
   ========================================================================== */

@font-face {
  font-family: 'system';
}

:root {
  --navy-950: #030818;
  --navy-900: #071130;
  --navy-800: #0b1b45;
  --navy-700: #122a63;
  --blue-500: #1f7bff;
  --blue-400: #3fa0ff;
  --cyan-400: #00e5ff;
  --gold-400: #ffcc00;
  --white: #f4f8ff;
  --danger: #ff4d4d;

  --space-1: 0.4rem;
  --space-2: 0.8rem;
  --space-3: 1.4rem;
  --space-4: 2.2rem;
  --space-5: 3.2rem;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }

/* Hide un-compiled Angular templates until the app boots, so the raw {{ }} /
   mic-permission overlay never flashes on load or refresh. */
[ng-cloak] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--navy-950);
  color: var(--white);
  font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

body {
  position: relative;
  display: flex;
  flex-direction: column;
}

img { -webkit-user-drag: none; user-drag: none; pointer-events: none; }

/* ---------- background fx ---------- */
.bg-fx {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% -10%, var(--navy-800) 0%, var(--navy-950) 60%);
}

.bg-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.55;
  animation: drift 14s ease-in-out infinite alternate;
}
.bg-glow-1 {
  width: 55vmax; height: 55vmax;
  background: radial-gradient(circle, rgba(31,123,255,0.55), transparent 70%);
  top: -20vmax; left: -15vmax;
}
.bg-glow-2 {
  width: 50vmax; height: 50vmax;
  background: radial-gradient(circle, rgba(0,229,255,0.35), transparent 70%);
  bottom: -18vmax; right: -12vmax;
  animation-delay: -6s;
}
@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(3vmax, -2vmax) scale(1.08); }
}

.bg-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(63,160,255,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(63,160,255,0.06) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(ellipse at 50% 40%, black 0%, transparent 75%);
}

/* ---------- screens ---------- */
.screen {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  padding: calc(var(--space-3) + var(--safe-t)) calc(var(--space-4) + var(--safe-r)) calc(var(--space-3) + var(--safe-b)) calc(var(--space-4) + var(--safe-l));
  display: flex;
  align-items: center;
  justify-content: center;
  animation: screenIn 0.5s ease both;
}

@keyframes screenIn {
  from { opacity: 0; transform: scale(0.98); }
  to   { opacity: 1; transform: scale(1); }
}

.stage {
  width: 100%;
  height: 100%;
  max-width: 1400px;
  max-height: 1000px;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* space-evenly spreads the leftover height equally above, between and below the
     elements, so the layout stays balanced and fills the screen instead of
     bunching in the middle with big gaps top and bottom. */
  justify-content: space-evenly;
  gap: var(--space-2);
}

/* ---------- logo treatment (NO animation / color change per brief) ---------- */
.logo-wrap { display: flex; align-items: center; justify-content: center; }
.event-logo { max-width: min(46vw, 420px); max-height: 26vh; width: auto; height: auto; object-fit: contain; }
.event-logo-small { max-width: min(22vw, 190px); max-height: 12vh; width: auto; height: auto; object-fit: contain; }

/* ==========================================================================
   PAGE 1 — START
   ========================================================================== */
.stage-start { gap: var(--space-3); }
.logo-hero { margin-bottom: var(--space-2); }

.tagline {
  margin: 0;
  font-size: clamp(1.6rem, 3.6vw, 3rem);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-align: center;
  background: linear-gradient(90deg, var(--cyan-400), var(--blue-400) 55%, var(--gold-400));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 40px rgba(31,123,255,0.35);
}

.subtagline {
  margin: 0;
  max-width: 640px;
  text-align: center;
  font-size: clamp(0.95rem, 1.6vw, 1.25rem);
  color: rgba(244,248,255,0.72);
  line-height: 1.5;
}

/* ---------- buttons ---------- */
.btn {
  border: none;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--white);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
}
.btn:active { transform: scale(0.95); }

.btn-primary {
  background: linear-gradient(135deg, var(--blue-500), var(--cyan-400));
  box-shadow: 0 10px 30px rgba(31,123,255,0.45), inset 0 1px 0 rgba(255,255,255,0.25);
}
.btn-primary[disabled] {
  filter: grayscale(0.7) brightness(0.6);
  cursor: not-allowed;
  box-shadow: none;
}
.btn-primary.is-ready { filter: none; }

.btn-huge {
  padding: 1.5rem 4rem;
  font-size: clamp(1.3rem, 2.6vw, 1.9rem);
  min-height: 96px;
}
.btn-large {
  padding: 1.1rem 3rem;
  font-size: clamp(1.05rem, 2vw, 1.4rem);
  min-height: 76px;
}
.btn-icon { font-size: 1.1em; line-height: 1; }

.pulse-glow {
  animation: pulseGlow 2.1s ease-in-out infinite;
}
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 10px 30px rgba(31,123,255,0.45), 0 0 0 0 rgba(0,229,255,0.5); }
  50% { box-shadow: 0 10px 40px rgba(31,123,255,0.6), 0 0 0 16px rgba(0,229,255,0); }
}

/* ==========================================================================
   PAGE 2 — TEAM SELECT
   ========================================================================== */
.stage-select { justify-content: space-between; padding-block: var(--space-2); }

.section-title {
  margin: 0;
  font-size: clamp(1.2rem, 2.6vw, 2rem);
  font-weight: 800;
  letter-spacing: 0.1em;
  text-align: center;
  color: var(--white);
  text-shadow: 0 0 24px rgba(31,123,255,0.4);
}

.team-grid {
  flex: 1 1 auto;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: clamp(0.7rem, 1.6vw, 1.6rem);
  align-items: stretch;
  min-height: 0;
}

.team-card {
  --team-accent: #1f7bff;
  position: relative;
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
  border: 2px solid rgba(255,255,255,0.12);
  border-radius: 22px;
  padding: var(--space-3) var(--space-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  cursor: pointer;
  min-height: 0;
  min-width: 0;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.team-card:active { transform: scale(0.96); }
.team-card:hover {
  border-color: var(--team-accent);
  box-shadow: 0 12px 26px -8px var(--team-accent);
  transform: translateY(-4px);
}
.team-card.is-selected {
  border-color: var(--team-accent);
  background: linear-gradient(180deg, color-mix(in srgb, var(--team-accent) 22%, rgba(255,255,255,0.05)), rgba(255,255,255,0.03));
  box-shadow: 0 0 0 3px var(--team-accent), 0 16px 34px -10px var(--team-accent);
  animation: cardSelectPop 0.35s ease;
}
@keyframes cardSelectPop {
  0% { transform: scale(1); }
  40% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

/* fixed, uniform box so mismatched source image sizes still look balanced */
.team-card-logo-box {
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 16vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.05);
  border-radius: 16px;
  padding: 0.6rem;
  overflow: hidden;
}
.team-card-logo {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}
.team-card-name {
  font-size: clamp(0.72rem, 1.25vw, 1.05rem);
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.02em;
  color: rgba(244,248,255,0.92);
  line-height: 1.2;
}

/* ---------- shared team banner (pages 3/4/5) ---------- */
.team-banner {
  --team-accent: #1f7bff;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.5rem 1.3rem;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  border: 1.5px solid var(--team-accent);
  box-shadow: 0 0 20px -4px var(--team-accent);
  font-weight: 700;
  font-size: clamp(0.9rem, 1.6vw, 1.25rem);
}
.team-banner-logo {
  width: clamp(28px, 4vw, 42px);
  height: clamp(28px, 4vw, 42px);
  object-fit: contain;
}

/* ==========================================================================
   PAGE 3 — COUNTDOWN
   ========================================================================== */
.stage-countdown { gap: var(--space-4); }
.countdown-hint {
  margin: 0;
  letter-spacing: 0.14em;
  font-weight: 700;
  color: rgba(244,248,255,0.75);
  font-size: clamp(0.9rem, 1.6vw, 1.2rem);
}

.countdown-ring {
  position: relative;
  width: min(40vmin, 320px);
  height: min(40vmin, 320px);
  display: flex;
  align-items: center;
  justify-content: center;
}
.countdown-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.countdown-track {
  fill: none;
  stroke: rgba(255,255,255,0.1);
  stroke-width: 10;
}
.countdown-progress {
  fill: none;
  stroke: var(--cyan-400);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 565.48;
  stroke-dashoffset: 0;
  animation-name: ringDrain;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}
@keyframes ringDrain {
  from { stroke-dashoffset: 0; }
  to { stroke-dashoffset: 565.48; }
}
.countdown-number {
  position: absolute;
  font-size: clamp(3.5rem, 9vw, 6.5rem);
  font-weight: 900;
  color: var(--white);
  text-shadow: 0 0 30px rgba(0,229,255,0.6);
  transform: scale(0.7);
  opacity: 0;
}
.countdown-number.pop {
  animation: numberPop 0.85s cubic-bezier(.2,1.4,.4,1) both;
}
@keyframes numberPop {
  0% { transform: scale(0.5); opacity: 0; }
  30% { transform: scale(1.15); opacity: 1; }
  60% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* ==========================================================================
   PAGE 4 — RECORD
   ========================================================================== */
.stage-record { gap: var(--space-3); }

.record-cta {
  margin: 0;
  text-align: center;
  font-size: clamp(1.3rem, 3.2vw, 2.4rem);
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--white);
  transition: text-shadow 0.15s ease, color 0.15s ease;
}
.record-cta.shout-active {
  color: var(--gold-400);
  text-shadow: 0 0 26px rgba(255,204,0,0.65);
}
.shout-elongate { color: var(--cyan-400); }

.record-prompt {
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.06em;
  font-size: clamp(0.9rem, 1.8vw, 1.25rem);
  color: rgba(244,248,255,0.7);
  min-height: 1.4em;
}
.record-prompt.is-waiting {
  color: var(--gold-400);
  animation: promptPulse 1s ease-in-out infinite;
}
@keyframes promptPulse {
  0%, 100% { opacity: 0.55; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.05); }
}
/* while waiting for the first shout, gently pulse the mic to invite the user */
.visualizer-wrap.is-waiting .mic-core {
  animation: micInvite 1.1s ease-in-out infinite;
}
@keyframes micInvite {
  0%, 100% { box-shadow: 0 0 30px rgba(31,123,255,0.5); transform: scale(1); }
  50% { box-shadow: 0 0 46px rgba(255,204,0,0.6); transform: scale(1.06); }
}

.visualizer-wrap {
  position: relative;
  width: min(38vmin, 300px);
  height: min(38vmin, 300px);
  display: flex;
  align-items: center;
  justify-content: center;
}
.visualizer-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid rgba(31,123,255,0.35);
  transition: border-color 0.15s ease;
}
.ring-2 { inset: 14%; border-color: rgba(0,229,255,0.3); }
.visualizer-wrap.is-loud .ring-1 {
  border-color: var(--gold-400);
  animation: ringPulse 0.6s ease-out infinite;
}
.visualizer-wrap.is-loud .ring-2 {
  border-color: var(--gold-400);
  animation: ringPulse 0.6s ease-out infinite 0.15s;
}
@keyframes ringPulse {
  0% { transform: scale(0.9); opacity: 0.9; }
  100% { transform: scale(1.18); opacity: 0; }
}
.mic-core {
  position: relative;
  z-index: 2;
  width: 34%;
  height: 34%;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--blue-400), var(--navy-700));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.6rem, 4vw, 2.6rem);
  box-shadow: 0 0 30px rgba(31,123,255,0.5);
}
.bars {
  position: absolute;
  bottom: -6%;
  left: 50%;
  transform: translateX(-50%);
  width: 78%;
  height: 30%;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: clamp(3px, 0.6vw, 6px);
  z-index: 1;
}
.bar {
  flex: 1 1 auto;
  height: 6%;
  min-height: 4px;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, var(--cyan-400), var(--blue-500));
  transition: height 0.06s linear;
}

.record-timer { display: flex; flex-direction: column; align-items: center; gap: 0.2rem; }
.record-timer-label {
  font-size: clamp(0.75rem, 1.3vw, 1rem);
  letter-spacing: 0.18em;
  font-weight: 700;
  color: rgba(244,248,255,0.6);
}
.record-timer-value {
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  font-weight: 900;
  color: var(--cyan-400);
  text-shadow: 0 0 24px rgba(0,229,255,0.5);
  font-variant-numeric: tabular-nums;
}
.record-timer-value small { font-size: 0.5em; opacity: 0.7; margin-left: 0.15em; }

.attempt-bar-track {
  width: min(70vw, 620px);
  height: 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}
.attempt-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--blue-500), var(--cyan-400));
  transition: width 0.1s linear;
}

/* ==========================================================================
   PAGE 5 — RESULT
   ========================================================================== */
.stage-result { gap: var(--space-3); position: relative; }
.team-banner-big {
  padding: 0.7rem 1.6rem;
}
.team-banner-logo-big {
  width: clamp(64px, 10vw, 110px);
  height: clamp(64px, 10vw, 110px);
  object-fit: contain;
}

.result-score-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  animation: resultPop 0.5s cubic-bezier(.2,1.4,.4,1) both;
}
@keyframes resultPop {
  0% { transform: scale(0.6); opacity: 0; }
  60% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
.result-score {
  font-size: clamp(4rem, 11vw, 7.5rem);
  font-weight: 900;
  line-height: 1;
  background: linear-gradient(90deg, var(--cyan-400), var(--gold-400));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 50px rgba(255,204,0,0.35);
}
.result-score small { font-size: 0.3em; margin-left: 0.2em; }

.result-tier {
  font-size: clamp(1.1rem, 2.4vw, 1.7rem);
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 0.4rem 1.4rem;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
}
.tier-legend { color: var(--gold-400); box-shadow: 0 0 26px rgba(255,204,0,0.4); }
.tier-great  { color: var(--cyan-400); box-shadow: 0 0 22px rgba(0,229,255,0.35); }
.tier-good   { color: var(--blue-400); }
.tier-try    { color: rgba(244,248,255,0.75); }

.result-team-name {
  margin: 0;
  color: rgba(244,248,255,0.75);
  font-size: clamp(0.95rem, 1.7vw, 1.25rem);
}

.refresh-note {
  font-size: clamp(0.8rem, 1.3vw, 1rem);
  color: rgba(244,248,255,0.5);
  letter-spacing: 0.04em;
}
.refresh-note span {
  color: var(--cyan-400);
  font-weight: 800;
}

.result-confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}
.confetti-piece {
  position: absolute;
  top: -5%;
  width: 10px;
  height: 16px;
  border-radius: 2px;
  opacity: 0.9;
  animation: confettiFall 2.4s linear infinite;
}
@keyframes confettiFall {
  0%   { transform: translateY(-10vh) rotate(0deg); opacity: 1; }
  100% { transform: translateY(115vh) rotate(540deg); opacity: 0.7; }
}

/* ==========================================================================
   MIC ERROR OVERLAY
   ========================================================================== */
.mic-error-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(3,8,24,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-3);
}
.mic-error-box {
  max-width: 520px;
  text-align: center;
  background: var(--navy-800);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 24px;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
}
.mic-error-icon { font-size: 3rem; }
.mic-error-box h3 { margin: 0; font-size: 1.3rem; }
.mic-error-box p { margin: 0; color: rgba(244,248,255,0.7); }

/* ==========================================================================
   RESPONSIVE ADJUSTMENTS
   ========================================================================== */
@media (max-width: 900px) {
  .team-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.5rem; }
  .team-card { padding: 0.7rem 0.4rem; border-radius: 16px; }
  .team-card-logo-box { border-radius: 12px; }
}

@media (max-height: 600px) {
  .stage { gap: var(--space-2); }
  .event-logo { max-height: 18vh; }
}

@media (orientation: portrait) {
  .team-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 1fr; }
}
