/**
 * Scrums Up — static web client (public/)
 *
 * Nineties jazz-cup energy: deep purple, electric teal, hot pink accents,
 * Bungee/Fredoka typography, SVG squiggles. Layout: lobby, session game view.
 */

/* -----------------------------------------------------------------------------
   Design tokens
   ----------------------------------------------------------------------------- */
:root {
  --bg: #0e0618;
  --surface: #1c1030;
  --surface-hover: #2a1b45;
  --border: rgba(181, 101, 255, 0.28);
  --text: #fff5ee;
  --text-muted: #a898c0;
  --accent: #2ec4b6;
  --accent-2: #ff3cac;
  --accent-hover: #3be8d8;
  --accent-muted: rgba(46, 196, 183, 0.22);
  --success: #2ec4b6;
  --error: #ff4f7a;
  --radius: 12px;
  --font: 'Fredoka', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-display: 'Bungee', cursive, sans-serif;
}

* {
  box-sizing: border-box;
}

/* -----------------------------------------------------------------------------
   Base layout
   ----------------------------------------------------------------------------- */
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  line-height: 1.5;
  background: var(--bg);
  position: relative;
}

/* Jazz squiggle strip + corner glows */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 120px;
  z-index: 0;
  pointer-events: none;
  opacity: 0.38;
  background: url('branding/jazz_squiggles_tiles.svg') center / cover no-repeat;
}

#app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
  position: relative;
  z-index: 1;
}

.header {
  text-align: center;
  margin-bottom: 1.75rem;
  position: relative;
  padding: 0.5rem 0 1.25rem;
  filter: drop-shadow(0 0 20px rgba(46, 196, 183, 0.15));
}

.header-line {
  position: absolute;
  bottom: 0;
  left: 5%;
  right: 5%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), var(--accent-2), var(--text-muted), var(--accent), transparent);
  border-radius: 2px;
  opacity: 0.55;
}

.header-brand {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 1.1rem 1.5rem;
  text-align: left;
}

.header-titles {
  min-width: min(100%, 320px);
}

.jazz-cup {
  width: 48px;
  height: auto;
  image-rendering: -webkit-optimize-contrast;
  filter: drop-shadow(0 2px 10px rgba(46, 196, 183, 0.45)) drop-shadow(0 0 6px rgba(255, 60, 172, 0.25));
}

.logo {
  font-family: var(--font-display);
  font-size: clamp(1.65rem, 3.5vw, 2.25rem);
  font-weight: 400;
  letter-spacing: 0.06em;
  margin: 0 0 0.2rem 0;
  line-height: 1.1;
  background: linear-gradient(100deg, var(--accent) 0%, #f8d4ff 35%, var(--accent-2) 70%, var(--accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 24px rgba(46, 196, 183, 0.2);
  text-transform: uppercase;
}

.tagline {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-style: italic;
  line-height: 1.4;
  max-width: 28em;
  margin-left: auto;
  margin-right: auto;
  text-align: left;
}

/* Lobby: create/join forms */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 2rem;
  max-width: 420px;
  margin: 0 auto;
}

.tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1.25rem;
}

.tab {
  flex: 1;
  padding: 0.6rem 1rem;
  font: inherit;
  font-size: 0.9rem;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: var(--text);
  background: var(--accent-muted);
  border-color: var(--accent);
}

.form-block label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  margin-top: 1rem;
}

.form-block label:first-of-type {
  margin-top: 0;
}

.form-block .emoji-picker-label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  margin-top: 1rem;
}

.form-block .emoji-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.form-block .emoji-btn {
  font: inherit;
  font-size: 1.1rem;
  line-height: 1.2;
  padding: 0.3rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}

.form-block .emoji-btn:hover {
  border-color: var(--accent);
  background: var(--accent-muted);
}

.form-block .emoji-btn.selected {
  border-color: var(--accent);
  background: var(--accent);
}

.form-block input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.form-block input::placeholder {
  color: var(--text-muted);
}

.form-block input:focus {
  outline: none;
  border-color: var(--accent);
}

.form-block .btn {
  width: 100%;
  margin-top: 1.25rem;
  padding: 0.75rem 1rem;
}

.btn {
  font: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  padding: 0.6rem 1.1rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
}

.btn.primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn.primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn.ghost:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.btn.small {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
}

