*,
::after,
::before {
    box-sizing: border-box;
}

user agent stylesheet header {
    display: block;
    unicode-bidi: isolate;
}

.game-title {
    margin: 0;
    padding: 8px 15px;
    color: white;
    font-weight: 500;
    font-size: 1.2rem;
    text-transform: capitalize;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
}

button {
    margin: 5px;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    background-color: #ffffff;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

button:hover {
    background-color: #e0e0e0;
}

.three-d-button-settings {
    background-color: #1E7A57;
    color: white;
    font-weight: bold;
    text-shadow: 1px 1px 0 rgba(70, 70, 70, .9);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    box-shadow: 0px 3px 0px #135119, 0px 6px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    padding: 8px;
    text-align: center;
    font-size: 15px;
    width: auto;
    /* Allow auto-width */
    min-width: 70px;
    /* Minimum width */
    text-decoration: none;
}

.three-d-button-settings:hover {
    background-color: #186344;
    box-shadow: 0px 3px 0px #0F3F11, 0px 6px 15px rgba(0, 0, 0, 0.2);
}

.three-d-button-small {
    padding: 2px 8px;
    font-size: 0.9em;
    margin-left: 5px;
    background-color: #4CAF50;
    border: none;
    width: 30px;
    color: white;
    cursor: pointer;
    border-radius: 3px;
}

.three-d-button-small:hover {
    background-color: #45a049;
}

.three-d-button {
    background-color: #259634;
    color: white;
    font-weight: bold;
    text-shadow: 1px 1px 0 rgba(70, 70, 70, .9);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    box-shadow: 0px 3px 0px #135119, 0px 6px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    padding: 8px;
    text-align: center;
    font-size: 15px;
    width: auto;
    /* Allow auto-width */
    min-width: 70px;
    /* Minimum width */
    text-decoration: none;
}

.three-d-button:hover {
    background-color: #1B7222;
    box-shadow: 0px 3px 0px #0F3F11, 0px 6px 15px rgba(0, 0, 0, 0.2);
}

.three-d-button.disabled {
    background-color: #165B18;
    color: white;
    text-shadow: none;
    /* Remove the shadow for a flat look */
    cursor: pointer;
    /* Change the cursor to indicate it's disabled */
    text-decoration: none;
    /* Ensure no underline for links */
    box-shadow: 0px 1px 0px #0F3F11, 0px 6px 15px rgba(0, 0, 0, 0.1);
}


.three-d-button-hint {
    background-color: #0082D8;
    color: white;
    font-weight: bold;
    text-shadow: 1px 1px 0 rgba(70, 70, 70, .9);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    box-shadow: 0px 3px 0px #004570, 0px 6px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    padding: 8px;
    text-align: center;
    font-size: 15px;
    width: auto;
    /* Allow auto-width */
    min-width: 60px;
    /* Minimum width */
    text-decoration: none;
}

.three-d-button-hint:hover {
    background-color: #0069AA;
    box-shadow: 0px 3px 0px #004570, 0px 6px 15px rgba(0, 0, 0, 0.2);
}

.custom-dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 220px;
    background-color: #FFFFFF;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    padding: 8px;
    margin: 5px 0;
}

.dropdown-menu.show {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dropdown-menu a,
.dropdown-menu button {
    display: flex;
    /* Changed to flex */
    align-items: center;
    /* Center content vertically */
    width: 100%;
    height: 40px;
    /* Fixed height for all items */
    padding: 0 16px;
    /* Removed vertical padding, using fixed height instead */
    color: #333333;
    font-weight: 500;
    font-size: 14px;
    text-decoration: none;
    background: none;
    border: none;
    text-align: left;
    border-radius: 6px;
    transition: background-color 0.2s;
    white-space: nowrap;
    box-sizing: border-box;
    margin: 0;
    cursor: pointer;
    /* Add pointer cursor to both */
    font-family: inherit;
    /* Ensure consistent font */
}

.dropdown-menu a:hover,
.dropdown-menu button:hover {
    background-color: #F5F5F5;
    color: #000000;
}

/* Container for bottom buttons */
.dropdown-menu .bottom-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #EEEEEE;
}

.dropdown-menu .bottom-buttons a,
.dropdown-menu .bottom-buttons button {
    display: flex;
    /* Use flex display */
    align-items: center;
    /* Center vertically */
    justify-content: center;
    /* Center horizontally */
    height: 36px !important;
    /* Fixed height */
    padding: 0 16px !important;
    /* Horizontal padding only */
    color: #333333;
    font-weight: 500;
    font-size: 14px;
    text-decoration: none;
    background: none;
    border: none;
    border-radius: 6px;
    transition: background-color 0.2s;
    white-space: nowrap;
    box-sizing: border-box;
    margin: 0 !important;
    margin-left: 0 !important;
    cursor: pointer;
    font-family: inherit;
    line-height: 1;
    /* Add this to ensure text is centered */
    text-align: center;
    /* Ensure text is centered */
}

