/* ── Reset & base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  font-family: 'Inter', sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  background: #F4F6F8;
}

/* ── App container — full-width, fills the viewport ───────────────────────── */
#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

/* ── Content wrap — max-width centering with breathing room ────────────────── */
.content-wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 20px;
  width: 100%;
}

/* ── Screen management ─────────────────────────────────────────────────────── */
.screen {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
.screen:not(.active) { display: none !important; }
.screen.active       { display: block !important; }

/* ── Court grid (intro + calculating bg) ───────────────────────────────────── */
.court-grid {
  background-image:
    linear-gradient(rgba(45,134,83,0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(45,134,83,0.07) 1px, transparent 1px);
  background-size: 40px 40px;
}

/* ── Padel ball (intro) ────────────────────────────────────────────────────── */
.ball-icon {
  width: 68px; height: 68px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 35%, #ffe066, #F5C518 60%, #c99a00);
  box-shadow: 0 0 0 5px rgba(245,197,24,0.18), 0 10px 28px rgba(245,197,24,0.3);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}
.ball-icon::before, .ball-icon::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,0.45);
}
.ball-icon::before { width: 75%; height: 75%; top: -22%; left: 50%; transform: translateX(-50%); }
.ball-icon::after  { width: 75%; height: 75%; bottom: -22%; left: 50%; transform: translateX(-50%); }

/* ── Small level badges (intro scale preview) ──────────────────────────────── */
.level-badge-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px; height: 42px;
  border-radius: 50%;
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

/* ── Intro screen ──────────────────────────────────────────────────────────── */
#screen-intro {
  background: #0F1C2E;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
#screen-intro.active { display: flex !important; }

#screen-intro .content-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 40px 28px;
}