.error {
  margin-top: 1rem;
  color: var(--error);
  font-size: 0.9rem;
}

.hidden {
  display: none !important;
}

/* -----------------------------------------------------------------------------
   Session view: bar, cards sidebar, main area (current card + vote + participants)
   ----------------------------------------------------------------------------- */
.session {
  display: block;
}

.session-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.session-id code {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  background: var(--bg);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

.participant-count {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.game-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.5rem;
  align-items: start;
}

.game-layout.game-layout--no-sidebar {
  grid-template-columns: 1fr;
}

@media (max-width: 800px) {
  .game-layout {
    grid-template-columns: 1fr;
  }
}

.cards-sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  position: sticky;
  top: 1rem;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.sidebar-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.card-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.card-list li {
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  border: 1px solid transparent;
  margin-bottom: 2px;
}

.card-list li:hover {
  background: var(--surface-hover);
}

.card-list li.active {
  background: var(--accent-muted);
  border-color: var(--accent);
}

.card-list .card-key-small {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.add-card-form {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.add-card-form input,
.add-card-form textarea {
  width: 100%;
  padding: 0.5rem 0.65rem;
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 0.5rem;
}

.add-card-form textarea {
  resize: vertical;
  min-height: 60px;
}

.add-card-actions {
  display: flex;
  gap: 0.5rem;
}

.main-area {
  min-width: 0;
}

.current-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.current-card .card-key {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent);
  margin-bottom: 0.35rem;
}

.current-card .card-title {
  margin: 0 0 0.5rem 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.current-card .card-description {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
  white-space: pre-wrap;
}

.fib-row {
  margin-bottom: 1.25rem;
}

.fib-label {
  margin: 0 0 0.5rem 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.fib-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.fib-btn {
  font: inherit;
  font-size: 1.25rem;
  font-weight: 600;
  min-width: 3.15rem;
  min-height: 2.75rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}

.fib-btn:hover {
  border-color: var(--accent);
  background: var(--accent-muted);
}

.fib-btn.selected {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.participants h3 {
  margin: 0 0 0.5rem 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
}

.vote-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin: 0 0 0.75rem 0;
  padding: 0.65rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
}

.vote-stats.hidden {
  display: none;
}

.vote-stat {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 4.5rem;
}

.vote-stat .vote-stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
}

.vote-stat .vote-stat-value {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
}

/* Mysterious Stranger (two-way tie on Fib / ½) */
.vote-stat--mysterious-stranger {
  flex: 1 1 100%;
  min-width: 100%;
  max-width: 100%;
  margin-top: 0.5rem;
  padding: 0.75rem 0.9rem;
  background: linear-gradient(135deg, rgba(12, 40, 24, 0.9) 0%, rgba(8, 20, 14, 0.95) 100%);
  border: 1px solid rgba(60, 200, 120, 0.45);
  border-radius: 8px;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.3),
    0 0 18px rgba(50, 200, 100, 0.15);
}

.mysterious-stranger-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.mysterious-stranger-svg {
  flex-shrink: 0;
  filter: drop-shadow(0 0 6px rgba(80, 220, 120, 0.35));
}

.mysterious-stranger-text {
  min-width: 0;
  flex: 1;
}

.vote-stat-label--stranger {
  display: block;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: #7dd87a;
  text-shadow: 0 0 8px rgba(100, 255, 150, 0.25);
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.mysterious-stranger-line {
  margin: 0 0 0.4rem 0;
  font-size: 0.8rem;
  color: #a8d4b0;
  line-height: 1.35;
  font-style: italic;
}

.mysterious-stranger-pick {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text);
}

.vote-stat-value--stranger {
  font-size: 1.35rem !important;
  color: #6ee7a0 !important;
  text-shadow: 0 0 12px rgba(100, 255, 150, 0.35);
}

.participants-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.participants-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
}

.participants-list .participant-avatar {
  font-size: 1.15rem;
  line-height: 1;
}

.participants-list .vote-badge {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--accent);
  min-width: 1.5rem;
  text-align: center;
}

.participants-list .vote-pending {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* -----------------------------------------------------------------------------
   Reveal countdown (all users) + finish animation
   ----------------------------------------------------------------------------- */
#session {
  position: relative;
}

.reveal-countdown-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(14, 6, 24, 0.9);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  pointer-events: all;
  transition: opacity 0.2s ease;
}

