/* Modern reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Nunito', sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--background-light);
    letter-spacing: 0.01em;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
}

p {
    color: var(--text-secondary);
}

/* Navigation Bar */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--card-bg);
    padding: 1rem 5%;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.04);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.logo a {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    text-decoration: none;
}

.nav-links {
    display: flex;
    list-style: none;
}

.nav-links li {
    margin-left: 1.5rem;
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    padding: 0.5rem 1rem;
    transition: color 0.2s;
}

.nav-links a:hover, .nav-links a.active {
    color: var(--primary-color);
}

.hamburger {
    display: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 20px;
}

.game-header {
    text-align: center;
    margin-bottom: 2rem;
}

.game-header h1 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.game-description {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Controls section */
.controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    margin-bottom: 1rem;
}

.controls button {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 4px;
    background-color: var(--primary-color);
    color: white;
    cursor: pointer;
    /* transition: background-color 0.3s; */
    font-weight: 500;
}

.controls button.active {
    background-color: var(--primary-dark);
}

.controls button:hover {
    background-color: var(--primary-dark);
}

#resetBtn {
    background-color: var(--primary-color);
}

#resetBtn:hover {
    background-color: var(--primary-dark);
}

.score {
    background-color: var(--primary-color);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1rem;
}

/* Game area */
.game-area {
    display: flex;
    flex-direction: column;
    margin-bottom: 2rem;
}

#map-container {
    width: 100%;
    height: 100%;
    min-height: 600px;
    background-color: var(--background-medium);
    border-radius: 0.375rem;
    overflow: hidden;
    position: relative;
}

#pieces-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    overflow-y: auto;
    height: 100%; /* Subtract header height */
    min-height: 600px; /* Match map container height minus header */
    align-content: flex-start;
    padding: 1rem;
    background-color: var(--background-medium);
    border: 1px solid var(--card-border);
    border-top: none; /* Remove top border as it connects with the header */
    border-radius: 0.375rem;
}

/* Ensure the card header above pieces container has matching border */
#pieces-container + .card-header,
.card > .card-header {
    border: 1px solid var(--card-border);
    border-bottom: none;
}

/* Make sure the card containing pieces container has proper styling */
#game-area-row .col-lg-4 .card {
    border: none; /* Remove default card border */
    overflow: hidden; /* Prevent border radius issues */
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05); /* Add subtle shadow */
}

/* Instructions */
.instructions {
    background-color: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    margin-bottom: 2rem;
}

.instructions h3 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

/* Completion message */
#completion-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.2);
    text-align: center;
    z-index: 1000;
}

#completion-message.hidden {
    display: none;
}

#playAgainBtn {
    border-radius: 8px;
    background-color: var(--primary-light);
    cursor: pointer;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);

}

#playAgainBtn:hover {
    background-color: var(--primary-color);
    color: white;
}

/* Footer */
.footer {
    background-color: var(--footer-bg);
    color: var(--footer-text);
    padding: 3rem 5% 1rem;
}

.footer-content {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    max-width: 1200px;
    margin: 0 auto;
}

.footer-section {
    flex: 1;
    min-width: 200px;
    margin-bottom: 2rem;
    padding-right: 2rem;
}

.footer-section h3 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.footer-section ul {
    list-style: none;
}

.footer-section ul li {
    margin-bottom: 0.5rem;
}

.footer-section a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

.footer-section a:hover {
    color: var(--primary-color);
}

.social-icons {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.social-icons a {
    color: var(--text-secondary);
    font-size: 1.2rem;
    transition: color 0.2s;
}

.social-icons a:hover {
    color: var(--primary-color);
}

.copyright {
    text-align: center;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--footer-text);
    font-size: 0.9rem;
}

/* Responsive design */
@media (max-width: 768px) {
    .navbar {
        padding: 1rem;
    }
    
    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        background-color: var(--primary-color);
        text-align: center;
        padding: 1rem 0;
    }
    
    .nav-links.active {
        display: flex;
    }
    
    .nav-links li {
        margin: 0.5rem 0;
    }
    
    .hamburger {
        display: block;
    }
    
    .controls {
        flex-direction: column;
        gap: 1rem;
    }
    
    .footer-section {
        flex: 0 0 100%;
        padding-right: 0;
    }
}

.map-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--background-medium);
}

.map-outline {
    width: 100%;
    height: 100%;
    display: block;
}

/* Level 1 shows state outlines */
#map-container.level1 .map-outline path {
    stroke-width: 2;
    background-color: var(--primary-light);
}

/* Level 2 hides state outlines */
#map-container.level2 .map-outline path {
    stroke: transparent;
}

#map-container.level2 #us-outline {
    stroke: rgba(255, 255, 255, 0.8);
    stroke-width: 2;
}

.state-piece {
    border-radius: 8px;
    margin-bottom: 8px;
    padding: 10px;
    cursor: grab;
    transition: transform 0.2s, box-shadow 0.2s;
}

