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

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100%;
  overflow: hidden;
  touch-action: none;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #fceef5;
  color: #5f5363;
}

#app {
  width: 100vw;
  height: var(--vvh, 100dvh);
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 18% 8%, rgba(255, 246, 201, .95) 0, transparent 28%),
    radial-gradient(circle at 82% 18%, rgba(217, 246, 239, .9) 0, transparent 25%),
    radial-gradient(circle at 48% 92%, rgba(231, 216, 255, .95) 0, transparent 30%),
    linear-gradient(180deg, #fff7fb 0%, #fceef5 100%);
}

.screen {
  display: none;
  width: min(100vw, 480px);
  height: var(--vvh, 100dvh);
  max-height: 920px;
  padding: 22px;
  position: relative;
}

.screen.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#startScreen.screen.active,
#gameOverScreen.screen.active {
  justify-content: flex-start;
  padding-top: max(10px, env(safe-area-inset-top, 0px));
}

.logo {
  text-align: center;
  margin-bottom: 14px;
}

.logo .brand {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
  color: #a36a93;
  font-weight: 800;
  letter-spacing: .04em;
  box-shadow: 0 10px 30px rgba(167, 111, 151, .14);
}

.logo h1 {
  margin: 14px 0 6px;
  font-size: clamp(42px, 12vw, 64px);
  line-height: .9;
  color: #c47dad;
  text-shadow: 0 4px 0 rgba(255,255,255,.8);
}

.logo p {
  margin: 0 auto;
  max-width: 300px;
  font-size: 16px;
}

.logo.small h1 {
  font-size: clamp(34px, 10vw, 52px);
}

.card, .result-card {
  width: 100%;
  max-width: 360px;
  padding: 18px;
  margin: 8px 0 20px;
  border-radius: 26px;
  background: rgba(255,255,255,.72);
  box-shadow: 0 18px 40px rgba(167, 111, 151, .16);
  text-align: center;
}

.result-card strong {
  display: block;
  font-size: 58px;
  color: #c47dad;
  margin: 2px 0 10px;
}

/* Anuncio fijo 320x100: solo inicio y pantalla de derrota.
   El wrapper recorta cualquier creatividad que AdSense intente renderizar fuera del tamaño. */
.ad-container {
  width: 320px !important;
  height: 100px !important;
  min-width: 320px !important;
  min-height: 100px !important;
  max-width: 320px !important;
  max-height: 100px !important;
  flex: 0 0 100px !important;
  margin: 0 auto 14px;
  padding: 0 !important;
  border-radius: 16px;
  background: rgba(255,255,255,.52);
  border: 1px dashed rgba(196,125,173,.35);
  box-shadow: 0 10px 24px rgba(167, 111, 151, .10);
  overflow: hidden !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  position: relative;
  align-self: center;
  line-height: 0 !important;
  font-size: 0 !important;
  isolation: isolate;
}

.ad-container .adsbygoogle,
.ad-container .fixed-ad-320x100,
.ad-container ins {
  display: inline-block !important;
  width: 320px !important;
  height: 100px !important;
  min-width: 320px !important;
  min-height: 100px !important;
  max-width: 320px !important;
  max-height: 100px !important;
  flex: 0 0 320px !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  position: relative !important;
  line-height: 0 !important;
}

.ad-container iframe,
.ad-container [id^="aswift"],
.ad-container [id^="google_ads"],
.ad-container [id^="google_ads_iframe"] {
  width: 320px !important;
  height: 100px !important;
  max-width: 320px !important;
  max-height: 100px !important;
  min-width: 320px !important;
  min-height: 100px !important;
  overflow: hidden !important;
  border: 0 !important;
}

#gameScreen .ad-container {
  display: none !important;
}

@media (max-width: 335px) {
  .ad-container {
    transform: scale(calc((100vw - 16px) / 320));
    transform-origin: top center;
    margin-bottom: calc(14px - (100px - (100px * ((100vw - 16px) / 320))));
  }
}

button {
  border: 0;
  cursor: pointer;
  font-weight: 800;
  font-size: 18px;
  border-radius: 999px;
}

.main-btn {
  width: min(100%, 340px);
  padding: 17px 24px;
  background: #ff9fc4;
  color: white;
  box-shadow: 0 12px 0 #df7ba6, 0 20px 40px rgba(223, 123, 166, .28);
}

