/* Game specific styles for Old Maid */

:root {
    --primary-color: #FF9800;
    --primary-hover: #F57C00;
    --text-main: #555;

    --card-width: 45px;
    --card-height: 63px;
    --gap: -35px;
    /* Tighter default */
    /* Stronger overlap for fan effect */
}

@media (min-width: 600px) {
    :root {
        --card-width: 60px;
        --card-height: 84px;
        --gap: -50px;
        /* Strong overlap on desktop */
    }
}

.game-container {
    max-width: 1000px;
    /* More space */
    margin: 0 auto;
    text-align: center;
    padding: 20px 0;
}

.game-container h1 {
    margin-bottom: 1.5rem;
    color: #333;
}

.game-description {
    margin-bottom: 2rem;
    color: #555;
    font-size: 1.1rem;
}

/* Polished Table */
.game-area-wrapper {
    position: relative;
    padding: 20px;
    background-color: #2E7D32;
    background-image: radial-gradient(circle at center, #388E3C 0%, #1B5E20 100%);
    border: 12px solid #3E2723;
    border-radius: 40px;
    margin-bottom: 2rem;
    min-height: 550px;
    display: flex;
    flex-direction: column;
    box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.6), 0 20px 40px rgba(0, 0, 0, 0.3);
}

.game-info {
    margin-bottom: 15px;
    color: rgba(255, 255, 255, 0.9);
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    font-size: 1.1rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 20px;
    padding: 5px 20px;
    align-self: center;
}

.turn-indicator {
    display: inline-block;
    color: #FFF;
    margin-left: 10px;
    background: rgba(0, 0, 0, 0.6);
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.game-board {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
}

.opponents-row,
.middle-row,
.player-area {
    display: flex;
    justify-content: center;
    position: relative;
}

.middle-row {
    justify-content: space-between;
    align-items: center;
    height: 160px;
    padding: 0 20px;
}

/* Player/Opponent Styles */
.opponent {
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: opacity 0.3s;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.opponent.active {
    color: #fff;
    transform: scale(1.05);
}

.player-left {
    flex-direction: row;
    align-items: center;
}

.player-right {
    flex-direction: row-reverse;
    align-items: center;
}

.avatar {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #424242, #212121);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #FFD54F;
    font-weight: bold;
    border: 3px solid #FFD54F;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    z-index: 5;
    margin: 5px;
    font-size: 1rem;
    text-shadow: 1px 1px 2px #000;
}

.opponent.active .avatar,
.player-area.active .player-label {
    border-color: #FF5722;
    box-shadow: 0 0 20px #FF5722;
    background: #424242;
    /* Keep dark background for avatar */
}

.player-area.active .player-label {
    background: #FFE0B2;
    color: #E64A19;
}

.hand-container {
    display: flex;
    justify-content: center;
    margin: 10px;
    perspective: 1000px;
}

.hand-container.vertical {
    flex-direction: column;
    margin: 0 10px;
}

/* Cards */
/* --- Cards (High Fidelity Port from Blackjack) --- */
:root {
    --card-width: 64px;
    --card-height: 89px;
}

@media (min-width: 600px) {
    :root {
        --card-width: 86px;
        --card-height: 120px;
    }
}

.card {
    width: var(--card-width);
    height: var(--card-height);
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2), 2px 2px 5px rgba(0, 0, 0, 0.3);
    position: relative;
    font-family: 'Times New Roman', serif;
    font-weight: bold;
    display: block;
    /* Changed for absolute positioning children */
    box-sizing: border-box;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), margin 0.3s;
    user-select: none;
    overflow: hidden;
    margin-left: var(--gap);
}

@media (min-width: 600px) {
    .card {
        border-radius: 10px;
    }
}

/* Hand Layout Overrides */
.hand-container.vertical .card {
    margin-left: 0;
    margin-top: -50px;
    /* Tighter overlap for vertical */
}

.hand-container:not(.vertical) .card:first-child {
    margin-left: 0;
}

.hand-container.vertical .card:first-child {
    margin-top: 0;
}

.card.red {
    color: #D32F2F;
}

.card.black {
    color: #212121;
}

.card.joker {
    color: #9C27B0;
}

