:root {
    --primary-color: #FF9966;
    --secondary-color: #FFCC99;
    --accent-color: #FF3333;
    --bg-start: #FFF5E6;
    --bg-end: #FFE4C4;
    --text-color: #5D4037;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

body {
    font-family: "Microsoft YaHei", sans-serif;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle, var(--bg-start), var(--bg-end));
}

#app {
    width: 100%;
    height: 100%;
    position: relative;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: opacity 0.3s;
}

.screen.hidden {
    display: none;
    opacity: 0;
    pointer-events: none;
}

.screen.active {
    display: flex;
    opacity: 1;
    pointer-events: all;
}

.btn-group {
    display: flex;
    gap: 20px;
    justify-content: center;
}

.hidden {
    display: none !important;
}

/* Start Screen */
#start-screen {
    z-index: 10;
}

#snow-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
}

.title {
    font-size: 3rem;
    color: var(--accent-color);
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
    margin-bottom: 2rem;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0px); }
}

.primary-btn {
    background-color: var(--accent-color);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.5rem;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.primary-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 8px rgba(0,0,0,0.15);
}

.primary-btn:active {
    transform: scale(0.95);
}

/* Game Screen */
#game-screen {
    justify-content: flex-start;
    padding-top: 20px;
}

.header, .footer {
    width: 90%;
    max-width: 600px;
    display: flex;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.6);
    padding: 10px 20px;
    border-radius: 15px;
    margin-bottom: 20px;
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--text-color);
}

.style-select {
    display: flex;
    align-items: center;
    gap: 8px;
}

#style-select {
    padding: 4px 8px;
    border-radius: 8px;
    border: 1px solid rgba(0,0,0,0.1);
    background: #fff;
    font-size: 1rem;
}

#game-board-container {
    width: 90vw;
    height: 90vw;
    max-width: 600px;
    max-height: 600px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    padding: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-board {
    position: relative;
    width: 100%;
    height: 100%;
}

.grid-background {
    display: grid;
    width: 100%;
    height: 100%;
    gap: 4px;
}

.grid-cell {
    background: rgba(255, 255, 255, 0.5);
    border-radius: 8px;
    cursor: pointer;
}

.grid-cell.selected {
    background: rgba(255, 255, 255, 0.8);
    box-shadow: 0 0 10px var(--accent-color);
}

.element {
    position: absolute;
    width: calc(100% / var(--grid-size) - 4px);
    height: calc(100% / var(--grid-size) - 4px);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    transition: top 0.3s ease-out, left 0.3s ease-out, transform 0.3s;
    border-radius: 50%;
    pointer-events: none; /* Let clicks pass through to grid cells */
    z-index: 10;
}

.element svg {
    width: 100%;
    height: 100%;
}

/* Animations */
@keyframes shake {
    0% { transform: translate(1px, 1px) rotate(0deg); }
    10% { transform: translate(-1px, -2px) rotate(-1deg); }
    20% { transform: translate(-3px, 0px) rotate(1deg); }
    30% { transform: translate(3px, 2px) rotate(0deg); }
    40% { transform: translate(1px, -1px) rotate(1deg); }
    50% { transform: translate(-1px, 2px) rotate(-1deg); }
    60% { transform: translate(-3px, 1px) rotate(0deg); }
    70% { transform: translate(3px, 1px) rotate(-1deg); }
    80% { transform: translate(-1px, -1px) rotate(1deg); }
    90% { transform: translate(1px, 2px) rotate(0deg); }
    100% { transform: translate(1px, -2px) rotate(-1deg); }
}

.shake {
    animation: shake 0.5s;
}

/* Responsive */
@media (min-width: 768px) {
    #game-board-container {
        width: 600px;
        height: 600px;
    }
}
