/* 小小想象家 - 儿童想象力联想游戏样式 */
:root {
    --primary-color: #4cc9f0;
    --secondary-color: #f72585;
    --accent-color: #4cc9f0;
    --background-color: #f8f9ff;
    --text-color: #333;
    --light-gray: #f0f0f0;
    --border-radius: 12px;
    --box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    --font-family: 'Comic Sans MS', cursive, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    padding: 20px;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background-color: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    text-align: center;
    padding: 30px 20px;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

header p {
    font-size: 1.2rem;
    opacity: 0.9;
}

main {
    padding: 30px;
}

.game-area {
    background-color: var(--light-gray);
    border-radius: var(--border-radius);
    padding: 25px;
    margin-bottom: 30px;
}

/* 魔法词区域逻辑已移至 word-container */


/* 拼音样式优化 */
ruby {
    ruby-align: center;
}

rt {
    font-size: 0.9rem;
    color: var(--secondary-color);
    -webkit-text-fill-color: var(--secondary-color); /* 覆盖父元素的透明设置 */
    letter-spacing: 2px;
    margin-bottom: 4px;
}

.instruction {
    font-size: 1.3rem;
    text-align: center;
    margin-bottom: 25px;
    color: var(--text-color);
    line-height: 1.6;
    padding: 0 20px;
    background-color: rgba(255, 255, 255, 0.7);
    border-radius: 8px;
}

.example-box {
    margin-top: 15px;
    padding: 12px;
    background-color: rgba(255, 255, 255, 0.5);
    border-radius: 12px;
    font-size: 0.95rem;
    color: #666;
    text-align: left;
    border-left: 4px solid var(--accent-color);
}

.input-area {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

textarea {
    width: 100%;
    min-height: 120px;
    padding: 15px;
    border: 2px solid var(--light-gray);
    border-radius: var(--border-radius);
    font-size: 1.1rem;
    resize: vertical;
    transition: border-color 0.3s;
    font-family: var(--font-family);
}

textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(76, 201, 240, 0.2);
}

.button-group {
    display: flex;
    gap: 10px;
    justify-content: center;
}

button {
    flex: 1;
    padding: 15px 20px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: var(--font-family);
}

.primary-btn {
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    color: white;
}

.primary-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(76, 201, 240, 0.3);
}

.secondary-btn {
    background-color: var(--light-gray);
    color: var(--text-color);
    border: 2px solid var(--primary-color);
}

.secondary-btn:hover {
    background-color: var(--primary-color);
    color: white;
    transform: translateY(-3px);
}

.feedback {
    margin-top: 20px;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    font-weight: bold;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.feedback.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.feedback.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.feedback.info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* 反馈内容布局 */
.feedback-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    width: 100%;
}

.feedback-text {
    font-size: 1.1rem;
    line-height: 1.6;
}

/* 图像加载中状态 */
.image-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 20px;
    color: #888;
    font-size: 0.95rem;
    font-weight: normal;
}

.image-loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e0e0e0;
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 反馈区图像 */
.feedback-image-container {
    width: 100%;
    display: flex;
    justify-content: center;
}

.feedback-image {
    width: 100%;
    max-width: 400px;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(76, 201, 240, 0.3);
    border: 3px solid var(--primary-color);
    animation: fadeInScale 0.5s ease;
    display: block;
}

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

/* 历史记录图片 */
.history-image-container {
    margin-top: 10px;
    display: flex;
    justify-content: center;
}