/* Back Design */
.card.back {
    background: repeating-linear-gradient(45deg, #b71c1c, #b71c1c 10px, #d32f2f 10px, #d32f2f 20px);
    border: 4px solid #fff;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: center;
    align-items: center;
}

.card.back::after {
    content: "♠♥♣♦";
    color: rgba(255, 255, 255, 0.1);
    font-size: 2rem;
    letter-spacing: -5px;
}

/* Corner Labels */
.card-corner {
    position: absolute;
    text-align: center;
    line-height: 0.9;
    font-size: 14px;
    width: 20px;
}

@media (min-width: 600px) {
    .card-corner {
        font-size: 18px;
        width: 24px;
    }
}

.top-left {
    top: 4px;
    left: 4px;
}

.bottom-right {
    bottom: 4px;
    right: 4px;
    transform: rotate(180deg);
}

/* Pips & Layouts */
.pips-layout {
    position: absolute;
    top: 15%;
    bottom: 15%;
    left: 18%;
    right: 18%;
    display: flex;
    justify-content: space-between;
}

.column {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    width: 32%;
}

.col-1 {
    justify-content: center;
}

.col-2,
.col-3,
.col-4 {
    justify-content: space-between;
}

.col-7-mid {
    justify-content: flex-start;
    padding-top: 18%;
}

.col-8-mid {
    justify-content: space-between;
}

.col-10-mid {
    justify-content: space-between;
    padding: 18% 0;
}

.pip {
    font-size: 14px;
    line-height: 1;
    filter: drop-shadow(1px 1px 1px rgba(0, 0, 0, 0.35));
}

.card.red .pip {
    color: #E53935;
}

.card.black .pip {
    color: #212121;
}

.pip.rotated {
    transform: rotate(180deg);
}

@media (min-width: 600px) {
    .pip {
        font-size: 20px;
    }

    .rank-8 .pip,
    .rank-9 .pip,
    .rank-10 .pip {
        font-size: 16px;
    }
}

/* Face Cards */
.court-card-container {
    position: absolute;
    top: 15%;
    bottom: 15%;
    left: 15%;
    right: 15%;
    border: 2px solid currentColor;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.8);
}

.court-border {
    width: 70%;
    height: 60%;
    border: 4px double currentColor;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.court-icon {
    font-size: 2.5rem;
    display: block;
}

.court-rank {
    font-size: 1.2rem;
    font-weight: 800;
}

.court-name {
    margin-top: 5px;
    font-size: 0.6rem;
    letter-spacing: 1px;
    border-top: 1px solid currentColor;
    border-bottom: 1px solid currentColor;
}

/* Ace */
.ace-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60%;
    height: 60%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.ace-pip {
    font-size: 4rem;
    line-height: 1;
    text-shadow: 2px 4px 6px rgba(0, 0, 0, 0.2);
}

/* Joker */
.joker-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    color: #9C27B0;
    text-align: center;
    font-family: 'Comic Sans MS', cursive, sans-serif;
}

/* Interaction */
.selectable .card.back:hover {
    transform: translateY(-15px) scale(1.1);
    cursor: pointer;
    box-shadow: 0 0 15px #FFEB3B;
    z-index: 20;
}

.hand-container.vertical .selectable .card.back:hover {
    transform: translateX(15px) scale(1.1);
}

.player-area .card:hover {
    transform: translateY(-20px) scale(1.1);
    /* Enhanced hover */
    z-index: 50;
}

/* Discard Pile */
.discard-pile {
    width: 60px;
    height: 80px;
    border: 3px dashed rgba(255, 255, 255, 0.4);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9rem;
    font-weight: bold;
}

/* Overlay & Common */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 28px;
    backdrop-filter: blur(5px);
}

.hidden {
    display: none;
}

.ranking-list {
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    width: 240px;
    text-align: left;
}

.rank-item {
    padding: 8px;
    border-bottom: 1px solid #eee;
    font-size: 1.2rem;
    color: #333;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
}

.primary-btn {
    background-color: var(--primary-color);
    color: white;
    font-size: 1.1rem;
    font-weight: bold;
    padding: 1rem 3rem;
    border-radius: 50px;
    border: none;
    cursor: pointer;
    box-shadow: 0 6px 0 rgba(230, 81, 0, 0.5);
    letter-spacing: 1px;
    transition: transform 0.1s;
}

.primary-btn:active {
    transform: translateY(3px);
    box-shadow: 0 3px 0 rgba(230, 81, 0, 0.5);
}

.instructions {
    background: #FAFAFA;
    padding: 2.5rem;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    text-align: left;
    margin: 3rem auto 5rem;
    color: #444;
    line-height: 1.8;
}

.instructions h3 {
    margin-top: 2rem;
    margin-bottom: 0.8rem;
    color: var(--primary-color);
    font-size: 1.3rem;
    font-weight: 700;
}