:root {
  --font: "Caveat Brush", cursive;
  --radius-card: 28px;
  --shadow-card:
    0 2px 4px rgba(0,0,0,0.12),
    0 8px 24px rgba(0,0,0,0.35),
    0 32px 80px rgba(0,0,0,0.45),
    0 0 0 1px rgba(255,255,255,0.06);
}

html,
body,
#app {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  font-family: 'Ubuntu', sans-serif;
  user-select: none;
  touch-action: none;
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  position: relative;
  overflow: hidden;
  font-family: var(--font);
}

/* ── BACKGROUND ───────────────────────────────────── */
#background {
  position: absolute;
  inset: 0;
  background: #1864ab;
  z-index: 0;
  transition: background-color 0.1s linear;
}

#background-right {
  position: absolute;
  width: 30%;
  height: 100%;
  right: 0;
  top: 0;
  transition: background 0.1s linear;
  z-index: 30;
  opacity: 0.5;
  pointer-events: none;
}

#background-left {
  position: absolute;
  width: 30%;
  height: 100%;
  left: 0;
  top: 0;
  transition: background 0.1s linear;
  z-index: 30;
  opacity: 0.5;
  pointer-events: none;
}

#bg-noise {
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  opacity: 0.05;
  pointer-events: none;
}

#bg-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(0,0,0,0.45) 100%);
  pointer-events: none;
}

/* ── STAGE ────────────────────────────────────────── */
#stage {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

/* ── CARD ─────────────────────────────────────────── */
.app-card {
  position: absolute;
  flex-shrink: 0;
  /* 9:16 portrait, fits viewport */
  height: min(88dvh, 680px, calc(70dvw * 16 / 9));
  width: calc(min(88dvh, 680px, calc(70dvw * 16 / 9)) * 9 / 16);
  top: calc((100dvh - min(88dvh, 680px, calc(70dvw * 16 / 9))) / 2);
  left: calc((100dvw - calc(min(88dvh, 680px, calc(70dvw * 16 / 9)) * 9 / 16)) / 2);
  border-radius: var(--radius-card);
  overflow: hidden;
  cursor: grab;
  user-select: none;
  touch-action: none;
  pointer-events: all;
  will-change: transform;
  box-shadow: var(--shadow-card);
  background: #101113;
  z-index: 10;
}

.app-card.grabbing {
  cursor: grabbing;
}

/* Card image area (top 62%) */
.card-img-wrap {
  position: absolute;
  inset: 0 0 10% 0;
  overflow: hidden;
  background: #1A1B1E;
}

.card-img-wrap.card-img-error {
  background: linear-gradient(160deg, #25262b 0%, #141517 100%);
}

.card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  display: block;
}

.card-img-placeholder {
  width: 100%;
  height: 100%;
  background: linear-gradient(160deg, #25262b 0%, #141517 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-img-placeholder::after {
  content: '🎓';
  font-size: 4rem;
  opacity: 0.3;
}

/* Bottom gradient over image */
.card-gradient {
  position: absolute;
  bottom: 10%;
  left: 0;
  right: 0;
  height: 40%;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(16,17,19,0.2) 35%,
    rgba(16,17,19,0.8) 65%,
    #101113 100%
  );
  pointer-events: none;
}

/* Card text body */
.card-body {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: clamp(16px, 5%, 28px) clamp(16px, 5%, 28px) clamp(20px, 6%, 32px);
}

.card-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.45);
  margin-bottom: 8px;
}

.card-text {
  font-family: var(--font);
  font-size: 1.5rem;
  font-weight: normal;
  text-align: center;
  color: #fff;
  line-height: 1.35;
  text-shadow: 0 1px 6px rgba(0,0,0,0.6);
}

/* ── SWIPE BADGES ─────────────────────────────────── */
.swipe-badge {
  position: absolute;
  top: 22px;
  padding: 6px 14px 6px 12px;
  border-radius: 8px;
  border: 2.5px solid;
  opacity: 0;
  pointer-events: none;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 6px;
  backdrop-filter: blur(4px);
}

/* ── FLOATING ELEMENTS ────────────────────────────── */
.floating-el {
  position: absolute;
  pointer-events: none;
  will-change: transform, opacity;
  /* center the element on its anchor point */
  transform: translate(-50%, -50%);
  z-index: 20;
}

