:root {
  --bg-deep: #041e32;
  --accent: #5eead4;
  --accent-glow: rgba(94, 234, 212, 0.4);
  --gold: #ffd166;
  --octo-color: #e07a5f;
  --card: rgba(255, 255, 255, 0.07);
  --card-border: rgba(255, 255, 255, 0.12);
  --text: #f0f8ff;
  --muted: #8fb4cc;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
}

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

html, body {
  margin: 0;
  min-height: 100%;
  font-family: "Nunito", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg-deep);
  overflow-x: hidden;
}

a { color: var(--accent); }
.muted { color: var(--muted); }

.ocean-bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(30, 120, 180, 0.3), transparent 55%),
    linear-gradient(180deg, #041e32, #062a45 60%, #041520);
  z-index: 0;
  pointer-events: none;
}

.step {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100dvh;
}

.step[hidden] { display: none !important; }

/* ── ШАГ 1: выбор матча ── */
.step--pick {
  display: flex;
  flex-direction: column;
  padding:
    calc(1rem + env(safe-area-inset-top, 0px))
    calc(1rem + env(safe-area-inset-right, 0px))
    calc(2rem + env(safe-area-inset-bottom, 0px))
    calc(1rem + env(safe-area-inset-left, 0px));
  max-width: 1200px;
  margin: 0 auto;
}

.pick-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.brand-emoji { font-size: 2.4rem; }
.pick-header h1 { margin: 0; font-size: 1.5rem; font-weight: 900; }
.pick-header p { margin: 0.2rem 0 0; font-size: 0.85rem; }

.pick-banner {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 222px;
  margin: 0 0 1rem;
  padding: 1rem 1.1rem 0.85rem;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(94, 234, 212, 0.28);
  background:
    linear-gradient(180deg, rgba(2, 18, 32, 0.55) 0%, rgba(2, 18, 32, 0.08) 38%, rgba(2, 18, 32, 0.08) 62%, rgba(2, 18, 32, 0.72) 100%),
    url("../assets/images/banner-octopus.png") center 42% / cover no-repeat;
  box-shadow: 0 14px 42px rgba(0, 0, 0, 0.35);
}

.pick-banner-title,
.pick-banner-subtitle {
  position: relative;
  z-index: 1;
  margin: 0;
  text-align: center;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.75);
}

.pick-banner-title {
  font-size: clamp(1.35rem, 4vw, 2rem);
  font-weight: 900;
  letter-spacing: 0.02em;
  color: #fff;
}

