@font-face {
  font-family: 'Press Start 2P';
  src: url('./PressStart2P-Regular.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}


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

/* Prevent text selection globally but allow in inputs/textareas */
html, body {
  user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
}

input, textarea {
  user-select: text;
  -webkit-user-select: text;
  -ms-user-select: text;
}

/* Reduce overscroll / pull-to-refresh */
html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Press Start 2P", monospace;
  background: #101612;
  color: #f6f0d8;
  overscroll-behavior-y: contain;
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: radial-gradient(circle at 50% 10%, #3a6340 0, #1f3323 45%, #121b14 100%);
}

/* Centered two-line app title at top */
#titleTop {
  position: absolute;
  top: 1.1rem; /* moved down to lower title/subtitle only */
  left: 0;
  right: 0;
  text-align: center;
  pointer-events: auto; /* allow long-press / clicks on title to trigger cheats / actions */
  z-index: 55;
  line-height: 1;
  user-select: none;
  /* subtle floating animation */
  animation: titleFloat 3.6s ease-in-out infinite;
}

/* paused state for the title (stop the float) */
#titleTop.paused {
  animation-play-state: paused;
}

@keyframes titleFloat {
  0% { transform: translateY(0); }
  25% { transform: translateY(-2px); }
  50% { transform: translateY(0); }
  75% { transform: translateY(1px); }
  100% { transform: translateY(0); }
}

/* Use the retro pixel font explicitly for the app name */
#titleTop .title-line1,
#titleTop .title-line2 {
  font-family: 'Press Start 2P', monospace;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: 0.06em;
}

#titleTop .title-line1 {
  font-size: 0.95rem;
  font-weight: 800;
  color: #ffdd55;
  text-shadow: 0 1px 0 #000;
  margin-bottom: 0.5rem; /* increased spacing between title and subtitle */
}

#titleTop .title-line2 {
  font-size: 0.62rem;
  color: #bfe6f0;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-shadow: 0 1px 0 rgba(0,0,0,0.9);
  margin-top: 0.1rem; /* small top gap to ensure clearer separation */
}

/* Small phones tweak for title sizing */
@media (max-height: 640px) {
  #titleTop .title-line1 { font-size: 0.82rem; }
  #titleTop .title-line2 { font-size: 0.56rem; }
}

/* Align hud/hamburger with title top */
#hud {
  position: absolute;
  top: 0.3rem; /* moved up to align with title */
  left: 0.35rem;
  right: 0.35rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.65rem;
  text-shadow: 0 1px 0 #000;
  pointer-events: none;
  /* slightly increase top spacing so points/time sit a few pixels lower */
  padding-top: 6px;
}

/* push a tiny additional offset specifically for the HUD columns */
#hud > div {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  margin-top: 4px; /* nudge content down a few pixels */
}

#scoreValue,
#streakValue,
#timeValue {
  font-size: 0.7rem; /* reduced overall numeric sizes */
  letter-spacing: 0.06em;
}

#scoreValue {
  color: #ffdd55;
}

#streakValue {
  color: #78ffb5;
}

/* Streak single-line under score */
.streak-line {
  display: none; /* Oculta la racha en la pantalla principal de juego */
}
.streak-line #streakLabel { color: #cfe6cf; letter-spacing: 0.06em; }
.streak-line #streakValue { color: #78ffb5; font-weight: 700; }

/* Make time a single-line "T: xx" */
#timeRow {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.28rem;
  margin-top: 0.22rem; /* keep separation from score */
}

#timeLabel {
  color: #cfe6cf; /* white/greenish for the "T:" label */
  font-size: 0.48rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

#timeValue {
  color: #ff4b3f; /* red numeric time */
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

#controls {
  position: absolute;
  bottom: 1.4rem;
  left: 0.35rem;
  right: 0.35rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 0.5rem;
}

.control-group {
  display: flex;
  gap: 0.35rem;
}