.f-text {
  font-family: var(--font);
  font-size: 2.0rem;
  font-weight: 700;
  color: #fff;
  text-shadow:
    0 2px 2px rgba(0,0,0,0.8),
    0 -2px 2px rgba(0,0,0,0.5),
    2px 0 2px rgba(0,0,0,0.3),
    -2px 0 2px rgba(0,0,0,0.3),
    0 5px 5px rgba(0,0,0,0.6);
  white-space: nowrap;
  letter-spacing: -0.01em;
  text-align: center;
}

.f-img img {
  object-fit: cover;
}

.img-placeholder {
  background: rgba(255,255,255,0.08);
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.1);
}

/* ── LOADER ───────────────────────────────────────── */
#loader {
  position: absolute;
  inset: 0;
  background: #101113;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  z-index: 200;
}

.loader-ring {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: rgba(255,255,255,0.8);
  animation: spin 0.8s linear infinite;
}

.loader-text {
  font-family: Arial, 'sans-serif';
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.25em;
  color: rgba(255,255,255,0.5);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── RESULT BADGE ─────────────────────────────────── */
.result-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.7);
  margin-bottom: 10px;
}

/* ── RESULT PANEL (MATCH) ─────────────────────────── */

.result-container {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 5vh 0 10vh 0;
  z-index: 50;
  pointer-events: all; /* Cały ekran reaguje na scroll/dotyk */
  scroll-behavior: smooth;
  font-family: var(--font);
  opacity: 0;
}

.result-container::-webkit-scrollbar {
  display: none;
}

.result-title {
  width: 100%;
  text-align: center;
  font-family: var(--font);
  font-size: 2.5rem;
  color: #fff;
  text-transform: uppercase;
  margin-bottom: 20px;
  text-shadow: 0 5px 5px rgba(0,0,0,0.6);
  flex-shrink: 0;
}

.result-card-static {
  width: calc(min(680px, calc(90dvw * 16 / 9)) * 9 / 16);
  background: #000; /* Wszystko od obrazka w dół na czarnym */
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.result-image-header {
  position: relative;
  width: 100%;
  /* height: 50%; */
  /* aspect-ratio: 16 / 9; */
  flex-shrink: 0;
  box-shadow: var(--shadow-card);
  z-index: 2;
  overflow: hidden;
  border-radius: var(--radius-card) var(--radius-card) 0 0;
}

.result-content-body {
  border-radius: 0 0 var(--radius-card) var(--radius-card);
  padding: 24px;
  color: #fff;
  background: #000;
}

.result-main-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transform: translateY(-1px);
}

.result-header-shadow {
  position: absolute;
  width: 100%;
  height: 80px;
  left: 0;
  bottom: 0;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(16, 17, 19, 0.9) 70%,
    rgba(0, 0, 0, 1) 100%
  );
}

.result-rating {
  position: absolute;
  bottom: 0;
  left: 15px;
  right: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 3;
}

.result-rating .stars {
  display: flex;
  gap: 2px;
}

.result-rating .stars svg {
  width: 18px;
  height: 18px;
  fill: #fab005;
}

.rating-number {
  color: #fab005;
  font-weight: 700;
  font-size: 1.1rem;
  text-shadow: 0 2px 4px rgba(0,0,0,0.8);
}

.course-name {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 4px;
  text-align: left;
}

.course-tagline {
  display: block;
  width: 100%;
  text-align: right;
  font-size: 0.9rem;
  color: #fab005;
  margin-bottom: 24px;
}

.course-description p {
  font-size: 1rem;
  line-height: 1.6;
  color: rgba(255,255,255,0.9);
  font-weight: 300;
  text-align: justify;
}

.course-description > *:not(:last-child) {
  margin-bottom: 24px;
}

.course-description a {
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px;
  border-radius: 28px;
}

.course-description a { background-color: #5c940d; }
.course-description a:hover { background-color: #66a80f; }
.course-description a:active { background-color: #74b816; }

.course-description a.button-accent-1 { background-color: #1864ab; }
.course-description a.button-accent-1:hover { background-color: #1971c2; }
.course-description a.button-accent-1:active { background-color: #1c7ed6; }

.course-description a.button-accent-2 { background-color: #d9480f; }
.course-description a.button-accent-2:hover { background-color: #e8590c; }
.course-description a.button-accent-2:active { background-color: #f76707; }

.course-description a svg {
  width: 24px;
  height: 24px;
}

.result-again-button {
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px;
  margin-top: 12px;
  color: white;
}

.result-again-button svg {
  stroke: white;
}

.go-back-button {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px;
  pointer-events: all;
  font-family: var(--font);
  opacity: 0.7;
  color: white;
}

.go-back-button svg {
  stroke: white;
}