/* =========================================================
   RESET + BODY
   ========================================================= */
html,
body {
  margin: 0;
  padding: 0;
}

body {
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;

  background-color: rgb(19, 43, 12);
  background-image: url(/assets/images/bg-static.jpg);
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

.menu-ingame,
.ui-button,
.highscore-box,
.highscore-list,
#timer {
  font-family: "MedievalSharp", system-ui, serif;
}

}

html, body {
  overflow: hidden;
}

/* =========================================================
   GAME CONTAINER + CANVAS
   ========================================================= */
#game-container {
  position: relative;
  width: min(600px, 100vw - 32px);
  aspect-ratio: 8 / 11;
  max-height: calc(100vh - 160px);
}

canvas {
  border: 4px ridge #bd8216;
  box-shadow: 0 0 20px #d4b46a;
  border-radius: 5px;
  background-color: rgb(133, 183, 90);
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* =========================================================
   HUD IN-GAME
   ========================================================= */
.menu-ingame {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;          /* centrado vertical real */
  width: 100%;                  /* que coincida con el contenedor */
  max-width: 600px;             /* mismo ancho máximo que el canvas */
  margin: 15px auto;            /* centrado horizontal */
  font-family: "MedievalSharp", system-ui, sans-serif; /* luego te digo esto */
}

.menu-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.ui-button {
  font-family: "MedievalSharp", system-ui, sans-serif;
  font-size: 16px;
  letter-spacing: 1px;
  text-transform: uppercase;

  padding: 6px 12px;

  color: rgb(245, 191, 54);              /* dorado */
  text-shadow: 2px 2px 4px #000000;

  background-color: rgba(0, 0, 0, 0.4);
  border: 2px solid #d4b46a;
  border-radius: 6px;
  box-shadow: 0 0 10px #00000080;

  cursor: pointer;
}

.ui-button:hover {
  background-color: rgba(0, 0, 0, 0.6);
}


.ui-icon-button {
  padding: 4px 8px;
  font-size: 18px;  /* icono un poco más grande */
  width: auto;
}

.ui-icon-button.muted {
  opacity: 0.5;
}

.title-text {
  width: 25%;
}

#timer {
  font-family: system-ui, Arial, sans-serif;
  text-shadow: 2px 2px 4px #000000;
  font-size: 40px;
  color: rgb(245, 191, 54);
  width: 25%;
  text-align: center;
}

#pause-button {
  font-family: system-ui, sans-serif;
  color: #bd8216;
  padding: 6px 10px;
  border-radius: 8px;
  background-color: rgba(0,0,0,0.4);
  border: 2px solid #d4b46a;
  box-shadow: 0 0 10px #00000080;
}

#pause-button:hover {
  cursor: pointer;
  background-color: rgba(0, 0, 0, 0.5);
}

.mute-toggle {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background-color: rgba(0, 0, 0, 0.4);
  color: rgb(245, 191, 54);
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 0 8px #00000080;
}
.mute-toggle.muted {
  opacity: 0.4;
}


/* =========================================================
   START MENU
   ========================================================= */
#start-menu {
  position: absolute;
  inset: 0;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  gap: 12px;
  padding: 12px;
  box-sizing: border-box;
}

#start-menu img {
  max-width: 100%;
  height: auto;
}

#startgame-ui {
  width: 70%;
  max-width: 320px;
}

#credit {
  color: #e4ddd0;
  text-shadow: 2px 2px 4px #000000;
}

.github-btn {
  padding: 4px 10px;
  background: #bd8216;
  color: white;
  border-radius: 4px;
  text-decoration: none;
  font-family: fantasy;
}

.github-btn:hover {
  background: #e3b56e;
}


/* =========================================================
   GAME OVER MENU
   ========================================================= */
#gameover-menu {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);

  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;

  gap: 10px;
  width: 90%;
  height: 90%;
  margin-top: 10%;
}

#gameover-menu img {
  width: 90%;
  height: auto;
}

#gameover-menu img#tryagain-ui {
  width: 40%;
}

/* =========================================================
   HIGH SCORE PANEL
   ========================================================= */
#highscore-panel {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);

  width: 70%;
  max-width: 420px;

  display: flex;
  align-items: center;
  justify-content: center;

  z-index: 10;
  pointer-events: auto;
}

.highscore-box {
  width: 100%;
  padding: 18px 24px;

  background: rgba(19, 43, 12, 0.92);
  border: 4px ridge #bd8216;
  border-radius: 6px;
  box-shadow: 0 0 20px #000000cc;

  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;

  color: rgb(245, 191, 54);
  text-shadow: 2px 2px 4px #000000;
}

.highscore-box p {
  margin: 0;
  text-align: center;
}

.highscore-box p:first-child {
  font-size: 28px;
  letter-spacing: 1px;
}

#highscore-time {
  font-size: 24px;
}

#highscore-name-input {
  width: 80%;
  padding: 6px 10px;
  margin-top: 6px;

  background-color: rgba(0, 0, 0, 0.6);
  border: 2px solid #d4b46a;
  border-radius: 4px;

  font-size: 16px;
  text-align: center;
  color: rgb(245, 191, 54);
  text-shadow: 1px 1px 2px #000000;
}

#highscore-name-input::placeholder {
  color: rgba(245, 191, 54, 0.6);
}

#highscore-save-button {
  margin-top: 8px;
  padding: 6px 16px;

  font-size: 18px;
  color: rgb(245, 191, 54);

  background-color: rgba(0, 0, 0, 0.45);
  border: 2px solid #d4b46a;
  border-radius: 5px;

  text-shadow: 2px 2px 4px #000000;
  box-shadow: 0 0 10px #00000080;

  cursor: pointer;
}

#highscore-save-button:hover {
  background-color: rgba(0, 0, 0, 0.7);
}

/* =========================================================
   HIGH SCORE LIST (START + GAME OVER)
   ========================================================= */
.highscore-list {
  width: 80%;
  margin-top: 10px;

  color: rgb(245, 191, 54);
  font-size: 18px;
  text-align: center;

  font-family: "Franklin Gothic Medium", "Arial Narrow", Arial, sans-serif;
  text-shadow: 1px 1px 2px #000000;
}

.highscore-list div {
  margin: 4px 0;
}

/* Título Top 5 solo en Start */
#highscore-list-start::before {
  content: "Top 5";
  display: block;
  margin-bottom: 4px;

  font-size: 25px;
  font-weight: bold;
  text-shadow: 2px 2px 4px #000000;
}

/* =========================================================
   UTILIDADES
   ========================================================= */
.hidden {
  display: none !important;
}

.clickable {
  cursor: pointer;
}

/* =========================================================
   MEDIA QUERIES
   ========================================================= */

/* Alturas muy bajas */
@media (max-height: 600px) {
  #start-menu {
    gap: 8px;
    padding: 8px;
  }

  .highscore-list {
    font-size: 14px;
  }
}

/* Version móvil (ancho bajo) */
@media (max-width: 768px) {
  #game-container {
    width: min(95vw, 500px);
    max-height: calc(100vh - 140px);
  }

  .menu-ingame {
    width: min(95vw, 500px);
    margin: 8px 0;
  }

  #timer {
    font-size: 28px;
  }

  #pause-button {
    font-size: 14px;
    padding: 4px 8px;
  }

  .title-text {
    width: 35%;
  }
}