.btn {
  min-width: 3.1rem;
  min-height: 3.1rem;
  border-radius: 0.6rem;
  border: 2px solid #263123;
  background: linear-gradient(#374234, #1c241c);
  color: #f6f0d8;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-shadow: 0 1px 0 #000;
  box-shadow:
    0 3px 0 #0b0f0b,
    0 0 0 1px #090c09 inset;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
}

.btn:active {
  transform: translateY(2px);
  box-shadow:
    0 1px 0 #0b0f0b,
    0 0 0 1px #090c09 inset;
}

.btn-dir {
  color: #c7f1ff;
}

.btn-main {
  background: linear-gradient(#2b6b8a, #114b63);
  border-color: #123f4d;
  color: #f6f7ee;
}

.btn-main:active {
  background: linear-gradient(#215970, #0f3a48);
}

/* Footer */
#footer {
  position: absolute;
  left: 0.35rem;
  right: 0.35rem;
  bottom: 0.5rem;
  font-size: 0.55rem;
  text-align: center;
  color: #c9d7c2;
  pointer-events: auto;
}

#footer a {
  color: #f6f0d8;
  text-decoration: none;
}

#footer a:active,
#footer a:focus {
  outline: none;
}

/* Modal / start screen */
.modal {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  /* changed overlay tint from green to blue to match game tones */
  background: radial-gradient(circle at 50% 30%, rgba(6,22,34,0.72), rgba(3,8,14,0.9));
  z-index: 50;
}

.modal-panel {
  /* changed panel gradient from green to slate-blue */
  background: linear-gradient(#193a4a, #0f2a33);
  border: 2px solid #234559;
  padding: 1.6rem; /* slightly increased padding for more vertical space */
  width: min(520px, 92%);
  max-width: 520px;
  color: #f6f0d8;
  text-align: center;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.6);
  font-size: 0.95rem; /* slightly larger for readability */
}

/* help modal tweaks: reuse modal-panel but ensure full-screen safe area on mobile */
#helpModal .modal-panel {
  max-width: 520px;
  width: calc(100% - 3rem);
  padding: 1rem;
}
/* keep list bullets readable */
#helpModal ul { margin-left: 0.8rem; }
#helpModal p { margin: 0.35rem 0; }

/* make modal title a bit taller and spaced */
.modal-panel h1 {
  margin: 0 0 1rem 0; /* increased bottom margin from 0.6rem to 1rem */
  font-size: 1.25rem;
  color: #ffdd55; /* match app title yellow */
  letter-spacing: 0.04em;
  font-family: 'Press Start 2P', monospace; /* use pixel font for modal title */
}

/* App icon beneath modal title */
.modal-panel .app-icon {
  display: block;
  margin: 0.2rem auto 0.6rem auto;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 6px 18px rgba(0,0,0,0.45);
  border: 2px solid rgba(255,255,255,0.04);
}

.modal-panel .app-icon img {
  width: 180%;
  height: 150%;
  object-fit: cover;
  image-rendering: pixelated;
}

/* more generous spacing for mode row and radio labels */
.mode-row {
  display:flex;
  justify-content:center;
  gap:1.2rem; /* increased gap */
  margin-top:1.2rem; /* moved further from start button */
  margin-bottom: 0.9rem; /* additional breathing room below selector */
  pointer-events: auto; /* allow interacting with radios */
}

.mode-row label {
  padding: 0.45rem 0.6rem; /* larger touch target */
  background: rgba(255,255,255,0.02);
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

/* level-row kept but spaced if present */
.level-row {
  display:flex;
  justify-content:center;
  align-items:center;
  gap:0.75rem;
  margin-bottom:0.9rem;
}

/* Center start button row with bigger spacing */
.modal-buttons {
  display: flex;
  justify-content: center;
  gap: 1rem; /* increased gap between buttons */
  margin-top: 0.9rem; /* larger top margin */
}

/* enlarge the primary start button for the initial modal */
#startBtn {
  min-width: 7rem; /* increased from 5.2rem to make the button wider */
  min-height: 4rem;
  padding: 0.6rem 1rem;
  font-size: 0.95rem;
  border-radius: 0.8rem;
  box-shadow:
    0 6px 0 #0b0f0b,
    0 0 0 1px #090c09 inset;
  pointer-events: auto;
  margin-top: 0.6rem; /* added top margin to separate from title */
  margin-bottom: 0.6rem; /* spacing between button and moved selector */
}

