/* Game specific styles for Blackjack */

:root {
    --primary-color: #FF9800;
    --primary-hover: #F57C00;
    --text-main: #333;
    --bg-card: #FFFFFF;

    --card-width: 64px;
    --card-height: 89px;
}

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

body {
    background-color: #f5f5f5;
    font-family: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
}

.game-container {
    max-width: 800px;
    margin: 0 auto;
    text-align: center;
    padding: 20px 0;
}

.game-container h1 {
    margin-bottom: 1.5rem;
    color: var(--text-main);
}

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

/* 
   Premium Table Design 
   Matches Mahjong/Sevens style: Dark green felt + Wood border
*/
.game-area-wrapper {
    position: relative;
    padding: 30px;
    background-color: #004D40;
    background-image: radial-gradient(circle at center, #00695C 10%, #004D40 90%);
    border: 15px solid #4E342E;
    /* Mahogany */
    border-radius: 40px;
    /* Rounded table */
    box-shadow:
        inset 0 0 80px rgba(0, 0, 0, 0.8),
        0 20px 50px rgba(0, 0, 0, 0.4);
    margin-bottom: 3rem;
    min-height: 500px;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
    color: #fff;
}

/* Stats Bar - Premium Casino Style */
.game-controls {
    background: linear-gradient(180deg, #2c3e50 0%, #000000 100%);
    padding: 12px 40px;
    border-radius: 50px;
    margin-bottom: 25px;
    border: 2px solid #FFD700;
    /* Gold Border */
    display: inline-block;
    box-shadow:
        0 4px 10px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    min-width: 300px;
}

.stats {
    display: flex;
    gap: 40px;
    font-size: 1.1rem;
    font-weight: bold;
    color: #fff;
    justify-content: center;
    align-items: center;
    font-family: 'Hiragino Kaku Gothic ProN', Meiryo, sans-serif;
}

.chip-count,
.bet-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.2;
}

.chip-count::before,
.bet-info::before {
    font-size: 0.8rem;
    color: #AAA;
    margin-bottom: 2px;
    font-weight: normal;
}

/* Re-using text content for styling labels if needed, but we changed HTML structure lightly. */
/* Let's trust the HTML text "所持チップ: 1000" pattern */

.chip-count {
    color: #FFD54F;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 1);
}

.bet-info {
    color: #81D4FA;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 1);
}


/* Game Table Layout */
.game-table {
    width: 100%;
    max-width: 700px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 10px 0;
}

.hand-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 160px;
}

.dealer-area {
    margin-bottom: 20px;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
    padding-bottom: 20px;
}

.player-area {
    margin-top: 20px;
}

.hand-label {
    color: rgba(255, 255, 255, 0.9);
    font-weight: bold;
    margin: 8px 0;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.1rem;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.8);
}

.score-badge {
    background: #000;
    color: #FFD54F;
    padding: 2px 12px;
    border-radius: 12px;
    min-width: 28px;
    border: 1px solid #FFD54F;
    box-shadow: 0 0 10px rgba(255, 213, 79, 0.3);
    font-family: monospace;
    font-size: 1.1rem;
}

.hand {
    display: flex;
    gap: 10px;
    min-height: var(--card-height);
    justify-content: center;
    flex-wrap: wrap;
    perspective: 1000px;
}

/* --- Cards V2 (Realistic Pips) --- */
.card {
    width: var(--card-width);
    height: var(--card-height);
    background-color: #fff;
    border-radius: 8px;
    /* Slightly rounder */
    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;
    /* Classic card font */
    font-weight: bold;
    display: block;
    /* Changed from flex for custom pip positioning */
    box-sizing: border-box;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    user-select: none;
    overflow: hidden;
}

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

.card:hover {
    transform: translateY(-10px) scale(1.05);
    z-index: 50;
}

.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;
}

.red {
    color: #D32F2F;
}

.black {
    color: #212121;
}

/* 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);
}

/* Face Cards */
/* --- Court Cards (J, Q, K) --- */
.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:
        linear-gradient(135deg, rgba(0, 0, 0, 0.02) 25%, transparent 25%) -10px 0,
        linear-gradient(225deg, rgba(0, 0, 0, 0.02) 25%, transparent 25%) -10px 0,
        linear-gradient(315deg, rgba(0, 0, 0, 0.02) 25%, transparent 25%),
        linear-gradient(45deg, rgba(0, 0, 0, 0.02) 25%, transparent 25%);
    background-size: 20px 20px;
    background-color: rgba(255, 255, 255, 0.8);
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1);
}

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

.court-inner {
    text-align: center;
    line-height: 1;
}

.court-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: -5px;
}

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

.court-name {
    margin-top: 10px;
    font-size: 0.8rem;
    letter-spacing: 2px;
    font-weight: bold;
    border-top: 1px solid currentColor;
    border-bottom: 1px solid currentColor;
    padding: 2px 8px;
}

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

.ace-pip {
    font-size: 5rem;
    line-height: 1;
    text-shadow: 2px 4px 6px rgba(0, 0, 0, 0.2);
    /* Maybe a decorative ring? */
    position: relative;
}