/* ── Screen slide animations ───────────────────────────────────────────────── */
@keyframes slideInRight  { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideInLeft   { from { transform: translateX(-100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideQInRight { from { transform: translateX(28px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideQInLeft  { from { transform: translateX(-28px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideQOutLeft  { from { transform: translateX(0); opacity: 1; } to { transform: translateX(-28px); opacity: 0; } }
@keyframes slideQOutRight { from { transform: translateX(0); opacity: 1; } to { transform: translateX(28px); opacity: 0; } }

.screen-enter-right { animation: slideInRight  0.26s ease-out forwards; }
.screen-enter-left  { animation: slideInLeft   0.26s ease-out forwards; }
.slide-exit-left    { animation: slideQOutLeft  0.18s ease-in  forwards; }
.slide-exit-right   { animation: slideQOutRight 0.18s ease-in  forwards; }
.slide-enter-right  { animation: slideQInRight  0.22s ease-out forwards; }
.slide-enter-left   { animation: slideQInLeft   0.22s ease-out forwards; }

/* ── Question screen ───────────────────────────────────────────────────────── */
#screen-question {
  background: #F4F6F8;
  display: flex;
  flex-direction: column;
}
#screen-question.active { display: flex !important; }

/* Header */
.q-header {
  background: white;
  border-bottom: 1px solid #E5E7EB;
  padding: 0 0 12px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
}
.q-header-row {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}
.q-back-btn {
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}
.q-back-btn:hover  { background: #F3F4F6; }
.q-back-btn:active { background: #E5E7EB; }

.q-progress-wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px;
}
.q-progress-bar-track {
  height: 5px;
  background: #E5E7EB;
  border-radius: 3px;
  overflow: hidden;
}
#progress-bar {
  height: 100%;
  background: #2D8653;
  border-radius: 3px;
  transition: width 0.4s ease-out;
}

/* Question content */
#q-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.q-slide {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 20px 48px;
  display: flex;
  flex-direction: column;
}

.q-category {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  color: #2D8653;
  background: #EDF7F2;
  padding: 4px 10px;
  border-radius: 20px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 12px;
  width: fit-content;
}

.q-text {
  font-size: 1.25rem;
  font-weight: 700;
  color: #0F1C2E;
  line-height: 1.4;
  margin: 0 0 12px;
}
@media (min-width: 480px) { .q-text { font-size: 1.45rem; } }

.q-hint {
  font-size: 0.78rem;
  color: #6B7280;
  line-height: 1.5;
  margin-bottom: 8px;
  padding: 8px 12px;
  background: #F0F7FF;
  border-left: 3px solid #93C5FD;
  border-radius: 0 6px 6px 0;
}

/* ── Choice cards ──────────────────────────────────────────────────────────── */
.choice-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}
.choice-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  border: 2px solid #E5E7EB;
  border-radius: 12px;
  background: white;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.choice-card:hover  { border-color: #9CA3AF; background: #F9FAFB; }
.choice-card:active { transform: scale(0.985); }
.choice-card.selected { border-color: #2D8653; background: #EDF7F2; }

.choice-check {
  display: flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid #D1D5DB;
  font-size: 0.75rem;
  font-weight: 700;
  color: transparent;
  flex-shrink: 0;
  transition: all 0.15s;
}
.choice-card.selected .choice-check {
  border-color: #2D8653;
  background: #2D8653;
  color: white;
}
.choice-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: #374151;
  line-height: 1.35;
}
.choice-card.selected .choice-label { color: #1a5c36; font-weight: 600; }

/* ── Rating dots (CSS grid — never overlaps) ───────────────────────────────── */
.rating-area { margin-top: 20px; }

.rating-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}
.rating-dot {
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  outline: 2.5px solid #D1D5DB;
  border: none;
  background: white;
  color: #6B7280;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: outline-color 0.14s, background 0.14s, color 0.14s, transform 0.1s, box-shadow 0.14s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
  font-family: inherit;
}
.rating-dot:hover  { outline-color: #9CA3AF; background: #F9FAFB; }
.rating-dot:active { transform: scale(0.9); }
.rating-dot.selected {
  outline-color: #2D8653;
  background: #2D8653;
  color: white;
  box-shadow: 0 4px 14px rgba(45,134,83,0.38);
  transform: scale(1.06);
}

.rating-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  gap: 12px;
}
.rating-label-low, .rating-label-high {
  font-size: 0.72rem;
  color: #9CA3AF;
  line-height: 1.3;
  max-width: 42%;
}
.rating-label-high { text-align: right; }

/* ── Calculating screen ────────────────────────────────────────────────────── */
#screen-calculating {
  background: #0F1C2E;
  display: flex;
  align-items: center;
  justify-content: center;
}
#screen-calculating.active { display: flex !important; }

@keyframes ballBounce {
  0%,100% { transform: translateY(0)    scaleY(1)    scaleX(1); }
  40%     { transform: translateY(-38px) scaleY(1.1)  scaleX(0.92); }
  55%     { transform: translateY(-38px) scaleY(1.1)  scaleX(0.92); }
  80%     { transform: translateY(2px)  scaleY(0.86) scaleX(1.1); }
}
.ball-bounce {
  width: 58px; height: 58px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 35%, #ffe066, #F5C518 60%, #c99a00);
  box-shadow: 0 0 0 6px rgba(245,197,24,0.2);
  animation: ballBounce 0.95s cubic-bezier(0.36, 0.07, 0.19, 0.97) infinite;
}
@keyframes dotPulse {
  0%,80%,100% { opacity: 0.2; transform: scale(0.8); }
  40%         { opacity: 1;   transform: scale(1); }
}
.dot-pulse {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: rgba(255,255,255,0.5);
  animation: dotPulse 1.2s ease-in-out infinite;
}

/* ── Results screen ────────────────────────────────────────────────────────── */
#screen-results { background: #F4F6F8; }

/* Hero */
.results-hero {
  background: linear-gradient(160deg, #0F1C2E 0%, #193656 100%);
  padding: 40px 0 32px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.results-hero .content-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hero-badges {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-bottom: 14px;
}
.hero-badge-col { text-align: center; }
.hero-divider { width: 1px; height: 72px; background: rgba(255,255,255,0.12); flex-shrink: 0; }
.hero-badge-sub { margin-top: 8px; }
.hero-badge-scale-label { display: block; font-size: 0.68rem; color: rgba(255,255,255,0.4); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.hero-badge-scale-range { display: block; font-size: 0.8rem; color: rgba(255,255,255,0.75); font-weight: 600; margin-top: 2px; }

.level-hero-badge {
  width: 84px; height: 84px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.1rem;
  font-weight: 900;
  letter-spacing: -0.04em;
  box-shadow: 0 8px 28px rgba(0,0,0,0.28);
  flex-shrink: 0;
}

#result-label {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: rgba(255,255,255,0.7);
}

/* ── Combined dual-scale track ─────────────────────────────────────────────── */
.scale-track-wrap {
  background: white;
  border-bottom: 1px solid #F0F0F0;
  padding: 20px 0;
}
.scale-track-wrap .content-wrap {
  padding: 0 24px;
}
.scale-track-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: #9CA3AF;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 14px;
}

/* Zone row — 7-column grid, zones span proportional columns */
.ct-zones-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  margin-bottom: 6px;
}
.ct-zone {
  border-radius: 5px;
  padding: 5px 0;
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #C4C4C4;
  background: #F3F4F6;
  transition: all 0.3s;
}
.ct-zone-d.ct-zone-active { background: #D1FAE5; color: #15803D; }
.ct-zone-c.ct-zone-active { background: #DBEAFE; color: #1D4ED8; }
.ct-zone-b.ct-zone-active { background: #EDE9FE; color: #6D28D9; }
.ct-zone-a.ct-zone-active { background: #FEF9C3; color: #92400E; }

/* Nodes row with connecting line */
.ct-nodes-wrap {
  position: relative;
  height: 52px;
  display: flex;
  align-items: center;
}
.ct-line-bg,
.ct-line-fill {
  position: absolute;
  left: calc(100% / 14);
  right: calc(100% / 14);
  height: 4px;
  border-radius: 2px;
  pointer-events: none;
}
.ct-line-bg   { background: #E5E7EB; }
.ct-line-fill {
  background: linear-gradient(90deg, #2D8653, #48b87a);
  transition: width 0.7s cubic-bezier(0.4,0,0.2,1);
  width: 0%;
}
.ct-nodes-row {
  position: relative;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  z-index: 1;
}
.ct-node {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: white;
  outline: 2px solid #D1D5DB;
  border: none;
  font-size: 0.8rem;
  font-weight: 700;
  color: #9CA3AF;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto;
  transition: all 0.3s;
}
.ct-node.ct-node-passed {
  background: #2D8653;
  outline-color: #2D8653;
  color: white;
}
@keyframes nodePulse {
  0%,100% { box-shadow: 0 0 0 0   rgba(45,134,83,0.5); }
  50%     { box-shadow: 0 0 0 9px rgba(45,134,83,0); }
}
.ct-node.ct-node-active {
  width: 44px; height: 44px;
  background: #2D8653;
  outline-color: #2D8653;
  color: white;
  font-size: 1rem;
  font-weight: 900;
  box-shadow: 0 4px 16px rgba(45,134,83,0.4);
  animation: nodePulse 1.8s ease-in-out infinite;
}

/* Position pill */
.ct-position-pill {
  margin-top: 12px;
  display: inline-block;
  background: #F0FDF4;
  color: #166534;
  border: 1.5px solid #BBF7D0;
  border-radius: 999px;
  padding: 5px 16px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* ── Result cards ──────────────────────────────────────────────────────────── */
.result-cards {
  padding: 20px 0 120px;
}
.result-cards .content-wrap {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.result-card {
  background: white;
  border-radius: 16px;
  padding: 18px 18px 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.result-card-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: #9CA3AF;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin: 0 0 10px;
}
#result-description {
  font-size: 0.92rem;
  color: #374151;
  line-height: 1.65;
  margin: 0;
}

/* Next steps */
.next-steps-list {
  list-style: none;
  margin: 0; padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.next-step-item { display: flex; align-items: flex-start; gap: 10px; }
.next-step-icon { font-size: 1.2rem; flex-shrink: 0; margin-top: 1px; }
.next-step-text { font-size: 0.88rem; color: #374151; line-height: 1.6; margin: 0; }

/* ── Racket cards ──────────────────────────────────────────────────────────── */
.racket-style-note {
  font-size: 13px;
  color: #6B7280;
  margin: -4px 0 16px;
}
.racket-style-note strong { color: #374151; }

.racket-cards-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.racket-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #F9FAFB;
  border: 1.5px solid #E5E7EB;
  border-radius: 14px;
  padding: 12px 14px;
}
.racket-img-wrap {
  flex-shrink: 0;
  width: 72px;
  height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #F3F4F6;
  border-radius: 10px;
  overflow: hidden;
}
.racket-img-wrap.img-missing {
  background: #F3F4F6;
}
.racket-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}
.racket-info { flex: 1; min-width: 0; }
.racket-tagline {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 3px;
}
.racket-brand {
  font-size: 11px;
  font-weight: 500;
  color: #9CA3AF;
  margin-bottom: 6px;
}
.racket-why {
  font-size: 12px;
  line-height: 1.5;
  color: #374151;
  margin-bottom: 8px;
  font-style: italic;
}
/* Clickable image link */
.racket-img-link {
  display: block;
  flex-shrink: 0;
  border-radius: 10px;
  overflow: hidden;
  transition: opacity 0.15s, transform 0.15s;
}
.racket-img-link:hover { opacity: 0.85; transform: scale(1.03); }
.racket-img-link:active { opacity: 0.7; }
/* Clickable name link */
.racket-name-link {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: #111827;
  text-decoration: none;
  margin-bottom: 1px;
  transition: color 0.15s;
}
.racket-name-link:hover { color: #2D8653; text-decoration: underline; }
.racket-level-badge {
  display: inline-block;
  background: #F3F4F6;
  color: #6B7280;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
}

/* ── Sticky results footer ─────────────────────────────────────────────────── */
#results-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid #E5E7EB;
  padding: 10px 16px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  display: none;
  gap: 10px;
  z-index: 100;
}
/* On wide screens: center it under the content column */
@media (min-width: 680px) {
  #results-footer {
    max-width: 640px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.07);
  }
}

.footer-btn {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 13px 10px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
}
.footer-btn:active { transform: scale(0.97); opacity: 0.85; }
.footer-btn-primary   { background: #2D8653; color: white; }
.footer-btn-secondary { background: #F3F4F6; color: #374151; }

/* ── App footer ────────────────────────────────────────────────────────────── */
.app-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px 0 8px;
  font-size: 12px;
  font-weight: 400;
  color: #9CA3AF;
}

/* Dark background variant (intro + calculating) */
.app-footer-dark {
  color: rgba(255, 255, 255, 0.28);
  padding-top: 24px;
}

/* Question screen variant — sits at bottom of the flex column */
.app-footer-question {
  flex-shrink: 0;
  border-top: 1px solid #F3F4F6;
  padding: 10px 0;
  background: #F4F6F8;
}

/* Calculating screen — absolute pinned to bottom */
.app-footer-abs {
  position: absolute;
  bottom: 16px;
  left: 0;
  right: 0;
  padding: 0;
}

.app-footer-sep { opacity: 0.5; }

.app-footer-dev {
  color: inherit;
  text-decoration: none;
  transition: color 0.15s, opacity 0.15s;
}
.app-footer-dev:hover { opacity: 0.75; text-decoration: underline; }

.app-footer-dev-dark { color: rgba(255, 255, 255, 0.28); }
.app-footer-dev-dark:hover { color: rgba(255, 255, 255, 0.55); text-decoration: underline; }

/* ── Misc ──────────────────────────────────────────────────────────────────── */
button { font-family: inherit; -webkit-tap-highlight-color: transparent; }