.state-piece:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
}

.state-piece .shape-container {
    margin-bottom: 8px;
}

.state-piece .state-label {
    text-align: center;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.shape-container {
    position: relative;
    background-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
    min-width: auto;
    min-height: auto;
    width: 100%;
}

.state-svg {
    width: 100%;
    height: 100%;
    display: block;
}

.state-label {
    font-size: 18px;
    font-weight: bold;
    text-align: center;
    padding: 5px 0;
    width: 100%;
    color: var(--text-primary);
    /* Ensure text doesn't get cut off */
    overflow: visible;
    white-space: normal;
    line-height: 1.2;
}

.state-piece.dragging {
    opacity: 0.7;
}

.placed-state {
    position: absolute;
    width: 10%;
    height: 10%;
    transform-origin: center;
    pointer-events: auto;
    cursor: pointer;
}

.placed-state .state-svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* Hide the label when the piece is placed */
.state-piece.placed {
    display: none;
}

.incorrect-feedback {
    position: absolute;
    width: 30px;
    height: 30px;
    background-color: var(--warning-color);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
    opacity: 0.7;
    animation: pulse 1s ease-out;
}

@keyframes pulse {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1.5);
        opacity: 0;
    }
}

/* Styling for placed states in the map */
#map-svg path.placed {
    transition: fill 0.3s ease-out;
}

/* Pulse animation for incorrect placement feedback */
.incorrect-feedback {
    position: absolute;
    width: 40px;
    height: 40px;
    background-color: rgba(231, 76, 60, 0.7);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    animation: pulse 1s ease-out;
    z-index: 100;
}

@keyframes pulse {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(2);
        opacity: 0;
    }
}

@media (min-width: 992px) {
    .game-area {
        flex-direction: row;
    }
    
    #map-container {
        flex: 2;
        min-height: auto;
    }
    
    #pieces-container {
        flex: 1;
        max-height: 600px;
    }
}

@media (max-width: 991px) {
    .state-piece {
        width: 200px;
        height: 70px;
    }
    
    .shape-container {
        width: 120px;
        height: 70px;
    }
}

@media (max-width: 767px) {
    .state-piece {
        width: 180px;
        height: 60px;
    }
    
    .shape-container {
        width: 100px;
        height: 60px;
    }
    
    .state-label {
        font-size: 16px;
    }
}

/* Map container specific styles */
#map-container {
    overflow: hidden;
    position: relative;
}

.map-background {
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: relative;
    background-color: var(--background-medium);
}

.map-outline {
    width: 100%;
    height: 100%;
}

/* Zoom controls */
.zoom-controls {
    position: absolute;
    right: 15px;
    top: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 100;
}

.zoom-btn {
    width: 35px;
    height: 35px;
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
    transition: background-color 0.2s;
}

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

/* Make sure bootstrap buttons maintain their active state */
.btn.active {
    box-shadow: 0 0 0 0.25rem rgba(91, 135, 170, 0.25);
}

/* Eye-friendly color palette and overall design */
:root {
    --primary-color: #5b87aa;
    --primary-dark: #4a7090;
    --primary-light: #d9e6f2;
    --secondary-color: #60a677;
    --accent-color: #f0b86e;
    --warning-color: #e98074;
    --text-primary: #333b44;
    --text-secondary: #5f6c7b;
    --background-light: #f8f9fa;
    --background-medium: #edf2f7;
    --card-bg: #ffffff;
    --card-border: rgba(0, 0, 0, 0.05);
    --footer-bg: #f1f1f1;
    --footer-text: #5f6c7b;
}

/* Card styling */
.card {
    border: 1px solid var(--card-border);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
    overflow: hidden;
    background-color: var(--card-bg);
    transition: transform 0.3s, box-shadow 0.3s;
    background-color: var(--background-medium);
}

.card-header {
    background-color: var(--background-medium);
    border-bottom: 1px solid var(--card-border);
    padding: 1rem 1.25rem;
}

.card-body {
    padding: 1.5rem;
}

/* Updated button styling */
.btn {
    border-radius: 8px;
    font-weight: 600;
    padding: 0.5rem 1.25rem;
    transition: all 0.3s;
    /* background-color: var(--background-light); */
}

