* {
  box-sizing: border-box;
}

:root {
  --black: #000000;
  --white: #ffffff;
  --gray: #888888;
  --light-gray: #d9d9d9;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--white);
  color: var(--black);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.app {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.screen {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

/* Corrige que el atributo [hidden] sea respetado: sin esto, .screen
   (display:flex) pisa el display:none por defecto del navegador y
   se ven todas las pantallas a la vez. */
.screen[hidden] {
  display: none !important;
}

h1 {
  font-size: 1.8rem;
  margin-bottom: 4px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.subtitle {
  color: var(--gray);
  margin-top: 0;
  margin-bottom: 24px;
  font-size: 0.95rem;
}

.field {
  width: 100%;
  margin-bottom: 16px;
  text-align: left;
}

.field label {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 6px;
  font-weight: 600;
}

.field input {
  width: 100%;
  padding: 12px 14px;
  font-size: 1.1rem;
  border: 2px solid var(--black);
  border-radius: 8px;
  background: var(--white);
  color: var(--black);
}

.field input:focus {
  outline: none;
  background: var(--light-gray);
}

.error {
  color: var(--black);
  background: var(--light-gray);
  border: 1px solid var(--black);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  width: 100%;
}

.btn {
  margin-top: 8px;
  padding: 14px 32px;
  font-size: 1.1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  background: var(--black);
  color: var(--white);
  border: 2px solid var(--black);
  border-radius: 8px;
  cursor: pointer;
  width: 100%;
}

.btn:active {
  background: var(--white);
  color: var(--black);
}

.btn-secondary {
  background: var(--white);
  color: var(--black);
  margin-top: 24px;
}

.btn-secondary:active {
  background: var(--black);
  color: var(--white);
}

/* Conteo */
.countdown {
  font-size: 6rem;
  font-weight: 900;
}

/* Juego */
.game-header {
  display: flex;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 16px;
}

.info {
  display: flex;
  flex-direction: column;
}

.info-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--gray);
  letter-spacing: 1px;
}

.info-value {
  font-size: 1.6rem;
  font-weight: 800;
}

.grid {
  display: grid;
  gap: 4px;
  width: 100%;
  aspect-ratio: 1 / 1;
  margin-bottom: 12px;
}

.cell {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--black);
  border-radius: 4px;
  font-weight: 700;
  background: var(--white);
  color: var(--black);
  cursor: pointer;
  user-select: none;
  font-size: clamp(0.6rem, 3vw, 1.3rem);
}

.cell.found {
  background: var(--black);
  color: var(--white);
  text-decoration: line-through;
  opacity: 0.4;
}

.hint {
  font-size: 0.8rem;
  color: var(--gray);
  margin: 0;
}

/* Resultados */
.result-stat {
  font-size: 1.2rem;
  font-weight: 700;
}

.result-list-label {
  font-size: 0.85rem;
  color: var(--gray);
  margin-bottom: 8px;
}

.result-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-bottom: 24px;
  max-height: 160px;
  overflow-y: auto;
}

.result-chip {
  border: 2px solid var(--black);
  border-radius: 6px;
  padding: 4px 10px;
  font-weight: 700;
  font-size: 0.9rem;
}

/* Responsivo para pantallas muy pequeñas */
@media (max-width: 360px) {
  h1 {
    font-size: 1.5rem;
  }
  .btn {
    padding: 12px 20px;
    font-size: 1rem;
  }
}

/* Landscape en celular: aprovechar altura */
@media (max-height: 500px) {
  .app {
    align-items: flex-start;
    padding-top: 8px;
  }
  .subtitle {
    margin-bottom: 12px;
  }
}