/* ========================
   RESET + BASE
======================== */
* {
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  font-family: Arial, sans-serif;
  background: radial-gradient(circle at top, #1a2438, #05070c);
  color: #fff;
  overflow: hidden;
}

/* Canvas: control táctil */
canvas {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ========================
   CONTENEDOR PRINCIPAL
======================== */
#app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* ========================
   HOME / LOGIN
======================== */
#home {
  text-align: center;
  padding: 16px;
}

#home h1 {
  margin: 8px 0;
  font-size: clamp(1.6rem, 5vw, 2.4rem);
  letter-spacing: 2px;
  text-shadow: 0 2px 6px #000;
}

.shield {
  width: clamp(90px, 25vw, 140px);
  margin: 10px auto;
  display: block;
  filter: drop-shadow(0 4px 8px #000);
}

.login {
  margin-top: 10px;
}

.login input {
  padding: 12px;
  margin: 6px;
  border-radius: 8px;
  border: none;
  width: min(90%, 260px);
  font-size: 1rem;
}

.login button {
  padding: 12px 20px;
  margin: 6px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(#cfa44a, #7a5b21);
  color: #000;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 6px #000;
}

.login button:hover {
  transform: scale(1.05);
}

/* Botón ranking en HOME */
.home-ranking-btn {
  margin-top: 14px;
  padding: 12px 20px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(#cfa44a, #7a5b21);
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 6px #000;
}

/* ========================
   ZONA DE JUEGO
======================== */
#game {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ========================
   MARCO DE PIEDRA (CANVAS)
======================== */
#playfield {
  width: 100%;
  max-width: 420px;
  aspect-ratio: 10 / 20;
  display: block;
  background: #111;
  border-radius: 14px;

  border: 18px solid transparent;
  background-clip: padding-box;
  position: relative;

  box-shadow:
    inset 0 0 20px #000,
    0 0 30px rgba(0,0,0,0.8);

  animation: stonePulse 6s ease-in-out infinite;
}

#playfield::before {
  content: "";
  position: absolute;
  inset: -18px;
  border-radius: 18px;
  background:
    repeating-linear-gradient(
      45deg,
      #4a4a4a,
      #3a3a3a 10px,
      #2a2a2a 20px
    );
  z-index: -1;
}

@keyframes stonePulse {
  0%, 100% {
    box-shadow:
      inset 0 0 20px #000,
      0 0 20px #000;
  }
  50% {
    box-shadow:
      inset 0 0 30px #000,
      0 0 35px rgba(0,0,0,0.9);
  }
}

/* ========================
   INFO SUPERIOR
======================== */
.top {
  width: 100%;
  max-width: 420px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.top button {
  padding: 6px 12px;
  border-radius: 8px;
  border: none;
  background: #8b2c2c;
  color: #fff;
  font-weight: bold;
  cursor: pointer;
}

/* ========================
   LOGROS
======================== */
#achievement {
  margin-top: 10px;
  font-size: 1.2rem;
  text-align: center;
  color: gold;
  text-shadow: 0 0 8px #000;
}

/* ========================
   RANKING LISTA
======================== */
#ranking-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 50vh;
  overflow-y: auto;
}

#ranking-list p {
  background: linear-gradient(90deg, #222, #111);
  border: 2px solid #7a5b21;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: inset 0 0 6px #000;
}

/* Medallas */
#ranking-list p:nth-child(1) {
  border-color: gold;
  color: gold;
}
#ranking-list p:nth-child(2) {
  border-color: silver;
  color: silver;
}
#ranking-list p:nth-child(3) {
  border-color: #cd7f32;
  color: #cd7f32;
}

/* ========================
   OVERLAYS (ARCADE / RANKING)
======================== */
.arcade-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 999;
  display: none;
}

.arcade-overlay.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.arcade-panel {
  background: radial-gradient(circle, #3b3b3b, #1a1a1a);
  border: 6px solid #7a5b21;
  border-radius: 20px;
  padding: 24px;
  width: min(90%, 360px);
  text-align: center;
  box-shadow: 0 0 40px #000;
  animation: arcadeIn 0.6s ease-out;
}

.arcade-panel h2 {
  margin-bottom: 16px;
  letter-spacing: 2px;
}

.arcade-panel button {
  width: 100%;
  margin: 8px 0;
  padding: 14px;
  font-size: 1.1rem;
  border-radius: 12px;
  border: none;
  background: linear-gradient(#cfa44a, #7a5b21);
  font-weight: bold;
  cursor: pointer;
}

/* ========================
   ANIMACIONES
======================== */
@keyframes arcadeIn {
  from {
    transform: scale(0.6);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

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

.audio-controls {
  display: flex;
  gap: 6px;
}

.audio-controls button {
  background: #222;
  border: 2px solid #7a5b21;
  border-radius: 8px;
  color: #fff;
  font-size: 1rem;
  padding: 4px 8px;
  cursor: pointer;
}

.audio-controls button.off {
  opacity: 0.4;
}

