:root {
  --red: #d51223;
  --red-dark: #73000b;
  --gold: #ffd43b;
  --blue: #24b7ff;
  --ink: #07030b;
  --panel: rgba(8, 5, 16, 0.82);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #020205;
  color: #fff;
  font-family: Arial, Helvetica, sans-serif;
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}

button,
a {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

#app {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 30%, rgba(120, 0, 20, 0.35), transparent 45%),
    #020205;
}

.screen {
  position: relative;
  width: min(100vw, calc(100svh * 9 / 16));
  height: min(100svh, calc(100vw * 16 / 9));
  max-width: 100vw;
  max-height: 100svh;
  overflow: hidden;
  background: #08040c;
  isolation: isolate;
}

.is-hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}


.preloader-screen {
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 35%, rgba(255, 196, 32, 0.28), transparent 26%),
    radial-gradient(circle at 50% 55%, rgba(205, 18, 35, 0.38), transparent 48%),
    linear-gradient(180deg, #190006, #05030b 72%);
}

.preloader-glow {
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(90deg, transparent 0 8%, rgba(255,255,255,0.025) 8.2% 8.4%),
    linear-gradient(130deg, transparent 35%, rgba(38, 184, 255, 0.12) 50%, transparent 65%);
  animation: loaderSweep 3.2s linear infinite;
  pointer-events: none;
}

.preloader-card {
  position: relative;
  z-index: 1;
  width: min(88%, 430px);
  padding: 28px 22px 24px;
  border: 1px solid rgba(255, 214, 65, 0.62);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(89, 0, 14, 0.9), rgba(5, 6, 18, 0.96));
  box-shadow: 0 0 46px rgba(255, 33, 50, 0.3), inset 0 0 32px rgba(255, 209, 54, 0.08);
  text-align: center;
}

.preloader-kicker {
  margin: 0 0 5px;
  color: #ffd84a;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.22em;
}

.preloader-card h1 {
  margin: 0 0 20px;
  font-size: clamp(1.9rem, 9vw, 3.2rem);
  line-height: 0.95;
  text-shadow: 0 0 24px rgba(255, 43, 49, 0.56);
}

.loader-ball {
  width: 76px;
  height: 76px;
  margin: 0 auto 18px;
  border: 7px solid #fff;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #d31225 0 19%, transparent 20%),
    conic-gradient(from 15deg, #ffd43b, #d31225, #fff, #d31225, #ffd43b);
  box-shadow: 0 0 28px rgba(255, 206, 55, 0.65);
  animation: loaderSpin 1.15s linear infinite;
}

.loader-track {
  width: 100%;
  height: 15px;
  overflow: hidden;
  border: 1px solid rgba(255, 222, 90, 0.5);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.46);
  box-shadow: inset 0 0 10px rgba(0,0,0,0.7);
}

#loaderFill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #d50e24, #ff8a13 48%, #ffe85a);
  box-shadow: 0 0 18px rgba(255, 202, 45, 0.72);
  transition: width 180ms ease-out;
}

#loaderPercent {
  display: block;
  margin-top: 10px;
  color: #ffe15b;
  font-size: 1.3rem;
}

#loaderStatus {
  min-height: 1.4em;
  margin: 7px 0 0;
  color: rgba(255,255,255,0.76);
  font-size: 0.82rem;
}

.loader-enter {
  width: 100%;
  margin-top: 16px;
}

@keyframes loaderSpin {
  to { transform: rotate(360deg); }
}

@keyframes loaderSweep {
  from { transform: translateX(-18%); }
  to { transform: translateX(18%); }
}

.home-screen {
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.05), rgba(0, 0, 0, 0.7)),
    radial-gradient(circle at 50% 45%, rgba(255, 36, 40, 0.42), transparent 48%),
    #08040c;
}

.cover-art {
  position: absolute;
  inset: 0;
  background-image: url('../assets/img/cpw_cover_spain.jpg');
  background-size: cover;
  background-position: center;
  z-index: -2;
}

.home-vignette {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(180deg, transparent 48%, rgba(0, 0, 0, 0.36) 64%, rgba(0, 0, 0, 0.88) 100%),
    radial-gradient(ellipse at center, transparent 45%, rgba(0, 0, 0, 0.35) 100%);
  pointer-events: none;
}

.home-content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: max(18px, env(safe-area-inset-top)) 22px max(16px, env(safe-area-inset-bottom));
}

.home-spacer {
  flex: 1;
}

.menu-card {
  width: min(86%, 420px);
  display: grid;
  gap: 10px;
  padding: 18px;
  border: 1px solid rgba(255, 216, 65, 0.55);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(35, 0, 5, 0.78), rgba(3, 3, 10, 0.9));
  box-shadow:
    0 0 28px rgba(255, 22, 35, 0.28),
    inset 0 0 24px rgba(255, 205, 45, 0.08);
  backdrop-filter: blur(8px);
}

