/* Medium-inspired Root Variables (Dark Mode Adaptation) */
:root {
    --text-color: #E8E8E8; /* Light text for dark background */
    --secondary-text-color: #B0B0B0; /* Slightly darker light text */
    --link-color: #4FC3F7; /* Bright blue for links and highlights */
    --background-color: #1A1A1A; /* Dark background */
    --card-background: #282828; /* Slightly lighter dark for cards/containers */
    --border-color:  #1A1A1A; /* Darker subtle borders */
    --header-bg: #1A1A1A; /* Dark header */

    /* Fonts (kept consistent with previous Medium style) */
    --font-serif: 'Merriweather', serif;
    --font-sans: 'Roboto', sans-serif;

    /* Your existing variables - adjusted for consistency if needed */
    --level-button-color: #4FC3F7; /* Matches link-color for buttons */
    --dark-navy-blue: #E8E8E8; /* Adjusted to match text-color for headings */
    --highlight-color: #FFEB3B; /* Yellow for specific highlights (like completed targets) */
    --danger-color: #EF5350; /* Red for errors */
    --secondary-color: #B0B0B0; /* Matches secondary-text-color */

    /* Font sizes (kept from your original, can be fine-tuned) */
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-md: 1.125rem;
    --font-size-lg: 1.5rem;
    --font-size-xl: 2.5rem;
    --font-weight-bold: 700;
}

body {
    background-color: var(--background-color); /* Dark background */
    color: var(--text-color); /* Light text */
    font-family: var(--font-sans); /* Medium-style sans-serif */
    margin: 0;
    padding: 20px; /* Increased padding for more breathing room */
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.hint-arrow {
    position: absolute;
    top: -20px; /* 修改为负值，表示在上方 */
    left: 50%;
    transform: translateX(-50%);
    font-size: 14px;
    color: var(--highlight-color);
    animation: bounce 1s infinite;
    white-space: nowrap;
}

@keyframes bounce {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(-5px); }
}



.mode-selector {
    padding: 10px;
    opacity: 0.5;
    background-color: var(--card-background);
    border-radius: 8px;
    font-size: var(--font-size-base);
}

#mode-select {
    background-color: var(--background-color);
    color: var(--text-color);
    border: 1px solid var(--link-color);
    padding: 5px 10px;
    font-size: var(--font-size-base);
    border-radius: 5px;
}

.mode-selector:hover {
    opacity: 1;
}




/* --- Footer --- */
.site-footer-simplified {
    width: 100%;
    background-color: var(--card-background); /* Use a slightly lighter dark for footer */
    color: var(--text-color); /* Light text */
    text-align: center;
    padding: 30px 0;
    font-size: 14px;
 /*   margin-top: 50px;*/
    border-top: 1px solid var(--border-color); /* Subtle border */
}

.footer-links-inline {
    margin-bottom: 15px;
}

.footer-link-inline {
    color: var(--secondary-text-color); /* Lighter secondary color for links */
    text-decoration: none;
    margin: 0 10px;
    transition: color 0.3s ease; /* Smooth transition */
}

.footer-link-inline:hover {
    color: var(--link-color); /* Highlight on hover */
}

.separator {
    color: rgba(var(--secondary-text-color), 0.5); /* Use rgba for transparency */
}

.footer-info-inline p {
    margin: 0;
    color: var(--secondary-text-color);
}

.footer-link-image {
    display: inline-block;
    margin-left: 5px;
    vertical-align: middle;
}

.email-icon {
    width: 20px;
    height: 20px;
    /* Invert filter is still useful if the original icon is dark */
    filter: invert(0.8) grayscale(100%); /* Makes icon light, subtle grayscale */
}

/* In your style.css or a <style> block */
.selected {
    background-color: #ffe08a; /* Example: a light yellow background */
    box-shadow: 0 0 8px rgba(255, 204, 0, 0.7); /* Example: a subtle glow */
}

/* Optional: Add a transition for a smoother visual effect */
.clickable-word, .slot {
    transition: all 0.2s ease-in-out;
}

/* --- Story Container --- */
.story-container {
    flex: 1;
    margin-bottom: 20px; /* Increased margin */
    background-color: var(--card-background); /* Dark card background */
    border: 1px solid var(--card-background); /* Subtle border */
    border-radius: 8px; /* Slightly rounded corners */
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2); /* Soft shadow */
}

