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

body {
  background: #000;
  overflow: hidden;
  font-family: 'Impact', 'Arial Black', sans-serif;
  color: #fff;
  user-select: none;
  -webkit-user-select: none;
}

#game {
  position: fixed;
  inset: 0;
}

/* ── Video layer ── */

#video-container {
  position: absolute;
  inset: -30px;
  will-change: transform;
}

#video-placeholder {
  position: absolute;
  inset: 0;
  background: #111;
  transition: background 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

#placeholder-label {
  display: none;
  font-size: 42px;
  letter-spacing: 4px;
  color: #fff;
  text-align: center;
  line-height: 1.4;
  white-space: pre;
  font-family: 'Courier New', monospace;
}

.clip {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  visibility: hidden;
}

.clip.active {
  visibility: visible;
}

/* ── UI overlay ── */

#ui-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 28px 32px;
  pointer-events: none;
}

/* "Tap to begin" splash */

#splash {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  cursor: pointer;
  transition: opacity 500ms ease;
}

#splash.hidden {
  opacity: 0;
  pointer-events: none;
}

#splash-text {
  font-family: 'Helvetica Neue', 'Inter', system-ui, -apple-system, sans-serif;
  font-weight: 200;
  font-size: clamp(11px, 1.6vw, 15px);
  letter-spacing: 6px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.72);
  text-shadow: none;
  animation: splash-pulse 2.6s ease-in-out infinite;
}

@keyframes splash-pulse {
  0%, 100% { opacity: 0.45; }
  50%      { opacity: 0.85; }
}

/* End-of-demo overlay — matches splash aesthetic (minimal, uppercase, pulsing CTA) */

#demo-end {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  cursor: pointer;
  transition: opacity 600ms ease;
}

#demo-end.hidden {
  opacity: 0;
  pointer-events: none;
}

#demo-end-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  text-align: center;
}

#demo-end-title {
  font-family: 'Helvetica Neue', 'Inter', system-ui, -apple-system, sans-serif;
  font-weight: 200;
  font-size: clamp(22px, 3.4vw, 38px);
  letter-spacing: 10px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.92);
}

#demo-end-sub {
  font-family: 'Helvetica Neue', 'Inter', system-ui, -apple-system, sans-serif;
  font-weight: 200;
  font-size: clamp(10px, 1.3vw, 13px);
  letter-spacing: 5px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
}

#demo-end-cta {
  margin-top: 14px;
  font-family: 'Helvetica Neue', 'Inter', system-ui, -apple-system, sans-serif;
  font-weight: 200;
  font-size: clamp(11px, 1.6vw, 15px);
  letter-spacing: 6px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.72);
  animation: splash-pulse 2.6s ease-in-out infinite;
}

.credit-line {
  font-family: 'Helvetica Neue', 'Inter', system-ui, -apple-system, sans-serif;
  font-weight: 300;
  font-size: clamp(9px, 1vw, 11px);
  letter-spacing: 3px;
  line-height: 1.8;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.38);
  text-align: center;
  pointer-events: auto;
}

.credit-line a {
  color: rgba(255, 255, 255, 0.62);
  text-decoration: none;
  transition: color 180ms ease, text-shadow 180ms ease;
}

.credit-line a:hover,
.credit-line a:focus-visible {
  color: rgba(255, 255, 255, 0.95);
  text-shadow: 0 0 18px rgba(255, 255, 255, 0.28);
  outline: none;
}

#demo-end-credit {
  max-width: min(560px, calc(100vw - 48px));
  margin-top: 12px;
}

/* Idle coach text — same treatment as splash, fades in/out with state */

#idle-text {
  position: absolute;
  bottom: 26%;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Helvetica Neue', 'Inter', system-ui, -apple-system, sans-serif;
  font-weight: 200;
  font-size: clamp(11px, 1.6vw, 15px);
  letter-spacing: 6px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.72);
  text-align: center;
  white-space: nowrap;
  padding: 22px 56px;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  isolation: isolate;
  transition: opacity 600ms ease, visibility 0s linear 600ms;
}

