:root {
  --red: #e50914;
  --red-dark: #b0060f;
  --red-bg: rgba(180, 0, 0, .75);
}

html, body {
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #000;
  color: #fff;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
  touch-action: manipulation;
}

/* === LOADING === */
#loading-screen {
  position: fixed; inset: 0;
  background: #000; z-index: 100;
  display: flex; align-items: center; justify-content: center;
}
#loading-screen.hidden { opacity: 0; pointer-events: none; transition: opacity .3s; }
.loader {
  width: 36px; height: 36px;
  border: 3px solid rgba(255,255,255,.08);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === WRAPPER === */
#video-wrapper {
  position: fixed; top: 0; left: 0;
  width: 100vw; height: 100dvh;
  background: #000; z-index: 10; overflow: hidden;
}
#video {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: contain; background: #000;
}

/* === TAP LAYER === */
#tap-layer {
  position: absolute; inset: 0;
  z-index: 50;
  background: transparent;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* === CENTER BUTTON === */
#center-btn {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 72px; height: 72px; border-radius: 50%;
  background: rgba(0,0,0,.5);
  border: 2px solid rgba(255,255,255,.2);
  display: none; align-items: center; justify-content: center;
  z-index: 55;
}
#center-btn svg { width: 30px; height: 30px; fill: #fff; }
#center-btn.show { display: flex; }

/* === CONTROLS BAR === */
#player-controls {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 0 16px 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgba(0,0,0,.85));
  z-index: 55; display: none;
  flex-direction: column; gap: 8px;
}
#player-controls.show { display: flex; }

#progress-container {
  width: 100%; height: 5px;
  background: rgba(255,255,255,.15);
  border-radius: 3px;
}
#progress-bar {
  height: 100%; background: var(--red);
  border-radius: 3px; max-width: 100%;
  position: relative; transition: width .2s linear;
}
#progress-bar::after {
  content: ''; position: absolute; right: -6px; top: 50%;
  transform: translateY(-50%);
  width: 14px; height: 14px;
  background: var(--red); border-radius: 50%;
}

#controls-row {
  display: flex; align-items: center; justify-content: space-between;
}
.controls-left, .controls-right {
  display: flex; align-items: center; gap: 12px;
}

.ctrl-btn {
  background: none; border: none; color: #fff;
  padding: 6px;
  display: flex; align-items: center; justify-content: center;
}
.ctrl-btn svg { width: 28px; height: 28px; fill: currentColor; }

.volume-group { display: flex; align-items: center; gap: 6px; }
.volume-icon { display: flex; align-items: center; padding: 4px; }
.volume-icon svg { width: 24px; height: 24px; fill: #fff; }
#volume-slider {
  -webkit-appearance: none; appearance: none;
  width: 70px; height: 3px;
  background: rgba(255,255,255,.25);
  border-radius: 2px; outline: none;
}
#volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px; height: 12px;
  background: #fff; border-radius: 50%;
}

#countdown-display {
  font-size: 13px; font-weight: 700;
  color: var(--red);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
#countdown-display.urgent { animation: blink .6s ease-in-out infinite; }
#countdown-display.reached { color: #22c55e; animation: none; }
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: .3; }
}

.speed-group {
  display: flex;
  background: rgba(255,255,255,.08);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.1);
}
.speed-option {
  font-size: 12px; font-weight: 700;
  color: rgba(255,255,255,.45);
  background: transparent; border: none;
  padding: 5px 12px;
  position: relative; line-height: 1;
}
.speed-option:not(:last-child)::after {
  content: ''; position: absolute; right: 0; top: 20%;
  height: 60%; width: 1px;
  background: rgba(255,255,255,.1);
}
.speed-option.active {
  color: #fff; background: var(--red);
}
.speed-option.active::after { display: none; }

/* === OFFER FLASH === */
#offer-flash {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 60; display: none;
  background: rgba(229,9,20,.92); color: #fff;
  padding: 18px 36px; border-radius: 8px;
  font-size: 18px; font-weight: 700;
  text-align: center;
  animation: flash-pulse .8s ease-in-out infinite;
  box-shadow: 0 0 50px rgba(229,9,20,.4);
  max-width: 90%;
}
#offer-flash.show { display: block; }
@keyframes flash-pulse {
  0%, 100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: .7; transform: translate(-50%, -50%) scale(1.03); }
}

