/* Main styling */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Arial', sans-serif;
}

body {
    background-color: #0a0a0a;
    color: #fff;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.game-container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.logo-link {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 10;
    transition: transform 0.2s ease;
}

.logo-link:hover {
    transform: scale(1.05);
}

.gamify-logo {
    width: 120px;
    height: auto;
    filter: drop-shadow(0 0 5px rgba(57, 220, 30, 0.5));
}

header {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
    width: 100%;
    position: relative;
    z-index: 5;
}

.logo-container {
    width: 100%;
    text-align: center;
}

.logo-container h1 {
    color: #ffffff;
    font-size: 48px;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    margin-bottom: 5px;
}

.logo-container h2 {
    color: #39DC1E;
    font-size: 19px;
    text-shadow: 0 0 5px rgba(57, 220, 30, 0.5);
}

.timer-container {
    position: absolute;
    top: 20px;
    right: 20px;
    background-color: rgba(10, 10, 10, 0.8);
    padding: 10px 15px;
    border-radius: 10px;
    border: 2px solid #39DC1E;
    z-index: 10;
}

#timer {
    font-size: 24px;
    font-weight: bold;
    color: #39DC1E;
}

/* Leaderboard styling */
.leaderboard-container {
    position: absolute;
    top: 180px;
    right: 20px;
    width: 250px;
    z-index: 10;
}

.leaderboard {
    background-color: rgba(10, 10, 10, 0.8);
    border-radius: 15px;
    border: 2px solid #39DC1E;
    padding: 15px;
}

.leaderboard h3 {
    color: #39DC1E;
    text-align: center;
    margin-bottom: 15px;
    font-size: 20px;
    border-bottom: 1px solid #39DC1E;
    padding-bottom: 8px;
}

.leaderboard-content {
    overflow-y: auto;
    max-height: 200px;
}

/* Metrics styling */
.metrics-container {
    position: absolute;
    top: 400px;
    right: 20px;
    width: 250px;
    z-index: 10;
}

.metrics {
    background-color: rgba(10, 10, 10, 0.8);
    border-radius: 15px;
    border: 2px solid #39DC1E;
    padding: 15px;
}

.metrics h3 {
    color: #39DC1E;
    text-align: center;
    margin-bottom: 15px;
    font-size: 20px;
    border-bottom: 1px solid #39DC1E;
    padding-bottom: 8px;
}

.metrics-content {
    overflow-y: auto;
    max-height: 200px;
}

.metrics-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 5px;
    border-bottom: 1px dotted rgba(57, 220, 30, 0.3);
}

.metrics-item:last-child {
    border-bottom: none;
}

.metrics-label {
    color: white;
    font-weight: bold;
}

.metrics-value {
    color: #39DC1E;
    font-family: monospace;
    text-align: right;
}

.table-logo {
    position: absolute;
    width: 220px;
    height: 150px;
    background-image: url('images/table-logo.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
}

/* Table styling */
.table {
    background-image: url('images/Gamify_Logo.png');
    background-size: cover;
    background-position: center;
    background-color: rgba(10, 10, 10, 0.7);
    border-radius: 50px;
    padding: 40px 20px;
    margin-bottom: 20px;
    position: relative;
    box-shadow: 0 0 20px rgba(57, 220, 30, 0.5);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 600px;
    border: 3px solid #39DC1E;
    width: 100%;
    max-width: 750px;
}

#dealer-hand {
    margin-top: 0;
    margin-bottom: 40px;
    position: relative;
    z-index: 2;
    background-color: rgba(10, 10, 10, 0.7);
    padding: 15px;
    border-radius: 15px;
}

#player-hand {
    margin-top: 40px;
    margin-bottom: 0;
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: rgba(10, 10, 10, 0.7);
    padding: 15px;
    border-radius: 15px;
}

#player-hand h2 {
    margin-top: 15px;
    margin-bottom: 0;
}

.hand {
    margin: 20px 0;
    text-align: center;
}

.hand h2 {
    margin-bottom: 10px;
    font-size: 24px;
    color: #ffffff;
    text-shadow: 0 0 10px rgba(57, 220, 30, 0.5);
}

.cards {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    min-height: 150px;
}

