:root {
    --bg-gradient-start: #88b63f;
    --bg-gradient-end: #3d6e14;
    --primary-color: #fdd835;
    /* Gold/Yellow */
    --primary-hover: #fbc02d;
    --text-light: #ffffff;
    --text-dark: #333333;
    --white-bg: rgba(255, 255, 255, 1);
    --glass-bg: rgba(255, 255, 255, 0.15);
    --glass-border: rgba(255, 255, 255, 0.3);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --card-bg: #fff;
    --card-completed: rgba(255, 255, 255, 0.4);
    --red-suit: #d32f2f;
    --black-suit: #212121;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: radial-gradient(circle, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    color: var(--text-light);
    height: 100dvh;
    overflow-x: hidden;
}

body.home-body {
    background: linear-gradient(-45deg, #3d6e14, #88b63f, #3d6e14, #88b63f);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
}

@keyframes gradientBG {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

.hidden {
    display: none !important;
}

/* Glassmorphism utility */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: var(--glass-shadow);
}

.white-bg {
    background: var(--white-bg);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    box-shadow: var(--glass-shadow);
}

/* --- Buttons --- */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 24px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    text-transform: uppercase;
}

.btn:hover {
    transform: scale(1.05);
}

.btn.primary {
    background-color: var(--primary-color);
    color: var(--text-dark);
    box-shadow: 0 4px 15px rgba(253, 216, 53, 0.4);
}

.btn.primary:hover {
    background-color: var(--primary-hover);
}

.btn.secondary {
    background-color: var(--glass-bg);
    color: var(--text-light);
    border: 1px solid var(--glass-border);
}

.btn.secondary:hover {
    background-color: rgba(255, 255, 255, 0.25);
}

.btn.text {
    background: transparent;
    color: var(--text-light);
    text-decoration: underline;
}

.btn.big-yellow {
    width: 90%;
    margin: 10px auto;
    padding: 15px;
    font-size: 1.5rem;
    background-color: var(--primary-color);
    color: var(--text-dark);
    border-radius: 30px;
}

.btn.big-yellow:disabled {
    background-color: #888;
    color: #444;
    cursor: not-allowed;
    transform: none;
}

/* --- Home --- */
.home-container {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    height: 100vh;
    padding: 0 5%;
    max-width: 1200px;
    margin: 0 auto;
    gap: 50px;
}

.home-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
}

.home-right {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hero-image-logo {
    max-width: 100%;
    height: auto;
    filter: drop-shadow(0 20px 30px rgba(0, 0, 0, 0.5));
    animation: floatLogo 4s ease-in-out infinite;
}

@keyframes floatLogo {
    0% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-15px);
    }

    100% {
        transform: translateY(0px);
    }
}

@media (max-width: 768px) {
    .home-container {
        flex-direction: column;
        text-align: center;
        padding: 20px;
        justify-content: center;
    }

    .home-left {
        align-items: center;
        order: 2;
        /* Controls below logo on mobile */
    }

    .home-right {
        order: 1;
        /* Logo at top on mobile */
        width: 100%;
        max-width: 350px;
    }
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 250px;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 3rem 2.5rem;
    width: 90%;
    max-width: 420px;
    text-align: center;
    background: rgba(46, 102, 13, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

@keyframes modalPop {
    0% {
        transform: scale(0.8) translateY(20px);
        opacity: 0;
    }

    100% {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.input-group {
    position: relative;
    margin-bottom: 20px;
    text-align: left;
}

.modern-input {
    width: 100%;
    padding: 16px 20px;
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, 0.15);
    background: rgba(0, 0, 0, 0.25);
    color: #fff;
    font-size: 1.1rem;
    transition: all 0.3s ease;
}

.modern-input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.modern-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(0, 0, 0, 0.4);
    box-shadow: 0 0 0 4px rgba(253, 216, 53, 0.2);
}

select.modern-input {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23ffffff%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 1.2rem top 50%;
    background-size: 0.8rem auto;
    cursor: pointer;
}

select.modern-input option {
    background: #0d660d;
    color: white;
}

.modal-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 30px;
    gap: 15px;
}

.modal-actions .btn {
    flex: 1;
    padding: 14px;
    font-size: 1.1rem;
}

/* --- Playing Cards --- */
.card-single {
    position: relative;
    perspective: 1000px;
    aspect-ratio: 2 / 3;
    user-select: none;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s ease-in-out;
    transform-style: preserve-3d;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    border-radius: 6px;
}

.card-single.completed .card-inner {
    transform: rotateY(180deg);
}

.card-front,
.card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 6px;
    border: 1px solid #ddd;
    overflow: hidden;
}

