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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: fixed;
  top: 0;
  left: 0;
  background: #000;
  font-family: 'Ultra', 'Arial Black', Arial, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
button, input, select, textarea { font-family: inherit; }

#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

.screen {
  position: fixed; inset: 0; z-index: 10;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  background: #000;
}
.hidden { display: none !important; }

#portada {
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  inset: 0;
}

.name-input {
  position: absolute;
  bottom: 83px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  font-size: clamp(18px, 3.25vw, 26px);
  font-weight: 400;
  color: #000;
  background: rgba(255,255,255,0.9);
  border: 3px solid rgba(72, 230, 200, 0.75);
  border-radius: 50px;
  padding: 12px 30px;
  text-align: center;
  outline: none;
  box-shadow: 0 0 15px rgba(72, 230, 200, 0.3);
}

.btn-main {
  position: relative;
  z-index: 2;
  margin-top: auto;
  margin-bottom: 9.67vh;
  padding: 18px 60px;
  font-size: clamp(20px, 4vw, 36px);
  font-weight: 900;
  color: #fff;
  background: linear-gradient(180deg, #22c55e, #15803d);
  border: 4px solid #fff;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 8px 0 rgba(0,0,0,0.4), 0 0 30px rgba(34,197,94,0.6);
  letter-spacing: 4px;
  transition: transform 0.1s;
  font-family: 'Roboto', sans-serif;
}
.btn-main:hover { transform: scale(1.05); }
.btn-main:active { transform: translateY(4px); box-shadow: 0 4px 0 rgba(0,0,0,0.4); }

.name-input {
  position: absolute;
  bottom: 250px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  font-size: clamp(18px, 3.25vw, 26px);
  font-weight: 400;
  color: #000;
  background: #fff;
  border: 3px solid #000;
  border-radius: 30px;
  text-align: center;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
  min-width: 260px;
  padding: 13px 26px;
  font-family: 'Roboto', sans-serif;
}
.name-input::placeholder {
  color: rgba(0,0,0,0.5);
}
.name-input:focus {
  border-color: #22c55e;
  background: #fff;
}

#splash { justify-content: flex-end; }

/* HUD */
#hud {
  position: fixed; inset: 0; z-index: 5;
  pointer-events: none;
}
.hud-top-right {
  position: absolute;
  top: 20px; right: 20px;
  display: flex;
  gap: 12px;
  pointer-events: auto;
}
.hud-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: rgba(0,0,0,0.55);
  border: 2px solid #fff;
  border-radius: 50%;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: all 0.2s;
}
.hud-btn:hover {
  transform: scale(1.1);
}
.hud-btn:active {
  transform: scale(0.95);
}
.hud-btn svg {
  flex-shrink: 0;
}
.hud-btn.audio-on {
  background: rgba(76, 175, 80, 0.7);
  border-color: #81c784;
}
.hud-btn.audio-on:hover {
  background: rgba(76, 175, 80, 0.85);
}
.hud-btn.audio-off {
  background: rgba(244, 67, 54, 0.7);
  border-color: #e57373;
}
.hud-btn.audio-off:hover {
  background: rgba(244, 67, 54, 0.85);
}
.audio-icon {
  width: 24px;
  height: 24px;
}
#scoreBox {
  position: absolute;
  bottom: 20px; left: 20px;
  background: rgba(10, 60, 20, 0.55);
  border: 3px solid rgba(72, 230, 200, 0.75);
  border-radius: 18px;
  padding: 16px 24px;
  color: #fff;
  text-align: center;
  backdrop-filter: blur(6px);
  box-shadow: 0 0 10px rgba(72, 230, 200, 0.25);
}
#shotsBox {
  position: absolute;
  bottom: 20px; right: 20px;
  background: rgba(10, 60, 20, 0.55);
  border: 3px solid rgba(72, 230, 200, 0.75);
  border-radius: 18px;
  padding: 16px 24px;
  color: #fff;
  text-align: center;
  backdrop-filter: blur(6px);
  box-shadow: 0 0 10px rgba(72, 230, 200, 0.25);
}
.player-name { font-size: clamp(29px, 4.8vw, 38px); font-weight: 700; letter-spacing: 1px; color: #ffd54a; margin-bottom: 3px; text-shadow: 0 2px 4px rgba(0,0,0,0.6); font-family: 'Roboto', sans-serif; }
.score-label { font-size: clamp(26px, 4vw, 35px); letter-spacing: 2px; opacity: 0.9; font-family: 'Roboto', sans-serif; margin-right: 8px; }
.score-row { display: flex; align-items: center; justify-content: center; gap: 8px; }
#score { font-size: clamp(77px, 12.8vw, 115px); color: #ffd54a; line-height: 1; margin: 0; text-shadow: 0 2px 6px rgba(0,0,0,0.6); }
.shots-label { display: flex; align-items: center; justify-content: center; gap: 13px; font-size: clamp(22px, 3.2vw, 29px); letter-spacing: 0 px; opacity: 0.85; font-family: 'Roboto', sans-serif; margin-top: 2px; }
.shots-label img { width: clamp(78px, 11.8vw, 110px); height: clamp(78px, 11.8vw, 110px); }

#message {
  position: absolute;
  top: 70%; left: 50%;
  transform: translate(-50%, -50%) scale(0.5);
  font-size: clamp(80px, 18vw, 192px);
  color: #fff;
  text-shadow: 0 2px 0 #000;
  opacity: 0;
  transition: opacity 0.35s cubic-bezier(.2,1.6,.4,1), transform 0.35s cubic-bezier(.2,1.6,.4,1);
  letter-spacing: 3px;
  -webkit-text-stroke: 2px #000;
  will-change: transform, opacity;
  white-space: nowrap;
}
#message.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#message.goal { color: #ffd54a; }
#message.miss { color: #ff5252; }