.main-btn:active {
  transform: translateY(5px);
  box-shadow: 0 7px 0 #df7ba6, 0 12px 28px rgba(223, 123, 166, .24);
}

.ghost-btn {
  margin-top: 16px;
  padding: 12px 20px;
  color: #9c6c8e;
  background: rgba(255,255,255,.64);
}

#gameScreen.active {
  justify-content: flex-start;
  padding: 7px 12px calc(env(safe-area-inset-bottom, 0px) + 8px);
  position: relative;
  overflow: hidden;
  gap: 5px;
}

#hud {
  z-index: 2;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  flex: 0 0 auto;
}

#hud div {
  background: rgba(255,255,255,.72);
  border-radius: 16px;
  padding: 6px 7px;
  text-align: center;
  box-shadow: 0 6px 16px rgba(167, 111, 151, .09);
  min-height: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#hud span {
  display: block;
  font-size: 11px;
  line-height: 1.05;
  opacity: .72;
}

#hud strong {
  font-size: 20px;
  line-height: 1.05;
  color: #be77a8;
}


#hud .score-box {
  position: relative;
  overflow: visible;
}

#scoreGain {
  position: absolute;
  left: 50%;
  bottom: -13px;
  transform: translateX(-50%) translateY(4px);
  min-width: max-content;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255,255,255,.92);
  box-shadow: 0 7px 16px rgba(167, 111, 151, .18);
  color: #c47dad;
  font-style: normal;
  font-size: 13px;
  font-weight: 950;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  z-index: 8;
  white-space: nowrap;
}

#scoreGain.show {
  animation: scoreGainPop .72s ease-out forwards;
}

#scoreGain.big {
  color: #f29a4b;
}

#scoreGain.huge {
  color: #ef5f68;
  font-size: 14px;
}

@keyframes scoreGainPop {
  0% { opacity: 0; transform: translateX(-50%) translateY(5px) scale(.86); }
  18% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1.08); }
  62% { opacity: 1; transform: translateX(-50%) translateY(-5px) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-13px) scale(.96); }
}

#hud.score-bump .score-box strong {
  animation: scoreNumberBump .28s ease-out;
}

@keyframes scoreNumberBump {
  0% { transform: scale(1); }
  45% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

#comboTimer {
  position: relative;
  z-index: 3;
  width: 100%;
  height: 13px;
  border-radius: 999px;
  background: rgba(255,255,255,.74);
  overflow: hidden;
  flex: 0 0 auto;
  box-shadow: inset 0 0 0 1px rgba(196,125,173,.18);
}

#comboTimer.is-empty {
  opacity: .58;
}

#comboTimerLabel {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: rgba(125,88,117,.70);
  pointer-events: none;
}

#comboFill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: #ff9fc4;
  transition: width .08s linear;
  transform-origin: left center;
}
#comboTimer.is-empty #comboFill {
  width: 100%;
  opacity: .16;
}

#gameCanvas {
  width: 100%;
  height: auto;
  aspect-ratio: 9 / 16;
  max-height: calc(var(--vvh, 100dvh) - 172px - env(safe-area-inset-bottom, 0px));
  border-radius: 32px;
  background: #fffafd;
  border: 3px solid rgba(255,255,255,.86);
  box-shadow:
    inset 0 0 0 2px rgba(196,125,173,.12),
    inset 0 0 28px rgba(255, 210, 229, .26),
    0 18px 38px rgba(167, 111, 151, .18),
    0 5px 0 rgba(255,255,255,.54);
  flex: 0 1 auto;
}

#powerStatus {
  display: none;
}

#bottomPanel {
  z-index: 5;
  width: 100%;
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  flex: 0 0 auto;
}

#activeEffects {
  width: 100%;
  min-height: 62px;
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 6px 4px;
}

#activeEffects:empty::after {
  content: "";
}