.pick-banner-subtitle {
  align-self: center;
  margin-top: auto;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  font-size: clamp(0.78rem, 2.4vw, 0.95rem);
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #062a45;
  background: linear-gradient(180deg, #ffe08a, var(--gold));
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
}

.pick-sections {
  flex: 1;
  overflow-y: auto;
  max-height: calc(100dvh - 394px);
  padding-bottom: 0.5rem;
}

.pick-section {
  margin-bottom: 1.25rem;
}

.pick-section--main {
  padding: 1rem;
  border-radius: 18px;
  border: 1px solid rgba(94, 234, 212, 0.35);
  background: linear-gradient(180deg, rgba(94, 234, 212, 0.08), rgba(4, 30, 48, 0.4));
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.pick-section--plain {
  padding: 0 0.25rem;
}

.pick-section-title {
  margin: 0 0 0.25rem;
  font-size: 1rem;
  font-weight: 900;
}

.pick-section-hint {
  margin: 0 0 0.75rem;
  font-size: 0.78rem;
}

.pick-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.65rem;
}

.pick-loading,
.pick-empty {
  text-align: center;
  color: var(--muted);
  padding: 1rem 0.5rem;
  font-size: 0.85rem;
  margin: 0;
}

.pick-loading code,
.pick-loading small {
  font-size: 0.72rem;
}

.pick-card {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-rows: auto auto auto auto;
  gap: 0.35rem 0.5rem;
  align-items: center;
  text-align: center;
  padding: 0.85rem 0.75rem;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  background: var(--card);
  color: inherit;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
  position: relative;
}
.pick-card--static {
  cursor: default;
}
.pick-card--static:hover {
  transform: none;
  box-shadow: none;
}
.pick-card:hover:not(:disabled):not(.pick-card--static) {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.pick-card:disabled { opacity: 0.45; cursor: not-allowed; }

.pick-card--live {
  border-color: rgba(255, 82, 82, 0.45);
}

.pick-card--stale {
  opacity: 0.72;
  filter: grayscale(0.35);
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.06);
}

.pick-card--replay:hover:not(:disabled) {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.pick-card-guess {
  grid-column: 1 / -1;
  margin: 0.2rem 0 0;
  font-size: 0.78rem;
  font-weight: 900;
  text-align: center;
}
.pick-card-guess--ok { color: #4ade80; }
.pick-card-guess--fail { color: #f87171; }

.pick-card-badge {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  font-size: 0.62rem;
  font-weight: 900;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.pick-card-badge--live {
  background: #ff5252;
  color: #fff;
  animation: live-pulse 1.4s ease-in-out infinite;
}
.pick-card-badge--done {
  background: rgba(255, 255, 255, 0.12);
  color: var(--muted);
}
.pick-card-badge--soon {
  background: rgba(94, 234, 212, 0.2);
  color: var(--accent);
}
@keyframes live-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}

.pick-card-meta {
  grid-column: 1 / -1;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
}

.pick-card-team {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.15;
}
.pick-card-team--home { grid-column: 1; }
.pick-card-team--away { grid-column: 3; }

.pick-flag {
  width: 52px;
  height: 36px;
  object-fit: contain;
  border: none;
  background: transparent;
}

.pick-card-vs {
  grid-column: 2;
  grid-row: 2;
  font-size: 0.7rem;
  font-weight: 900;
  color: var(--gold);
  opacity: 0.7;
}

.pick-card-score {
  grid-column: 2;
  grid-row: 2;
  font-size: 1rem;
  font-weight: 900;
  color: var(--gold);
}

.pick-card-odds {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-top: 0.15rem;
}

.pick-odd {
  font-size: 0.68rem;
  font-weight: 800;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.pick-odd em {
  font-style: normal;
  color: var(--muted);
  margin-right: 0.2rem;
  font-weight: 700;
}

.pick-source {
  margin: 0.75rem 0 0;
  font-size: 0.68rem;
  text-align: center;
}

/* ── ШАГ 2: думает ── */
.step--think {
  display: grid;
  place-items: center;
  padding:
    calc(1.5rem + env(safe-area-inset-top, 0px))
    calc(1.5rem + env(safe-area-inset-right, 0px))
    calc(1.5rem + env(safe-area-inset-bottom, 0px))
    calc(1.5rem + env(safe-area-inset-left, 0px));
}

.think-card {
  text-align: center;
  max-width: 420px;
  width: 100%;
  padding: 2rem 1.5rem;
  background: rgba(4, 30, 48, 0.9);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  animation: think-in 0.5s ease;
}

@keyframes think-in {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

.think-octo {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  margin-bottom: 1rem;
  height: 64px;
}
.think-body {
  font-size: 3rem;
  animation: think-wobble 1s ease-in-out infinite;
}
.think-leg {
  display: block;
  width: 8px;
  height: 28px;
  background: linear-gradient(180deg, var(--octo-color), #a04030);
  border-radius: 0 0 50% 50%;
  animation: think-leg 0.8s ease-in-out infinite;
}
.think-leg:nth-child(odd) { animation-delay: 0.15s; height: 22px; }

@keyframes think-wobble {
  0%, 100% { transform: rotate(-6deg); }
  50% { transform: rotate(6deg); }
}
@keyframes think-leg {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(1.2); }
}

.think-card h2 {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
  font-weight: 900;
}
.think-match {
  margin: 0 0 1.25rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--gold);
}

.think-bar {
  height: 8px;
  background: rgba(255,255,255,0.1);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0.75rem;
}
.think-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--octo-color), var(--accent));
  border-radius: 999px;
  transition: width 0.1s linear;
}

.think-status {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  min-height: 1.2em;
}

/* ── ШАГ 3: видео ── */
.step--video {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding:
    0.5rem
    calc(0.5rem + env(safe-area-inset-right, 0px))
    calc(0.5rem + env(safe-area-inset-bottom, 0px))
    calc(0.5rem + env(safe-area-inset-left, 0px));
  gap: 0.75rem;
}

.video-wrap {
  position: relative;
  width: min(960px, 100vw);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: #000;
}

.video-wrap::before {
  content: "";
  display: block;
  padding-top: 56.25%;
}

@supports (aspect-ratio: 16 / 9) {
  .video-wrap::before {
    display: none;
  }
  .video-wrap {
    aspect-ratio: 16 / 9;
  }
}

.video-wrap > .scene-canvas,
.video-wrap > .scene-video-src,
.video-wrap > .video-loading,
.video-wrap > .freebet-drawer {
  position: absolute;
  inset: 0;
}

.scene-canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  z-index: 2;
}

.scene-video-src {
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  z-index: 1;
  pointer-events: none;
}

.video-loading {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  background: rgba(4, 30, 48, 0.82);
  backdrop-filter: blur(4px);
}

.video-loading[hidden] {
  display: none !important;
}

.video-loading-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(94, 234, 212, 0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: video-spin 0.85s linear infinite;
}

@keyframes video-spin {
  to { transform: rotate(360deg); }
}

.video-loading-text {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--text);
  text-align: center;
  padding: 0 1rem;
}

.video-ui {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1rem;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  width: 100%;
  max-width: min(960px, 100vw);
}

.video-speech {
  margin: 0;
  background: #fff;
  color: #1a2a3a;
  font-weight: 800;
  font-size: 1rem;
  padding: 0.55rem 1.1rem;
  border-radius: 14px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.35);
  animation: speech-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes speech-pop {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}

