* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: "PingFang TC", "Heiti TC", "Microsoft JhengHei", sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100vw;
    height: 100vh;
    padding: 5vw;
}

.game-title {
    font-size: clamp(24px, 7vw, 40px);
    color: #fff;
    margin-bottom: 3vh;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.grid-wrapper {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 4vw;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    position: relative;
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2vw;
    width: 80vw;
    max-width: 400px;
    height: 80vw;
    max-height: 400px;
    position: relative;
}

.grid-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(20px, 7vw, 36px);
    font-weight: bold;
    color: #333;
    background: #f8f9fa;
    border-radius: 12px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid #e9ecef;
    user-select: none;
    width: 100%;
    height: 100%;
}

.grid-cell.selected {
    background: #ffd43b;
    color: #222;
    border-color: #f08c00;
    transform: scale(1.05);
}

.grid-cell.empty {
    opacity: 0.35;
    background: rgba(248, 249, 250, 0.55);
    border-style: dashed;
}

.grid-cell.first-char-hint {
    background: linear-gradient(135deg, #fff3bf 0%, #ffd43b 100%);
    color: #1f2933;
    border-color: #f08c00;
    box-shadow: 0 0 18px rgba(255, 212, 59, 0.9);
    animation: hintGlow 1s ease-in-out infinite;
}

.grid-cell.sequence-hint {
    background: linear-gradient(135deg, #63e6be 0%, #20c997 100%);
    color: #fff;
    border-color: #087f5b;
    box-shadow: 0 0 22px rgba(32, 201, 151, 0.95);
    animation: sequenceHintPulse 0.7s ease-in-out infinite;
}

.grid-cell.star-vanish {
    background: linear-gradient(135deg, #ffd43b 0%, #ff922b 100%);
    color: #fff;
    border-color: #ffd43b;
    animation: starVanish 0.42s ease forwards;
}

.grid-cell.falling {
    animation: gravityDrop 0.36s cubic-bezier(0.18, 0.82, 0.28, 1.08);
}

.grid-cell.new-char {
    background: #e7f5ff;
    border-color: #4dabf7;
    animation: refillDrop 0.42s cubic-bezier(0.18, 0.82, 0.28, 1.08);
}

@keyframes starVanish {
    0% { transform: scale(1); opacity: 1; }
    45% { transform: scale(1.25) rotate(12deg); opacity: 1; }
    100% { transform: scale(0.15) rotate(-18deg); opacity: 0; }
}

@keyframes gravityDrop {
    0% { transform: translateY(calc(var(--drop-distance, 118%) * -1)); opacity: 0.78; }
    72% { transform: translateY(5%); opacity: 1; }
    100% { transform: translateY(0); opacity: 1; }
}

@keyframes refillDrop {
    0% { transform: translateY(calc(var(--drop-distance, 236%) * -1)) scale(0.92); opacity: 0; }
    72% { transform: translateY(6%) scale(1); opacity: 1; }
    100% { transform: translateY(0) scale(1); opacity: 1; }
}

.controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 3vw;
    margin-top: 4vh;
}

.btn {
    padding: 3vw 6vw;
    font-size: clamp(16px, 4.5vw, 20px);
    font-weight: 600;
    color: #fff;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50px;
    cursor: pointer;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.btn:active {
    transform: translateY(0);
}

.btn.hint {
    background: linear-gradient(135deg, #ffb347 0%, #ffcc33 100%);
    border: none;
}

.btn.clear {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    border: none;
}

.btn.reset {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    border: none;
}

.message {
    margin-top: 3vh;
    font-size: clamp(14px, 4vw, 18px);
    color: #fff;
    text-align: center;
    line-height: 1.5;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.message.success {
    font-size: clamp(16px, 4.5vw, 22px);
    font-weight: bold;
    animation: pulse 1s infinite;
}

@keyframes hintGlow {
    0%, 100% { transform: scale(1); box-shadow: 0 0 14px rgba(255, 212, 59, 0.75); }
    50% { transform: scale(1.05); box-shadow: 0 0 24px rgba(255, 212, 59, 1); }
}

@keyframes sequenceHintPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}