.effect-pill {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  background: rgba(255,255,255,.86);
  box-shadow: inset 0 0 0 1px rgba(196,125,173,.10), 0 8px 18px rgba(167, 111, 151, .13);
  display: grid;
  grid-template-rows: 14px 28px 8px;
  align-items: center;
  justify-items: center;
  padding: 4px 5px 5px;
}
.effect-pill img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  grid-row: 2 / 3;
}
.effect-time {
  font-size: 9px;
  line-height: 1;
  font-weight: 950;
  color: #7d5875;
  grid-row: 1 / 2;
  white-space: nowrap;
  text-transform: uppercase;
}
.effect-bar {
  height: 5px;
  border-radius: 99px;
  background: #ff9fc4;
  justify-self: stretch;
  grid-row: 3 / 4;
  transform-origin: left center;
}
#stormBanner {
  min-height: 0;
  height: 0;
  overflow: hidden;
}

@media (max-height: 700px) {
  .screen {
    padding: 14px;
  }
}


html, body, canvas, button, #app {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}
@media (max-width: 380px) {
  .effect-pill { width: 54px; height: 56px; }
  #activeEffects { gap: 6px; }
}

@media (max-height: 720px) {
  #gameScreen.active { padding-top: 8px; gap: 5px; }
  #hud div { padding: 5px 6px; min-height: 44px; border-radius: 15px; }
  #hud strong { font-size: 19px; }
  #hud span { font-size: 10px; }
  
#comboTimer { height: 12px; }
  #gameCanvas { max-height: calc(var(--vvh, 100dvh) - 158px - env(safe-area-inset-bottom, 0px)); }
  #bottomPanel, #activeEffects { min-height: 56px; }
  .effect-pill { width: 52px; height: 54px; border-radius: 16px; }
  .effect-pill img { width: 26px; height: 26px; }
}


/* Ranking online */
.ranking-card,
.submit-card {
  width: 100%;
  max-width: 360px;
  padding: 14px 16px;
  margin: 4px 0 16px;
  border-radius: 24px;
  background: rgba(255,255,255,.72);
  box-shadow: 0 14px 34px rgba(167, 111, 151, .13);
  text-align: center;
}

.ranking-title {
  font-weight: 900;
  color: #a36a93;
  margin-bottom: 8px;
}

.ranking-list {
  list-style: none;
  padding: 0;
  margin: 0;
  width: 100%;
}

.ranking-list li {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 6px 4px;
  color: #6c5a70;
  font-weight: 800;
  border-bottom: 1px solid rgba(196,125,173,.12);
}

.ranking-list.compact li {
  padding: 4px 2px;
  font-size: 14px;
}

.ranking-list li:last-child {
  border-bottom: 0;
}

.rank-name {
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-score {
  color: #c47dad;
  font-variant-numeric: tabular-nums;
}

.rank-link {
  margin-top: 8px;
  border: 0;
  background: transparent;
  color: #c47dad;
  font-size: 14px;
  font-weight: 900;
  text-decoration: underline;
  padding: 4px 8px;
  box-shadow: none;
}

.submit-card {
  margin-top: -8px;
  margin-bottom: 14px;
}

.submit-card label {
  display: block;
  margin-bottom: 8px;
  font-weight: 900;
  color: #a36a93;
}

.submit-card input {
  width: 100%;
  border: 2px solid rgba(196,125,173,.22);
  border-radius: 999px;
  padding: 12px 16px;
  font-size: 16px;
  text-align: center;
  color: #5f5363;
  background: rgba(255,255,255,.88);
  outline: none;
}

.submit-card input:focus {
  border-color: rgba(196,125,173,.62);
}

.saved-name {
  min-height: 20px;
  margin-top: 6px;
  font-size: 13px;
  color: #7b687c;
  font-weight: 700;
}

.small-btn {
  width: 100%;
  padding: 12px 18px;
  margin-top: 8px;
  font-size: 16px;
  box-shadow: 0 8px 0 #df7ba6, 0 14px 30px rgba(223, 123, 166, .22);
}

.submit-status {
  min-height: 18px;
  margin-top: 6px;
  font-size: 13px;
  font-weight: 800;
  color: #7b687c;
}

.ranking-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(86, 62, 88, .32);
  backdrop-filter: blur(4px);
}

.ranking-modal.open {
  display: flex;
}

.ranking-modal-card {
  position: relative;
  width: min(100%, 390px);
  max-height: min(720px, calc(var(--vvh, 100dvh) - 36px));
  overflow: auto;
  padding: 22px 18px 18px;
  border-radius: 28px;
  background: #fff8fc;
  box-shadow: 0 24px 70px rgba(109, 72, 102, .25);
  text-align: center;
}