/* Site-specific button */
.btn-site {
    background-color: var(--primary-light);
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-site:hover, .btn-site:focus {
    background-color: var(--primary-color);
    color: white;
}

.btn-site.active {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 0 0 0.25rem rgba(91, 135, 170, 0.25);
}

/* Reset button */
.btn-reset {
    /* background-color: var(--primary-light); */
    border: 1px solid var(--primary-color);
    color: white;
}   

.btn-reset:hover, .btn-reset:focus {
    background-color: var(--primary-color);
    color: white;
}

/* Modal buttons */
.modal-footer .btn {
    padding: 0.5rem 1.5rem;
}

.btn-outline-secondary {
    color: var(--text-secondary);
    border-color: var(--text-secondary);
}

.btn-outline-secondary:hover {
    background-color: var(--text-secondary);
    color: white;
}

/* Modal styling */
.modal-content {
    border-radius: 12px;
    border: none;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.modal-header {
    background-color: var(--primary-color);
    color: white;
    border-bottom: none;
    border-radius: 12px 12px 0 0;
}

.trophy-icon {
    color: var(--accent-color);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.completion-time {
    background-color: var(--primary-light);
    color: var(--primary-dark);
    border: 1px solid var(--primary-color);
    display: inline-block;
    min-width: 200px;
}

#completionTime {
    font-weight: 700;
    font-size: 1.2em;
    color: var(--primary-color);
}

/* Add a confetti animation to the modal */
@keyframes confetti {
    0% { 
        opacity: 1;
        transform: translateY(0) rotate(0);
    }
    100% { 
        opacity: 0;
        transform: translateY(100px) rotate(720deg);
    }
}

.modal-open .modal-content::before {
    content: "";
    position: absolute;
    top: -50px;
    left: 0;
    right: 0;
    height: 50px;
    background: 
        radial-gradient(circle, var(--accent-color) 10%, transparent 10%) 0 0,
        radial-gradient(circle, var(--primary-color) 10%, transparent 10%) 25px 25px,
        radial-gradient(circle, var(--secondary-color) 10%, transparent 10%) 50px 50px;
    background-size: 100px 100px;
    animation: confetti 1.5s ease-in-out forwards;
    pointer-events: none;
}

/* Footer styling */
footer {
    background-color: var(--footer-bg);
    color: var(--footer-text);
}

.footer-link {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

.footer-link:hover {
    color: var(--primary-color);
    text-decoration: none;
}

.social-icon {
    color: var(--text-secondary);
    transition: color 0.2s;
}

.social-icon:hover {
    color: var(--primary-color);
}

/* Media queries for better responsiveness */
@media (max-width: 768px) {
    .card-body {
        padding: 1.25rem;
    }
    
    h1 {
        font-size: 2rem;
    }
}

/* For dark mode preference - optional */
@media (prefers-color-scheme: dark) {
    /* The user can add dark mode styles here if needed */
}

/* Game area layout */
#game-area-row {
    min-height: 600px;
    gap: 0.5rem !important; /* Override Bootstrap's default gap */
}

/* If you prefer to keep the column structure intact but remove gap */
#game-area-row > [class*="col-"] {
    padding-left: 0.25rem !important;
    padding-right: 0.25rem !important;
}

#game-area-row .card {
    height: 100%;
    margin-bottom: 0;
}

#map-container {
    width: 100%;
    height: 100%;
    min-height: 600px;
    background-color: var(--background-medium);
    border-radius: 0.375rem;
    overflow: hidden;
    position: relative;
}

.map-background {
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: relative;
    background-color: var(--background-medium);
}

.map-outline {
    width: 100%;
    height: 100%;
}

#pieces-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    overflow-y: auto;
    height: calc(100%); /* Subtract header height */
    min-height: calc(600px); /* Match map container height minus header */
    align-content: flex-start;
    padding: 1rem;
    background-color: var(--background-medium);
}

/* Responsive adjustments */
@media (max-width: 991px) {
    #game-area-row {
        min-height: auto;
    }
    
    #map-container {
        min-height: 400px;
    }
    
    #pieces-container {
        min-height: 300px;
        max-height: 300px;
    }
    
    .card-header h5 {
        font-size: 1rem;
    }
}

/* Sound toggle button */
#soundToggleBtn {
    padding: 0.4rem 0.6rem;
    font-size: 1rem;
    color: var(--text-secondary);
    background-color: var(--background-light);
}

#soundToggleBtn.sound-off {
    color: var(--warning-color);
}

/* Enhance incorrect feedback animation */
.incorrect-feedback {
    position: absolute;
    width: 30px;
    height: 30px;
    background-color: var(--warning-color);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
    opacity: 0.7;
    animation: pulse 1s ease-out;
}

@keyframes pulse {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1.5);
        opacity: 0;
    }
}

/* Hide zoom controls on touch devices */
@media (pointer: coarse) {
    .zoom-controls,
    .zoom-btn {
        display: none !important;
    }
}

/* Hide the zoom controls when touch is detected via JavaScript */
.touch-device .zoom-controls,
.touch-device .zoom-btn {
    display: none !important;
}

.navbar {
    height: 60px; /* Set your desired height */
    min-height: 60px;
    max-height: 60px;
    display: flex;
    align-items: center; /* Vertically center content */
    padding: 0 15px;
    box-sizing: border-box; /* Ensures padding doesn't affect height */
  }
  