:root {
    --background-color: #121212;
    --primary-text-color: #ffffff;
    --secondary-text-color: #b3b3b3;
    --accent-color: #1db954;
    --container-background: #282828;
}

body.light-mode {
    --background-color: #ffffff;
    --primary-text-color: #121212;
    --secondary-text-color: #4a4a4a;
    --accent-color: #007bff;
    --container-background: #f0f0f0;
}

body {
    background-color: var(--background-color);
    color: var(--primary-text-color);
    font-family: 'Helvetica Neue', sans-serif;
    margin: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

header, footer {
    background-color: var(--container-background);
    padding: 1rem;
    text-align: center;
}

#theme-toggle,
#muscle-explorer-btn,
#flashcard-app-btn {
    background-color: var(--accent-color);
    color: var(--primary-text-color);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    margin-left: 1rem;
}

#theme-toggle:hover,
#muscle-explorer-btn:hover,
#flashcard-app-btn:hover {
    opacity: 0.8;
}

main {
    flex-grow: 1;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    padding: 2rem;
    gap: 2rem;
}

#muscle-diagram {
    flex: 2;
    min-width: 300px;
    max-width: 600px;
    height: auto;
}

muscle-info {
    flex: 1;
    min-width: 300px;
}

.muscle-info-container {
    background-color: var(--container-background);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

h2 {
    color: var(--accent-color);
}

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

svg {
    width: 100%;
    height: auto;
}

path {
    fill: #888;
    stroke: #fff;
    stroke-width: 1px;
    transition: fill 0.3s ease;
}

path:hover, path.active {
    fill: var(--accent-color);
}

.region-navigation {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
    width: 100%;
}

.region-navigation button {
    background-color: var(--accent-color);
    color: var(--primary-text-color);
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1.1rem;
    transition: background-color 0.3s ease;
}

.region-navigation button:hover {
    opacity: 0.8;
}

/* Flashcard App Styles */
#flashcard-app {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    width: 100%;
    max-width: 600px; /* Limit width for better card appearance */
}

.flashcard-container {
    width: 100%;
    height: 300px; /* Fixed height for the card */
    perspective: 1000px; /* 3D perspective for flip effect */
}

.flashcard {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d; /* Preserve 3D space for children */
    transition: transform 0.6s; /* Smooth flip animation */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    background-color: var(--container-background); /* Use theme background */
}

.flashcard.flipped {
    transform: rotateY(180deg);
}

.flashcard-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    backface-visibility: hidden; /* Hide the back of the card during flip */
    border-radius: 10px;
    padding: 20px;
    box-sizing: border-box;
}

.flashcard-front, .flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-backface-visibility: hidden; /* For Safari */
    backface-visibility: hidden;
    border-radius: 10px;
    font-size: 1.5rem;
    color: var(--primary-text-color);
    background-color: var(--container-background);
}

.flashcard-back {
    transform: rotateY(180deg); /* Initially rotate the back to hide it */
}

.flashcard p {
    margin: 0;
    text-align: center;
    color: inherit; /* Inherit color from parent */
}

.controls {
    display: flex;
    gap: 15px;
    margin-top: 20px;
}

.controls button {
    background-color: var(--accent-color);
    color: var(--primary-text-color);
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1.1rem;
    transition: background-color 0.3s ease;
}

.controls button:hover {
    opacity: 0.8;
}