.ranking-modal-card h2 {
  margin: 0 34px 14px;
  color: #c47dad;
  font-size: 24px;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(196,125,173,.13);
  color: #9c6c8e;
  font-size: 26px;
  line-height: 1;
  box-shadow: none;
}

@media (max-height: 760px) {
  .ranking-card { padding: 10px 14px; margin-bottom: 10px; }
  .ranking-list.compact li { padding: 3px 2px; }
  .submit-card { padding: 11px 14px; }
  .submit-card input { padding: 10px 14px; }
}

/* Ajuste compacto exclusivo para pantalla Game Over */
#gameOverScreen.screen.active {
  justify-content: flex-start;
  gap: 7px;
  padding: max(6px, env(safe-area-inset-top, 0px)) 16px calc(env(safe-area-inset-bottom, 0px) + 10px);
  overflow-y: auto;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

#gameOverScreen .ad-container {
  margin-bottom: 6px;
}

#gameOverScreen .logo.small {
  margin-bottom: 2px;
}

#gameOverScreen .logo.small .brand {
  padding: 5px 12px;
  font-size: 12px;
}

#gameOverScreen .logo.small h1 {
  margin: 6px 0 0;
  font-size: clamp(26px, 8vw, 38px);
  line-height: 1;
}

#gameOverScreen .result-card {
  max-width: 340px;
  padding: 10px 16px;
  margin: 2px 0 6px;
  border-radius: 20px;
}

#gameOverScreen .result-card p {
  margin: 2px 0;
  font-size: 13px;
  line-height: 1.15;
}

#gameOverScreen .result-card strong {
  font-size: clamp(32px, 10vw, 44px);
  line-height: 1;
  margin: 0 0 5px;
}

#gameOverScreen .submit-card {
  max-width: 340px;
  padding: 10px 14px;
  margin: 0 0 6px;
  border-radius: 20px;
}

#gameOverScreen .submit-card label {
  margin-bottom: 6px;
  font-size: 13px;
}

#gameOverScreen .submit-card input {
  padding: 9px 14px;
  font-size: 15px;
}

#gameOverScreen .saved-name {
  min-height: 16px;
  margin-top: 4px;
  font-size: 12px;
}

#gameOverScreen .small-btn {
  padding: 10px 16px;
  margin-top: 6px;
  font-size: 15px;
  box-shadow: 0 7px 0 #df7ba6, 0 12px 24px rgba(223, 123, 166, .20);
}

#gameOverScreen #changeNameBtn {
  margin-top: 4px;
  padding: 2px 8px;
  font-size: 12px;
}

#gameOverScreen .submit-status {
  min-height: 14px;
  margin-top: 3px;
  font-size: 12px;
}

#gameOverScreen #restartBtn {
  width: min(100%, 340px);
  padding: 12px 20px;
  font-size: 16px;
  box-shadow: 0 8px 0 #df7ba6, 0 14px 28px rgba(223, 123, 166, .22);
}

#gameOverScreen #homeBtn {
  margin-top: 4px;
  padding: 8px 18px;
  font-size: 14px;
}

#gameOverScreen .all-games-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 4px;
  color: #9c6c8e;
  font-size: 14px;
  font-weight: 900;
  text-decoration: none;
}

#gameOverScreen .all-games-link:active {
  transform: translateY(1px);
}

@media (max-height: 700px) {
  #gameOverScreen.screen.active {
    gap: 5px;
    padding-left: 14px;
    padding-right: 14px;
  }

  #gameOverScreen .ad-container {
    margin-bottom: 4px;
  }

  #gameOverScreen .logo.small .brand {
    padding: 4px 10px;
  }

  #gameOverScreen .logo.small h1 {
    font-size: clamp(24px, 7.2vw, 34px);
  }

  #gameOverScreen .result-card {
    padding: 8px 14px;
  }

  #gameOverScreen .result-card strong {
    font-size: clamp(30px, 9vw, 40px);
  }

  #gameOverScreen .submit-card {
    padding: 9px 12px;
  }

  #gameOverScreen #restartBtn {
    padding: 11px 18px;
  }
}