#idle-text::before {
  content: '';
  position: absolute;
  inset: -8px -24px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  -webkit-mask-image: radial-gradient(ellipse at center, #000 35%, transparent 85%);
          mask-image: radial-gradient(ellipse at center, #000 35%, transparent 85%);
  z-index: -1;
}

#idle-text.visible {
  opacity: 1;
  visibility: visible;
  transition: opacity 600ms ease, visibility 0s;
}

/* Image buttons with idle/hover cross-fade (Start + punch buttons) */

.btn-fade {
  position: relative;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  pointer-events: auto;
}

.btn-img {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
  transition: opacity 420ms ease;
}

.btn-img-hover {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.btn-fade:hover .btn-img-hover { opacity: 1; }
.btn-fade:hover .btn-img-idle  { opacity: 0; }

.btn-fade:active { transform: scale(0.96); }

/* Title-screen START button */

#btn-start {
  position: absolute;
  left: 50%;
  bottom: 26%;
  transform: translateX(-50%);
  display: none;
  width: clamp(180px, 22vw, 320px);
}

#btn-start.visible {
  display: block;
}

#btn-start:active { transform: translateX(-50%) scale(0.96); }

#title-credit {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  padding: 36px 24px 20px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.72) 0%, rgba(0, 0, 0, 0.5) 45%, rgba(0, 0, 0, 0) 100%);
  color: rgba(255, 255, 255, 0.82);
  opacity: 0;
  visibility: hidden;
  transition: opacity 700ms ease, visibility 0s linear 700ms;
}

#title-credit a {
  color: rgba(255, 255, 255, 0.96);
}

#btn-start.visible + #title-credit {
  opacity: 1;
  visibility: visible;
  transition: opacity 700ms ease 200ms, visibility 0s;
}

/* Input overlay */

#input-overlay {
  position: absolute;
  left: 50%;
  bottom: 26%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 14px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease, visibility 0s linear 0.15s;
}

#input-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.15s ease, visibility 0s;
}

#punch-buttons {
  display: flex;
  gap: clamp(12px, 2vw, 28px);
  align-items: center;
  justify-content: center;
}

.punch-btn {
  width: clamp(120px, 18vw, 220px);
}

/* Timer bar */

#timer-bar-container {
  width: 220px;
  height: 3px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  overflow: hidden;
}

#timer-bar {
  height: 100%;
  width: 100%;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 2px;
}

/* ── Game over overlay ── */

#game-over-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
}

#game-over-box {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}

#game-over-text {
  font-size: 56px;
  letter-spacing: 6px;
  text-shadow: 0 0 40px rgba(255, 255, 255, 0.35);
  line-height: 1.1;
}

#replay-btn {
  background: transparent;
  border: 1.5px solid rgba(255, 255, 255, 0.55);
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  letter-spacing: 5px;
  padding: 13px 36px;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s, border-color 0.15s;
}

#replay-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.9);
}

/* ── Result flash ── */

@keyframes flash-success {
  0%   { box-shadow: none; }
  40%  { box-shadow: inset 0 0 120px rgba(0, 230, 100, 0.35); }
  100% { box-shadow: none; }
}

@keyframes flash-fail {
  0%   { box-shadow: none; }
  40%  { box-shadow: inset 0 0 120px rgba(230, 30, 30, 0.45); }
  100% { box-shadow: none; }
}

@keyframes flash-draw {
  0%   { box-shadow: none; }
  40%  { box-shadow: inset 0 0 120px rgba(120, 140, 230, 0.4); }
  100% { box-shadow: none; }
}

#game.flash-success { animation: flash-success 0.5s ease forwards; }
#game.flash-fail    { animation: flash-fail    0.5s ease forwards; }
#game.flash-draw    { animation: flash-draw    0.5s ease forwards; }