#instructions {
  position: absolute;
  bottom: 40%;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-size: clamp(30px, 3vw, 28px);
  letter-spacing: 2px;
  text-shadow: 0 2px 6px rgba(0,0,0,0.8), 0 0 12px rgba(0,0,0,0.6);
  opacity: 0.85;
  animation: pulse 1.4s ease-in-out infinite;
  font-family: 'Roboto', sans-serif;
}

/* Desktop-only: increase instructions text size by 1.2x */
@media (min-width: 1025px) {
  #instructions {
    font-size: clamp(36px, 3.6vw, 34px);
  }
  .hud-btn {
    width: 62px;
    height: 62px;
  }
  .audio-icon {
    width: 31px;
    height: 31px;
  }
  .hud-btn svg {
    width: 31px;
    height: 31px;
  }
}
@keyframes pulse { 50% { opacity: 0.4; } }
#instructions.hide { display: none; }

#swipePointer {
  position: absolute;
  bottom: 35%;
  left: 50%;
  transform: translateX(-50%);
  opacity: 0.9;
  animation: swipeAnim 1.5s ease-in-out infinite;
}
@keyframes swipeAnim {
  0%, 100% { transform: translateX(-50%) translateY(60px); opacity: 0.5; }
  50% { transform: translateX(-50%) translateY(-60px); opacity: 1; }
}

#swipePointerLeft {
  position: absolute;
  bottom: 35%;
  left: 40%;
  transform: translateX(-50%);
  opacity: 0.9;
  animation: swipeLeftAnim 1.5s ease-in-out infinite;
}
@keyframes swipeLeftAnim {
  0%, 100% { transform: translateX(-50%) translate(60px, 60px); opacity: 0.5; }
  50% { transform: translateX(-50%) translate(-60px, -60px); opacity: 1; }
}

#swipePointerRight {
  position: absolute;
  bottom: 35%;
  left: 60%;
  transform: translateX(-50%);
  opacity: 0.9;
  animation: swipeRightAnim 1.5s ease-in-out infinite;
}
@keyframes swipeRightAnim {
  0%, 100% { transform: translateX(-50%) translate(-60px, 60px); opacity: 0.5; }
  50% { transform: translateX(-50%) translate(60px, -60px); opacity: 1; }
}

#swipePointer.hide, #swipePointerLeft.hide, #swipePointerRight.hide { display: none; }