/* Spade A often has branding. Let's add a decorative circle for all Aces for consistency */
.ace-pip::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 120%;
    height: 120%;
    transform: translate(-50%, -50%);
    border: 1px dotted currentColor;
    border-radius: 50%;
    opacity: 0.3;
}

/* --- Column Based Pip Layout (V4) --- */
.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%;
    /* Ensure proper spacing */
}

/* Vertical Spacing within Columns */
.col-1 {
    justify-content: center;
}

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

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

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

/* Mid-Column Tweaks for standard optical balance */
.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;
    /* Push them inwards to avoid crowding top/bot */
}

/* Rotated Pips */
.pip.rotated {
    transform: rotate(180deg);
}

/* Pip Visual Polish & Sizing Fix */
.pip {
    font-size: 16px;
    /* Reduced from 24px */
    line-height: 1;
    filter: drop-shadow(1px 1px 1px rgba(0, 0, 0, 0.35));
    /* Subtle depth */
}

/* Richer Colors for Pips specifically */
.card.red .pip {
    color: #E53935;
}

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

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

    /* Reduced from 32px */
}

.pip.large-pip {
    font-size: 3rem;
    line-height: 1;
    /* Reset large pip */
}

/* Optimize Density for High Ranks (8, 9, 10) */
.rank-8 .pip,
.rank-9 .pip,
.rank-10 .pip {
    font-size: 14px;
    /* Reduced from 20px */
}

@media (min-width: 600px) {

    .rank-8 .pip,
    .rank-9 .pip,
    .rank-10 .pip {
        font-size: 18px;
        /* Reduced from 26px */
    }
}

.card-top,
.card-center {
    display: none;
}


/* Center Message - Dramatic Pop */
.message-area {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    color: #FFD54F;
    padding: 20px 40px;
    border-radius: 16px;
    font-size: 1.5rem;
    font-weight: 800;
    pointer-events: none;
    z-index: 200;
    text-align: center;
    white-space: pre-wrap;
    /* allow newline */
    border: 3px solid #FFD54F;
    box-shadow: 0 0 30px rgba(255, 213, 79, 0.5);
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    from {
        transform: translate(-50%, -50%) scale(0);
        opacity: 0;
    }

    to {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

/* Action Controls (Hit/Stand/Double) */
.action-controls {
    margin-top: 20px;
    z-index: 10;
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.game-btn {
    border: none;
    border-radius: 50px;
    padding: 14px 30px;
    font-size: 1.1rem;
    font-weight: bold;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 6px 0 rgba(0, 0, 0, 0.3);
    text-transform: uppercase;
    transition: transform 0.1s;
    letter-spacing: 1px;
    min-width: 140px;
}

.game-btn:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3);
}

.hit {
    background: linear-gradient(to bottom, #66BB6A, #43A047);
    border-bottom: 4px solid #2E7D32;
}

.stand {
    background: linear-gradient(to bottom, #EF5350, #E53935);
    border-bottom: 4px solid #C62828;
}

.double {
    background: linear-gradient(to bottom, #FFA726, #FB8C00);
    border-bottom: 4px solid #EF6C00;
}

/* Betting Overlay */
.bet-controls {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 25px;
    z-index: 50;
    color: #fff;
}

.bet-controls p {
    margin-bottom: 30px;
    font-size: 1.5rem;
    font-weight: bold;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

.bet-buttons {
    display: flex;
    gap: 20px;
    margin-bottom: 40px;
    flex-wrap: wrap;
    justify-content: center;
}

/* Chips as 3D Objects */
.bet-btn {
    background: radial-gradient(circle at 30% 30%, #FFF 0%, #EEE 40%, #BDBDBD 100%);
    color: #424242;
    border: 6px dashed #FBC02D;
    /* Stitching look */
    border-radius: 50%;
    width: 80px;
    height: 80px;
    font-weight: 800;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow:
        inset 0 0 10px rgba(0, 0, 0, 0.2),
        0 5px 15px rgba(0, 0, 0, 0.5);
    position: relative;
    transition: transform 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
}

.bet-btn::before {
    /* Inner Ring */
    content: '';
    position: absolute;
    width: 70%;
    height: 70%;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
}

.bet-btn:hover {
    transform: translateY(-5px);
}

.bet-btn.selected {
    transform: scale(1.1) translateY(-5px);
    box-shadow: 0 0 20px #FFD700;
    border-color: #E65100;
    border-style: solid;
    background: #FFF9C4;
}

/* Primary Deal Button */
.primary-btn {
    background: linear-gradient(to bottom, #FFCA28, #FFB300);
    color: #3E2723;
    font-size: 1.3rem;
    font-weight: 800;
    padding: 1rem 4rem;
    border-radius: 50px;
    border: none;
    cursor: pointer;
    box-shadow: 0 6px 0 #FF6F00, 0 10px 20px rgba(0, 0, 0, 0.4);
    transition: transform 0.1s;
}

.primary-btn:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 #FF6F00;
}

.primary-btn:disabled {
    filter: grayscale(1);
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.hidden {
    display: none !important;
}

/* Instructions */
.instructions {
    background: #fff;
    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;
}