/* --- Base Styles --- */
:root {
    --button-border-radius: 0.5rem;
    --card-border-radius: 0.5rem;
    --color-dark-gray: #222222;
    --color-medium-gray: #333333;
    --color-light-gray: #AAAAAA;
    --color-very-light-gray: #DDDDDD;
    --color-white: #FFFFFF;
    --color-black: #111111;
    --selection-gradient: linear-gradient(90deg, #2dd4bf, #8b5cf6);
    --selection-color-1: #2dd4bf;
    --selection-color-2: #ef4444;
    --selection-blue: #3B82F6;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Nova Oval', sans-serif;
    overflow: hidden;
    background-color: var(--color-dark-gray);
    color: var(--color-very-light-gray);
}

.hidden {
    display: none !important;
}

/* --- Main Menu & Modal Styles --- */
.main-menu-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    text-align: center;
}

.main-logo {
    width: 150px;
    height: 150px;
    margin-bottom: 1rem;
}

.main-menu-container h1 {
    font-size: 4.5rem;
    font-weight: bold;
    margin-bottom: 1rem;
}

.main-menu-container p {
    font-size: 1.25rem;
    color: var(--color-light-gray);
    margin-bottom: 3rem;
}

.menu-buttons {
    display: flex;
    gap: 1rem;
}

.modal {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    overflow-y: auto; /* Allow scrolling for tall modals like rules */
}

.modal-content {
    background-color: var(--color-medium-gray);
    padding: 2rem;
    border-radius: 0.75rem;
    box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
    text-align: center;
    width: 90%;
    max-width: 800px; /* UPDATED */
    margin-top: 2rem;
}

.modal-content h1, .modal-content h2 {
    font-size: 1.8rem;
    font-weight: bold;
    margin-bottom: 1rem;
}

.modal-content h4 {
    font-size: 1.25rem;
    text-decoration: underline;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.modal-content ul, .modal-content ol {
    padding-left: 25px;
}

.modal-content p {
    color: var(--color-light-gray);
    margin-bottom: 1rem;
}

.options-grid {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    text-align: left;
    margin-bottom: 2.5rem;
}

.option-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.option-group h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--color-very-light-gray);
    margin-bottom: 0.25rem;
}

.option-group .btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.option-group .btn-group button {
    flex-grow: 1;
}

.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
}


/* --- Button Styles --- */
button {
    position: relative;
    z-index: 1;
    padding: 0.75rem 1.5rem;
    border-radius: var(--button-border-radius);
    color: var(--color-white);
    font-weight: bold;
    border: none;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    text-align: center;
    font-family: 'Nova Oval', sans-serif;
    background: transparent;
}

button::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: inherit;
    background-color: #555555;
    transition: background-color 0.3s ease;
}

button::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    z-index: -2;
    border-radius: var(--button-border-radius);
    background: var(--selection-gradient);
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

button:not(:disabled):hover::before {
    opacity: 1;
}

.btn-red::after {
    background-color: #444444;
}

button.selected::after {
    background-color: var(--selection-blue);
}

button.selected::before {
    opacity: 1;
}

button:disabled {
    cursor: not-allowed;
    color: var(--color-light-gray);
}

button:disabled::after {
    background-color: #444444;
    opacity: 0.7;
}

button:disabled::before {
    opacity: 0;
}

/* --- Game-Specific CSS --- */
.card {
    position: relative;
    width: 100%;
    height: 100%;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: var(--card-border-radius);
    background-color: transparent;
}

.card::before {
    content: '';
    position: absolute;
    inset: -2px;
    z-index: 0;
    background: var(--selection-gradient);
    border-radius: inherit;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.card::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
    border-radius: inherit;
    pointer-events: none;
}

.card-value,
.card-suit {
    position: relative;
    z-index: 2;
    font-weight: 500;
    line-height: 1;
}

.card.selected::before,
.card-wrapper-hand:hover .card::before {
    opacity: 1;
}

.player-card::after {
    background-color: #CCCCCC;
}

.player-card .suit-red, .player-card .suit-black {
    color: var(--color-black);
}

.opponent-card {
    cursor: default;
}

.opponent-card::after {
    background-color: #444444;
}