/* Separator before bottom section */
.dropdown-menu .menu-separator {
    height: 1px;
    background-color: #EEEEEE;
    margin: 8px 0;
    width: 100%;
}

.dropdown-menu li {
    padding: 8px 16px;
    color: #515151;
    font-weight: 500;
    cursor: pointer;
    font-size: 15px;
    border: none;
    /* Ensure no border */
}

.dropdown-menu li:hover {
    background-color: #E0E0E0;
}

.dropdown-menu li>a {
    display: block;
    padding: 5px;
    margin: -8px -16px;
    height: 100%;
    color: inherit;
    text-decoration: none;
}

.dropdown-menu li>a:hover {
    background-color: transparent;
}

/* Modify the existing dropdown-toggle style */
.dropdown-toggle::after {
    font-size: 0.8em;
    vertical-align: middle;
    margin-left: 5px;
}

#gameHeader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 36px;
    background-color: #145214;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    z-index: 99999;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}


.footerInfo {
    text-decoration: none;
}


#gameTimer,
#moveCounter,
#statisticsBtn,
#bookmarkBtn,
.footerInfo {
    height: 30px;
    color: white;
    background: rgba(0, 0, 0, 0.2) !important;
    padding: 4px 8px !important;
    border-radius: 3px !important;
    min-width: 70px;
    border: none !important;
    text-align: center;
    font-size: 14px !important;
    margin-left: 5px !important;
}

#gameHeader .logo {
    flex-shrink: 0;
    /* Prevent logo from shrinking */
    margin-top: 5px;
}

#gameHeader .variations {
    display: flex;
    gap: 20px;
    padding: 0 10px;
    flex-wrap: nowrap;
    /* Prevent wrapping */
}

#gameHeader .variations a {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s;
    white-space: nowrap;
    /* Prevent text wrapping */
}

#gameHeader .variations a:hover {
    color: white;
}

.page-container {
    display: flex;
    flex-direction: column;
}

.game-section {
    height: 100vh;
    /* Full viewport height for game section */
    position: relative;
}

.instructions-section {
    min-height: 100vh;
    /* Full viewport height for instructions */
    background-color: #248424;
    padding: 40px 20px;
    color: white;
}

.instructions-content {
    max-width: 800px;
    margin: 0 auto;
    line-height: 1.6;
}

/* Add some basic styling for the instructions */
.instructions-content h1 {
    text-align: center;
    margin-bottom: 20px;
    color: #4caf50;
    font-size: 2.5em;
}

.instructions-content h2 {
    color: #81c784;
    margin-top: 20px;
    margin-bottom: 10px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 10px;
}

.instructions-content p {
    margin-bottom: 15px;
}

.instructions-content ul {
    margin-left: 30px;
    margin-bottom: 15px;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-right: 20px;
}

.header-icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    transition: background-color 0.2s;
}

.header-icon:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.blog-container {
    width: 97%;
    margin: 50px 23px;
    padding: 20px;
    padding-right: 400px;
    background-color: #ffffff;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    border: 1px solid #ddd;
}

.button-group {
    height: fit-content;
    /* Add this to ensure proper height */
    display: inline-flex;
    margin-right: 10px;
    color: white;
    font-weight: bold;
    text-align: center;
    font-size: 15px;
    width: auto;
    /* Allow auto-width */
    min-width: 70px;
    /* Minimum width */
    text-decoration: none;
    /* Space between this group and other buttons */
}

.button-group .three-d-button {
    border-radius: 0;
    margin: 0;
    height: 100%;
    /* Ensure full height */
    display: flex;
    /* Add these flex properties */
    align-items: center;
    /* to ensure content is vertically centered */
    justify-content: center;
    box-sizing: border-box;
    /* Ensure padding is included in height calculation */
}

.button-group .three-d-button,
.three-d-button,
.three-d-button-settings,
.three-d-button-hint {
    padding: 0rem 0.3rem;
    line-height: 1;
    /* Add this to ensure consistent text height */
    height: 35px;
    /* Set explicit height to match other buttons */
    box-sizing: border-box;
}

/* Round only the left edges of the first button */
.button-group .three-d-button:first-child {
    border-top-left-radius: 6px;
    border-bottom-left-radius: 6px;
}

/* Round only the right edges of the last button */
.button-group .three-d-button:last-child {
    border-top-right-radius: 6px;
    border-bottom-right-radius: 6px;
}

/* Add a subtle separator between buttons */
.button-group .three-d-button:not(:last-child) {
    border-right: 1px solid rgba(0, 0, 0, 0.1);
}


/*.card-loader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.card-stack {
    position: relative;
    width: 100px;
    height: 140px;
    margin-bottom: 20px;
}

.card {
    position: absolute;
    width: 100px;
    height: 140px;
    border-radius: 8px;
    background: white;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.card1 { transform: translateX(-30px); }
.card2 { transform: translateX(-10px); }
.card3 { transform: translateX(10px); }
.card4 { transform: translateX(30px); }*/

