@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@600;700&family=Plus+Jakarta+Sans:wght@500;600;700;800&display=swap');

:root {
  /* Typography */
  --font-display: 'Fredoka', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-body: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Kahoot Royal Purple / Indigo Backdrop */
  --bg-deep: #1c1445;
  --bg-royal: #2b0f63;
  --bg-vivid: #46178f;
  --bg-gradient: linear-gradient(135deg, #2b0f63 0%, #46178f 52%, #1c1445 100%);

  /* Surfaces & Text */
  --surface-white: #ffffff;
  --surface-soft: #f6f4ff;
  --surface-glass: rgba(255, 255, 255, 0.13);
  --surface-glass-strong: rgba(255, 255, 255, 0.2);
  --border-glass: rgba(255, 255, 255, 0.22);
  --border-light: #e5e0f7;

  --text-dark: #1b1536;
  --text-dark-muted: #5b547a;
  --text-light: #ffffff;
  --text-light-muted: rgba(255, 255, 255, 0.82);

  /* Kahoot Answer Tiles */
  --tile-red: #e21b3c;
  --tile-red-dark: #b0122c;
  --tile-red-hover: #f12749;

  --tile-blue: #1368ce;
  --tile-blue-dark: #0d4c99;
  --tile-blue-hover: #1d78e6;

  --tile-amber: #d89e00;
  --tile-amber-dark: #a37700;
  --tile-amber-hover: #ebae06;

  --tile-green: #26890c;
  --tile-green-dark: #1b6308;
  --tile-green-hover: #2fa111;

  --tile-purple: #864cbf;
  --tile-purple-dark: #623391;
  --tile-purple-hover: #995cd4;

  /* Accent & Status */
  --accent-gold: #ffd166;
  --accent-cyan: #38bdf8;
  --status-live: #22c55e;
  --status-warn: #f59e0b;
  --status-danger: #ef4444;

  /* Radii & Shadows */
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 28px;
  --radius-pill: 9999px;

  --shadow-card: 0 18px 42px rgba(15, 7, 41, 0.34), 0 4px 12px rgba(15, 7, 41, 0.18);
  --shadow-glass: 0 12px 32px rgba(12, 6, 36, 0.28);
  --focus-ring: 0 0 0 3px #ffd166, 0 0 0 6px rgba(27, 21, 54, 0.55);

  --transition-fast: 150ms cubic-bezier(0.22, 1, 0.36, 1);
  --transition-bounce: 260ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-weight: 600;
  line-height: 1.45;
  color: var(--text-light);
  background: var(--bg-royal);
  background-image:
    radial-gradient(circle at 18% 15%, rgba(134, 76, 191, 0.42) 0%, transparent 45%),
    radial-gradient(circle at 84% 82%, rgba(19, 104, 206, 0.34) 0%, transparent 48%),
    var(--bg-gradient);
  background-attachment: fixed;
  overflow-x: hidden;
  position: relative;
}

h1, h2, h3, h4, .font-display {
  font-family: var(--font-display);
  letter-spacing: 0.01em;
  margin: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* =========================================================
   Animated Floating Geometric Background Shapes
   ========================================================= */
.bg-shapes {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.bg-shapes > * {
  position: absolute;
  opacity: 0.09;
  will-change: transform;
  animation: floatShape 18s ease-in-out infinite;
}

.shape-circle {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: #ffffff;
  top: 8%;
  left: 6%;
  animation-duration: 21s;
}

.shape-diamond {
  width: 110px;
  height: 110px;
  background: #ffd166;
  border-radius: 16px;
  transform: rotate(45deg);
  top: 16%;
  right: 9%;
  animation-duration: 19s;
  animation-delay: -4s;
}

.shape-triangle {
  width: 0;
  height: 0;
  border-left: 70px solid transparent;
  border-right: 70px solid transparent;
  border-bottom: 120px solid #38bdf8;
  bottom: 12%;
  left: 10%;
  animation-duration: 24s;
  animation-delay: -8s;
}

.shape-square {
  width: 128px;
  height: 128px;
  border-radius: 22px;
  border: 14px solid #ffffff;
  background: transparent;
  bottom: 14%;
  right: 8%;
  animation-duration: 22s;
  animation-delay: -11s;
}

.bg-shapes .shape-circle:nth-of-type(5) {
  width: 84px;
  height: 84px;
  top: 58%;
  left: 48%;
  opacity: 0.06;
  animation-duration: 16s;
  animation-delay: -3s;
}

.bg-shapes .shape-diamond:nth-of-type(6) {
  width: 68px;
  height: 68px;
  bottom: 34%;
  left: 24%;
  opacity: 0.07;
  animation-duration: 20s;
  animation-delay: -6s;
}

.bg-shapes .shape-square:nth-of-type(7) {
  width: 76px;
  height: 76px;
  top: 44%;
  right: 22%;
  opacity: 0.06;
  animation-duration: 25s;
  animation-delay: -9s;
}

/* =========================================================
   Cards & Surfaces
   ========================================================= */
.white-card {
  background: var(--surface-white);
  color: var(--text-dark);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  border: 2px solid rgba(255, 255, 255, 0.9);
  position: relative;
  z-index: 1;
}

.white-card h1,
.white-card h2,
.white-card h3,
.white-card h4 {
  color: var(--text-dark);
}

.glass-card {
  background: var(--surface-glass);
  color: var(--text-light);
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--border-glass);
  box-shadow: var(--shadow-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  position: relative;
  z-index: 1;
}

/* =========================================================
   3D Tactile Kahoot Answer Tiles
   ========================================================= */
.tile-red,
.tile-blue,
.tile-amber,
.tile-green,
.tile-purple {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  width: 100%;
  min-height: 72px;
  padding: 14px 20px;
  border: none;
  border-radius: var(--radius-md);
  color: #ffffff;
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 1.05rem;
  line-height: 1.25;
  text-align: left;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition:
    transform var(--transition-fast),
    box-shadow var(--transition-fast),
    filter var(--transition-fast),
    opacity var(--transition-fast);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.tile-red {
  background: var(--tile-red);
  box-shadow: 0 6px 0 var(--tile-red-dark), 0 10px 20px rgba(0, 0, 0, 0.22);
}
.tile-red:hover:not(:disabled) {
  background: var(--tile-red-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 0 var(--tile-red-dark), 0 14px 24px rgba(0, 0, 0, 0.26);
}
.tile-red:active:not(:disabled),
.tile-red.is-pressed {
  transform: translateY(4px);
  box-shadow: 0 2px 0 var(--tile-red-dark), 0 4px 10px rgba(0, 0, 0, 0.2);
}

.tile-blue {
  background: var(--tile-blue);
  box-shadow: 0 6px 0 var(--tile-blue-dark), 0 10px 20px rgba(0, 0, 0, 0.22);
}
.tile-blue:hover:not(:disabled) {
  background: var(--tile-blue-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 0 var(--tile-blue-dark), 0 14px 24px rgba(0, 0, 0, 0.26);
}
.tile-blue:active:not(:disabled),
.tile-blue.is-pressed {
  transform: translateY(4px);
  box-shadow: 0 2px 0 var(--tile-blue-dark), 0 4px 10px rgba(0, 0, 0, 0.2);
}

.tile-amber {
  background: var(--tile-amber);
  box-shadow: 0 6px 0 var(--tile-amber-dark), 0 10px 20px rgba(0, 0, 0, 0.22);
}
.tile-amber:hover:not(:disabled) {
  background: var(--tile-amber-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 0 var(--tile-amber-dark), 0 14px 24px rgba(0, 0, 0, 0.26);
}
.tile-amber:active:not(:disabled),
.tile-amber.is-pressed {
  transform: translateY(4px);
  box-shadow: 0 2px 0 var(--tile-amber-dark), 0 4px 10px rgba(0, 0, 0, 0.2);
}

.tile-green {
  background: var(--tile-green);
  box-shadow: 0 6px 0 var(--tile-green-dark), 0 10px 20px rgba(0, 0, 0, 0.22);
}
.tile-green:hover:not(:disabled) {
  background: var(--tile-green-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 0 var(--tile-green-dark), 0 14px 24px rgba(0, 0, 0, 0.26);
}
.tile-green:active:not(:disabled),
.tile-green.is-pressed {
  transform: translateY(4px);
  box-shadow: 0 2px 0 var(--tile-green-dark), 0 4px 10px rgba(0, 0, 0, 0.2);
}

.tile-purple {
  background: var(--tile-purple);
  box-shadow: 0 6px 0 var(--tile-purple-dark), 0 10px 20px rgba(0, 0, 0, 0.22);
}
.tile-purple:hover:not(:disabled) {
  background: var(--tile-purple-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 0 var(--tile-purple-dark), 0 14px 24px rgba(0, 0, 0, 0.26);
}
.tile-purple:active:not(:disabled),
.tile-purple.is-pressed {
  transform: translateY(4px);
  box-shadow: 0 2px 0 var(--tile-purple-dark), 0 4px 10px rgba(0, 0, 0, 0.2);
}

.tile-red:disabled,
.tile-blue:disabled,
.tile-amber:disabled,
.tile-green:disabled,
.tile-purple:disabled {
  cursor: not-allowed;
  opacity: 0.72;
}

.tile-red.is-dimmed,
.tile-blue.is-dimmed,
.tile-amber.is-dimmed,
.tile-green.is-dimmed,
.tile-purple.is-dimmed {
  opacity: 0.36;
  filter: grayscale(0.35);
}

.tile-red.is-selected,
.tile-blue.is-selected,
.tile-amber.is-selected,
.tile-green.is-selected,
.tile-purple.is-selected {
  outline: 4px solid #ffffff;
  outline-offset: 2px;
  transform: translateY(-2px);
}

.tile-shape {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.18);
  font-size: 1.25rem;
  line-height: 1;
}

/* =========================================================
   3D Tactile General Buttons (.btn-3d)
   ========================================================= */
.btn-3d {
  --btn-bg: #5b21b6;
  --btn-shadow: #3b0f82;
  --btn-hover: #6d28d9;
  --btn-color: #ffffff;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--btn-bg);
  color: var(--btn-color);
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 0.98rem;
  line-height: 1.2;
  text-decoration: none;
  box-shadow: 0 5px 0 var(--btn-shadow), 0 8px 18px rgba(0, 0, 0, 0.22);
  transition:
    transform var(--transition-fast),
    box-shadow var(--transition-fast),
    background var(--transition-fast),
    opacity var(--transition-fast);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn-3d:hover:not(:disabled) {
  background: var(--btn-hover);
  transform: translateY(-2px);
  box-shadow: 0 7px 0 var(--btn-shadow), 0 12px 22px rgba(0, 0, 0, 0.26);
}

.btn-3d:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--btn-shadow), 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-3d:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.btn-3d.primary,
.btn-3d.btn-primary {
  --btn-bg: #7c3aed;
  --btn-hover: #8b5cf6;
  --btn-shadow: #4c1d95;
  --btn-color: #ffffff;
}

.btn-3d.success,
.btn-3d.btn-success {
  --btn-bg: #26890c;
  --btn-hover: #2ea20f;
  --btn-shadow: #185807;
  --btn-color: #ffffff;
}

.btn-3d.danger,
.btn-3d.btn-danger {
  --btn-bg: #e21b3c;
  --btn-hover: #f22c4d;
  --btn-shadow: #a5112a;
  --btn-color: #ffffff;
}

.btn-3d.amber,
.btn-3d.btn-amber {
  --btn-bg: #eab308;
  --btn-hover: #facc15;
  --btn-shadow: #a16207;
  --btn-color: #1b1536;
}

.btn-3d.ghost,
.btn-3d.btn-ghost {
  --btn-bg: rgba(255, 255, 255, 0.16);
  --btn-hover: rgba(255, 255, 255, 0.26);
  --btn-shadow: rgba(15, 7, 41, 0.45);
  --btn-color: #ffffff;
  border: 1.5px solid rgba(255, 255, 255, 0.28);
}

.btn-3d.btn-sm {
  padding: 8px 14px;
  font-size: 0.86rem;
  border-radius: 12px;
}

.btn-3d.btn-lg {
  padding: 15px 28px;
  font-size: 1.12rem;
  border-radius: 18px;
}

/* =========================================================
   Sync Pill & Live Dot
   ========================================================= */
.sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 13px;
  border-radius: var(--radius-pill);
  background: rgba(17, 11, 44, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  backdrop-filter: blur(8px);
}

.pulse-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--status-live);
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
  animation: pulseGlow 1.8s infinite;
  flex-shrink: 0;
}

.sync-pill.is-offline .pulse-dot {
  background: var(--status-danger);
  animation: none;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.8);
}

.sync-pill.is-slow .pulse-dot {
  background: var(--status-warn);
}

/* =========================================================
   Badges & Avatar Chips
   ========================================================= */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1.2;
  white-space: nowrap;
}

.badge-purple {
  background: #ede9fe;
  color: #5b21b6;
}

.badge-blue {
  background: #dbeafe;
  color: #1d4ed8;
}

.badge-green {
  background: #dcfce7;
  color: #15803d;
}

.badge-amber {
  background: #fef3c7;
  color: #b45309;
}

.badge-red {
  background: #fee2e2;
  color: #b91c1c;
}

.badge-glass {
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.avatar-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: var(--surface-soft);
  color: var(--text-dark);
  border: 1.5px solid var(--border-light);
  font-weight: 700;
  font-size: 0.88rem;
  box-shadow: 0 2px 6px rgba(27, 21, 54, 0.08);
}

.avatar-chip.is-glass {
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.25);
}

.avatar-chip .avatar-emoji {
  font-size: 1.15rem;
  line-height: 1;
}

/* =========================================================
   Toast Notifications
   ========================================================= */
.toast-container {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(380px, calc(100vw - 24px));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: #1e1645;
  color: #ffffff;
  border: 1.5px solid rgba(255, 255, 255, 0.24);
  box-shadow: 0 14px 32px rgba(10, 5, 30, 0.45);
  font-size: 0.92rem;
  font-weight: 700;
  animation: popIn 0.24s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.toast.toast-success {
  background: #166534;
  border-color: #4ade80;
}

.toast.toast-error {
  background: #991b1b;
  border-color: #f87171;
}

.toast.toast-warning {
  background: #92400e;
  border-color: #fbbf24;
}

.toast.toast-info {
  background: #311b92;
  border-color: #a78bfa;
}

/* =========================================================
   Modals
   ========================================================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(13, 6, 36, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal-backdrop[hidden] {
  display: none !important;
}

.modal-card {
  width: 100%;
  max-width: 780px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface-white);
  color: var(--text-dark);
  border-radius: var(--radius-xl);
  box-shadow: 0 28px 60px rgba(8, 3, 28, 0.55);
  padding: 24px;
  animation: popIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* =========================================================
   Keyframe Animations
   ========================================================= */
@keyframes popIn {
  0% {
    opacity: 0;
    transform: scale(0.88) translateY(10px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

@keyframes pulseGlow {
  0% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.72);
  }
  70% {
    box-shadow: 0 0 0 9px rgba(34, 197, 94, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
  }
}

@keyframes floatShape {
  0%, 100% {
    transform: translate3d(0, 0, 0) rotate(0deg);
  }
  33% {
    transform: translate3d(18px, -24px, 0) rotate(12deg);
  }
  66% {
    transform: translate3d(-14px, 16px, 0) rotate(-10deg);
  }
}

@keyframes podiumRise {
  0% {
    opacity: 0;
    transform: translateY(48px) scaleY(0.75);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scaleY(1);
  }
}

@keyframes countdownPop {
  0% {
    opacity: 0;
    transform: scale(0.35);
  }
  55% {
    opacity: 1;
    transform: scale(1.16);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.anim-pop {
  animation: popIn 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.anim-shake {
  animation: shake 0.42s ease-in-out;
}

.anim-pulse-glow {
  animation: pulseGlow 1.8s infinite;
}

.anim-podium {
  transform-origin: bottom center;
  animation: podiumRise 0.65s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.anim-countdown {
  animation: countdownPop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* =========================================================
   Responsive & Reduced Motion
   ========================================================= */
@media (max-width: 768px) {
  .tile-red,
  .tile-blue,
  .tile-amber,
  .tile-green,
  .tile-purple {
    min-height: 62px;
    padding: 12px 15px;
    font-size: 0.96rem;
    gap: 10px;
  }

  .tile-shape {
    width: 32px;
    height: 32px;
    font-size: 1.05rem;
  }

  .modal-card {
    padding: 18px;
    border-radius: 20px;
  }

  .toast-container {
    top: 12px;
    right: 12px;
    left: 12px;
    max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bg-shapes > *,
  .pulse-dot,
  .anim-pop,
  .anim-shake,
  .anim-pulse-glow,
  .anim-podium,
  .anim-countdown {
    animation: none !important;
  }

  .tile-red,
  .tile-blue,
  .tile-amber,
  .tile-green,
  .tile-purple,
  .btn-3d {
    transition: none;
  }
}