.btn-reset {
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font-family: inherit;
  font-weight: 700;
  font-size: 0.85rem;
  min-height: 44px;
  padding: 0.65rem 1.25rem;
  border-radius: 999px;
  cursor: pointer;
  transition: opacity 0.35s ease;
}
.btn-reset[hidden] { display: none; }
.btn-reset:hover { background: rgba(94, 234, 212, 0.12); }

/* ── Фрибеты (полный оверлей поверх видео) ── */
.freebet-drawer {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  background: linear-gradient(180deg, #0f3d5c, #062a45);
  transition: opacity 0.4s ease, visibility 0.4s;
}
.freebet-drawer.is-open {
  pointer-events: auto;
  opacity: 1;
  visibility: visible;
}

.freebet-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: transparent;
  border-top: none;
  padding: clamp(0.45rem, 2vw, 0.75rem) clamp(0.5rem, 2.2vw, 0.85rem) clamp(0.35rem, 1.5vw, 0.55rem);
  box-shadow: none;
}

.freebet-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: clamp(0.25rem, 1.2vw, 0.4rem);
  flex-shrink: 0;
}
.freebet-emoji { font-size: clamp(1.1rem, 3.5vw, 1.45rem); }
.freebet-head h3 { margin: 0; font-size: clamp(0.78rem, 2.6vw, 0.95rem); font-weight: 900; line-height: 1.15; }
.freebet-sub { margin: 0.1rem 0 0; font-size: clamp(0.62rem, 2vw, 0.75rem); color: var(--muted); line-height: 1.2; }

.freebet-track {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: clamp(0.35rem, 1.4vw, 0.55rem);
  min-height: 0;
  overflow: hidden;
}

.freebet-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  min-height: 0;
  min-width: 0;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: clamp(0.55rem, 2.4vw, 0.9rem) clamp(0.6rem, 2.5vw, 0.95rem);
}

.freebet-bk {
  display: flex;
  align-items: center;
  gap: clamp(0.35rem, 1.2vw, 0.55rem);
  margin-bottom: clamp(0.25rem, 1vw, 0.4rem);
  flex-shrink: 0;
}
.freebet-logo {
  width: clamp(30px, 8vw, 42px);
  height: clamp(30px, 8vw, 42px);
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: clamp(0.55rem, 1.8vw, 0.7rem);
  color: #fff;
  flex-shrink: 0;
}
.freebet-logo--betboom { background: linear-gradient(135deg, #ff3d00, #ff9100); }
.freebet-logo--pari { background: linear-gradient(135deg, #6c5ce7, #a29bfe); }
.freebet-logo--ligastavok { background: linear-gradient(135deg, #00b894, #00cec9); }
.freebet-logo--olimpbet { background: linear-gradient(135deg, #e17055, #fdcb6e); }
.freebet-bk-name {
  font-weight: 900;
  font-size: clamp(0.82rem, 3vw, 1.05rem);
  line-height: 1.1;
}
.freebet-offer {
  font-size: clamp(0.78rem, 2.9vw, 1rem);
  font-weight: 800;
  color: var(--gold);
  margin: 0;
  line-height: 1.25;
  flex: 1;
  display: flex;
  align-items: center;
}
.freebet-detail {
  font-size: clamp(0.68rem, 2.4vw, 0.88rem);
  color: var(--muted);
  margin: clamp(0.2rem, 0.8vw, 0.35rem) 0;
  line-height: 1.25;
  flex-shrink: 0;
}
.freebet-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 44px;
  text-align: center;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  background: var(--accent);
  color: #043049;
  font-weight: 800;
  font-size: clamp(0.72rem, 2.6vw, 0.92rem);
  text-decoration: none;
  margin-top: clamp(0.2rem, 0.8vw, 0.35rem);
  flex-shrink: 0;
}
.legal {
  flex-shrink: 0;
  margin: clamp(0.2rem, 1vw, 0.35rem) 0 0;
  font-size: clamp(0.52rem, 1.6vw, 0.62rem);
  text-align: center;
  line-height: 1.15;
}

@media (max-width: 768px) {
  .pick-grid { grid-template-columns: 1fr; }
  .pick-banner {
    min-height: 180px;
    padding: 0.75rem 0.85rem 0.7rem;
  }
  .pick-sections { max-height: calc(100dvh - 360px); }

  .video-wrap > .freebet-drawer.is-open {
    position: fixed;
    inset: 0;
    z-index: 200;
    border-radius: 0;
  }

  .freebet-drawer.is-open .freebet-panel {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
  }

  .freebet-track {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    grid-auto-rows: auto;
    flex: none;
    overflow: visible;
    gap: 0.6rem;
  }

  .freebet-card {
    height: auto;
    min-height: unset;
  }

  .freebet-offer {
    flex: none;
  }
}