.loading-text {
    color: white;
    font-size: 24px;
    font-family: Arial, sans-serif;
    text-align: center;
    margin-top: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.game-toast-container {
    position: fixed;
    bottom: 0;
    left: min(10px, 1vw);
    transform: none;
    z-index: 9999;
    display: flex;
    flex-direction: column-reverse;
    gap: clamp(0.5rem, 1vh, 1rem);
    pointer-events: none;
    width: min(400px, 40vw);
}

.game-toast {
    position: relative;
    min-height: clamp(4rem, 8vh, 6rem);
    /* Minimum height to accommodate beaver */
    width: fit-content;
    max-width: 100%;
    opacity: 0;
    transform: translateX(-1rem);
    transition: all 0.3s ease;
    pointer-events: auto;
    display: flex;
    align-items: center;
    /* Center text vertically */
    margin-bottom: 0;
    /* Ensure no bottom margin */
}

/* Text bubble */
.game-toast span {
    background: rgba(25, 118, 210, 0.95);
    /* Blue background for text only */
    color: white;
    padding: clamp(0.5rem, 1vh, 1rem) clamp(1rem, 1.5vw, 1.5rem);
    border-radius: clamp(0.25rem, 0.5vw, 0.5rem);
    font-size: clamp(0.875rem, 1.25vw, 1rem);
    margin-bottom: clamp(2rem, 5vh, 3rem);
    /* Lift text up from beaver */
    box-shadow: 0 clamp(2px, 0.3vh, 4px) clamp(4px, 0.6vh, 8px) rgba(0, 0, 0, 0.2);
}

/* Beaver image */
.game-toast::before {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    /* Align to bottom */
    width: clamp(3.5rem, 7vh, 5rem);
    /* Bigger beaver */
    height: clamp(3.5rem, 7vh, 5rem);
    background-size: contain;
    background-repeat: no-repeat;
    background-position: bottom center;
}

.game-toast.show {
    opacity: 1;
    transform: translateY(0);
}

.game-toast.error span {
    background: #0082D8;
}

.game-toast.success span {
    background: rgba(46, 125, 50, 0.95);
}

.game-toast.info span {
    background: rgba(25, 118, 210, 0.95);
}

.game-toast.warning span {
    background: rgba(237, 108, 2, 0.95);
}

/* Screen size ranges */
/* Extra Large Screens (4K and above) */
@media (min-width: 2560px) {
    .game-toast-container {
        bottom: min(30px, 3vh);
        left: min(30px, 3vw);
    }

    .game-toast span {
        font-size: clamp(1rem, 1.5vw, 1.25rem);
    }
}

@media (max-width: 768px) {
    .game-toast-container {
        bottom: min(120px, 15vh);
        left: min(15px, 2vw);
        width: min(300px, 85vw);
    }
}

@media (max-width: 480px) {
    .game-toast-container {
        bottom: min(120px, 15vh);
        left: min(10px, 1.5vw);
        width: min(280px, 90vw);
    }

    .game-toast span {
        font-size: clamp(0.75rem, 1.25vw, 0.875rem);
    }
}

#rotate-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #1a6d1a;
    color: #fff;
    display: none;
    justify-content: center;
    align-items: center;
    text-align: center;
    font-family: Arial, sans-serif;
    font-size: 1.5rem;
    z-index: 9999;
}

@media screen and (orientation: landscape) {
    #rotate-overlay {
        display: flex;
    }
}

@media screen and (orientation: portrait) {
    #rotate-overlay {
        display: none;
    }
}

/* Win modal score table (Hearts/Spades) - remove borders between rows/columns */
.modal-overlay .hearts-score-table {
    border-collapse: collapse !important;
    border-spacing: 0 !important;
    border: none !important;
}

.modal-overlay .hearts-score-table tr {
    border: none !important;
}

.modal-overlay .hearts-score-table th,
.modal-overlay .hearts-score-table td {
    border: none !important;
    border-radius: 7px;
}

/* Reconnection full-page overlay */
.reconnection-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 410px; /* leave space for the ad banner on the right */
    height: 100vh;
    display: flex; /* always flex; visibility controls showing/hiding */
    visibility: hidden; /* default hidden; JS toggles to visible */
    align-items: center;
    justify-content: center;
    z-index: 100000; /* above #gameHeader (99999) */
}

.reconnection-overlay-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.reconnection-spinner {
    width: 64px;
    height: 64px;
    border: 6px solid rgba(255, 255, 255, 0.25);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: reconnection-spin 1s linear infinite;
}

@keyframes reconnection-spin {
    to { transform: rotate(360deg); }
}

.reconnection-text {
    color: #ffffff;
    font-size: 18px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    font-weight: 500;
}

/* Accessibility helper for screen readers */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}