* {
    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, #7b68ee 0%, #9370db 100%);
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    width: 100vw;
    height: 100vh;
    padding: 3vh 4vw;
    gap: 1.2vh;
}

.direction-hint,
.progress {
    font-size: clamp(14px, 4.3vw, 21px);
    color: #fff;
    font-weight: bold;
    background: rgba(255,255,255,0.2);
    padding: 0.8vw 3vw;
    border-radius: 12px;
    text-shadow: 1px 1px 4px rgba(0,0,0,0.2);
}

.progress {
    font-size: clamp(13px, 3.8vw, 18px);
}

.grid-wrapper {
    background: rgba(255, 255, 255, 0.98);
    border-radius: 20px;
    padding: 3vw;
    box-shadow: 0 12px 45px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.8);
    position: relative;
}

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

.grid-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(18px, 6.5vw, 34px);
    font-weight: bold;
    color: #333;
    background: #fefefe;
    border-radius: 14px;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 2px solid #f0f0f0;
    user-select: none;
    width: 100%;
    height: 100%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.grid-cell.fixed {
    background: #4096ff;
    color: #fff;
    cursor: not-allowed;
    border-color: #3088ff;
    box-shadow: 0 4px 12px rgba(64, 150, 255, 0.3);
}

.grid-cell.filled {
    background: #fff;
    border-color: #d0d0d0;
    cursor: grab;
}

.grid-cell.completed-0 { background: linear-gradient(135deg, #52c41a 0%, #73d13d 100%); color: #fff; border-color: #52c41a; box-shadow: 0 0 18px rgba(82, 196, 26, 0.55); animation: celebrate 0.6s ease-out; }
.grid-cell.completed-1 { background: linear-gradient(135deg, #fa8c16 0%, #ffa940 100%); color: #fff; border-color: #fa8c16; box-shadow: 0 0 18px rgba(250, 140, 22, 0.55); animation: celebrate 0.6s ease-out; }
.grid-cell.completed-2 { background: linear-gradient(135deg, #13c2c2 0%, #36cfc9 100%); color: #fff; border-color: #13c2c2; box-shadow: 0 0 18px rgba(19, 194, 194, 0.55); animation: celebrate 0.6s ease-out; }
.grid-cell.completed-3 { background: linear-gradient(135deg, #eb2f96 0%, #f759ab 100%); color: #fff; border-color: #eb2f96; box-shadow: 0 0 18px rgba(235, 47, 150, 0.55); animation: celebrate 0.6s ease-out; }

.floating-cell {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(18px, 6.5vw, 34px);
    font-weight: bold;
    color: #333;
    background: #fefefe;
    border-radius: 14px;
    border: 2px solid #f0f0f0;
    z-index: 999;
    pointer-events: none;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    transform: scale(1.08);
}

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

.pool-wrapper {
    width: 88vw;
    max-width: 430px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 18px;
    padding: 2.5vw 3vw;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
}

.pool-title {
    text-align: center;
    font-size: clamp(13px, 3.8vw, 17px);
    color: #666;
    margin-bottom: 1.5vh;
    font-weight: 50;
}

.word-pool {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 1.8vw;
    justify-items: center;
}

.pool-cell {
    width: clamp(35px, 11vw, 60px);
    height: clamp(35px, 11vw, 60px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(16px, 5.5vw, 30px);
    font-weight: bold;
    color: #fff;
    background: linear-gradient(135deg, #69b1ff 0%, #4096ff 100%);
    border-radius: 10px;
    cursor: grab;
    box-shadow: 0 4px 10px rgba(64, 150, 255, 0.3);
    user-select: none;
    transition: transform 0.2s;
}

.pool-cell:active {
    transform: scale(0.95);
}

.pool-cell.used {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
}

.controls {
    display: flex;
    gap: 3.5vw;
}

.btn {
    padding: 2.5vw 5.5vw;
    font-size: clamp(15px, 4.2vw, 19px);
    font-weight: 600;
    color: #fff;
    background: rgba(255, 255, 255, 0.25);
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 50px;
    cursor: pointer;
    backdrop-filter: blur(12px);
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

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

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

.btn.reset {
    background: linear-gradient(135deg, #69b1ff 0%, #4096ff 100%);
    border: none;
}

.message {
    font-size: clamp(13px, 3.8vw, 17px);
    color: #fff;
    text-align: center;
    line-height: 1.4;
    text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.2);
    padding: 0.8vw 3vw;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.1);
}

.message.success {
    font-size: clamp(15px, 4.2vw, 21px);
    font-weight: bold;
    animation: pulse 1.2s infinite;
    background: rgba(82, 196, 26, 0.3);
}

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