.reveal-countdown-inner {
  text-align: center;
  padding: 1rem;
}

.reveal-countdown-value {
  display: block;
  font-family: var(--font-display, system-ui, sans-serif);
  font-size: clamp(3.5rem, 15vw, 6.5rem);
  line-height: 1;
  font-weight: 800;
  color: var(--accent);
  text-shadow:
    0 0 48px rgba(46, 196, 183, 0.6),
    0 0 2px #fff3;
  letter-spacing: 0.02em;
}

.reveal-countdown-value.countdown-bump {
  animation: countdown-bump 0.32s ease-out;
}

.reveal-countdown-wait {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  font-size: 1.1rem;
  color: var(--text-muted);
  font-style: italic;
  margin: 0;
}

.reveal-countdown-wait::before {
  content: '';
  display: block;
  width: 1.1rem;
  height: 1.1rem;
  border: 2px solid var(--accent-2, #ff3cac);
  border-top-color: var(--accent);
  border-radius: 50%;
  flex-shrink: 0;
  animation: reveal-spin 0.75s linear infinite;
}

@keyframes reveal-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes countdown-bump {
  0% {
    transform: scale(0.35);
    opacity: 0.6;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.main-area.reveal-reveal-burst {
  animation: mainRevealGlow 0.8s ease-out;
}

@keyframes mainRevealGlow {
  0% {
    filter: brightness(1) saturate(1);
  }
  30% {
    filter: brightness(1.1) drop-shadow(0 0 14px rgba(46, 196, 183, 0.4));
  }
  100% {
    filter: brightness(1) saturate(1);
  }
}

.main-area.reveal-reveal-burst .participants-list li {
  animation: voteStagger 0.48s cubic-bezier(0.22, 1, 0.28, 1) both;
}

.main-area.reveal-reveal-burst .vote-stat {
  animation: statPop 0.45s ease-out 0.15s both;
}

.main-area.reveal-reveal-burst .vote-stat:nth-child(2) {
  animation-delay: 0.22s;
}
.main-area.reveal-reveal-burst .vote-stat:nth-child(3) {
  animation-delay: 0.3s;
}

.main-area.reveal-reveal-burst .participants-list li:nth-child(1) { animation-delay: 0.04s; }
.main-area.reveal-reveal-burst .participants-list li:nth-child(2) { animation-delay: 0.1s; }
.main-area.reveal-reveal-burst .participants-list li:nth-child(3) { animation-delay: 0.16s; }
.main-area.reveal-reveal-burst .participants-list li:nth-child(4) { animation-delay: 0.22s; }
.main-area.reveal-reveal-burst .participants-list li:nth-child(5) { animation-delay: 0.28s; }
.main-area.reveal-reveal-burst .participants-list li:nth-child(6) { animation-delay: 0.36s; }
.main-area.reveal-reveal-burst .participants-list li:nth-child(7) { animation-delay: 0.42s; }
.main-area.reveal-reveal-burst .participants-list li:nth-child(8) { animation-delay: 0.5s; }
.main-area.reveal-reveal-burst .participants-list li:nth-child(9) { animation-delay: 0.55s; }
.main-area.reveal-reveal-burst .participants-list li:nth-child(10) { animation-delay: 0.6s; }
.main-area.reveal-reveal-burst .participants-list li:nth-child(11) { animation-delay: 0.64s; }
.main-area.reveal-reveal-burst .participants-list li:nth-child(12) { animation-delay: 0.68s; }
.main-area.reveal-reveal-burst .participants-list li:nth-child(n + 13) { animation-delay: 0.75s; }

@keyframes voteStagger {
  0% {
    opacity: 0.15;
    transform: translateY(0.5rem) scale(0.88);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes statPop {
  0% {
    opacity: 0;
    transform: scale(0.85);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* -----------------------------------------------------------------------------
   Mega reveal explosion (all users / host can disable)
   ----------------------------------------------------------------------------- */
.reveal-explosion-layer {
  position: fixed;
  inset: 0;
  z-index: 3500;
  pointer-events: none;
  overflow: hidden;
  contain: layout style;
}

.reveal-explosion-layer:not(.hidden) {
  pointer-events: none;
}

#app.reveal-app-shake {
  animation: revealAppShake 0.65s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes revealAppShake {
  0%,
  100% {
    transform: translate(0, 0) rotate(0);
  }
  10% {
    transform: translate(-8px, 4px) rotate(-0.4deg);
  }
  20% {
    transform: translate(10px, -5px) rotate(0.5deg);
  }
  30% {
    transform: translate(-6px, 5px) rotate(-0.3deg);
  }
  40% {
    transform: translate(7px, 2px) rotate(0.3deg);
  }
  50% {
    transform: translate(-4px, -3px) rotate(0);
  }
  60% {
    transform: translate(3px, 2px) rotate(0);
  }
  70%,
  80% {
    transform: translate(0, 0) rotate(0);
  }
}

.explosion-flash {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at 50% 45%,
    rgba(255, 255, 255, 0.95) 0%,
    rgba(46, 196, 183, 0.35) 18%,
    rgba(255, 60, 172, 0.2) 40%,
    transparent 70%
  );
  animation: explosionFlash 0.45s ease-out forwards;
  mix-blend-mode: screen;
}

@keyframes explosionFlash {
  0% {
    opacity: 1;
    transform: scale(0.2);
  }
  30% {
    opacity: 1;
    transform: scale(1.1);
  }
  100% {
    opacity: 0;
    transform: scale(1.4);
  }
}

.explosion-stars {
  position: absolute;
  width: 120%;
  height: 120%;
  left: -10%;
  top: -10%;
  background: conic-gradient(
    from 0deg,
    rgba(46, 196, 183, 0) 0deg,
    rgba(46, 196, 183, 0.15) 40deg,
    rgba(255, 60, 172, 0.12) 100deg,
    rgba(181, 101, 255, 0.1) 200deg,
    rgba(46, 196, 183, 0) 360deg
  );
  animation: explosionStars 1.1s linear forwards;
  mix-blend-mode: screen;
  pointer-events: none;
}

@keyframes explosionStars {
  0% {
    transform: scale(0) rotate(0deg);
    opacity: 0.9;
  }
  100% {
    transform: scale(1.4) rotate(45deg);
    opacity: 0;
  }
}

.explosion-shockring {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8vw;
  height: 8vw;
  min-width: 4rem;
  min-height: 4rem;
  margin: -4rem 0 0 -4rem;
  border: 3px solid var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(46, 196, 183, 0.5), 0 0 40px var(--accent-2, #ff3cac);
  animation: shockRing 0.9s ease-out forwards;
  pointer-events: none;
}

.explosion-shockring--2 {
  border-color: var(--accent-2, #ff3cac);
  animation-delay: 0.08s;
  animation-name: shockRing2;
}

.explosion-shockring--3 {
  border-color: #9b6dff;
  animation-delay: 0.16s;
  animation-name: shockRing2;
}

@keyframes shockRing {
  0% {
    transform: scale(0.1);
    opacity: 1;
  }
  100% {
    transform: scale(22);
    opacity: 0;
  }
}

@keyframes shockRing2 {
  0% {
    transform: scale(0.15);
    opacity: 0.7;
  }
  100% {
    transform: scale(16);
    opacity: 0;
  }
}

.explosion-particle {
  position: absolute;
  font-size: clamp(1.4rem, 3.5vw, 2.6rem);
  line-height: 1;
  will-change: transform, opacity;
  filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.5));
  animation: explParticle 1.15s var(--d, 0s) cubic-bezier(0.1, 0.8, 0.2, 1) forwards;
}

@keyframes explParticle {
  0% {
    transform: translate(0, 0) scale(0) rotate(0deg);
    opacity: 0;
  }
  8% {
    transform: translate(0, 0) scale(1.15) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translate(var(--tx, 0), var(--ty, 0)) scale(0.3) rotate(var(--rot, 0deg));
    opacity: 0;
  }
}

.explosion-bang {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  font-size: min(20vw, 6rem);
  line-height: 1;
  animation: bangText 0.6s ease-out 0.05s both;
  text-shadow: 0 0 20px #fff, 0 0 50px var(--accent);
  pointer-events: none;
  white-space: nowrap;
}

@keyframes bangText {
  0% {
    transform: translate(-50%, -50%) scale(0) rotate(-10deg);
    opacity: 0;
  }
  35% {
    transform: translate(-50%, -50%) scale(1.1) rotate(2deg);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(0.2) rotate(0);
    opacity: 0;
  }
}