.story-content {
    height: 100%;
    overflow-y: auto;
    padding: 30px; /* More padding for content */
    padding-bottom: 50px; /* Space for indicator */
    line-height: 1.7; /* Increased line height for readability */
    font-size: var(--font-size-lg); /* Slightly larger text */
    font-family: var(--font-serif); /* Serif font for story content */
}

#stage-indicator {
    position: absolute;
    bottom: -10px; /* Adjusted position */
    right: 20px; /* Adjusted position */
    background: rgba(0, 0, 0, 0.6); /* Slightly more transparent */
    color: var(--secondary-text-color); /* Consistent text color */
    padding: 8px 15px; /* More padding */
    border-radius: 20px; /* More rounded */
    font-size: var(--font-size-lg);
    pointer-events: none;
}

.story-history, .current-story {
    padding-bottom: 15px; 
    margin-bottom: 15px; 
}

.story-history {
    opacity: 0.7;
    border-bottom: 1px solid var(--border-color); /* Lighter border */
    font-size: var(--font-size-lg); 
    color: var(--secondary-text-color);
}

#current-story {
    scroll-margin-top: 15px; /* 设置顶部的额外空间 */
}


.stage-completed {
    color: var(--highlight-color); 
    margin-top: 20px; /* More margin */
    padding: 15px; /* More padding */
    background-color: rgba(255, 235, 59, 0.1); /* Subtle yellow background */
    border-left: 4px solid var(--highlight-color); /* Thicker border */
    font-family: var(--font-serif); /* Sans-serif for alerts */
    border-radius: 4px;
}

.story-text {
    line-height: 1.8; /* Increased line height for spacious feel */
    font-size: 20px; /* Larger base font size for story */
    font-family: var(--font-serif); /* Use serif font */
    color: var(--text-color);
}

.clickable-word {
    color: white; 
    cursor: pointer;
    transition: color 0.2s ease, background-color 0.2s ease, text-shadow 0.2s ease;
    position: relative;
    padding: 0 3px; /* Slightly more padding */
    border-bottom: 1px solid rgba(var(--link-color), 0.4); /* Subtle underline */
}

.clickable-word:hover {
    color: var(--highlight-color); /* Yellow on hover */
    text-shadow: none; /* Remove text shadow for cleaner look */
    border-bottom-color: var(--highlight-color);
}

.clickable-word.selected {
    color: var(--background-color); /* Dark text on selected */
    background-color: #ffeb3b; /* Blue background when selected */
    font-weight: bold;
    border-radius: 4px;
    border-bottom: none; /* Remove underline when selected */
}

/* --- Operations --- */
.operations {
    display: flex;
    justify-content: center;
    gap: 20px; /* Increased gap */
    margin: 5px 0; /* More margin */
    padding: 10px;
    border-top: 1px solid var(--border-color); /* Subtle top border */
    border-bottom: 1px solid var(--border-color); /* Subtle bottom border */
}