/* === UNMUTE HINT (auto-play muted state) === */
#unmute-hint {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 16px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, .75);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 65;
  backdrop-filter: blur(8px);
  animation: pulse-hint 2s ease-in-out infinite;
  pointer-events: none;
}
#unmute-hint.hidden { display: none; }
#unmute-hint svg { width: 18px; height: 18px; fill: #fff; }
@keyframes pulse-hint {
  0%, 100% { transform: translateX(-50%) scale(1); opacity: 1; }
  50% { transform: translateX(-50%) scale(1.05); opacity: .85; }
}

/* === IN-VIDEO MESSAGES === */
.in-video-msg {
  position: absolute; left: 50%;
  transform: translateX(-50%) translateY(-12px);
  background: rgba(0, 0, 0, .85);
  color: #fff;
  padding: 12px 22px;
  border-radius: 8px;
  font-size: 15px; font-weight: 700;
  text-align: center;
  max-width: 86%;
  z-index: 58;
  opacity: 0;
  pointer-events: none;
  transition: opacity .35s ease, transform .35s ease;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .4);
  white-space: pre-wrap;
}
.in-video-msg.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.in-video-msg.pos-top { top: calc(env(safe-area-inset-top) + 60px); }
.in-video-msg.pos-center { top: 50%; transform: translate(-50%, calc(-50% - 12px)); }
.in-video-msg.pos-center.show { transform: translate(-50%, -50%); }
.in-video-msg.pos-bottom { bottom: 90px; }

@media (max-width: 768px) {
  .in-video-msg { font-size: 14px; padding: 10px 18px; }
}

/* === PAUSE OVERLAY (vermelho, zoom) === */
#pause-overlay {
  position: absolute; inset: 0;
  background: var(--red-bg);
  display: none; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 60; padding: 20px;
  animation: zoom-in .3s ease-out;
}
#pause-overlay.show { display: flex; }
@keyframes zoom-in {
  from { transform: scale(1.08); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
#pause-overlay-text {
  color: #fff;
  font-size: clamp(16px, 4.5vw, 24px);
  font-weight: 700; text-align: center;
  max-width: 520px; line-height: 1.5;
  margin-bottom: 24px;
  text-shadow: 0 2px 8px rgba(0,0,0,.5);
}
#pause-overlay-btn {
  background: #fff; color: #b00; border: none;
  padding: 14px 44px;
  font-size: 16px; font-weight: 800;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* === START SCREEN (dopaminérgica) === */
#start-screen {
  position: absolute; inset: 0;
  z-index: 80;
  display: flex; align-items: center; justify-content: center;
  touch-action: manipulation;
}
#start-screen.hidden { display: none; }
#start-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.4);
}
#start-content {
  position: relative; z-index: 2;
  display: flex; flex-direction: column;
  align-items: center; gap: 14px;
  pointer-events: none;
}
#start-ring {
  width: 110px; height: 110px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  animation: ring-pulse 2s ease-in-out infinite;
}
#start-ring::before {
  content: ''; position: absolute; inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(229,9,20,.4);
  animation: ring-expand 2s ease-in-out infinite;
}
#start-ring::after {
  content: ''; position: absolute; inset: -16px;
  border-radius: 50%;
  border: 1px solid rgba(229,9,20,.2);
  animation: ring-expand 2s ease-in-out infinite .3s;
}
#start-play {
  width: 90px; height: 90px; border-radius: 50%;
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  border: none;
  display: flex; align-items: center; justify-content: center;
  box-shadow:
    0 0 30px rgba(229,9,20,.6),
    0 0 60px rgba(229,9,20,.3),
    inset 0 0 20px rgba(255,255,255,.1);
  transition: transform .15s;
}
#start-play:active { transform: scale(.95); }
#start-play svg {
  width: 38px; height: 38px; fill: #fff;
  margin-left: 5px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.3));
}
#start-label {
  color: #fff;
  font-size: 15px; font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  text-align: center;
  text-shadow: 0 2px 8px rgba(0,0,0,.5);
}
#start-sub {
  color: rgba(255,255,255,.7);
  font-size: 13px; font-weight: 600;
  display: flex; align-items: center; gap: 4px;
  animation: pulse-sub 2s ease-in-out infinite;
}
#start-sub svg {
  width: 18px; height: 18px; fill: #fff;
  vertical-align: middle;
}
@keyframes ring-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
@keyframes ring-expand {
  0% { transform: scale(1); opacity: .6; }
  100% { transform: scale(1.4); opacity: 0; }
}
@keyframes pulse-sub {
  0%, 100% { opacity: .7; }
  50% { opacity: .35; }
}

