body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    padding: 20px;
    margin: 0;
    /* Dark Blue Gradient Background */
    background: radial-gradient(circle at center top, #1b2e4b 0%, #0d121f 100%);
    color: #ecf0f1;

    /* Full screen layout for vertical centering */
    min-height: 100vh;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* === TOP AREA (Clock + Rules) === */
#top-area {
    width: 100%;
    max-width: 900px;
    /* Flex grow pushes bottom area down, centering the content */
    flex-grow: 1;
    display: flex;
    flex-direction: column;

    /* Subtle divider line */
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 20px;
    margin-bottom: 0;
}

/* Rules & Dropdown */
#rules-area {
    margin-bottom: 10px;
    text-align: center;
    z-index: 10;
}

#clock-select-container {
    margin-bottom: 15px;
    font-size: 18px;
    font-weight: bold;
    color: #aab7c4;
}

#clock-select {
    margin-top: 30px;
    margin-left: 8px;
    padding: 8px 12px;
    font-size: 16px;
    border-radius: 5px;
    border: 1px solid #445;
    background-color: #162035;
    color: white;
}

/* === CLOCK & GAME BOARD === */
#game-board {
    position: relative;
    width: 940px;
    height: 880px;
    margin: auto;
    border-radius: 50%;
    background-color: transparent;
}

/* 1. The Clock Image */
#clock-image {
    width: 600px;
    height: 600px;
    object-fit: contain;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
    pointer-events: none;
    border-radius: 50%;
    filter: drop-shadow(0 0 40px rgba(0, 0, 0, 0.5));
}

/* 2. The Interactive Overlay */
#clock-overlay {
    position: absolute;
    width: 600px;
    height: 600px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
}

.segment-path {
    fill: transparent;
    stroke: none;
    cursor: pointer;
    transition: fill 0.2s ease;
}

.segment-path:hover {
    fill: rgba(255, 255, 255, 0.15);
}

/* 3. The UI Layer */
#clock-ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    pointer-events: none;
}

/* Container for a specific wedge's UI elements */
.wedge-container {
    position: absolute;
    width: 100px;
    height: auto;
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    pointer-events: none;
    z-index: 10;
}

/* Info Bubble (Sum) */
.wedge-info {
    order: 100;
    position: relative;
    margin-bottom: 15px;
    text-align: center;
    font-size: 14px;
    font-weight: bold;
    color: #fff;
    text-shadow: 1px 1px 2px black;
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 4px 8px;
    border-radius: 12px;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Status Icon (Check/Cross) */
.wedge-status {
    order: -1;
    position: relative;
    margin-bottom: 20px;
    font-size: 32px;
    font-weight: bold;
    text-shadow: 0px 0px 5px rgba(0, 0, 0, 0.8);
}

/* === CARD STYLING === */

.card,
.hand-card,
.segment-card {
    width: 72px;
    height: 96px;
    border-radius: 6px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 32px;
    font-weight: bold;
    border: 2px solid #111;
    box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.6);
    background-color: white;
    user-select: none;
}

/* Cards on Board (Stacking Logic) */
.wedge-container .segment-card {
    width: 82px;
    height: 110px;
    font-size: 34px;
    border-color: #222;
    margin-bottom: -45px;
    margin-top: 0;
    box-shadow: 0 -3px 6px rgba(0, 0, 0, 0.4);
    position: relative;
}

.wedge-container .segment-card:first-child {
    margin-bottom: 0;
}

/* Day/Night Colors */
.day-card {
    background: #fdfdfd;
    color: #000;
    border: 2px solid #222;
}

.night-card {
    background: #0d2249;
    color: #aaddff;
    border: 2px solid #6688aa;
}

/* === FACE DOWN IMAGES === */

.face-down {
    color: transparent !important;
    background-color: transparent !important;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    border: none !important;
    box-shadow: none !important;
    filter: drop-shadow(3px 3px 5px rgba(0, 0, 0, 0.5));
}

.day-card.face-down {
    background-image: url('assets/day_back.png');
}

.night-card.face-down {
    background-image: url('assets/night_back.png');
}

/* Forces the PNG to show, overriding any white background or text */
.card-image-active {
    background-size: contain !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
    background-color: transparent !important;
    color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.5));
}

.wedge-container .segment-card.card-image-active {
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    background-size: contain !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
    color: transparent !important;
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.5));
    z-index: 10;
}

/* === BOTTOM AREA (Player & AI) === */
#bottom-area {
    width: 100%;
    max-width: 900px;
    flex-shrink: 0;
    margin-top: 0;
    padding-top: 10px;
    text-align: center;
}

#player-hand-container h3 {
    margin-top: 0;
    color: #aab7c4;
    font-size: 16px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#player-hand {
    display: flex;
    gap: 15px;
    height: 130px;
    align-items: center;
    justify-content: center;
}

.hand-card {
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, outline 0.1s;
}

.hand-card:hover {
    transform: translateY(-10px);
}

.hand-card.selected {
    outline: 4px solid #00d2ff;
    box-shadow: 0 0 20px rgba(0, 210, 255, 0.6);
    transform: translateY(-15px);
    border-color: #fff;
}

