/* Solo se animan las casillas cuyo contenido realmente cae. */
.tile.falling {
  animation: ingredient-fall .46s cubic-bezier(.18, .75, .3, 1);
}

@keyframes ingredient-fall {
  from { transform: translateY(-70px); }
  75% { transform: translateY(4px); }
  to { transform: translateY(0); }
}

/* Distribución: jugador y poderes a la izquierda, tablero al centro, rival a la derecha. */
body {
  background: linear-gradient(145deg, #deedcf, #f5eaca 55%, #d5e8dc);
}

.account-bar {
  width: min(100%, 1120px);
  margin: 0 auto 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-shadow: none;
}

.account-bar button {
  margin-left: 6px;
  padding: 7px 12px;
  border: 2px solid #ffffffaa;
  border-radius: 10px;
  color: #365d36;
  background: #fffef3;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.account-bar button.signup { color: white; background: #dc7658; }
.brand-mini { font-size: 13px; font-weight: 900; }
.profile-photo { font-size: 24px; }
.rating { display: block; margin-top: 2px; color: #8a6531; font-size: 10px; }

main {
  width: min(100%, 1120px);
  margin-inline: auto;
  grid-template-columns: 230px minmax(420px, 590px) 230px;
  grid-template-areas:
    "p board bot"
    "pow board bot";
}

.game,
.panel,
#board {
  min-width: 0;
}

.panel { background: #faf6ec; }
.game { background: #f7efe3; }

#board {
  grid-template-columns: repeat(9, minmax(0, 1fr));
  overflow: hidden;
  background: #a7c59c;
}

.tile {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.player,
.player.active {
  opacity: 1;
  outline: 0;
  transform: none;
}

.powers {
  position: static;
  align-self: start;
}

#powers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-top: 9px;
}

.power {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  min-height: 92px;
  margin: 0;
  text-align: center;
  background: #f8e9bb;
  border-color: #ddaF4f;
}

.power:hover:not(:disabled),
.power.armed {
  background: #f4dda0;
}

.power:nth-child(5) {
  grid-column: auto;
  min-height: 92px;
}

.power:last-child:nth-child(odd) {
  grid-column: 1 / -1;
  min-height: 96px;
}

.power-info {
  min-height: 108px;
  margin-top: 8px;
  padding: 10px;
  border: 2px solid #b9cbaa;
  border-radius: 12px;
  background: #fffef8;
  color: #382d27;
  font-size: 11px;
  line-height: 1.35;
  opacity: 1;
  box-shadow: 0 4px 12px #384c302b;
}

.power-info b,
.power-info span,
.power-info strong {
  display: block;
}

.power-info b {
  margin-bottom: 4px;
  color: #352820;
  font-size: 13px;
}

.power-info strong {
  margin-top: 6px;
  color: #9b562e;
  font-size: 13px;
}

.power > b {
  min-height: 30px;
  display: grid;
  place-items: center;
  line-height: 1.05;
}

.abandon {
  width: 100%;
  margin-top: 7px;
  padding: 8px;
  border: 2px solid #d4b8ae;
  border-radius: 11px;
  color: #8e463b;
  background: #fff7f2;
  cursor: pointer;
  font-weight: 800;
}

.social-area {
  width: min(calc(100% - 28px), 1120px);
  margin: 0 auto 30px;
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 14px;
}

.social-area h2 { margin: 0 0 8px; font-size: 18px; }
.chat-messages { height: 150px; overflow-y: auto; padding: 8px; border-radius: 12px; background: #e9e4d9; }
.chat-messages p { width: fit-content; max-width: 85%; margin: 5px 0; padding: 7px 9px; border-radius: 10px; font-size: 12px; }
.chat-messages .bot-message { background: white; }
.chat-messages .my-message { margin-left: auto; color: white; background: #659e61; }
#chatForm { display: grid; grid-template-columns: 1fr auto; gap: 7px; margin-top: 8px; }
#chatForm input { min-width: 0; padding: 10px; border: 2px solid #d3c9b9; border-radius: 10px; }
#chatForm button { padding: 8px 15px; border: 0; border-radius: 10px; color: white; background: #567fbd; font-weight: 800; cursor: pointer; }
.ranking-note { margin: -4px 0 7px; color: #80766b; font-size: 10px; }
#globalRanking { margin: 0; padding: 0; list-style: none; }
#globalRanking li { display: flex; justify-content: space-between; align-items: center; padding: 7px; border-bottom: 1px solid #e4dccf; font-size: 12px; }
#globalRanking li span b { display: inline-grid; place-items: center; width: 22px; height: 22px; margin-right: 6px; border-radius: 50%; color: white; background: #76a967; }
#globalRanking li strong { color: #a05d31; }
.rating-change { display: block; margin: 10px 0; color: #9a632b; font-size: 16px !important; }

.power .cost {
  width: 100%;
  margin-top: auto;
  text-align: center;
}

.power .tip {
  right: auto;
  left: calc(100% + 8px);
  padding: 12px;
  color: #fff;
  background: #171717f5;
  border: 2px solid #ffffff35;
  font-size: 13px;
  line-height: 1.45;
  text-shadow: none;
  box-shadow: 0 7px 20px #0008;
}

.power .tip strong {
  display: inline-block;
  margin-top: 5px;
  color: #ffe071;
  font-size: 14px;
}

.power .cost {
  color: #392b24;
  font-size: 13px;
  font-weight: 900;
}

.turn-banner {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 9px;
  min-height: 45px;
  margin-bottom: 10px;
  border: 2px solid;
  border-radius: 14px;
  color: white;
  letter-spacing: 1.2px;
  box-shadow: 0 4px 10px #526b4a2b;
  transition: background .25s, border-color .25s;
}

.turn-banner span { font-size: 22px; }
.turn-timer {
  display: grid;
  place-items: center;
  width: 33px;
  height: 33px;
  margin-left: 5px;
  border: 2px solid #ffffffaa;
  border-radius: 50%;
  background: #ffffff24;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.turn-timer.urgent {
  color: #fff2a6;
  border-color: #ffe56f;
  animation: timer-warning .55s ease-in-out infinite alternate;
}

@keyframes timer-warning {
  to { transform: scale(1.12); background: #d94c4caa; }
}

.turn-banner.yours { background: linear-gradient(135deg, #74bf62, #4d9b56); border-color: #a8df92; }
.turn-banner.rival { background: linear-gradient(135deg, #718ed1, #526faf); border-color: #aebfe8; animation: turn-pulse 1.2s ease-in-out infinite alternate; }

@keyframes turn-pulse {
  to { box-shadow: 0 4px 16px #5878c277; }
}

@media (max-width: 900px) {
  main {
    width: 100%;
    grid-template-columns: 190px minmax(390px, 520px) 190px;
  }
}

@media (max-width: 760px) {
  main {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "board board"
      "p bot"
      "pow pow";
  }

  .power { min-height: 92px; }
  .power .tip { left: 0; top: 100%; }
  .social-area { grid-template-columns: 1fr; }
}

@media (max-width: 500px) {
  main { display: flex; }
  #powers { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