.card {
    width: 85px;
    height: 128px;
    margin: 0 5px;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    transition: transform 0.5s ease;
    transform-style: preserve-3d;
    position: relative;
}

.card.flipped {
    transform: rotateY(180deg);
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 10px;
}

.card-front {
    background-color: white;
    transform: rotateY(180deg);
    padding: 5px;
    color: #000;
    display: flex;
    flex-direction: column;
}

.card-front.red-card {
    color: #d40000;
}

.card-value-top, .card-suit-top {
    position: absolute;
    top: 5px;
    left: 5px;
    font-size: 20px;
    font-weight: bold;
}

.card-suit-top {
    top: 25px;
}

.card-value-bottom, .card-suit-bottom {
    position: absolute;
    bottom: 5px;
    right: 5px;
    font-size: 20px;
    font-weight: bold;
    transform: rotate(180deg);
}

.card-suit-bottom {
    bottom: 25px;
}

.card-center-suit {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 40px;
}

.card-back {
    background-image: url('images/card-back.png');
    background-size: cover;
    background-position: center;
}

.hand-value {
    display: inline-block;
    margin-top: 10px;
    font-size: 20px;
    background-color: rgba(10, 10, 10, 0.7);
    padding: 5px 15px;
    border-radius: 20px;
    color: #39DC1E;
    border: 1px solid #39DC1E;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Controls styling */
.controls {
    background-color: rgba(10, 10, 10, 0.8);
    padding: 20px;
    border-radius: 15px;
    border: 2px solid #39DC1E;
    width: 100%;
    max-width: 750px;
}

.balance-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.balance {
    font-size: 22px;
    font-weight: bold;
    color: #39DC1E;
    margin: 10px 0;
}

.probability-btn {
    margin-left: 15px;
    background-color: #0a0a0a;
    color: #39DC1E;
    border: 1px solid #39DC1E;
}

.probability-btn:hover {
    background-color: #39DC1E;
    color: #0a0a0a;
}

.probability-btn.active {
    background-color: #39DC1E;
    color: #0a0a0a;
}

.probability-display {
    display: none;
    background-color: rgba(10, 10, 10, 0.9);
    border: 1px solid #39DC1E;
    border-radius: 10px;
    padding: 15px;
    margin-top: 15px;
    color: #39DC1E;
}

.probability-display.visible {
    display: block;
}

.probability-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px dotted rgba(57, 220, 30, 0.3);
}

.probability-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.probability-action {
    font-weight: bold;
}

.probability-value {
    font-family: monospace;
}

.probability-high {
    color: #00ff00;
}

.probability-medium {
    color: #ffff00;
}

.probability-low {
    color: #ff3333;
}

.bet-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

.bet-controls label {
    margin-right: 10px;
    font-size: 18px;
}

#bet-input {
    width: 100px;
    padding: 8px;
    border-radius: 5px;
    border: 2px solid #39DC1E;
    background-color: #0a0a0a;
    color: white;
    font-size: 16px;
    margin-right: 10px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 5px;
    background-color: #39DC1E;
    color: #0a0a0a;
    border: 1px solid #39DC1E;
}

#deal-button {
    background-color: #39DC1E;
}

#hit-button {
    background-color: #39DC1E;
}

#stand-button {
    background-color: #39DC1E;
}

#double-button {
    background-color: #39DC1E;
}

.btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 10px rgba(57, 220, 30, 0.5);
    background-color: #0a0a0a;
    color: #39DC1E;
}

.btn:active {
    transform: scale(0.98);
}

.btn:disabled {
    background-color: #333;
    cursor: not-allowed;
    transform: scale(1);
    box-shadow: none;
    color: #777;
    border-color: #555;
}

.actions {
    display: none;
    text-align: center;
    margin: 15px 0;
}

.message {
    text-align: center;
    font-size: 22px;
    font-weight: bold;
    color: #39DC1E;
    min-height: 30px;
    margin-top: 10px;
}