.history-image {
    width: 100%;
    max-width: 260px;
    border-radius: 10px;
    border: 2px solid var(--primary-color);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    display: block;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.history-image:hover {
    transform: scale(1.03);
    box-shadow: 0 8px 20px rgba(76, 201, 240, 0.35);
}

/* 历史记录AI反馈样式 */
.history-ai-feedback {
    margin-left: 20px;
    margin-top: 6px;
    color: #155724;
    font-size: 0.95rem;
    line-height: 1.5;
    padding: 8px 12px;
    background-color: #d4edda;
    border-radius: 6px;
}

.history-area {
    background-color: var(--light-gray);
    border-radius: var(--border-radius);
    padding: 25px;
}

.history-area h2 {
    text-align: center;
    margin-bottom: 20px;
    color: var(--secondary-color);
}

.history-list {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 20px;
    padding-right: 10px;
}

.history-item {
    background-color: white;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    border-left: 4px solid var(--primary-color);
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.word-container {
    display: flex !important;
    flex-direction: row !important; /* 强制水平排列 */
    align-items: center;
    justify-content: center;
    gap: 30px;
    margin: 30px 0 50px 0;
    width: 100%;
}

.word-main {
    flex: 0 0 auto; /* 词语区大小固定，不随内容收缩 */
    display: flex !important;
    flex-direction: column !important; /* 词语和按钮上下排 */
    align-items: center !important;
    justify-content: center;
    gap: 15px;
    border: 3px dashed var(--primary-color);
    padding: 25px 40px;
    border-radius: 20px;
    background-color: rgba(255, 255, 255, 0.6);
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

.magic-word {
    font-size: 4.5rem;
    color: var(--primary-color);
    margin: 0;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.1);
    line-height: 1.1;
}

.mini-btn {
    width: 120px;
    padding: 8px 0;
    font-size: 0.95rem;
    border-radius: 20px;
    flex: none !important;
}

.parent-tip {
    flex: 1; /* 贴士区占据剩余空间 */
    max-width: 450px; /* 限制最大宽度防止过长撑破布局 */
    min-width: 280px;
    font-size: 1.05rem;
    color: #555;
    background-color: #fff;
    padding: 20px 25px;
    border-radius: 20px;
    text-align: left;
    border: 3px solid #ff4d6d;
    box-shadow: 0 8px 20px rgba(0,0,0,0.08);
    line-height: 1.7;
    position: relative;
    align-self: flex-start; /* 贴士从顶部对齐 */
    margin-top: 10px;
}

/* 只有在极窄的手机屏幕上（小于 768px）才允许堆叠 */
@media (max-width: 768px) {
    .word-container {
        flex-direction: column !important;
        gap: 20px;
    }
    .parent-tip {
        max-width: 90%;
        min-width: unset;
        align-self: center;
        margin-top: 0;
    }
}



.parent-tip::before {
    content: "📌 家长贴士：";
    font-weight: bold;
    color: #ff4d6d;
    margin-bottom: 8px;
    display: block;
}


/* 移动端适配：改为上下排列且居中 */
@media (max-width: 600px) {
    .word-container {
        flex-direction: column;
        gap: 15px;
    }
    .magic-word {
        font-size: 3rem;
    }
    .parent-tip {
        max-width: 90%;
        text-align: center;
        border-left: none;
        border-top: 5px solid var(--secondary-color);
    }
}


.history-word {
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 8px;
    display: block;
    font-size: 1.1rem;
}

.history-response {
    margin-left: 20px;
    color: var(--text-color);
    line-height: 1.5;
}

.clear-btn {
    width: 100%;
    padding: 12px;
    background-color: #ff9800;
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: var(--font-family);
}

.clear-btn:hover {
    background-color: #f57c00;
    transform: translateY(-2px);
}

footer {
    text-align: center;
    padding: 20px;
    color: #666;
    font-size: 0.9rem;
    border-top: 1px solid var(--light-gray);
}

/* 双图容器布局 */
.dual-image-container {
    display: flex;
    gap: 15px;
    margin-top: 15px;
}

.image-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.image-label {
    font-size: 0.9rem;
    color: var(--secondary-color);
    font-weight: bold;
    background: #fff;
    padding: 2px 10px;
    border-radius: 20px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.regen-btn {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid var(--secondary-color);
    color: var(--secondary-color);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.regen-btn:hover:not(:disabled) {
    background: var(--secondary-color);
    color: white;
    transform: scale(1.05);
}

.regen-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.regen-btn.rotating::before {
    content: "";
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: rotate 1s linear infinite;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.img-wrapper {
    width: 100%;
    min-height: 180px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 2px dashed rgba(255, 107, 107, 0.2);
}

.feedback-image {
    width: 100%;
    height: auto;
    cursor: zoom-in;
    transition: transform 0.3s ease;
}

.feedback-image:hover {
    transform: scale(1.02);
}

/* 历史记录双图布局 */
.history-dual-images {
    display: flex;
    gap: 12px;
    margin-top: 12px;
}

.hist-img-box {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.history-image {
    width: 100%;
    max-height: 120px; /* 限制足迹图片高度，不再显得突兀 */
    object-fit: cover; /* 保证裁剪后依然美观 */
    border-radius: 8px;
    box-shadow: 0 4px 8px var(--shadow-color);
    cursor: zoom-in;
    transition: transform 0.2s;
}

.history-image:hover {
    transform: scale(1.03);
}

.hist-img-box small {
    margin-top: 6px;
    color: #888;
    font-size: 0.75rem;
}

.img-error {
    color: #999;
    font-size: 0.85rem;
    text-align: center;
}

/* ===== Lightbox 图片放大灯箱 ===== */
.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    animation: lightboxFadeIn 0.25s ease forwards;
    cursor: zoom-out;
}

@keyframes lightboxFadeIn {
    to { opacity: 1; }
}

.lightbox-overlay.closing {
    animation: lightboxFadeOut 0.2s ease forwards;
}

@keyframes lightboxFadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

.lightbox-img {
    max-width: 90vw;
    max-height: 88vh;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    border: 3px solid rgba(76, 201, 240, 0.6);
    transform: scale(0.85);
    animation: lightboxZoomIn 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    cursor: default;
    user-select: none;
}

@keyframes lightboxZoomIn {
    to { transform: scale(1); }
}

.lightbox-close {
    position: fixed;
    top: 20px;
    right: 24px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    border: 2px solid rgba(255, 255, 255, 0.4);
    color: white;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
    z-index: 10000;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: scale(1.1) rotate(90deg);
}

/* 可点击图片加放大镜光标 */
.feedback-image,
.history-image {
    cursor: zoom-in;
}

/* 响应式设计 */

/* 攻略模态框样式 */
.more-link {
    color: var(--primary-color);
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    text-decoration: underline;
    margin-left: 10px;
    transition: color 0.3s;
}

.more-link:hover {
    color: var(--secondary-color);
}

.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    overflow-y: auto;
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 30px;
    border-radius: 20px;
    width: 85%;
    max-width: 700px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    position: relative;
    animation: slideIn 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes slideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.close-guide {
    color: #aaa;
    position: absolute;
    right: 25px;
    top: 15px;
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
}

.close-guide:hover {
    color: var(--primary-color);
}

.guide-body h2 {
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 25px;
}

.guide-body h3 {
    color: var(--secondary-color);
    border-bottom: 2px solid #eee;
    padding-bottom: 5px;
    margin-top: 20px;
}

.guide-body p, .guide-body ul {
    color: #555;
    line-height: 1.8;
    margin: 10px 0;
}

.guide-body ul {
    padding-left: 20px;
}

.guide-body li {
    margin-bottom: 8px;
}

/* 欢迎弹窗特定样式 */
.welcome-content {
    text-align: center;
    border: 4px solid var(--accent-light);
}

.welcome-body {
    padding: 20px 0;
}

#user-name-input {
    width: 100%;
    max-width: 300px;
    padding: 12px 20px;
    margin: 20px 0;
    border: 2px solid #ddd;
    border-radius: 25px;
    font-size: 1.2rem;
    text-align: center;
    font-family: inherit;
    outline: none;
    transition: border-color 0.3s;
}

#user-name-input:focus {
    border-color: var(--primary-color);
}

.agreement-area {
    margin: 15px 0 25px 0;
    font-size: 0.9rem;
    color: #666;
}

.terms-details {
    margin-top: 20px;
    background: #f9f9f9;
    padding: 15px;
    border-radius: 10px;
    text-align: left;
    max-height: 200px;
    overflow-y: auto;
    font-size: 0.85rem;
    border: 1px inset #eee;
}

/* 自定义复选框 */
.checkbox-container {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    gap: 8px;
}

.checkmark {
    width: 20px;
    height: 20px;
    border: 2px solid var(--primary-color);
    border-radius: 4px;
    position: relative;
    display: inline-block;
}

.checkbox-container input:checked ~ .checkmark {
    background-color: var(--primary-color);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.checkbox-container input:checked ~ .checkmark:after {
    display: block;
}

.checkbox-container input {
    display: none;
}

/* 按钮脉冲效果 */
.pulse {
    animation: pulse-animation 2s infinite;
}

@keyframes pulse-animation {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(76, 201, 240, 0.4); }
    70% { transform: scale(1.05); box-shadow: 0 0 0 10px rgba(76, 201, 240, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(76, 201, 240, 0); }
}

#start-game-btn:disabled {
    animation: none;
    background-color: #ccc;
    cursor: not-allowed;
}