.card-front {
    background-color: var(--card-bg);
}

.card-back {
    background: repeating-linear-gradient(-45deg, var(--bg-gradient-end), var(--bg-gradient-end) 10px, var(--bg-gradient-start) 10px, var(--bg-gradient-start) 20px);
    transform: rotateY(180deg);
}

.card-single.suit-red .card-front {
    color: var(--red-suit);
}

.card-single.suit-black .card-front {
    color: var(--black-suit);
}

.card-corner {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-weight: bold;
    font-size: 0.85rem;
    line-height: 1;
}

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

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

.card-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.my-cards-grid .card-center {
    font-size: 1.5rem;
}

/* --- Board View --- */
.board-body {
    overflow: hidden;
    padding: 10px;
}

.room-id-tag {
    color: var(--black-suit);
}

.board-grid {
    display: grid;
    grid-template-columns: 1fr minmax(280px, auto) 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 45px;
    height: 100vh;
    padding: 20px;
}

#board-player-0 {
    grid-column: 1;
    grid-row: 1;
    align-self: center;
}

#board-player-1 {
    grid-column: 3;
    grid-row: 1;
    align-self: center;
}

#board-player-2 {
    grid-column: 1;
    grid-row: 2;
    align-self: center;
}

#board-player-3 {
    grid-column: 3;
    grid-row: 2;
    align-self: center;
}

.player-zone {
    background: var(--glass-bg);
    border-radius: 12px;
    padding: 5px;
    display: flex;
    flex-direction: column;
}

.zone-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
    background: rgba(0, 0, 0, 0.2);
    padding: 5px 10px;
    border-radius: 8px;
    width: 100%;
}

.player-name {
    font-weight: bold;
    font-size: 1.2rem;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(2, minmax(0, 16vh));
    gap: 10px 0px;
    flex: 1;
    width: 100%;
    padding: 10px;
}

.board-grid .card-single {
    height: 100%;
    width: auto;
    max-height: 14vh;
    max-width: 100%;
    margin: auto;
}

.board-grid .card-center {
    font-size: 1.8rem;
}

.board-grid .card-corner {
    font-size: 0.80rem;
}

/* Center Pot Area */
.center-pot {
    grid-column: 2;
    grid-row: 1 / 3;
    align-self: center;
    justify-self: center;
    width: 100%;
    max-width: 340px;
    padding: 20px;
    text-align: center;
    z-index: 5;
}

.pot-coins {
    margin-bottom: 15px;
}

#potAmount {
    color: var(--black-suit);
    font-size: 1.2rem;
}

.dice-display,
.dice-animation-area {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 15px 0;
}

.dice {
    font-size: 3rem;
    background: linear-gradient(145deg, #e53935, #c62828);
    border-radius: 10px;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    line-height: 1;
    padding-bottom: 8px; /* Offset unicode baseline */
    box-shadow:
        inset -3px -3px 6px rgba(0, 0, 0, 0.4),
        inset 3px 3px 6px rgba(255, 255, 255, 0.3),
        0 6px 12px rgba(0, 0, 0, 0.4);
    border: 1px solid #b71c1c;
    transform-style: preserve-3d;
}

@keyframes rollTumble {
    0% {
        transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg) scale(1);
    }

    50% {
        transform: rotateX(180deg) rotateY(180deg) rotateZ(180deg) scale(1.1);
    }

    100% {
        transform: rotateX(360deg) rotateY(360deg) rotateZ(360deg) scale(1);
    }
}

.dice.rolling {
    animation: rollTumble 0.4s infinite linear;
}

.turn-status {
    font-weight: bold;
    margin-bottom: 5px;
    color: var(--black-suit);
}

.roll-message {
    font-size: 0.9rem;
    color: var(--black-suit);
}

/* --- Player View --- */
.player-body {
    display: flex;
    flex-direction: column;
    height: 100dvh;
}

.player-header {
    background: var(--glass-bg);
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.player-name-text {
    color: var(--primary-color);
}

.turn-display {
    text-align: right;
    font-size: 0.9rem;
}

.player-main {
    flex: 1;
    padding: 15px;
    padding-bottom: 130px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow-y: auto;
}

.my-cards-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-gap: 8px;
}

.pot-status-banner {
    padding: 15px;
    text-align: center;
    border-radius: 30px;
}

.my-coins-banner {
    text-align: center;
}

#myCoinsAmount {
    color: var(--primary-color);
    margin-top: 5px;
}

.player-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 10px 10px 20px 10px;
    text-align: center;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    z-index: 100;
}

.my-roll-message {
    margin-bottom: 5px;
    font-size: 0.9rem;
    min-height: 20px;
}