.empty-slot {
    visibility: hidden;
    width: 72px;
}

/* Face Up/Down Toggle */
#face-choice {
    margin-top: 15px;
    font-size: 18px;
    background: rgba(255, 255, 255, 0.05);
    padding: 10px 30px;
    display: inline-flex;
    justify-content: center;
    gap: 30px;
    border-radius: 50px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#face-choice label {
    cursor: pointer;
    color: #ddd;
    display: flex;
    align-items: center;
    gap: 8px;
}

#face-choice input {
    transform: scale(1.3);
    accent-color: #00d2ff;
}

/* === OPPONENT HANDS === */

#opponents-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 20;
}

.opponent-hand {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    pointer-events: auto;
}

#opponent-left {
    left: 20px;
}

#opponent-right {
    right: 20px;
}

.player-label {
    color: #aab7c4;
    font-weight: bold;
    text-transform: uppercase;
    font-size: 14px;
    margin-bottom: 5px;
    text-shadow: 1px 1px 2px black;
}

.opponent-hand .cards-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: -40px;
}

.opponent-card {
    width: 100px;
    height: 140px;
    border-radius: 5px;
    border: 2px solid #d2b48c;
    /* Tan/Sepia-ish */
    background-color: #2c3e50;
    background-image: url('assets/day_back.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.6);
    margin-bottom: -50px;
    transition: transform 0.2s;
}

.opponent-card.night-bg {
    background-image: url('assets/night_back.png');
}

.opponent-card:last-child {
    margin-bottom: 0;
}

.opponent-hand:hover .opponent-card {
    margin-bottom: -20px;
}

/* === SHARED MODAL STYLES (Game Over & Bidding) === */

/* 1. The Backdrop (Full Screen Overlay) */
.modal-overlay {
    display: none;
    /* Hidden by default, toggled to 'flex' by JS */
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 2000 !important;

    /* Centering */
    align-items: center;
    justify-content: center;

    /* REVERTED: Transparent Background, No Blur */
    background-color: rgba(0, 0, 0, 0.2) !important;
    backdrop-filter: none !important;
}

/* 2. The Content Box */
.modal-content {
    min-width: 350px;
    max-width: 550px;

    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 30px;
    text-align: center;

    background-color: rgba(140, 140, 140, 0.55) !important;

    /* SEPIA BORDER */
    border: 4px solid #120044 !important;
    border-radius: 16px;

    /* Shadow to lift it off the page */
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);

    /* Ensure text color is dark enough to read on light grey */
    color: #0c0c0c;
}

/* 3. Typography */
.modal-content h2 {
    margin: 0;
    font-size: 2.2em;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #14004b;
    /* Sepia Title Base */
    text-shadow: 1px 1px 0px rgba(255, 255, 255, 0.5);
}

.modal-content p {
    font-size: 1.1em;
    color: #222;
    /* Darkened for readability on transparent bg */
    margin: 0;
    font-weight: 500;
}

/* 4. Inputs & Dropdowns */
.restart-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    text-align: left;
}

.restart-options label {
    font-weight: bold;
    color: #111;
    font-size: 0.9em;
}

#restart-clock-select {
    padding: 10px;
    font-size: 1em;
    border: 2px solid #ccc;
    border-radius: 6px;
    background-color: #fff;
    cursor: pointer;
    width: 100%;
}

/* 5. General Buttons (Restart & Bidding) */
button {
    font-family: inherit;
    transition: all 0.2s;
}

.restart-btn {
    background-color: #4CAF50;
    color: white;
    font-size: 1.2em;
    font-weight: bold;
    padding: 12px 40px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    margin-top: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

.restart-btn:hover {
    background-color: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.25);
}

/* 6. Bidding Specific Buttons */
.bid-btn {
    padding: 12px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.bid-btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

.bid-btn.low {
    background-color: #594e94;
}

/* Blue Grey */
.bid-btn.mid {
    background-color: #50289b;
}

/* Brown/Sepia Tone */
.bid-btn.high {
    background-color: #190394;
}

/* Gold */

/* === FACE UP TRACKER === */
#faceup-tracker {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 100;
    background: rgba(0, 0, 0, 0.6);
    padding: 10px 15px;
    border-radius: 12px;
    border: 2px solid #704214;
    /* Sepia border */
    display: flex;
    flex-direction: column;
    gap: 5px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

.tracker-label {
    font-size: 12px;
    text-transform: uppercase;
    color: #aab7c4;
    font-weight: bold;
    letter-spacing: 1px;
}

#tokens-container {
    display: flex;
    gap: 8px;
}

.token-wrapper {
    position: relative;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.token-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: opacity 0.3s;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.5));
}

.token-wrapper.used img {
    opacity: 0.5;
    filter: grayscale(100%);
}

.token-wrapper.used::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        linear-gradient(to top right, transparent calc(50% - 2px), #ff3333, transparent calc(50% + 2px)),
        linear-gradient(to bottom right, transparent calc(50% - 2px), #ff3333, transparent calc(50% + 2px));
    pointer-events: none;
}

.flying-card {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    transition: all 0.6s cubic-bezier(0.25, 1, 0.5, 1);
    transform-origin: center center;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
}