.operation-btn {
    width: 55px; /* Slightly larger buttons */
    height: 55px;
    border: 2px solid var(--link-color); /* Blue border */
    background-color: transparent;
    color: var(--link-color);
    font-size: 28px; /* Larger icon */
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.operation-btn.selected {
    background-color: var(--link-color);
    color: var(--background-color); /* Dark text when selected */
}

.operation-btn:disabled {
    opacity: 0.4; /* Slightly more visible when disabled */
    cursor: not-allowed;
    border-color: var(--secondary-text-color);
    color: var(--secondary-text-color);
}

/* --- Targets --- */
.targets {
    margin: 5px 0;
    padding: 10px;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    text-align: center;
    font-family: var(--font-sans);
    color: var(--secondary-text-color);
}

.target-words {
    display: flex;
    flex-wrap: wrap;
    gap: 10px; /* Slightly smaller gap between words */
    justify-content: center;
    margin: 5px 0;
}

.target-word {
    padding: 6px 12px; 
    border: 2px solid var(--link-color);
    border-radius: 20px; /* More rounded */
    transition: all 0.3s ease;
    margin: 4px; /* More margin */
    font-size: var(--font-size-lg);
    color: var(--link-color);
    background-color: transparent;
}

.target-word.completed {
    background-color: var(--highlight-color); /* Yellow fill */
    color: var(--background-color); /* Dark text */
    border-color: var(--highlight-color);
}

/* --- Inventory --- */
.inventory {
    margin-top: 5px;
    padding: 5px 0;
    border-top: 1px solid var(--border-color);
    font-family: var(--font-sans);
    color: var(--secondary-text-color);
}

.inventory-scroll {
    display: flex;
    overflow-x: auto;
    gap: 10px; /* Increased gap */
    padding-bottom: 15px; /* More padding for scrollbar */
    -webkit-overflow-scrolling: touch;
}

.inventory-scroll::-webkit-scrollbar {
    height: 7px; /* Thicker scrollbar */
}

.inventory-scroll::-webkit-scrollbar-track {
    background: var(--card-background); /* Darker track */
    border-radius: 10px;
}

.inventory-scroll::-webkit-scrollbar-thumb {
    background: var(--secondary-text-color); /* Subtle scrollbar color */
    border-radius: 10px;
}

.slot {
    /* Adjust these values to make the boxes smaller */
    border: 2px solid var(--secondary-text-color); /* 边框样式 */
    border-radius: 20px; 
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1px; /* Reduced padding to fit smaller box */
    position: relative;
    flex-shrink: 0;
    background-color: transparent;
    transition: all 0.2s ease;
    font-family: var(--font-sans);
    color: var(--text-color);
    font-size: var(--font-size-lg); 
    cursor: pointer;
}


.slot.filled {
    background-color: rgba(var(--link-color), 0.1); /* Subtle blue tint */
    border-color: var(--link-color);
}

.slot.selected {
    background-color: rgba(var(--link-color), 0.4); /* Stronger blue tint */
    border-color: var(--link-color);
}

.delete-word {
    position: absolute;
    top: -8px; /* Adjusted position */
    right: -8px; /* Adjusted position */
    width: 24px; /* Larger delete button */
    height: 24px;
    background-color: var(--danger-color); /* Red */
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 14px; /* Larger font */
    cursor: pointer;
    display: none;
    line-height: 1; /* Center X */
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.slot:hover .delete-word {
    display: flex; /* Use flex to center 'x' */
    align-items: center;
    justify-content: center;
}

/* --- Controls --- */
.controls {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
    padding: 15px 0;
    border-top: 1px solid var(--border-color);
}

.btn {
    padding: 10px 20px; /* More padding */
    background-color: var(--card-background); /* Dark button background */
    color: var(--text-color); /* Light text */
    border: 1px solid var(--border-color); /* Subtle border */
    border-radius: 5px;
    cursor: pointer;
    font-family: var(--font-sans);
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn:hover:not(:disabled) {
    background-color: var(--border-color); /* Lighter on hover */
    color: var(--text-color);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: var(--border-color); /* Maintain some background */
}

/* --- Ending Panel --- */
.ending-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.95); /* Darker overlay */
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px; /* More padding */
    z-index: 100;
    color: var(--text-color);
    font-family: var(--font-serif); /* Use serif font */
}

.ending-text {
    max-width: 600px; /* Wider text area */
    margin-bottom: 30px; /* More margin */
    line-height: 1.8; /* Increased line height for spacious feel */
    font-size: 20px; /* Larger base font size for story */
    font-family: var(--font-serif); /* Use serif font */
    color: var(--text-color)
}

.continue-btn {
    padding: 15px 30px; /* Larger button */
    background-color: var(--level-button-color); /* Blue button */
    color: var(--background-color); /* Dark text on button */
    border: none;
    border-radius: 25px; /* Pill shape */
    font-weight: var(--font-weight-bold);
    cursor: pointer;
    font-size: var(--font-size-md);
    transition: all 0.2s ease;
}

.continue-btn:hover {
    background-color: #0069d9; /* Darker blue on hover */
    transform: translateY(-2px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.full-story-view button {
    margin-top: 30px; /* More margin */
    width: auto; /* Auto width, not full width */
    padding: 10px 20px;
    background-color: var(--card-background);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    cursor: pointer;
    font-family: var(--font-serif);
    font-weight: 500;
    transition: all 0.2s ease;
}

.full-story-view button:hover {
    background-color: var(--border-color);
}

.full-story-view {
    max-height: 70vh; /* Taller view */
    overflow-y: auto;
    padding: 25px; /* More padding */
    background-color: rgba(0,0,0,0.4); /* More subtle background */
    border-radius: 8px;
    margin-bottom: 20px;
    color: var(--text-color);
    font-family: var(--font-serif); /* Serif for story text */
}

.full-story-view p {
    margin-bottom: 15px; /* More spacing */
    line-height: 1.7;
    font-size: var(--font-size-lg);
}

/* Hint Highlighting */
/* 提示 - 句子/字符高亮 */
.hint-sentence {
    background-color: var(--link-color);
    color: #000;
    padding: 0px 2px;
    border-radius: 0px;
    font-weight: bold;
    transition: background-color 0.3s;
    margin: 0 1px;
    z-index: 1;
}

/* Hint Tooltip */
#hint-tooltip {
    position: fixed;
    z-index: 1000;
    color: white;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 14px;
    max-width: 280px;
    text-align: center;
    pointer-events: none;
    animation: tooltip-fadeIn 0.3s ease-out;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    line-height: 1.5;
    backdrop-filter: blur(2px);
}

/* 第一层提示工具提示样式 */
#hint-tooltip.level-1 {
    background-color: rgba(70, 130, 180, 0.9); /* 蓝色 */
    border-left: 4px solid #4682b4;
}

/* 第二层提示工具提示样式 */
#hint-tooltip.level-2 {
    background-color: rgba(218, 165, 32, 0.9); /* 金色 */
    border-left: 4px solid #daa520;
}

