* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none; /* Prevent text selection during gameplay */
}

body {
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    background-color: #ffe6ea; /* 浅粉色底色 */
    background-image: radial-gradient(#ffb6c1 15%, transparent 16%), radial-gradient(#ffb6c1 15%, transparent 16%);
    background-size: 40px 40px;
    background-position: 0 0, 20px 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: auto;
    overflow-y: hidden;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

#game-container {
    position: relative;
    width: 100%;
    max-width: 500px; /* Mobile max width */
    height: 100%;
    /* Keep 9:16 aspect ratio roughly by limiting width if needed, but handled mostly in JS */
    aspect-ratio: 9/16; 
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%); /* Light background for the game itself */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

@media (min-aspect-ratio: 9/16) {
    #game-container {
        height: 100%;
        width: auto;
    }
}
@media (max-aspect-ratio: 9/16) {
    #game-container {
        width: 100%;
        height: auto;
    }
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Let clicks pass through */
    display: flex;
    justify-content: center;
    align-items: center;
}

#debug-panel {
    position: absolute;
    top: 50px;
    right: 10px;
    background: rgba(25, 25, 35, 0.85);
    color: #eee;
    padding: 15px;
    border-radius: 10px;
    pointer-events: auto;
    font-size: 14px;
    backdrop-filter: blur(5px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    z-index: 100;
}

#debug-panel.hidden {
    display: none;
}

#debug-panel h3 {
    margin-bottom: 10px;
    font-size: 16px;
    color: #fff;
    border-bottom: 1px solid #555;
    padding-bottom: 5px;
}

.control-group {
    margin-bottom: 12px;
}

.control-group label {
    display: block;
    margin-bottom: 5px;
}

.control-group input[type="range"] {
    width: 100%;
}

.switch-group label {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.switch-group input {
    margin-right: 8px;
    transform: scale(1.2);
}

.buttons {
    display: flex;
    gap: 8px;
    margin-top: 15px;
}

.buttons button {
    flex: 1;
    padding: 6px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    background: #4a4a6a;
    color: white;
    font-weight: bold;
}

.buttons button:hover {
    background: #5a5a8a;
}

#btn-save {
    background: #28a745;
}
#btn-save:hover {
    background: #218838;
}

#win-popup {
    background: rgba(255, 255, 255, 0.9);
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 15px 35px rgba(0,0,0,0.2);
    pointer-events: auto; /* Catch clicks on the popup */
    transform: scale(0.8);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#win-popup:not(.hidden) {
    transform: scale(1);
    opacity: 1;
}

.hidden {
    display: none !important;
}

#win-popup h1 {
    color: #e94560;
    font-size: 28px;
    margin-bottom: 15px;
}

#win-popup p {
    color: #333;
    font-size: 18px;
    margin-bottom: 25px;
}

#btn-restart {
    background: #e94560;
    color: white;
    border: none;
    padding: 12px 25px;
    font-size: 16px;
    border-radius: 30px;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(233, 69, 96, 0.4);
    transition: background 0.2s, transform 0.1s;
}

#btn-restart:hover {
    background: #ff5e7b;
}

#btn-restart:active {
    transform: scale(0.95);
}