/* modal credits reuse footer style inside panel */
.modal .credits { margin-top: 1rem; font-size: 0.78rem; color: #c9dff0; pointer-events: auto; }
.modal .credits a { color: #eaf7ff; text-decoration: none; }

/* Help modal should sit above other UI */
#helpModal {
  z-index: 90;
  pointer-events: none; /* default inert until explicitly shown */
}

/* Ensure modal-panel still receives pointer events when help is visible */
#helpModal[aria-hidden="false"] {
  pointer-events: auto;
}

/* Retro scanline overlay (subtle) */
#app::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(
    rgba(0, 0, 0, 0.18) 1px,
    transparent 1px
  );
  background-size: 100% 3px;
  mix-blend-mode: soft-light;
  pointer-events: none;
}

/* Small phones tweak */
@media (max-height: 640px) {
  #hud {
    font-size: 0.55rem;
  }

  .btn {
    min-width: 2.7rem;
    min-height: 2.7rem;
    font-size: 0.6rem;
  }

  #footer {
    font-size: 0.5rem;
  }
}

/* place time to the far right */
.hud-left,
.hud-center {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
/* added spacing between score and streak */
.hud-center {
  margin-left: 0.9rem;
}
/* remove previously positioned time on right */
.hud-right {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

/* small hamburger in HUD */
.hud-menu {
  pointer-events: auto;
  position: absolute;
  left: 0.35rem;
  top: 0.28rem; /* keep near top but allow growth downward */
  background: linear-gradient(#2b6b8a, #114b63);
  border: 2px solid #123f4d;
  color: #f6f0d8;
  font-size: 1.25rem; /* slightly larger icon */
  line-height: 1;
  padding: 0.6rem 0.7rem; /* larger touch area so the button grows vertically */
  min-width: 48px;       /* ensure minimum tappable size */
  min-height: 48px;      /* ensure it grows downward visually */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  box-shadow:
    0 6px 0 #0b0f0b,
    0 0 0 1px #090c09 inset;
  cursor: pointer;
  transform-origin: top left; /* expansion happens downward from top position */
  z-index: 80;
}
.hud-menu:active { transform: translateY(1px); }

/* push HUD left-group to the right when menu is on the left */
.hud-left { margin-left: auto; }

/* Menu modal (simple centered but visually distinct) */
.menu-modal {
  position: absolute;
  inset: 0;
  display: none;
  align-items: flex-end;
  justify-content: center;
  /* change background overlay to blue-tinted */
  background: linear-gradient(rgba(2,10,18,0.45), rgba(0,6,10,0.7));
  z-index: 60;
  pointer-events: auto;
}
.menu-modal[aria-hidden="false"] { display: flex; }

.menu-panel {
  width: 92%;
  max-width: 420px;
  /* change menu-panel background to match modal-panel (blue slate) */
  background: linear-gradient(#173443, #0d2730);
  border: 2px solid #193f4a;
  padding: 0.8rem;
  border-radius: 10px 10px 0 0;
  box-shadow: 0 -6px 20px rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: stretch;
}

/* ensure menu buttons look prominent on touch */
.menu-panel .btn {
  min-height: 3.4rem;
  font-size: 0.85rem;
  pointer-events: auto;
}

/* Make Sound and Music buttons use full available width */
.menu-sound-music-row {
  display: flex;
  flex-direction: row;
  gap: 0.5rem;
}

#menuSound,
#menuMusic {
  flex: 1 1 0;
}

/* Make the "Volver a inicio" button sit above and visually separated */
.menu-panel .btn-back {
  margin-bottom: 0.6rem;
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
  /* changed back button to deep-blue-red accent for contrast */
  background: linear-gradient(#4b2a3b, #2b1630);
  border-color: #2a1a28;
}

/* Place "Continuar" visually below the other menu items */
.menu-panel .btn-continue {
  margin-top: 0.6rem;
}

/* modal-panel .app-icon tweaks kept same */
.modal-panel .app-icon{
  width: 160px;
  height: 160px;
  margin: 0.2rem auto 0.6rem;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 6px 18px rgba(0,0,0,0.45);
  border: 2px solid rgba(255,255,255,0.04);
  display: block;
}

.modal-panel .app-icon__img{
  width: 125% !important;
  height: 125% !important;
  object-fit: cover;
  image-rendering: pixelated;
  display: block;
  transform: translate(-10%, -10%); /* centra la imagen agrandada */
}