.opponent-card .opponent-black, .opponent-card .opponent-red {
    color: var(--color-very-light-gray);
}

.card-back {
    border: 2px solid #4a4a4a;
}

.card-back::after {
    background-color: #1a1a1a;
}

.card-value {
    font-size: 1.25rem;
}

.card-suit {
    font-size: 1rem;
}

.card-wrapper-board {
    width: 90%;
    aspect-ratio: 1 / 1;
}

.card-wrapper-hand {
    width: 64px;
    aspect-ratio: 1 / 1;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.card-wrapper-hand:hover {
    transform: translateY(-12px);
    z-index: 10;
}

.card-wrapper-modal {
    width: 80px;
    flex-shrink: 0;
    aspect-ratio: 1 / 1;
}

#king-selection, #vanguard-selection, #discard-selection, #king-selection-deck {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}

.board-tile {
    transition: box-shadow 0.2s ease;
    aspect-ratio: 1/1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.board-tile.valid-move {
    box-shadow: inset 0px 0px 12px 2px var(--selection-color-1);
    cursor: pointer;
}

.board-tile.valid-capture {
    box-shadow: inset 0px 0px 12px 2px var(--selection-color-2);
    cursor: pointer;
}

#game-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    height: 100vh;
    width: 100vw;
    background: var(--color-dark-gray);
    padding: 1rem;
}

#opponent-area,
#player-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    width: 100%;
    margin: 0 auto;
    flex-shrink: 0;
}

#player-area {
}

#opponent-area {
    flex-direction: row;
    flex-wrap: wrap;
    padding: 1rem;
    min-height: 100px;
    border: 2px dashed var(--color-medium-gray);
    border-radius: 0.5rem;
    background-color: rgba(0,0,0,0.1);
}


#center-field {
    display: flex;
    gap: 2rem;
    padding: 1rem;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    width: 100%;
    flex-grow: 1;
    min-height: 0;
}

#game-board {
    display: grid;
    justify-content: center;
    align-items: center;
    aspect-ratio: 1 / 1;
    max-height: 100%;
    max-width: 100%;
    height: 100%;
}

#player-hand {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    min-height: 100px;
    padding: 0.5rem;
    border: 2px dashed var(--color-medium-gray);
    border-radius: 0.5rem;
    background-color: rgba(0,0,0,0.1);
    width: 100%;
}


.side-piles {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 2rem;
}

.pile-container {
    width: 80px;
    height: 112px;
    background-color: rgba(0, 0, 0, 0.2);
    border: 2px dashed #555555;
    border-radius: 0.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
}

.pile-label {
    font-weight: bold;
    color: var(--color-light-gray);
    font-size: 0.8rem;
}

.pile-count {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--color-white);
}

.coin-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

#coin {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background-color: #FFD700; /* Gold */
    color: var(--color-black); /* Black text for contrast */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: bold;
    transform-style: preserve-3d;
    transition: transform 1s;
    cursor: pointer;
}

#coin.animate {
    transform: rotateY(1800deg);
}

.tile-light {
    background-color: #AAAAAA;
}

.tile-dark {
    background-color: #666666;
}

#vanguard-selection {
    border: 1px solid #555555;
    padding: 1rem;
    border-radius: 0.5rem;
}

#game-log-container {
    width: 100%;
    text-align: center;
}

#turn-counter {
    font-weight: bold;
    font-size: 1.125rem;
}

#action-log {
    list-style: none;
    padding-left: 10px;
    border: 1px solid #555555;
    font-family: 'Courier New', Courier, monospace;
    text-align: center;
    height: 5rem;
    overflow-y: auto;
    background: rgba(0,0,0,0.2);
    border-radius: 0.5rem;
    padding: 0.5rem;
    font-size: 0.875rem;
}

#action-log li {
    padding: 2px 0;
    border-bottom: 1px dashed #555555;
}

#action-log li:last-child {
    border-bottom: none;
}

#player-actions-and-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
}

#info-text {
    font-size: 1.125rem;
    color: var(--color-very-light-gray);
    font-weight: 500;
    text-align: center;
    min-height: 1.5rem;
}

.player-buttons {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#rules-open-btn {
    padding: 0.75rem;
    border-radius: var(--button-border-radius);
}