/* ---------- Lobby ---------- */

.player.empty {
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--muted);
}

.keys {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  align-items: center;
  font-size: 0.95rem;
}

kbd {
  display: inline-block;
  min-width: 1.8em;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-bottom-width: 3px;
  border-radius: 6px;
  background: var(--surface);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
}

/* ---------- Game ---------- */

.av-game {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.av-top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
  min-height: 1.5em;
}

/* Hold and stats | your grid | next pieces | the others' mini grids. */
.av-play {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-start;
  justify-content: center;
}

.av-play > .av-side {
  width: 96px;
  flex: none;
}

@media (max-width: 600px) {
  .av-play {
    gap: 8px;
  }
  .av-play > .av-side {
    width: 64px;
  }
  .av-box {
    padding: 6px;
  }
  .av-label {
    font-size: 0.58rem;
    letter-spacing: 0.02em;
  }
  .av-stat {
    font-size: 0.95rem;
  }
}

.av-side {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.av-box {
  padding: 8px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
}

/* The canvases get an inline pixel size; let them shrink to their column. */
.av-box canvas {
  display: block;
  width: 100% !important;
  height: auto !important;
}

.av-label {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 4px;
}

.av-stat {
  font-weight: 800;
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.av-board-wrap {
  position: relative;
  display: flex;
  gap: 6px;
}

.av-board-wrap canvas.board {
  display: block;
  border-radius: 10px;
  box-shadow: var(--shadow);
  touch-action: none;
}

/* Incoming garbage: fills from the bottom, next to the grid. */
.av-meter {
  position: relative;
  width: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.av-meter > span {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bad);
  transition: height 0.2s ease;
}

.av-meter.hit {
  animation: shake 0.3s ease;
}

@keyframes shake {
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  text-align: center;
  padding: 12px;
}

.overlay-text {
  padding: 14px 20px;
  border-radius: 16px;
  background: rgb(20 18 15 / 80%);
  color: #fff;
  font-size: clamp(1.1rem, 4vw, 1.5rem);
  font-weight: 900;
  animation: pop 0.35s ease-out;
}

.overlay-text.big {
  font-size: clamp(3rem, 14vw, 5rem);
  padding: 4px 28px;
  background: transparent;
  text-shadow: 0 4px 0 rgb(0 0 0 / 35%), 0 0 24px rgb(0 0 0 / 40%);
}

.overlay-text small {
  display: block;
  font-size: 0.65em;
  font-weight: 700;
  opacity: 0.85;
}

/* ---------- Opponents ---------- */

.av-opponents {
  display: grid;
  grid-template-columns: auto;
  gap: 8px;
  align-content: start;
  flex: none;
}

.av-opponents.two-cols {
  grid-template-columns: auto auto;
}

.av-opp {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 5px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.av-opp canvas {
  display: block;
  border-radius: 4px;
}

.av-opp.out canvas {
  opacity: 0.35;
}

.av-opp.offline {
  opacity: 0.55;
}

.av-opp.hit {
  border-color: var(--bad);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--bad) 35%, transparent);
}

.av-opp-name {
  font-weight: 800;
  font-size: 0.72rem;
  line-height: 1.2;
  min-width: 0;
}

.av-opp-name span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.av-opp-meta {
  display: flex;
  justify-content: space-between;
  gap: 4px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.wins {
  color: var(--warn);
  letter-spacing: 1px;
  white-space: nowrap;
}

.av-feed {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 2px 14px;
  font-size: 0.85rem;
  color: var(--muted);
  min-height: 1.5em;
}

.av-feed li strong {
  color: var(--text);
}

.av-feed li.me {
  color: var(--bad);
}

/* ---------- Touch controls ---------- */

.touch {
  display: none;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 12px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.touch.on {
  display: grid;
}

.touch button {
  min-height: 56px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 1.3rem;
  font-weight: 900;
  box-shadow: var(--shadow);
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.touch button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.touch button:active {
  transform: scale(0.95);
}
