/* ============================================================
   Post-game dialog: backdrop, dialog chrome, buttons, toast
   All colors from wood design tokens — no hardcoded values
   ============================================================ */

/* Backdrop */
.pg-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(42, 24, 12, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1080;
    padding: 1rem;
}

/* Dialog chrome */
.pg-dialog {
    position: relative;
    background: #fff8ee;
    border: 1px solid rgba(124, 74, 44, 0.18);
    border-radius: 0.5rem;
    box-shadow: 0 8px 32px rgba(42, 24, 12, 0.16);
    padding: 1.5rem 1.5rem 1.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    min-width: 15rem;
    max-width: 22rem;
    width: 100%;
}

/* Close / × button */
.pg-close-btn {
    position: absolute;
    top: 0.6rem;
    right: 0.7rem;
    width: 2rem;
    height: 2rem;
    min-width: 2rem;
    min-height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    font-size: 1.3rem;
    line-height: 1;
    color: var(--wood-text-on-light, #5a381f);
    cursor: pointer;
    border-radius: 0.25rem;
    padding: 0;
    transition: background 0.15s;
}

.pg-close-btn:hover {
    background: rgba(124, 74, 44, 0.1);
}

/* Tooltip on close button */
.pg-close-btn[data-tooltip] {
    position: absolute;
    overflow: visible;
}

.pg-close-btn[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 0.35rem);
    left: 50%;
    transform: translateX(-50%);
    padding: 0.25rem 0.55rem;
    font-size: 0.78rem;
    font-weight: 400;
    font-family: inherit;
    white-space: nowrap;
    background: #2c1f16;
    color: #fff;
    border-radius: 4px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    z-index: 1100;
}

.pg-close-btn[data-tooltip]:hover::after {
    opacity: 1;
}

/* Headline and detail */
.pg-headline {
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--wood-text-on-light, #5a381f);
    margin: 0;
    text-align: center;
    padding: 0 1.75rem;
}

.pg-detail {
    font-size: 0.88rem;
    color: var(--wood-text-on-light, #5a381f);
    opacity: 0.75;
    margin: 0;
    text-align: center;
}

.pg-detail--tc {
    font-size: 1.1rem;
    font-weight: 600;
    opacity: 0.85;
    letter-spacing: 0.02em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
}

.pg-detail--tc .challenge-color-dot {
    width: 1em;
    height: 1em;
}

/* Action buttons */
.pg-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.45rem;
    width: 100%;
    margin-top: 0.9rem;
}

.pg-actions--row {
    flex-direction: row;
    justify-content: center;
    align-items: stretch;
}

.pg-btn {
    width: auto;
    min-width: 10rem;
    max-width: 100%;
    padding: 0.45rem 1.5rem;
    font-size: 0.95rem;
    border-radius: 0.35rem;
    cursor: pointer;
    position: relative;
    overflow: visible;
    font-family: inherit;
}

.pg-actions--row .pg-btn {
    flex: 1;
}

/* Tooltip on action buttons */
.pg-btn[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 0.35rem);
    left: 50%;
    transform: translateX(-50%);
    padding: 0.25rem 0.55rem;
    font-size: 0.75rem;
    font-weight: 400;
    font-family: inherit;
    white-space: nowrap;
    background: #2c1f16;
    color: #fff;
    border-radius: 4px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    z-index: 1100;
    max-width: 18rem;
    text-align: center;
    white-space: normal;
    word-break: break-word;
}

.pg-btn[data-tooltip]:hover::after {
    opacity: 1;
}

/* Lobby button — slightly muted to be visually subordinate */
.pg-btn--lobby {
    opacity: 0.82;
}

.pg-btn--lobby:hover {
    opacity: 1;
}

/* Pending spinner */
.pg-spinner {
    display: flex;
    gap: 0.35rem;
    align-items: center;
    margin: 0.5rem 0;
}

.pg-spinner-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: var(--wood-text-on-light, #5a381f);
    opacity: 0.4;
    animation: pg-dot-pulse 1.2s infinite ease-in-out;
}

.pg-spinner-dot:nth-child(2) { animation-delay: 0.2s; }
.pg-spinner-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes pg-dot-pulse {
    0%, 100% { opacity: 0.2; transform: scale(0.85); }
    50%       { opacity: 0.8; transform: scale(1.1); }
}

/* Toast */
.pg-toast {
    position: fixed;
    bottom: 1.25rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1090;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: #fff8ee;
    border: 1px solid rgba(124, 74, 44, 0.28);
    border-radius: 0.4rem;
    box-shadow: 0 4px 16px rgba(42, 24, 12, 0.14);
    padding: 0.55rem 1rem 0.55rem 1.1rem;
    max-width: 92vw;
    animation: pg-toast-in 0.2s ease;
}