/* Animations */
@keyframes dealCard {
    0% {
        transform: translateY(-100px) scale(0.5);
        opacity: 0;
    }
    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

@keyframes flip {
    0% {
        transform: rotateY(0deg);
    }
    100% {
        transform: rotateY(180deg);
    }
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

.deal-animation {
    animation: dealCard 0.5s ease-out forwards;
}

.flip-animation {
    animation: flip 0.5s ease-in-out forwards;
}

.pulse-animation {
    animation: pulse 2s infinite;
}

/* Responsive adjustments */
@media (max-width: 1200px) {
    .game-container {
        max-width: 100%;
        padding: 10px;
    }
    
    .leaderboard-container {
        top: 150px;
    }
    
    .metrics-container {
        top: 380px;
    }
}

/* For screens between 1000px and 1200px */
@media (max-width: 1100px) and (min-width: 1001px) {
    .table, .controls {
        max-width: 700px;
    }
    
    .main-content {
        max-width: 750px;
    }
}

@media (max-width: 1000px) {
    .timer-container {
        position: static;
        margin: 0 auto 15px;
    }
    
    .leaderboard-container,
    .metrics-container {
        position: static;
        width: 90%;
        max-width: 425px;
        margin: 15px auto;
    }
    
    .table, .controls {
        max-width: 90%;
    }
    
    .main-content {
        padding-right: 0; /* Remove padding on smaller screens */
    }
    
    header {
        max-width: 90%;
    }
    
    .logo-container {
        padding-right: 0; /* Remove padding on smaller screens */
    }
}

@media (max-width: 768px) {
    .game-container {
        padding: 10px 0;
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .main-content {
        width: 100%;
        padding: 0;
        margin: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .table {
        width: calc(100% - 20px); /* Full width minus small padding */
        min-height: 400px;
        padding: 20px 10px;
        margin: 10px;
        border-radius: 30px;
        box-sizing: border-box;
    }

    .controls {
        width: calc(100% - 20px); /* Match table width */
        padding: 15px;
        margin: 10px;
        border-radius: 15px;
        box-sizing: border-box;
    }

    .leaderboard-container,
    .metrics-container {
        width: calc(100% - 20px);
        margin: 10px;
    }

    .logo-container {
        width: 100%;
        text-align: center;
        padding: 0 10px;
        margin-bottom: 20px;
    }

    .logo-container h1 {
        font-size: 36px;
        margin-bottom: 5px;
        text-align: center;
    }

    .logo-container h2 {
        font-size: 16px;
        text-align: center;
    }

    .balance-container {
        flex-direction: column;
        align-items: center;
        text-align: center;
        width: 100%;
    }

    .balance {
        font-size: 24px; /* Make balance text larger */
        margin-bottom: 15px;
    }

    .bet-controls {
        margin-top: 10px;
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }

    .bet-controls label {
        font-size: 20px; /* Make label text larger */
        margin-bottom: 10px;
    }

    #bet-input {
        width: 90%;
        max-width: none;
        margin: 0 auto;
        text-align: center;
        font-size: 20px; /* Make input text larger */
        padding: 12px;
        height: 50px;
    }

    #deal-button {
        width: 90%;
        max-width: none;
        margin: 10px auto 0;
        height: 50px;
        font-size: 20px;
    }

    /* Adjust card sizes for better mobile display */
    .card {
        width: 70px;
        height: 105px;
    }

    .hand {
        margin: 10px 0;
    }

    .hand h2 {
        font-size: 24px;
        margin: 15px 0;
    }

    .cards {
        min-height: 120px;
        justify-content: center;
        gap: 5px;
    }

    .hand-value {
        font-size: 20px;
        padding: 8px 20px;
    }

    /* New mobile-specific layout */
    .leaderboard-container,
    .metrics-container {
        order: 3;
        width: 100%;
        max-width: none;
        margin: 20px 0;
    }

    .main-content {
        order: 1;
        width: 100%;
        padding: 0;
    }

    .controls {
        order: 2;
    }

    /* Center the timer */
    .timer-container {
        width: 100%;
        text-align: center;
        margin-bottom: 20px;
    }
}

/* Add specific styles for very small screens */
@media (max-width: 360px) {
    .logo-container h1 {
        font-size: 32px;
    }

    .logo-container h2 {
        font-size: 14px;
    }

    .card {
        width: 60px;
        height: 90px;
    }
}

/* Main content area */
.main-content {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding-right: 270px; /* Add space for the sidebar elements */
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.score-entry {
    display: flex;
    justify-content: space-between;
    padding: 8px 5px;
    border-bottom: 1px dotted rgba(57, 220, 30, 0.3);
}

.score-entry:last-child {
    border-bottom: none;
}

.score-rank {
    color: #39DC1E;
    font-weight: bold;
    width: 25px;
}

.score-initials {
    font-weight: bold;
    color: white;
    flex: 1;
    text-align: center;
}

.score-value {
    color: #39DC1E;
    font-family: monospace;
    text-align: right;
}

.no-scores {
    color: #888;
    font-style: italic;
    text-align: center;
    padding: 20px 0;
}

.today-date {
    font-size: 12px;
    color: #cccccc;
    text-align: center;
    margin-bottom: 10px;
}

/* Modal for score submission */
.modal {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: #0a0a0a;
    border-radius: 15px;
    border: 2px solid #39DC1E;
    padding: 25px;
    width: 90%;
    max-width: 500px;
    animation: modal-appear 0.3s ease-out;
}

@keyframes modal-appear {
    from { 
        opacity: 0;
        transform: translateY(-50px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-content h3 {
    color: #39DC1E;
    text-align: center;
    margin-bottom: 15px;
    font-size: 24px;
}

.modal-content p {
    text-align: center;
    margin-bottom: 20px;
    font-size: 18px;
}

.high-score-message {
    background-color: rgba(57, 220, 30, 0.1);
    border: 1px solid #39DC1E;
    color: #39DC1E;
    padding: 10px;
    text-align: center;
    border-radius: 5px;
    margin-bottom: 20px;
    display: none;
}

.high-score-message.visible {
    display: block;
}

.initials-input {
    margin-bottom: 20px;
}

.initials-input label {
    display: block;
    margin-bottom: 8px;
}

.initials-input input {
    width: 100px;
    padding: 8px;
    border-radius: 5px;
    border: 2px solid #39DC1E;
    background-color: #0a0a0a;
    color: white;
    font-size: 18px;
    margin-right: 10px;
    text-align: center;
    text-transform: uppercase;
}

.initials-input button {
    margin-top: 10px;
}

#play-again {
    display: block;
    margin: 0 auto;
}

/* === FLEX LAYOUT FOR MAIN CONTAINERS === */
.main-flex-layout {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: flex-start;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    gap: 20px;
}

.metrics-container {
    position: static;
    width: 250px;
    min-width: 220px;
    max-width: 250px;
    margin: 0;
    z-index: 10;
}

.leaderboard-container {
    position: static;
    width: 250px;
    min-width: 220px;
    max-width: 250px;
    margin: 0;
    z-index: 10;
}

.main-content {
    flex: 1 1 0;
    max-width: 800px;
    min-width: 320px;
    width: 100%;
    margin: 0 10px;
    padding: 0;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Remove old absolute positioning for metrics/leaderboard on desktop */
@media (min-width: 769px) {
    .main-flex-layout {
        align-items: flex-start;
        margin-top: 60px;
    }
    .metrics-container,
    .leaderboard-container {
        margin-top: 110px !important;
        padding-top: 0 !important;
    }
}

/* === MOBILE STACKED LAYOUT === */
@media (max-width: 768px) {
    .main-flex-layout {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        width: 100%;
        max-width: 100%;
    }
    .metrics-container,
    .leaderboard-container,
    .main-content {
        width: 100%;
        max-width: none;
        min-width: 0;
        margin: 0;
        padding: 0;
        box-sizing: border-box;
    }
    .main-content {
        order: 2;
    }
    .controls {
        order: 3;
    }
    .metrics-container {
        order: 4;
        margin: 0 0 20px 0;
        padding: 0 0 20px 0;
    }
    .leaderboard-container {
        order: 5;
        margin: 0 0 20px 0;
        padding: 0 0 20px 0;
    }
    .logo-link {
        position: static;
        margin: 20px auto 0 auto;
        display: flex;
        justify-content: center;
        width: 100%;
        order: 0;
    }
    .timer-container {
        position: static;
        margin: 10px auto 0 auto;
        width: 100%;
        text-align: center;
        order: 1;
    }
}