/* End */
#endScreen { background: rgba(0,0,0,0.6); }
#endScreen.screenshot-transparent { background: transparent !important; }
.end-card {
  background: rgba(10, 60, 20, 0.75);
  border: 3px solid rgba(72, 230, 200, 0.75);
  border-radius: 22px;
  backdrop-filter: blur(8px);
  box-shadow: 0 0 20px rgba(72, 230, 200, 0.3);
  padding: 32px 44px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
}
.end-content {
  display: flex;
  align-items: center;
  gap: 40px;
}
.end-image-container {
  flex-shrink: 0;
}
.end-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.btn-home {
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  transition: transform 0.2s;
}
.btn-home:hover {
  transform: scale(1.1);
}
.btn-home:active {
  transform: scale(0.95);
}
.btn-home-label {
  color: #ffd54a !important;
  font-family: 'Roboto', sans-serif;
  font-size: clamp(10px, 1.4vw, 13px);
  font-weight: 700;
  letter-spacing: 1px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
  white-space: nowrap;
}
.splash-home {
  cursor: default;
}
.btn-home img {
  display: block;
}
.end-win-image {
  width: clamp(300px, 62.5vw, 500px);
  height: auto;
  display: block;
  filter: drop-shadow(0 0 0 4px rgba(255,255,255,1));
}
.end-win-image.hidden {
  display: none;
}
.end-lose-image {
  width: clamp(300px, 62.5vw, 500px);
  height: auto;
  display: block;
  filter: drop-shadow(0 0 0 4px rgba(255,255,255,1));
}
.end-lose-image.hidden {
  display: none;
}
.end-lose-message {
  font-size: clamp(18px, 4vw, 28px);
  font-weight: 700;
  letter-spacing: 1px;
  color: #ffd54a;
  text-align: center;
  margin-bottom: 20px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.6);
  font-family: 'Roboto', sans-serif;
}
.end-lose-message.hidden {
  display: none;
}
.end-player-name {
  font-size: clamp(24px, 5vw, 36px);
  color: #ffd54a;
  text-align: center;
  margin-bottom: 15px;
  font-weight: 700;
  letter-spacing: 2px;
  text-shadow: 0 4px 8px rgba(0,0,0,0.8);
  font-family: 'Roboto', sans-serif;
}
#endTitle {
  font-size: clamp(40px, 10vw, 120px);
  color: #fff;
  text-align: center;
  margin-bottom: 20px;
  -webkit-text-stroke: 3px #000;
  text-shadow: 0 6px 0 #000;
  padding: 0 20px;
}
#endTitle.win { color: #ffd54a; }
#endTitle.lose { color: #22c55e; font-size: clamp(32px, 8vw, 96px); }
#endScore {
  font-size: clamp(20px, 4vw, 36px);
  color: #fff;
  margin-bottom: 30px;
  font-family: 'Roboto', sans-serif;
}
.btn-secondary {
  position: relative;
  z-index: 2;
  margin: 0 0 20px 0;
  padding: 14px 40px;
  font-size: clamp(16px, 3vw, 24px);
  font-weight: 700;
  color: #fff;
  background: linear-gradient(180deg, #3b82f6, #1d4ed8);
  font-family: 'Roboto', sans-serif;
  border: 3px solid #fff;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 6px 0 rgba(0,0,0,0.4), 0 0 20px rgba(59,130,246,0.5);
  letter-spacing: 1px;
  transition: transform 0.1s;
}
.btn-secondary:hover { transform: scale(1.05); }
.btn-secondary:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(0,0,0,0.4); }
#endScreen .btn-main { margin: 0; }
.end-card .btn-main { margin: 0; }

/* Loading */
#loading { color: #ffd54a; font-size: 22px; gap: 20px; z-index: 20; }
.spinner {
  width: 60px; height: 60px;
  border: 5px solid rgba(255,255,255,0.2);
  border-top-color: #22c55e;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  margin-bottom: 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-ball {
  width: 25px;
  height: 25px;
  animation: bounce 1s ease-in-out infinite;
}
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-15px); }
}

/* Confetti */
#confetti {
  position: fixed;
  inset: 0;
  z-index: 15;
  pointer-events: none;
}