@keyframes pg-toast-in {
    from { opacity: 0; transform: translateX(-50%) translateY(0.5rem); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.pg-toast__message {
    font-size: 0.9rem;
    color: var(--wood-text-on-light, #5a381f);
}

.pg-toast__close {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    color: var(--wood-text-on-light, #5a381f);
    padding: 0.1rem 0.25rem;
    position: relative;
    overflow: visible;
    min-width: 2rem;
    min-height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pg-toast__close[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 0.35rem);
    left: 50%;
    transform: translateX(-50%);
    padding: 0.2rem 0.45rem;
    font-size: 0.75rem;
    white-space: nowrap;
    background: #2c1f16;
    color: #fff;
    border-radius: 4px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    z-index: 1100;
}

.pg-toast__close[data-tooltip]:hover::after {
    opacity: 1;
}

/* Bot rematch: ← Lobby | Rematch | ⌄ row */
.pg-rematch-row {
    display: flex;
    align-items: stretch;
    gap: 0.3rem;
}

.pg-rematch-btn {
    flex: 1;
}

.pg-lobby-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.4rem;
    min-width: 2.4rem;
    padding: 0;
    background: transparent;
    border: 1px solid rgba(124, 74, 44, 0.28);
    border-radius: 0.35rem;
    color: var(--wood-text-on-light, #5a381f);
    opacity: 0.7;
    cursor: pointer;
    font-size: 0.9rem;
    position: relative;
    overflow: visible;
    transition: background 0.15s, opacity 0.15s;
}

.pg-lobby-icon-btn:hover {
    background: rgba(124, 74, 44, 0.08);
    opacity: 1;
}

.pg-lobby-icon-btn[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 0.35rem);
    left: 50%;
    transform: translateX(-50%);
    padding: 0.25rem 0.55rem;
    font-size: 0.78rem;
    font-weight: 400;
    font-family: inherit;
    white-space: nowrap;
    background: #2c1f16;
    color: #fff;
    border-radius: 4px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    z-index: 1100;
}

.pg-lobby-icon-btn[data-tooltip]:hover::after {
    opacity: 1;
}

.pg-settings-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.4rem;
    min-width: 2.4rem;
    padding: 0;
    background: transparent;
    border: 1px solid rgba(124, 74, 44, 0.28);
    border-radius: 0.35rem;
    color: var(--wood-text-on-light, #5a381f);
    opacity: 0.7;
    cursor: pointer;
    font-size: 0.9rem;
    position: relative;
    overflow: visible;
    transition: background 0.15s, opacity 0.15s;
}

.pg-settings-icon-btn:hover {
    background: rgba(124, 74, 44, 0.08);
    opacity: 1;
}

.pg-settings-icon-btn[aria-expanded="true"] {
    background: rgba(124, 74, 44, 0.12);
    opacity: 1;
}

/* Tooltip for gear icon */
.pg-settings-icon-btn[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 0.35rem);
    left: 50%;
    transform: translateX(-50%);
    padding: 0.25rem 0.55rem;
    font-size: 0.78rem;
    font-weight: 400;
    font-family: inherit;
    white-space: nowrap;
    background: #2c1f16;
    color: #fff;
    border-radius: 4px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    z-index: 1100;
}

.pg-settings-icon-btn[data-tooltip]:hover::after {
    opacity: 1;
}

/* Expanded dialog when settings are visible */
.pg-dialog--expanded {
    max-width: 28rem;
}

.pg-settings-panel {
    width: 100%;
    margin-top: 0.85rem;
    padding-top: 0.85rem;
    border-top: 1px solid rgba(124, 74, 44, 0.16);
}

.pg-settings-panel--hidden {
    display: none;
}

.pg-game-info {
    margin-top: 0.5rem;
}

.pg-game-info-profile {
    font-weight: 600;
    opacity: 0.9;
}

.pg-game-info-sep {
    opacity: 0.45;
    margin: 0 0.1rem;
}

/* Mobile */
@media (max-width: 480px) {
    .pg-dialog {
        max-width: 92vw;
        padding: 1.25rem 1rem 1rem;
    }

    .pg-dialog--expanded {
        max-width: 95vw;
    }

    .pg-btn {
        min-width: 0;
        width: 100%;
    }

    .pg-actions--row {
        flex-direction: column;
    }

    .pg-actions--row .pg-btn {
        width: 100%;
    }

    .pg-headline {
        font-size: 1.15rem;
    }
}
