/* Amigos: misma estructura que friends.css de WhatPiece (perfil con código ocultable, solicitudes,
   pestañas, desplegable «Añadir amigo» con caja ✕, ranking en tabla) con el estilo de papel de DB. */
.db-friends-page { padding-top: 23px; }
/* El panel de la pestaña activa es lo último que se ve (el otro está oculto): sin su margen,
   el hueco hasta «¿Quieres más?» es el mismo que el de debajo (ver .db-main en common.css). */
#friendsContent > [role="tabpanel"] { margin-bottom: 0; }
.db-friends-page [hidden] { display: none !important; }
.db-friends-notice { max-width: 820px; margin: 0 auto 16px; padding: 10px 16px; border: 1px solid #6e9e63; border-radius: 10px; background: #e9f1d9; color: #2f5a3c; font-weight: 800; font-size: 13px; text-align: center; }
.db-friends-notice.is-error { border-color: #c27b6c; background: #f8ddd2; color: #8a2f1f; }
.db-friends-hint { margin: 6px 0 0; font-size: 12px; color: var(--db-muted); }
.db-friends-hint:empty { display: none; }
.db-friends-hint.is-error { color: var(--db-red); font-weight: 800; }
.db-friends-hint.is-ok { color: var(--db-correct); font-weight: 800; }
.db-friends-empty { margin: 0; padding: 18px 6px 6px; text-align: center; color: var(--db-muted); font-size: 13px; }

/* Botón píldora secundario (Ver código / Mostrar códigos) */
.db-btn-pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 14px; border: 1px solid #c5b797; border-radius: 20px; background: #efe3c6; color: var(--db-text); font-size: 12px; font-weight: 900; white-space: nowrap; transition: border-color .15s, color .15s; }
.db-btn-pill i { color: var(--db-orange-dark); }
.db-btn-pill:hover { border-color: var(--db-orange); color: var(--db-orange-dark); }

/* ── Esqueleto ── */
@keyframes db-skel-shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.db-skel { display: block; border-radius: 6px; background: linear-gradient(90deg, #eadcbc 25%, #f6ecd5 50%, #eadcbc 75%); background-size: 200% 100%; animation: db-skel-shimmer 1.4s linear infinite; }
.db-skel-profile { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.db-skel-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid #e3d6b8; }
.db-skel-row:last-child { border-bottom: 0; }
.db-skel-circle { flex-shrink: 0; width: 38px; height: 38px; border-radius: 50%; }
.db-skel-circle--lg { width: 64px; height: 64px; }
.db-skel-line { width: 55%; height: 13px; }
.db-skel-line--lg { width: 40%; height: 20px; }
.db-skel-line--med { width: 40%; }
.db-skel-line--xl { width: 70%; }
.db-skel-line--title { width: 35%; height: 18px; margin-bottom: 8px; }
@media (prefers-reduced-motion: reduce) { .db-skel { animation: none; } }

/* ── Perfil ── */
.db-friends-profile { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.db-friends-profile-title { align-self: stretch; justify-content: center; margin-bottom: 0; }
.db-friends-me { display: flex; align-items: center; gap: 14px; min-width: 0; max-width: 100%; }
.db-friends-me-name { min-width: 0; font-family: 'Bangers', Impact, sans-serif; font-weight: 400; font-size: 30px; letter-spacing: .03em; line-height: 1.1; overflow-wrap: anywhere; }
.db-friends-code-row { display: inline-flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px 12px; padding: 8px 14px; border: 1px dashed #c9b58e; border-radius: 10px; background: #fffaf0; }
.db-friends-code-label { font-size: 11px; font-weight: 800; color: var(--db-muted); text-transform: uppercase; letter-spacing: .06em; }
.db-friends-code-badge { font-size: 20px; font-weight: 900; letter-spacing: .14em; color: var(--db-orange-dark); background: none; }
.db-friends-profile-form, .db-add-code-row { display: flex; gap: 8px; }
.db-add-code-row .db-input { flex: 1; min-width: 0; }
.is-copied, .db-btn-primary.is-copied { border-color: #2c5c3d; background: var(--db-correct); box-shadow: 0 3px 0 #23472f; }

/* ── Solicitudes ── */
.db-requests-badge { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--db-red); color: #fff; font-size: 12px; font-weight: 900; }
.db-requests-out-title { margin: 12px 0 2px; padding-top: 10px; border-top: 1px dashed #c9b58e; font-size: 12px; font-weight: 900; color: var(--db-muted); text-transform: uppercase; letter-spacing: .06em; }
.db-req-btn { display: inline-flex; align-items: center; gap: 5px; }

/* ── Filas (solicitudes y lista) ── */
.db-friends-rows { list-style: none; margin: 0; padding: 0; }
.db-friend-row { display: flex; align-items: center; gap: 12px; padding: 10px 6px; border-bottom: 1px solid #e3d6b8; }
.db-friend-row:last-child { border-bottom: 0; }
.db-friend-row.is-pending .db-row-avatar { filter: grayscale(.6); }
.db-row-info { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.db-row-name { min-width: 0; font-weight: 900; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.db-row-code { font-size: 12px; font-weight: 800; color: var(--db-muted); letter-spacing: .08em; background: none; }
.db-row-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* Más de ~10 filas: scroll vertical dentro de la tarjeta, como WhatPiece. */
.db-friends-scroll { overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--db-border) transparent; }
.db-friends-scroll--requests { max-height: 600px; }
.db-friends-scroll--list { max-height: 640px; }
.db-friends-scroll--ranking { max-height: 580px; }

/* ── Lista: cabecera con «Añadir amigo» ▾ y caja de acción con ✕ ── */
.db-friends-list-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding-bottom: 14px; margin-bottom: 12px; border-bottom: 1px dashed #c9b58e; }
.db-friends-list-head .db-card-title { margin: 0; }
.db-add-dropdown { position: relative; }
.db-dropdown-arrow { font-size: 11px; transition: transform .2s; }
#btnAddFriend.is-open .db-dropdown-arrow { transform: rotate(180deg); }
.db-add-menu { position: absolute; top: calc(100% + 6px); right: 0; z-index: 50; min-width: 220px; overflow: hidden; border: 2px solid #233f4b; border-radius: 10px; background: var(--db-surface); box-shadow: var(--db-shadow); }
.db-add-option { display: flex; align-items: center; gap: 9px; width: 100%; padding: 12px 16px; border: 0; border-bottom: 1px solid #e3d6b8; background: none; color: var(--db-text); font-size: 13px; font-weight: 900; text-align: left; }
.db-add-option:last-child { border-bottom: 0; }
.db-add-option i { color: var(--db-orange-dark); font-size: 16px; }
.db-add-option:hover, .db-add-option:focus-visible { background: #f5832718; }
.db-add-action { flex-basis: 100%; overflow: hidden; border: 2px solid var(--db-border); border-radius: 12px; background: #fffaf0; animation: db-add-in .18s ease-out; }
@keyframes db-add-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .db-add-action { animation: none; } }
.db-add-action-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 8px 7px 14px; border-bottom: 1px solid var(--db-border); background: #f2e6cb; }
.db-add-action-title { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 900; color: var(--db-orange-dark); }
.db-add-action-close { display: inline-grid; place-items: center; flex-shrink: 0; width: 30px; height: 30px; padding: 0; border: 1px solid #c5b797; border-radius: 50%; background: #efe3c6; color: var(--db-text); font-size: 13px; transition: transform .15s, background .15s, color .15s; }
.db-add-action-close:hover { background: var(--db-orange); border-color: var(--db-orange-dark); color: #fff; transform: rotate(90deg); }
@media (prefers-reduced-motion: reduce) { .db-add-action-close:hover { transform: none; } }
.db-add-action-body { padding: 12px 14px; }
.db-code-input { text-transform: uppercase; letter-spacing: .12em; }
.db-invite-box { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px dashed #c9b58e; border-radius: 8px; background: var(--db-surface); }
.db-invite-link { flex: 1; min-width: 0; font-size: 12px; font-weight: 800; color: var(--db-orange-dark); overflow-wrap: anywhere; user-select: all; }
.db-invite-box .db-btn-primary { flex-shrink: 0; }
.db-friends-toggle-row { margin-bottom: 4px; }

/* ── Ranking: pestañas de juego en una fila con scroll horizontal (como WhatPiece). Los márgenes
   auto del primero/último las centran cuando caben y no recortan el inicio al desbordar
   (justify-content: center sí lo haría). La fila sangra hasta el borde de la tarjeta. ── */
.db-friends-page .db-level-tabs {
    flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; overscroll-behavior-x: contain;
    margin: 0 -24px 10px; padding: 2px 24px 10px; scroll-padding-inline: 24px;
    scrollbar-width: thin; scrollbar-color: var(--db-border) transparent;
}
.db-friends-page .db-level-tabs::-webkit-scrollbar { height: 4px; }
.db-friends-page .db-level-tabs::-webkit-scrollbar-thumb { border-radius: 2px; background: var(--db-border); }
.db-friends-page .db-level-tab { flex-shrink: 0; white-space: nowrap; }
.db-friends-page .db-level-tab:first-child { margin-left: auto; }
.db-friends-page .db-level-tab:last-child { margin-right: auto; }
.db-level-sub { font-size: 11px; font-weight: 700; opacity: .9; }
.db-level-arrow { margin-left: 2px; font-size: 10px; opacity: .8; }
/* Desplegable de nivel de Personaje: fijo en <body> para no quedar recortado por el scroll. */
.db-level-drop { position: fixed; z-index: 150; display: flex; flex-direction: column; gap: 2px; min-width: 120px; padding: 5px; border: 2px solid #233f4b; border-radius: 10px; background: var(--db-surface); box-shadow: var(--db-shadow); }
.db-level-drop-option { padding: 7px 14px; border: 0; border-radius: 7px; background: none; color: var(--db-text); font-size: 13px; font-weight: 800; white-space: nowrap; }
.db-level-drop-option:hover, .db-level-drop-option:focus-visible { background: #f5832718; }
.db-level-drop-option.is-active { background: var(--db-orange); color: #fff; }

/* ── Ranking: tabla ── */
.db-friends-table { width: 100%; table-layout: fixed; border-collapse: separate; border-spacing: 0; }
.db-friends-table th { position: sticky; top: 0; z-index: 1; padding: 6px 8px; border-bottom: 2px solid var(--db-border); background: var(--db-surface); color: var(--db-muted); font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: .06em; text-align: left; }
.db-friends-table th:first-child, .db-friends-table td:first-child { width: 48px; text-align: center; }
.db-friends-table th:last-child, .db-friends-table td:last-child { width: 36%; text-align: right; }
.db-friends-table td { padding: 8px; border-bottom: 1px solid #e3d6b8; vertical-align: middle; }
.db-friends-table tr:last-child td { border-bottom: 0; }
.db-friends-table tr.is-self td { background: #f5832718; }
.db-friends-table tr.is-self td:first-child { border-radius: 10px 0 0 10px; }
.db-friends-table tr.is-self td:last-child { border-radius: 0 10px 10px 0; }
.db-friends-table tr.is-idle td { opacity: .65; }
.db-rank-pos { font-family: 'Bangers', Impact, sans-serif; font-size: 22px; color: var(--db-muted); }
.db-rank-player { display: flex; align-items: center; gap: 8px; min-width: 0; }
.db-rank-name { min-width: 0; font-weight: 900; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.db-rank-player .db-verified, .db-rank-player .db-you-badge { flex-shrink: 0; }
.db-rank-value { display: inline-block; padding: 3px 10px; border-radius: 20px; background: #38744e22; color: var(--db-correct); font-size: 12px; font-weight: 900; }
.db-rank-value.is-loss { background: #bc3c2b1c; color: var(--db-red); }
.db-rank-idle { display: inline-block; padding: 3px 10px; border-radius: 20px; background: #e6dcc2; color: var(--db-muted); font-size: 12px; font-weight: 900; }
.db-rank-extra { display: inline-flex; align-items: center; margin-left: 6px; padding: 0; border: 0; background: none; color: var(--db-correct); font-size: 12px; font-weight: 800; cursor: help; }
.db-rank-extra.is-hints { color: #a8641b; }

@media (max-width: 640px) {
    .db-paper-card { padding: 16px 14px; }
    .db-friends-page .db-level-tabs { margin-inline: -14px; padding-inline: 14px; scroll-padding-inline: 14px; }
    .db-friend-row { gap: 10px; }
    /* Código propio: la etiqueta arriba y código + «Copiar» juntos en la fila de abajo; con
       flex-wrap el botón caía solo a una tercera línea y quedaba descolgado. */
    .db-friends-code-row { display: inline-grid; grid-template-columns: auto auto; align-items: center; gap: 6px 12px; }
    .db-friends-code-label { grid-column: 1 / -1; } de la lista centrada en columna y menú bajo el botón (como WhatPiece). */
    .db-friends-list-head { flex-direction: column; text-align: center; }
    .db-friends-list-head .db-card-title { justify-content: center; }
    .db-add-menu { right: auto; left: 50%; transform: translateX(-50%); }
    /* En columna flex-basis: 100% sería la altura: el ancho lo fija width para que no se salga a 320px. */
    .db-add-action { flex-basis: auto; align-self: stretch; width: 100%; min-width: 0; text-align: left; }
    .db-friends-toggle-row { text-align: center; }
    /* Enlace encima y botón a lo ancho debajo: en fila el enlace quedaba apretadísimo. */
    .db-invite-box { flex-direction: column; align-items: stretch; }
    /* Solicitudes: botones solo con ✓ / ✗. */
    .db-req-btn span { display: none; }
    .db-req-btn { padding: 7px 10px; font-size: 14px; }
    /* Tabla: sin columna de posición (como WhatPiece) y sin el texto de pistas (se ve al tocar el icono). */
    .db-friends-table th:first-child, .db-friends-table td:first-child { display: none; }
    .db-friends-table tr.is-self td:nth-child(2) { border-radius: 10px 0 0 10px; }
    .db-friends-table th, .db-friends-table td { padding-inline: 6px; }
    .db-friends-table th:last-child, .db-friends-table td:last-child { width: 44%; }
    .db-rank-extra-label { display: none; }
    .db-rank-value, .db-rank-idle { padding-inline: 8px; font-size: 11px; }
}
/* Móvil estrecho: las dos pestañas principales a partes iguales y sin partir el texto en dos líneas. */
@media (max-width: 400px) {
    .db-friends-page .db-tabs { gap: 6px; }
    .db-friends-page .db-tab { flex: 1 1 0; min-width: 0; justify-content: center; gap: 5px; padding: 9px 8px; font-size: 12px; white-space: nowrap; }
    .db-friends-me-name { font-size: 26px; }
    .db-rank-player { gap: 6px; }
    .db-rank-player .db-row-avatar { width: 32px; height: 32px; font-size: 17px; }
}