/* Rotate device overlay */
#rotateOverlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #000;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 30px;
  text-align: center;
  color: #fff;
}
.rotate-icon {
  font-size: 80px;
  margin-bottom: 30px;
  animation: rotateAnim 2s ease-in-out infinite;
}
.rotate-ball {
  width: 30px;
  height: 30px;
  margin-bottom: 30px;
  animation: bounce 1s ease-in-out infinite;
}
.rotate-text {
  font-size: clamp(20px, 6vw, 32px);
  font-weight: 900;
  letter-spacing: 1px;
  line-height: 1.4;
  text-shadow: 0 2px 6px rgba(0,0,0,0.8);
  max-width: 90%;
  font-family: 'Roboto', sans-serif;
}
@keyframes rotateAnim {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(90deg); }
}
/* Show overlay only on portrait mobile/tablet devices */
@media (orientation: portrait) and (max-width: 1024px) {
  #rotateOverlay { display: flex; }
}

/* Mobile-only text size adjustments (landscape phones) */
@media (max-width: 1200px) and (orientation: landscape) {
  #message { font-size: clamp(40px, 10vw, 90px); letter-spacing: 2px; -webkit-text-stroke: 1px #000; }
  #message.miss { font-size: clamp(34px, 8.5vw, 77px); }
  #message.saved { font-size: clamp(34px, 8.5vw, 77px); }
  #instructions { font-size: clamp(14px, 2.2vw, 18px); letter-spacing: 1px; }
  #endTitle { font-size: clamp(16.8px, 4.2vw, 38.4px); -webkit-text-stroke: 1px #000; }
  #endTitle.win { font-size: clamp(16.8px, 4.2vw, 38.4px); -webkit-text-stroke: 1px #000; }
  #endTitle.lose { font-size: clamp(13.2px, 3.3vw, 31.2px); -webkit-text-stroke: 1px #000; }
  .end-player-name { font-size: clamp(16px, 3.5vw, 24px); margin-bottom: 3px; }
  #endScore { font-size: clamp(14px, 3vw, 22px); margin-bottom: 6px; }
  .end-content { gap: 20px; }
  .end-info { gap: 4px; }
  .end-win-image { width: clamp(160px, 30vw, 240px); margin-bottom: 0; }
  .end-lose-image { width: clamp(160px, 30vw, 240px); margin-bottom: 0; }
  .end-lose-message { font-size: clamp(12px, 2.5vw, 16px); margin-bottom: 6px; letter-spacing: 0.5px; }
  .btn-main { font-size: clamp(14px, 3vw, 24px); padding: 12px 36px; margin-bottom: 7.4vh; }
  .btn-secondary { font-size: clamp(12px, 2.5vw, 18px); padding: 10px 28px; }
  .player-name { font-size: clamp(13px, 2.4vw, 17px); }
  .score-label { font-size: clamp(10px, 1.6vw, 13px); }
  #score { font-size: clamp(22px, 4.5vw, 36px); }
  .shots-label { font-size: clamp(14px, 2vw, 18px); letter-spacing: 0px; }
  .shots-label img { width: clamp(39px, 5.9vw, 55px); height: clamp(39px, 5.9vw, 55px); }
  .name-input { font-size: clamp(11px, 2vw, 16px); padding: 8px 20px; min-width: 160px; bottom: 100px; }
  #swipePointer, #swipePointerLeft, #swipePointerRight { width: 30px; height: 30px; }
  #swipePointer svg, #swipePointerLeft svg, #swipePointerRight svg { width: 30px; height: 30px; }
  #scoreBox { padding: 11px 17px; }
  #shotsBox { padding: 10px 14px; right: 15px; }
  .btn-home { top: 7px; left: 10px; }
  .btn-home-label { font-size: clamp(8px, 1.2vw, 11px); }
}

/* iOS-specific arrow scaling */
@supports (-webkit-touch-callout: none) and (orientation: landscape) {
  #swipePointer, #swipePointerLeft, #swipePointerRight { width: 30px; height: 30px; }
  #swipePointer svg, #swipePointerLeft svg, #swipePointerRight svg { width: 30px; height: 30px; }
}