/* === RESUME SCREEN === */
#resume-screen {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.88);
  display: flex; align-items: center; justify-content: center;
  z-index: 75; padding: 24px;
}
#resume-screen.hidden { display: none !important; }
.resume-box {
  display: flex; flex-direction: column; gap: 12px;
  max-width: 340px; width: 100%;
}
.resume-box p {
  font-size: 17px; line-height: 1.4;
  margin-bottom: 8px; text-align: center;
}
.resume-box button {
  padding: 14px 20px; border-radius: 8px;
  font-size: 16px; font-weight: 700;
  background: var(--red); color: #fff;
}
.resume-box button.secondary {
  background: rgba(255,255,255,.12);
}
.resume-box button.checkout {
  background: #22c55e;
}
.resume-box button.hidden { display: none; }

/* === CHECKOUT (fade in) === */
#checkout-section {
  position: fixed; inset: 0;
  background: #fff;
  z-index: 5; opacity: 0; pointer-events: none;
  transition: opacity .8s cubic-bezier(.4, 0, .2, 1);
}
#checkout-section.visible {
  opacity: 1; pointer-events: auto;
}
#checkout-iframe {
  width: 100%; height: 100%;
  border: none;
}

/* === PIP MODE (canto inferior direito) === */
#video-wrapper.pip-mode {
  position: fixed;
  top: auto; left: auto;
  bottom: 20px; right: 20px;
  width: 320px; height: 180px;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.6);
  z-index: 9999;
}
#video-wrapper.pip-mode #video { object-fit: cover; }
#video-wrapper.pip-mode #tap-layer,
#video-wrapper.pip-mode #center-btn,
#video-wrapper.pip-mode #player-controls,
#video-wrapper.pip-mode #offer-flash,
#video-wrapper.pip-mode #pause-overlay,
#video-wrapper.pip-mode #start-screen { display: none !important; }

#pip-close {
  display: none; position: absolute;
  top: -8px; right: -8px;
  width: 28px; height: 28px;
  background: rgba(0,0,0,.85);
  border: 2px solid rgba(255,255,255,.4);
  border-radius: 50%;
  color: #fff; font-size: 16px; font-weight: 700;
  align-items: center; justify-content: center;
  z-index: 10001;
  line-height: 1;
}
#video-wrapper.pip-mode #pip-close { display: flex; }

/* === MOBILE === */
@media (max-width: 768px) {
  #player-controls {
    padding: 0 14px 20px;
    padding-bottom: max(24px, env(safe-area-inset-bottom, 24px));
    gap: 10px;
  }
  #progress-container { height: 7px; }
  #progress-bar::after { width: 16px; height: 16px; right: -7px; }
  .ctrl-btn { padding: 8px; }
  .ctrl-btn svg { width: 30px; height: 30px; }
  .volume-icon svg { width: 26px; height: 26px; }
  #volume-slider { display: none !important; }
  #center-btn { width: 80px; height: 80px; }
  #center-btn svg { width: 36px; height: 36px; }
  .speed-option { padding: 6px 11px; font-size: 12px; }
  #countdown-display { font-size: 15px; font-weight: 800; }
  #start-ring { width: 120px; height: 120px; }
  #start-play { width: 100px; height: 100px; }
  #start-play svg { width: 42px; height: 42px; }
  #start-label { font-size: 16px; letter-spacing: 2px; }
  #start-sub { font-size: 14px; }
  #offer-flash { font-size: 15px; padding: 14px 24px; }
  #video-wrapper.pip-mode {
    width: 180px; height: 100px;
    bottom: 12px; right: 12px;
  }
}
@media (max-width: 400px) {
  #player-controls { padding: 0 10px 16px; }
  .controls-left, .controls-right { gap: 8px; }
  .speed-option { padding: 5px 8px; font-size: 11px; }
}
