body {
    background: #0d1117;
    color: #f1f5f9;
    font-family: 'Inter', sans-serif;
    margin: 0;
    padding-top: 60px;
    /* Add padding to body to avoid content hiding behind fixed header */
    overflow-x: hidden;
    /* overflow-y: auto; */
    /* height: 100vh; */
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    box-sizing: border-box;
}

header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: #161b22;
    padding: 10px 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    z-index: 10;
    box-sizing: border-box;
    height: 60px; /* Ensure header has a fixed height */
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 600px;
    position: relative; /* Needed for absolute positioning of the flash element */
}

.percentage-flash {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    padding: 5px 15px;
    border-radius: 8px;
    font-size: 1.2em;
    font-weight: bold;
    color: white;
    opacity: 0;
    transition: opacity 0.5s ease-out;
    pointer-events: none; /* So it doesn't interfere with clicks */
}

.percentage-flash.show {
    opacity: 1;
}

.percentage-flash.positive {
    background-color: #22C55E; /* green-500 */
}

.percentage-flash.negative {
    background-color: #EF4444; /* red-500 */
}

header h1 {
    margin: 0;
    font-size: 1.5em;
    color: #4f46e5;
    font-weight: bold;
}

#progress-tracker {
    font-size: 1em;
    color: #c7d2fe;
    cursor: pointer;
    transition: background-color 0.2s;
    border-radius: 8px;
    padding: 5px 10px;
    background-color: #2d3748;
}

#progress-tracker:hover {
    background-color: #374151;
}

#max-progress-value {
    font-weight: bold;
    color: #818cf8;
}

.progress-label {
    margin-right: 0.25em;
}

.hidden-score {
    display: none;
}

#tree {
    flex-grow: 1;
    overflow-y: auto;
    position: relative;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    padding: 40px 0;
    padding-bottom: 160px;
    /* Extra space to ensure last nodes aren't hidden */
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 1;
}

#lines {
    position: fixed;
    /* Size and position are controlled by JS using visualViewport to avoid URL-bar offsets */
    top: 0;
    left: 0;
    z-index: 0;
    pointer-events: none;
}

.word-node {
    background: #1f2937;
    border-radius: 12px;
    padding: 10px 18px;
    margin: 4px 0; /* Remove horizontal margin from base class */
    width: fit-content;
    text-align: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    position: relative;
    opacity: 0;
    transform: translateY(-10px);
    animation: fadeIn 0.4s forwards;
    outline: 2px solid transparent;
    transition: transform 0.2s, background 0.3s, outline-color 0.3s ease-in-out;
}

.word-node:hover {
    transform: scale(1.05);
    background: #374151;
}

.word-node.selected {
    background: #4f46e5;
}

.word-node.path {
    background: #312e81;
}

.word-node.visited {
    background: #4f555f; /* A brighter, less prominent color */
}

.word-node-clone {
    position: fixed;
    z-index: 100;
    pointer-events: none;
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.8s;
    background: #22c55e; /* Match target color */
    border-radius: 12px;
    padding: 10px 18px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
    /* Ensure text content is visible */
    color: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Target node should always appear green, regardless of other states */
.word-node.target,
.word-node.target.selected,
.word-node.target.path,
.word-node.target.visited {
    background: #22c55e;
}

.start-node {
    margin-left: auto;
    margin-right: auto;
}

.start-node {
    margin: 4px auto; /* Explicitly center the start node */
}

.start-node {
    margin: 4px auto; /* Explicitly center the start node */
}

.options {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-top: 20px;
}

.options-container {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 5px 10px;
    margin-top: 30px;
    width: 100%;
}

.option {
    background: #2d3748;
    border-radius: 10px;
    padding: 8px 14px;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}

.option:hover {
    background: #4f46e5;
    transform: translateY(-2px);
}

#target {
    border: 2px dashed #4f46e5;
    border-radius: 12px;
    padding: 10px 18px;
    width: fit-content;
    text-align: center;
    color: #c7d2fe;
    cursor: default;
    font-size: 1.1em;
    font-weight: bold;
    background: #0d1117; /* Give it a background to hide lines passing behind it */
}

.sim-score {
    color: #9ca3af;
    font-size: 0.8em;
    margin-left: 5px;
}

.positive-score {
    color: #22c55e; /* green-500 */
}

.negative-score {
    color: #ef4444; /* red-500 */
}

@keyframes fadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Flash animation */
.flash {
    animation: flash 0.7s ease-in-out;
}

/* Modal styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: #1f2937;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    color: #f1f5f9;
    position: relative;
    display: flex;
    flex-direction: column;
    max-height: 80vh; /* Or whatever max-height you prefer */
    width: 90%;
    max-width: 500px;
    box-sizing: border-box;
}

#info-modal .modal-scrollable-content {
    text-align: left;
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 28px;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
    transition: color 0.2s;
}

.close-btn:hover {
    color: #fff;
}

.modal-scrollable-content {
    overflow-y: auto;
    padding-right: 15px; /* To avoid content hiding behind the scrollbar */
    margin-right: -15px; /* To compensate for the padding */
}

.modal-actions {
    margin-top: auto; /* Pushes the buttons to the bottom */
    padding-top: 20px; /* Adds some space above the buttons */
}

.modal-content h2 {
    color: #22c55e;
    margin-top: 0;
}

#play-again-btn {
    background: #4f46e5;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    margin-top: 20px;
    font-size: 16px;
    transition: background 0.2s;
}

#play-again-btn:hover {
    background: #4338ca;
}

#continue-playing-btn {
    background: #374151;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    /* margin-top: 20px; */
    margin-left: 10px;
    font-size: 16px;
    transition: background 0.2s;
}

#continue-playing-btn:hover {
    background: #4b5563;
}

footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: #161b22;
    padding: 10px 20px;
    padding-bottom: 25px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.5);
    z-index: 10;
    box-sizing: border-box;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 600px;
}

.stats-container {
    display: flex;
    gap: 20px;
}

.stat {
    color: #c7d2fe;
}

.stat span:last-child {
    font-weight: bold;
    color: #818cf8;
}

#new-game-btn {
    background: #4f46e5;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    /* margin-top: 20px; */
    transition: background 0.2s;
}

#new-game-btn:hover {
    background: #4338ca;
}

#target-container {
    position: fixed;
    bottom: 80px; /* Position it right above the footer */
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 10px 0;
    z-index: 9; /* Below the main footer but above content */
}

#success-path {
    margin-top: 20px;
    margin-bottom: 20px;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #374151;
    border-radius: 8px;
    padding: 10px;
}

.path-item {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
}

.path-word {
    color: #f1f5f9;
}

.path-percentage {
    color: #818cf8;
    font-weight: bold;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: #0d1117;
}

::-webkit-scrollbar-thumb {
    background-color: #1f2937;
    border-radius: 10px;
    border: 3px solid #0d1117;
}

::-webkit-scrollbar-thumb:hover {
    background-color: #374151;
}

#show-best-path-btn,
#info-btn,
#show-settings-btn,
#chain-btn {
    background: #2d3748;
    color: #c7d2fe;
    border: none;
    padding: 5px;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.5em; /* Increased size for better visibility */
    transition: background-color 0.2s;
    margin-left: 10px; /* Spacing between buttons */
    line-height: 1; /* Ensure consistent height */
    display: flex;
    align-items: center;
    justify-content: center;
}

#show-best-path-btn:hover,
#info-btn:hover,
#show-settings-btn:hover,
#chain-btn:hover {
    background-color: #374151;
}

.stats-columns {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    margin-top: 10px;
    margin-bottom: 10px;
    text-align: center;
}

.stat-item-full-width {
    width: 100%;
    text-align: center;
    margin-bottom: 15px;
}

.stats-column {
    width: 48%;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stats-column h4 {
    font-size: 1.1em;
    color: #a5b4fc;
    margin-bottom: 5px;
    border-bottom: 1px solid #374151;
    padding-bottom: 5px;
    margin-top: 0;
}

.stat-item {
    background-color: #2d3748;
    padding: 8px;
    border-radius: 8px;
}

.stat-label {
    display: block;
    font-size: 0.8em;
    color: #c7d2fe;
}

.stat-value {
    display: block;
    font-size: 1.2em;
    font-weight: bold;
    color: #818cf8;
}

.streak-indicator {
    margin-left: 5px;
    font-size: 0.8em;
    vertical-align: middle;
}

#stats-display h3 {
    color: #c7d2fe;
    border-bottom: 1px solid #374151;
    padding-bottom: 10px;
    margin-bottom: 0px;
}

/* Modal button priority styles (override ID backgrounds) */
#new-game-btn.button-primary,
#continue-playing-btn.button-primary {
    background: #4f46e5; /* primary purple */
    color: #ffffff;
}

#new-game-btn.button-primary:hover,
#continue-playing-btn.button-primary:hover {
    background: #4338ca;
}

#new-game-btn.button-secondary,
#continue-playing-btn.button-secondary {
    background: #374151; /* secondary gray */
    color: #ffffff;
}

#new-game-btn.button-secondary:hover,
#continue-playing-btn.button-secondary:hover {
    background: #4b5563;
}

/* Normalize size for Menu and Max Progress controls */
#progress-tracker,
#show-best-path-btn,
#info-btn,
#show-settings-btn,
#chain-btn {
    padding: 8px 14px;      /* slightly larger padding */
    font-size: inherit;     /* match footer stat text size */
    font-family: inherit;   /* match footer stat font */
    line-height: inherit;   /* match footer stat line-height */
    display: inline-flex;   /* consistent vertical centering */
    align-items: center;
}
/* position version number at top of success model */
/* centre the version number */

.version-number {
    position: absolute;
    top: 5px;
    left: 10px;
    font-size: 0.5em;
    color: #6b7280; /* gray-500 */
    font-weight: normal;
    vertical-align: middle;
    /* margin-left: auto;
    margin-right: auto; */
    
}

.neutral-arrow {
    color: #c9c9c9; /* Or any other neutral color you prefer */
}

#share-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #374151;
    border: none;
    cursor: pointer;
    color: #c7d2fe;
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

#success-modal #info-btn {
    position: absolute;
    top: 15px;
    left: 15px;
    font-size: 1.5em;
    width: 40px;
    height: 40px;
}


#share-btn:hover {
    background: #4b5563;
    color: #fff;
}

#share-btn svg {
    width: 24px;
    height: 24px;
}

#chain-display .chain-item {
    background-color: #2d3748;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: background-color 0.2s;
}

#chain-display .chain-item:hover {
    background-color: #374151;
}

#chain-display .chain-item-header {
    display: flex;
    justify-content: space-between;
    font-weight: bold;
}

#chain-display .chain-item-path {
    margin-top: 8px;
    font-size: 0.9em;
    color: #c7d2fe;
    display: none; /* Hidden by default */
}


@media (min-width: 1024px) {
    #tree {
        max-width: 1200px;
    }

    .header-content,
    .footer-content {
        max-width: 1200px;
    }
}

.stat-item.streak-in-danger .stat-value {
    color: #f97316; /* Orange color for danger */
    font-weight: bold;
}

#info-modal a {
    color: #818cf8;
    text-decoration: none;
}

#info-modal a:hover {
    text-decoration: underline;
}
#info-modal ul {
    padding-left: 20px;
}
#info-modal li {
    margin-bottom: 8px;
}