#hint-tooltip .tooltip-content {
    position: relative;
}


@keyframes tooltip-fadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, 10px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

/* 移动端响应式 */
@media (max-width: 768px) {
    #hint-tooltip {
        font-size: 13px;
        padding: 8px 12px;
        max-width: 220px;
        left: 50% !important;
        right: unset !important;
        bottom: 70px !important;
        transform: translateX(-50%) !important;
    }
    
    #hint-tooltip .tooltip-content::after {
        top: auto;
        bottom: -10px;
    }
    
    #hint-tooltip.level-1 .tooltip-content::after {
        border-color: rgba(70, 130, 180, 0.9) transparent transparent transparent;
    }
    
    #hint-tooltip.level-2 .tooltip-content::after {
        border-color: rgba(218, 165, 32, 0.9) transparent transparent transparent;
    }
    
    .clickable-word.hint-highlight {
        padding: 1px 3px;
        font-size: 0.9em;
    }
    
    .hint-sentence {
        padding: 1px 2px;
        font-size: 0.95em;
    }
}

/* --- Media Queries (Mobile/Tablet) --- */
@media (min-width: 768px) {
    .inventory-scroll {
        flex-wrap: wrap;
        overflow-x: visible; /* No horizontal scrollbar on larger screens */
        justify-content: center;
        padding-bottom: 0; /* No extra padding for scrollbar */
    }
    
    .slot {
        min-width: 100px; /* Larger slots on desktop */
        height: 100px;
    }

 
}

@media (max-width: 767px) {
    body {
        padding: 10px;
    }

    .mode-selector {
        font-size: var(--font-size-xs);
    }

    #mode-select {
        background-color: var(--background-color);
        color: var(--text-color);
        border: 1px solid var(--link-color);
        padding: 5px 10px;
        font-size: var(--font-size-xs);
        border-radius: 5px;
    }

    .site-footer-simplified {
        font-size: 10px;
    }

    .story-container {
        margin-bottom: 15px;
        padding: 15px;
    }

    .story-content {
        padding: 20px;
        padding-bottom: 40px;
        font-size: var(--font-size-base);
    }

    .story-history {
        font-size: var(--font-size-base); 
    }

    .story-text {
        font-size: 17px;
    }

    #stage-indicator {
    font-size: var(--font-size-base);
    }

    .operations {
        flex-wrap: wrap;
        gap: 10px;
        margin: 5px 0;
        padding: 5px;
    }

    .operation-btn {
        width: 45px;
        height: 45px;
        font-size: 22px;
    }


    .target-word {
        font-size: var(--font-size-md);
    }

    .inventory {
        margin-top: 10px;
        padding: 5px 0;
    }

    .slot {
        min-width: 70px;
        height: 70px;
        border-radius: 10px;
        font-size: var(--font-size-md);
    }

    .delete-word {
        width: 20px;
        height: 20px;
        font-size: 10px;
        top: -5px;
        right: -5px;
    }

    .controls {
        margin-top: 15px;
        padding: 10px 0;
    }

    .btn {
        padding: 8px 15px;
        font-size: var(--font-size-sm);
    }

    .ending-panel {
        padding: 15px;
    }

    .ending-text {
        font-size: var(--font-size-base);
        margin-bottom: 20px;
    }

    .continue-btn {
        padding: 10px 20px;
        font-size: var(--font-size-base);
    }

    .full-story-view {
        padding: 15px;
        max-height: 60vh;
    }

    .full-story-view p {
        font-size: var(--font-size-base);
    }
}