@import url('https://fonts.googleapis.com/css2?family=ZCOOL+KuaiLe&display=swap');

* {
    box-sizing: border-box;
    user-select: none;
    -webkit-user-drag: none;
}
body {
    margin: 0;
    padding: 0;
    background-color: #222;
    font-family: 'Chewy', cursive, sans-serif;
    overflow: hidden;
}
#game-wrapper {
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-image: url('img/wood_bg.jpg');
    background-size: cover;
    background-position: center;
}
#game-container {
    width: 1920px;
    height: 1080px;
    position: relative;
    transform-origin: center center;
}
.notebook {
    position: absolute;
    top: 60px;
    left: 80px;
    right: 80px;
    bottom: 60px;
    background-color: #fff;
    border-radius: 10px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.4);
    display: flex;
    flex-direction: column;
}
.holes-container {
    position: absolute;
    top: 15px;
    left: 0;
    width: 100%;
    height: 40px;
    display: flex;
    justify-content: space-evenly;
    align-items: center;
}
.hole {
    width: 30px;
    height: 30px;
    background-image: url('img/wood_bg.jpg');
    background-attachment: fixed;
    background-size: cover;
    background-position: center;
    border-radius: 50%;
    box-shadow: inset 0 3px 6px rgba(0,0,0,0.6);
    position: relative;
}
.hole::after {
    content: '';
    position: absolute;
    top: -20px;
    left: 8px;
    width: 14px;
    height: 25px;
    background-image: url('img/wood_bg.jpg');
    background-attachment: fixed;
    background-size: cover;
    background-position: center;
    box-shadow: inset 0 3px 6px rgba(0,0,0,0.6);
}

#top-ui {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 60px 80px 20px 80px;
}
.ui-left {
    display: flex;
    gap: 15px;
    align-items: center;
}
.ui-center {
    flex-grow: 1;
    text-align: center;
}
#level-indicator {
    font-size: 36px;
    font-weight: bold;
    color: #fff;
    background-color: #ff4757;
    border: 4px solid #000;
    border-radius: 20px;
    padding: 10px 30px;
    box-shadow: 0 6px 0 #000;
    text-shadow: 2px 2px 0 rgba(0,0,0,0.3);
    display: inline-block;
    transform: rotate(-3deg);
    transition: transform 0.2s;
}
#level-indicator:hover {
    transform: rotate(0deg) scale(1.05);
}
.ui-right {
    display: flex;
    justify-content: flex-end;
    gap: 20px;
}
.action-btn {
    background-color: #fff;
    border: 4px solid #000;
    border-radius: 40px;
    padding: 5px 5px 5px 25px;
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 32px;
    font-weight: bold;
    box-shadow: 0 6px 0 #000;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
    color: #333;
}
.action-btn:active {
    transform: translateY(6px);
    box-shadow: 0 0 0 #000;
}
.action-btn.icon-only-btn {
    padding: 5px;
}
.icon-circle {
    font-size: 36px;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 4px solid #000;
}
.bg-yellow {
    background-color: #ffde59;
}
.bg-green {
    background-color: #70e000;
}
.ui-icon {
    width: 208%;
    height: 208%;
    object-fit: contain;
}

