/* ==========================================================================
   MAFIA GAME - MODERN 3D INTERACTIVE ROLE CARD
   ========================================================================== */

.role-screen-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin: 0 auto;
}

.player-top-bar {
    width: min(330px, 86vw);
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 auto 14px auto;
    padding: 10px 16px;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    gap: 12px;
}

.player-nickname {
    font-weight: 700;
    font-size: 1rem;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.player-nickname span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.player-room-tag {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-family: var(--font-heading);
    letter-spacing: 1px;
    flex-shrink: 0;
    max-width: 48%;
    overflow-wrap: anywhere;
    text-align: right;
}

/* 3D Perspective Card Container with Perfect 1:1.45 Playing Card Proportions */
.card-scene {
    perspective: 1200px;
    width: min(330px, 86vw);
    aspect-ratio: 1 / 1.45;
    height: auto;
    user-select: none;
    -webkit-user-select: none;
    margin: 0 auto 14px auto;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.65s cubic-bezier(0.4, 0.2, 0.2, 1);
    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d;
    will-change: transform;
    cursor: pointer;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
}

.card-inner.is-flipped {
    transform: rotateY(180deg);
    -webkit-transform: rotateY(180deg);
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 32px 24px;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
}

/* Card Front: Mystery / Cover */
.card-front {
    transform: rotateY(0deg);
    -webkit-transform: rotateY(0deg);
    background: radial-gradient(circle at 50% 30%, #1c202c 0%, #0d0f14 100%);
    color: #ffffff;
}

.card-front::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(
        transparent,
        rgba(230, 57, 70, 0.2),
        transparent 30%
    );
    animation: rotateCardBorder 8s linear infinite;
    pointer-events: none;
}

.card-front::after {
    content: '';
    position: absolute;
    inset: 3px;
    background: radial-gradient(circle at 50% 30%, #161922 0%, #0c0e13 100%);
    border-radius: calc(var(--radius-lg) - 3px);
    z-index: 1;
}

@keyframes rotateCardBorder {
    100% { transform: rotate(1turn); }
}

.card-front-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    width: 100%;
    text-align: center;
}

.mystery-seal {
    width: 104px;
    height: 104px;
    border-radius: 50%;
    background: rgba(230, 57, 70, 0.1);
    border: 2px solid rgba(230, 57, 70, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-crimson);
    font-size: 44px;
    margin: 10px auto 0 auto;
    box-shadow: 0 0 30px var(--accent-crimson-glow);
    animation: pulseGlow 3s ease-in-out infinite alternate;
}

.mystery-seal i {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

@keyframes pulseGlow {
    0% { transform: scale(0.96); box-shadow: 0 0 20px var(--accent-crimson-glow); }
    100% { transform: scale(1.04); box-shadow: 0 0 35px var(--accent-crimson-glow); }
}

.mystery-title {
    font-family: var(--font-heading);
    font-size: 1.7rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #ffffff;
    margin-top: 10px;
}

.tap-hint {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
    padding: 10px 18px;
    border-radius: 24px;
    animation: bounceTap 2s infinite ease-in-out;
}

@keyframes bounceTap {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

/* Card Back: Revealed Role */
.card-back {
    transform: rotateY(180deg);
    -webkit-transform: rotateY(180deg);
    background: radial-gradient(circle at 50% 20%, #1f2433 0%, #0d0f14 100%);
    color: #ffffff;
}

.card-back-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    text-align: center;
}

.role-badge-icon {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 38px;
    margin: 0 auto 14px auto;
    text-align: center;
}

.role-badge-icon i {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    margin: auto;
}

.role-team-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    padding: 5px 14px;
    border-radius: 20px;
    margin: 0 auto 12px auto;
}

.role-name-display {
    font-family: var(--font-heading);
    font-size: 2.1rem;
    font-weight: 900;
    letter-spacing: 2px;
    margin: 0 auto 16px auto;
    text-transform: uppercase;
    text-align: center;
    width: 100%;
}

.role-desc-box {
    width: 100%;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 16px 18px;
    font-size: 0.92rem;
    line-height: 1.6;
    color: var(--text-secondary);
    margin-bottom: 20px;
    text-align: left;
}

.role-desc-box strong {
    color: #ffffff;
}

.hide-role-btn {
    width: 100%;
    padding: 12px 16px;
    font-size: 0.92rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
}

.hide-role-btn:hover {
    background: var(--bg-surface-hover);
    color: #ffffff;
    border-color: var(--border-active);
}

/* Role Themes */
.theme-mafia .role-badge-icon { background: rgba(230, 57, 70, 0.2); color: var(--role-mafia); border: 2px solid var(--role-mafia); box-shadow: 0 0 25px var(--accent-crimson-glow); }
.theme-mafia .role-team-pill { background: rgba(230, 57, 70, 0.2); color: var(--role-mafia); border: 1px solid rgba(230, 57, 70, 0.4); }
.theme-mafia .role-name-display { color: var(--role-mafia); }

.theme-don .role-badge-icon { background: rgba(244, 162, 97, 0.2); color: var(--role-don); border: 2px solid var(--role-don); box-shadow: 0 0 25px rgba(244, 162, 97, 0.35); }
.theme-don .role-team-pill { background: rgba(244, 162, 97, 0.2); color: var(--role-don); border: 1px solid rgba(244, 162, 97, 0.4); }
.theme-don .role-name-display { color: var(--role-don); }

.theme-doctor .role-badge-icon { background: rgba(6, 214, 160, 0.2); color: var(--role-doctor); border: 2px solid var(--role-doctor); box-shadow: 0 0 25px rgba(6, 214, 160, 0.35); }
.theme-doctor .role-team-pill { background: rgba(6, 214, 160, 0.2); color: var(--role-doctor); border: 1px solid rgba(6, 214, 160, 0.4); }
.theme-doctor .role-name-display { color: var(--role-doctor); }

.theme-sheriff .role-badge-icon { background: rgba(58, 134, 255, 0.2); color: var(--role-sheriff); border: 2px solid var(--role-sheriff); box-shadow: 0 0 25px rgba(58, 134, 255, 0.35); }
.theme-sheriff .role-team-pill { background: rgba(58, 134, 255, 0.2); color: var(--role-sheriff); border: 1px solid rgba(58, 134, 255, 0.4); }
.theme-sheriff .role-name-display { color: var(--role-sheriff); }

.theme-maniac .role-badge-icon { background: rgba(155, 93, 229, 0.2); color: var(--role-maniac); border: 2px solid var(--role-maniac); box-shadow: 0 0 25px rgba(155, 93, 229, 0.35); }
.theme-maniac .role-team-pill { background: rgba(155, 93, 229, 0.2); color: var(--role-maniac); border: 1px solid rgba(155, 93, 229, 0.4); }
.theme-maniac .role-name-display { color: var(--role-maniac); }

.theme-kamikaze .role-badge-icon { background: rgba(251, 86, 7, 0.2); color: var(--role-kamikaze); border: 2px solid var(--role-kamikaze); box-shadow: 0 0 25px rgba(251, 86, 7, 0.35); }
.theme-kamikaze .role-team-pill { background: rgba(251, 86, 7, 0.2); color: var(--role-kamikaze); border: 1px solid rgba(251, 86, 7, 0.4); }
.theme-kamikaze .role-name-display { color: var(--role-kamikaze); }

.theme-villager .role-badge-icon { background: rgba(141, 153, 174, 0.2); color: var(--role-villager); border: 2px solid var(--role-villager); box-shadow: 0 0 25px rgba(141, 153, 174, 0.35); }
.theme-villager .role-team-pill { background: rgba(141, 153, 174, 0.2); color: var(--role-villager); border: 1px solid rgba(141, 153, 174, 0.4); }
.theme-villager .role-name-display { color: var(--role-villager); }

.theme-custom .role-badge-icon { 
    background: rgba(255, 255, 255, 0.08); 
    color: var(--custom-role-color, #3a86ff); 
    border: 2px solid var(--custom-role-color, #3a86ff); 
    box-shadow: 0 0 25px var(--custom-role-color, #3a86ff); 
}
.theme-custom .role-team-pill { 
    background: rgba(255, 255, 255, 0.08); 
    color: var(--custom-role-color, #3a86ff); 
    border: 1px solid var(--custom-role-color, #3a86ff); 
}
.theme-custom .role-name-display { 
    color: var(--custom-role-color, #3a86ff); 
}

/* Elimination Notice */
.eliminated-banner {
    width: min(370px, 92vw);
    margin: 0 auto;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #ef4444;
    padding: 12px 18px;
    border-radius: var(--radius-md);
    display: none;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 700;
    margin-top: 14px;
}

.eliminated-banner.show {
    display: flex;
}

/* Mobile zero-scroll & proportional adjustments */
@media (max-width: 600px) {
    .player-top-bar {
        width: min(310px, 84vw);
        margin: 0 auto 10px auto;
        padding: 9px 14px;
        font-size: 0.92rem;
    }
    .card-scene {
        width: min(310px, 84vw);
        aspect-ratio: 1 / 1.45;
        height: auto;
        margin: 0 auto 10px auto;
    }
    .card-face {
        padding: 20px 16px;
    }
    .mystery-seal {
        width: 78px;
        height: 78px;
        font-size: 34px;
        margin: 6px auto 0 auto;
    }
    .mystery-title {
        font-size: 1.4rem;
        margin-top: 6px;
    }
    .tap-hint {
        padding: 7px 14px;
        font-size: 0.8rem;
    }
    .role-badge-icon {
        width: 70px;
        height: 70px;
        font-size: 32px;
        margin: 0 auto 8px auto;
    }
    .role-name-display {
        font-size: 1.55rem;
        margin: 0 auto 8px auto;
    }
    .role-desc-box {
        padding: 10px 14px;
        font-size: 0.82rem;
        line-height: 1.45;
        margin-bottom: 10px;
        max-height: 110px;
        overflow-y: auto;
    }
    .hide-role-btn {
        padding: 10px 14px;
        font-size: 0.82rem;
    }
}

/* A purpose-built horizontal card avoids squashing the portrait proportions. */
@media (orientation: landscape) and (max-height: 600px) {
    .player-top-bar {
        width: min(520px, 72vw);
        margin-bottom: 10px;
        padding: 8px 14px;
    }

    .card-scene {
        width: min(520px, 72vw);
        height: min(250px, 62dvh);
        max-height: none;
        aspect-ratio: auto;
        margin-bottom: 10px;
    }

    .card-face {
        padding: 14px 18px;
    }

    .card-front-content {
        display: grid;
        grid-template-columns: 96px minmax(0, 1fr);
        grid-template-rows: 1fr auto;
        column-gap: 18px;
        row-gap: 10px;
    }

    .mystery-seal {
        grid-column: 1;
        grid-row: 1 / 3;
        width: 72px;
        height: 72px;
        margin: auto;
        font-size: 32px;
        flex-shrink: 0;
    }

    .card-front-content > div:nth-child(2) {
        grid-column: 2;
        grid-row: 1;
        align-self: end;
    }

    .mystery-title {
        font-size: 1.45rem;
        margin-top: 0;
    }

    .card-front-content .tap-hint {
        grid-column: 2;
        grid-row: 2;
        align-self: start;
        min-height: 44px;
        padding: 8px 14px;
    }

    .card-back {
        display: grid;
        grid-template-columns: minmax(120px, 0.85fr) minmax(0, 1.15fr);
        grid-template-rows: minmax(0, 1fr) auto;
        column-gap: 16px;
        row-gap: 10px;
    }

    .card-back-header {
        grid-column: 1;
        grid-row: 1 / 3;
        align-self: center;
    }

    .role-badge-icon {
        width: 56px;
        height: 56px;
        margin-bottom: 7px;
        font-size: 26px;
    }

    .role-team-pill {
        margin-bottom: 7px;
        padding: 4px 10px;
        font-size: 0.68rem;
    }

    .role-name-display {
        margin-bottom: 0;
        font-size: 1.35rem;
    }

    .role-desc-box {
        grid-column: 2;
        grid-row: 1;
        min-height: 0;
        max-height: none;
        margin: 0;
        padding: 10px 12px;
        overflow-y: auto;
        font-size: 0.78rem;
        line-height: 1.35;
    }

    .hide-role-btn {
        grid-column: 2;
        grid-row: 2;
        min-height: 44px;
        padding: 8px 12px;
    }
}