.primary-btn,
.secondary-btn,
.icon-btn {
  min-height: 52px;
  border-radius: 12px;
  font-weight: 900;
  letter-spacing: 0.07em;
}

.primary-btn {
  color: #270003;
  background: linear-gradient(180deg, #fff36c 0%, #ffc928 48%, #ff7a00 100%);
  box-shadow:
    0 4px 0 #9b2800,
    0 0 22px rgba(255, 195, 40, 0.45);
}

.primary-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #9b2800;
}

.secondary-btn,
.icon-btn {
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: linear-gradient(180deg, rgba(47, 59, 91, 0.9), rgba(12, 14, 30, 0.96));
}

.icon-btn {
  min-height: 44px;
  font-size: 0.8rem;
}

.controls-copy {
  margin: 5px 0 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: clamp(0.72rem, 2.2vw, 0.88rem);
  line-height: 1.35;
  text-align: center;
}

.powered {
  margin-top: 14px;
  color: #fff;
  font-size: 0.8rem;
  text-decoration: none;
  text-shadow: 0 1px 6px #000;
}

.game-screen {
  background: #05020a;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.hud {
  position: absolute;
  z-index: 4;
  top: max(8px, env(safe-area-inset-top));
  left: 8px;
  right: 8px;
  display: grid;
  grid-template-columns: 1fr 0.75fr 0.75fr;
  gap: 6px;
  pointer-events: none;
}

.hud-box {
  min-width: 0;
  padding: 7px 10px 8px;
  border: 1px solid rgba(255, 203, 54, 0.42);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(35, 4, 8, 0.88), rgba(5, 8, 22, 0.88));
  box-shadow: inset 0 0 14px rgba(255, 172, 24, 0.08), 0 3px 12px rgba(0, 0, 0, 0.45);
}

.hud-box span {
  display: block;
  color: #ffd64a;
  font-size: clamp(0.56rem, 1.7vw, 0.72rem);
  letter-spacing: 0.1em;
}

.hud-box strong {
  display: block;
  overflow: hidden;
  font-size: clamp(0.88rem, 3vw, 1.25rem);
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-actions {
  position: absolute;
  z-index: 5;
  top: calc(max(8px, env(safe-area-inset-top)) + 61px);
  right: 8px;
  display: flex;
  gap: 7px;
}

.round-btn {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 211, 67, 0.55);
  border-radius: 50%;
  color: #fff;
  background: rgba(6, 7, 18, 0.82);
  box-shadow: 0 0 14px rgba(255, 48, 48, 0.2);
}

.level-banner {
  position: absolute;
  z-index: 7;
  top: 42%;
  left: 50%;
  min-width: 62%;
  padding: 16px 24px;
  transform: translate(-50%, -50%);
  border: 2px solid #ffd43b;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(133, 0, 15, 0.93), rgba(10, 5, 18, 0.96));
  box-shadow: 0 0 36px rgba(255, 47, 47, 0.55), inset 0 0 24px rgba(255, 205, 60, 0.15);
  text-align: center;
  animation: bannerPulse 0.9s ease-in-out infinite alternate;
  pointer-events: none;
}

.level-banner span,
.level-banner small {
  display: block;
  letter-spacing: 0.18em;
}

.level-banner strong {
  display: block;
  margin: 2px 0;
  color: #ffe363;
  font-size: clamp(3rem, 15vw, 6rem);
  line-height: 0.95;
  text-shadow: 0 0 18px rgba(255, 211, 48, 0.7);
}

@keyframes bannerPulse {
  from { transform: translate(-50%, -50%) scale(0.97); }
  to { transform: translate(-50%, -50%) scale(1.02); }
}

.modal {
  position: absolute;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(8px);
}

.modal-card {
  width: min(92%, 420px);
  display: grid;
  gap: 12px;
  padding: 24px;
  border: 1px solid rgba(255, 215, 60, 0.58);
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(99, 0, 12, 0.96), rgba(7, 7, 19, 0.98));
  box-shadow: 0 0 40px rgba(255, 32, 45, 0.35);
  text-align: center;
}

.modal-card h2 {
  margin: 0 0 8px;
  color: #ffe36a;
  font-size: clamp(1.8rem, 8vw, 3rem);
}

.modal-card p {
  margin: 0;
  font-size: 1.05rem;
}

.orientation-hint {
  display: none;
}

@media (orientation: landscape) and (max-height: 650px) {
  .orientation-hint {
    position: absolute;
    z-index: 50;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 30px;
    background: #05020a;
    color: #ffe05b;
    font-weight: 800;
    text-align: center;
  }
}


/* Perfil estable para móviles: se eliminan animaciones y filtros de composición
   que en algunos Android provocan parpadeos sobre el canvas. */
@media (pointer: coarse), (max-width: 700px) {
  .game-screen {
    contain: layout paint size;
  }

  .level-banner {
    animation: none;
  }

  .hud-box,
  .round-btn {
    box-shadow: none;
  }

  .modal {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}