#level-title {
    font-size: 38px;
    text-align: center;
    margin: 25px auto 10px;
    color: #333;
    z-index: 10;
    position: relative;
    padding: 15px 40px;
    border-radius: 15px;
    border: 4px solid #000;
    width: max-content;
    max-width: 85%;
    line-height: 1.3;
    background-color: #fff9e6;
    box-shadow: 6px 6px 0px rgba(0,0,0,0.1);
}
#level-title::before {
    content: '';
    position: absolute;
    top: -12px;
    left: 20px;
    width: 20px;
    height: 20px;
    background-color: #ff4757;
    border-radius: 50%;
    border: 3px solid #000;
    box-shadow: 2px 2px 0 rgba(0,0,0,0.2);
}
#level-title::after {
    content: '';
    position: absolute;
    top: -12px;
    right: 20px;
    width: 20px;
    height: 20px;
    background-color: #1dd1a1;
    border-radius: 50%;
    border: 3px solid #000;
    box-shadow: 2px 2px 0 rgba(0,0,0,0.2);
}
.title-word {
    display: inline-block;
    cursor: grab;
    position: relative;
    color: #ef233c;
    border-bottom: 3px dashed #ef233c;
}
#game-area {
    width: 100%;
    flex: 1;
    position: relative;
    overflow: hidden;
    border-radius: 0 0 10px 10px;
}
.game-element {
    position: absolute;
    cursor: pointer;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    transition: transform 0.2s;
}
.draggable {
    cursor: grab;
}
.draggable:active {
    cursor: grabbing;
}
#cheer-screen, #hint-modal, #level-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
    border-radius: 0;
}
.hidden {
    display: none !important;
}
.modal-content {
    background: #fff9e6;
    padding: 80px 50px 40px;
    border-radius: 45px;
    width: 80%;
    max-width: 600px;
    text-align: center;
    box-shadow: 0 0 0 12px #ffcc80, 0 0 0 18px #ff9800, 0 30px 60px rgba(0,0,0,0.4);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 8px solid #fff;
    position: relative;
    margin-top: 50px;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.modal-title-banner {
    background: linear-gradient(to bottom, #ffb74d, #ff9800);
    position: absolute;
    top: -55px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 50px;
    padding: 15px 70px;
    border: 6px solid #fff;
    box-shadow: 0 8px 0 #e67e22, inset 0 -4px 0 rgba(255,255,255,0.4), 0 15px 25px rgba(0,0,0,0.2);
    z-index: 10;
}
.level-modal-content .modal-title-banner {
    background: linear-gradient(to bottom, #ffde59, #ffc400);
    border: 6px solid #fff;
    box-shadow: 0 8px 0 #f39c12, inset 0 -4px 0 rgba(255,255,255,0.5), 0 15px 25px rgba(0,0,0,0.2);
    top: -55px;
    padding: 15px 80px;
    border-radius: 50px;
    white-space: nowrap;
}
.modal-title-banner h3 {
    margin: 0 !important;
    color: #fff !important;
    font-size: 56px !important;
    letter-spacing: 2px !important;
    text-shadow: 3px 3px 0 rgba(0,0,0,0.2) !important;
}
.level-modal-content .modal-title-banner h3 {
    color: #fff !important;
    font-size: 60px !important;
    text-shadow: 0 4px 0 #d35400, 3px 3px 0 #d35400, -3px -3px 0 #d35400, 3px -3px 0 #d35400, -3px 3px 0 #d35400, 0 8px 15px rgba(0,0,0,0.3) !important;
    letter-spacing: 4px !important;
}
.level-modal-content {
    max-width: 900px;
    width: 90%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    padding: 110px 50px 40px;
    background-color: #fff9e6;
    border-radius: 45px;
    box-shadow: 0 0 0 12px #ffde59, 0 0 0 18px #f39c12, 0 30px 60px rgba(0,0,0,0.4);
    border: 8px solid #fff;
    position: relative;
    margin-top: 50px;
}
.level-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 25px;
    overflow-y: auto;
    padding: 10px 10px 20px 10px;
    flex: 1;
}
.level-grid::-webkit-scrollbar {
    width: 15px;
}
.level-grid::-webkit-scrollbar-track {
    background: #fff8e8; /* 和背景色一致 */
    border-radius: 10px;
    border: none;
}
.level-grid::-webkit-scrollbar-thumb {
    background: #ffde59; 
    border-radius: 10px;
    border: none;
}
.level-grid::-webkit-scrollbar-thumb:hover {
    background: #ffc400;
}
.level-btn {
    background: linear-gradient(to bottom, #6bc2ff, #3895e0);
    color: white;
    font-size: 46px;
    font-weight: bold;
    border: 4px solid #fff;
    border-radius: 24px;
    aspect-ratio: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 8px 0 #2a75d3, inset 0 -6px 0 rgba(0,0,0,0.15), inset 0 6px 0 rgba(255,255,255,0.4), 0 10px 15px rgba(0,0,0,0.2);
    transition: transform 0.1s, box-shadow 0.1s, filter 0.2s;
    font-family: inherit;
    text-shadow: 0 3px 0 rgba(0,0,0,0.2);
}
.level-btn:hover:not(.locked) {
    filter: brightness(1.1);
    transform: translateY(-4px);
    box-shadow: 0 12px 0 #2a75d3, inset 0 -6px 0 rgba(0,0,0,0.15), inset 0 6px 0 rgba(255,255,255,0.4), 0 15px 20px rgba(0,0,0,0.2);
}
.level-btn:active:not(.locked) {
    transform: translateY(4px);
    box-shadow: 0 4px 0 #2a75d3, inset 0 -4px 0 rgba(0,0,0,0.1), inset 0 4px 0 rgba(255,255,255,0.2), 0 5px 10px rgba(0,0,0,0.2);
}
.level-btn.locked {
    background: linear-gradient(to bottom, #e1e8f0, #c4cbd4);
    cursor: not-allowed;
    border: 4px solid #fff;
    box-shadow: 0 8px 0 #a5b1c2, inset 0 -6px 0 rgba(0,0,0,0.1), inset 0 6px 0 rgba(255,255,255,0.4);
    color: transparent;
}
.level-btn.locked span {
    display: none;
}
.level-btn.locked::after {
    content: "";
    width: 45px;
    height: 45px;
    background-image: url('img/icon_lock.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    display: block;
    opacity: 0.6; /* 让锁图标透一点点，更好看 */
}
.level-btn.completed {
    background: linear-gradient(to bottom, #98e84a, #76c024);
    box-shadow: 0 8px 0 #5f9e1e, inset 0 -6px 0 rgba(0,0,0,0.15), inset 0 6px 0 rgba(255,255,255,0.4), 0 10px 15px rgba(0,0,0,0.2);
    border: 4px solid #fff;
}
.level-btn.completed:hover {
    filter: brightness(1.1);
    transform: translateY(-4px);
    box-shadow: 0 12px 0 #5f9e1e, inset 0 -6px 0 rgba(0,0,0,0.15), inset 0 6px 0 rgba(255,255,255,0.4), 0 15px 20px rgba(0,0,0,0.2);
}
.level-btn.completed:active {
    transform: translateY(4px);
    box-shadow: 0 4px 0 #5f9e1e, inset 0 -4px 0 rgba(0,0,0,0.1), inset 0 4px 0 rgba(255,255,255,0.2), 0 5px 10px rgba(0,0,0,0.2);
}
.level-btn.current {
    background: linear-gradient(to bottom, #a4e857, #8be138);
    box-shadow: 0 8px 0 #5f9e1e, inset 0 -6px 0 rgba(0,0,0,0.15), inset 0 6px 0 rgba(255,255,255,0.4), 0 10px 15px rgba(0,0,0,0.2), 0 0 20px rgba(139, 225, 56, 0.6);
    animation: pulse-border 1.5s infinite;
    border: 4px solid #fff;
}
.level-btn.current:hover {
    filter: brightness(1.1);
    transform: translateY(-4px);
    box-shadow: 0 12px 0 #5f9e1e, inset 0 -6px 0 rgba(0,0,0,0.15), inset 0 6px 0 rgba(255,255,255,0.4), 0 15px 20px rgba(0,0,0,0.2), 0 0 25px rgba(139, 225, 56, 0.8);
}
.level-btn.current:active {
    transform: translateY(4px);
    box-shadow: 0 4px 0 #5f9e1e, inset 0 -4px 0 rgba(0,0,0,0.1), inset 0 4px 0 rgba(255,255,255,0.2), 0 5px 10px rgba(0,0,0,0.2);
}
@keyframes pulse-border {
    0% { transform: scale(1); filter: brightness(1); }
    50% { transform: scale(1.05); filter: brightness(1.2); }
    100% { transform: scale(1); filter: brightness(1); }
}
@keyframes popIn {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}
.close-x-btn {
    position: absolute;
    right: 25px;
    top: 25px;
    background: linear-gradient(135deg, #ff6b81 0%, #ff4757 100%);
    border: 5px solid #fff;
    border-radius: 50%;
    width: 65px;
    height: 65px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275), filter 0.15s, box-shadow 0.15s;
    padding: 14px;
    z-index: 20;
    box-shadow: 0 6px 0 #d63031, 0 10px 20px rgba(0,0,0,0.3);
}
.level-modal-content .close-x-btn {
    right: 35px;
    top: 35px;
    background: linear-gradient(135deg, #ff6b81 0%, #ff4757 100%);
    border: 5px solid #fff;
    box-shadow: 0 6px 0 #d63031, 0 10px 20px rgba(0,0,0,0.3);
    padding: 14px;
    width: 65px;
    height: 65px;
    border-radius: 50%;
    z-index: 20;
}
.close-x-btn img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 2px 2px rgba(0,0,0,0.2));
}
.close-x-btn:hover {
    transform: translateY(-2px) scale(1.05);
    filter: brightness(1.1);
}
.close-x-btn:active {
    transform: translateY(4px) scale(0.95);
    box-shadow: 0 2px 0 #d63031, 0 4px 10px rgba(0,0,0,0.2);
}
.hint-icon-container {
    width: 100%;
    height: 100%;
    position: relative;
    top: -5px;
}
.hint-title-text {
    text-shadow: 2px 2px 0 rgba(0,0,0,0.1);
}
.hint-text-box {
    background-color: #fff;
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: inset 0 5px 15px rgba(0,0,0,0.05);
    width: 100%;
    box-sizing: border-box;
}
.modal-content h3 {
    margin-top: 0;
    color: #ff9800;
    font-size: 64px;
    letter-spacing: 2px;
}
.modal-content p {
    font-size: 32px;
    line-height: 1.5;
    color: #555;
    margin: 0;
}
#close-hint-btn, #next-btn {
    padding: 16px 70px;
    font-size: 36px;
    background-color: #5dade2;
    color: white;
    border: none;
    border-radius: 40px;
    cursor: pointer;
    font-weight: normal;
    box-shadow: 0 10px 20px rgba(93, 173, 226, 0.4);
    transition: transform 0.1s, box-shadow 0.1s, background-color 0.1s;
    font-family: inherit;
    letter-spacing: 1px;
}
#close-hint-btn:active, #next-btn:active {
    transform: translateY(4px);
    box-shadow: 0 5px 10px rgba(93, 173, 226, 0.4);
}
#close-hint-btn:hover, #next-btn:hover {
    background-color: #4ca1d6;
}
#cheer-screen h1 {
    color: white;
    font-size: 96px;
    text-shadow: 0 6px 15px rgba(0,0,0,0.5);
    margin-bottom: 50px;
    animation: bounce 1s infinite alternate;
}
@keyframes bounce {
    0% { transform: translateY(0); }
    100% { transform: translateY(-30px); }
}

#ribbon-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 90;
}

.keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
    width: 500px;
    position: absolute;
    left: 630px;
    top: 200px;
}
.key {
    background: #edf2f4;
    padding: 30px;
    text-align: center;
    font-size: 48px;
    font-weight: bold;
    color: #2b2d42;
    border-radius: 20px;
    cursor: pointer;
    box-shadow: 0 8px 0 #8d99ae;
    transition: transform 0.1s, box-shadow 0.1s;
}
.key:active {
    transform: translateY(8px);
    box-shadow: 0 0 0 #8d99ae;
}
.sea-level {
    position: absolute;
    bottom: -60px;
    left: -80px;
    width: calc(100% + 160px);
    background: linear-gradient(to bottom, #48cae4 0%, #0077b6 100%);
    height: 250px;
    z-index: 5;
    border-top: 5px solid #90e0ef;
    cursor: n-resize;
    border-radius: 0 0 10px 10px;
}
.fuse {
    width: 20px;
    height: 250px;
    background: repeating-linear-gradient(45deg, #d62828, #d62828 15px, #f77f00 15px, #f77f00 30px);
    position: absolute;
    left: 980px;
    top: 50px;
    z-index: 1;
    border-radius: 10px;
    cursor: pointer;
}

@media screen and (max-width: 1560px) {
    .notebook {
        left: -120px;
        right: -120px;
    }
    .level-modal-content {
        transform: scale(0.8);
        transform-origin: center center;
    }
    .modal-content {
        animation: popInLaptop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    }
    .close-x-btn {
        right: 40px !important;
        top: 40px !important;
    }
    .level-modal-content .close-x-btn {
        right: 40px !important;
        top: 40px !important;
    }
}

@keyframes popInLaptop {
    0% { transform: scale(0.64); opacity: 0; }
    100% { transform: scale(0.8); opacity: 1; }
}

#toast-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.toast {
    background-color: #fff;
    color: #333;
    padding: 20px 40px;
    border-radius: 20px;
    border: 4px solid #ff4757;
    font-size: 32px;
    font-weight: bold;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    max-width: 80%;
    line-height: 1.4;
    text-shadow: none;
    letter-spacing: normal;
    pointer-events: none;
    width: max-content;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, calc(-50% - 150px)); /* 直接用 transform 来定位，避免 margin 和 translate 的动画冲突 */
    opacity: 0;
}
.toast.show {
    animation: toastPopIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards, toastFadeOut 0.3s ease-out 2.7s forwards;
    opacity: 1;
}
.toast.hidden {
    display: none !important;
}

@keyframes toastPopIn {
    0% { transform: translate(-50%, calc(-50% - 180px)) scale(0.8); opacity: 0; }
    100% { transform: translate(-50%, calc(-50% - 150px)) scale(1); opacity: 1; }
}

@keyframes toastFadeOut {
    0% { transform: translate(-50%, calc(-50% - 150px)) scale(1); opacity: 1; }
    100% { transform: translate(-50%, calc(-50% - 180px)) scale(0.8); opacity: 0; }
}