body {
  margin: 0;
  background: #ffffff;
  font-family: Arial, sans-serif;
  overflow: hidden;
}

.container {
  width: 100vw;
  height: 100vh;
  background: #f5f5f5;
  box-sizing: border-box;
}

/* ===== BASE ===== */
#avatar {
  border-radius: 20px;
  box-shadow: 0 10px 20px rgba(0,0,0,.2);
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

#text-box {
  border-radius: 14px;
  padding: 22px;
  font-size: clamp(16px, 2.2vmin, 22px);
  text-align: center;
  line-height: 1.4;
  background: rgba(255,255,255,0.65);
  box-shadow: 0 5px 15px rgba(0,0,0,.15);
}

#mic-btn {
  margin-top: 2vh;
  align-self: center;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: crimson;
  color: white;
  font-size: clamp(22px, 4vmin, 36px);
  padding: clamp(16px, 3vmin, 24px);
  box-shadow: 0 5px 15px rgba(0,0,0,.3);
}

/* =====================================================
   🖥️ HORIZONTAL — avatar izquierda / panel derecho real
===================================================== */

@media (min-aspect-ratio: 4/3) {

  .container {
    display: grid;
    grid-template-columns: 1fr 1.3fr;
    grid-template-rows: auto auto;
    padding: 4vh 4vw;
    gap: 3vh 4vw;
    box-sizing: border-box;
    align-items: start;
  }

  #avatar {
    grid-column: 1;
    grid-row: 1 / span 2;
    height: 90vh;
    max-height: 100%;
    justify-self: center;
    align-self: center;
  }

  #text-box {
    grid-column: 2;
    grid-row: 1;
    width: 100%;
    height: 60%;
    max-height: 60vh;          /* 🔑 CLAVE */
    overflow-y: auto;          /* 🔑 CLAVE */
    margin-top: 10vh;
    justify-self: center;
    align-self: center;
  }

  #mic-btn {
    grid-column: 2;
    grid-row: 2;               /* 🔑 SIEMPRE DEBAJO */
    justify-self: center;
    align-self: center;
    margin-top: 1vh;
  }
}

/* =====================================================
   📱 VERTICAL — avatar arriba / texto entre / mic abajo
===================================================== */
@media (max-aspect-ratio: 37/56) {

  .container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 3vh 0;
  }

  #avatar {
    width: 92vw;
  }

  #text-box {
    width: 80vw;
    max-height: 15vw;
    overflow-y: auto;
    margin: 2vh 0;
    flex-shrink: 0;
  }

  #mic-btn {
    margin-bottom: 2vh;
  }
}

/* =====================================================
   ⬜ CUADRADO / CASI CUADRADO (≈ 1 : 1.2)
===================================================== */
@media (min-aspect-ratio: 37/56) and (max-aspect-ratio: 4/3) {

  .container {
    position: relative;
  }

  #avatar {
    position: absolute;
    width: 70vmin;
    max-width: 90vw;
    max-height: 90vh;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }

  #text-box {
    position: absolute;
    width: 60vmin;
    height: 60%;
    max-height: 12vh;
    top: 60%;
    left: 50%;
    transform: translateX(-50%);
  }

  #mic-btn {
    position: absolute;
    top: calc(60% + 18vmin);
    left: 50%;
    transform: translateX(-50%);
  }
}
