:root {
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --text-color: #f8fafc;
    --accent-color: #38bdf8;
    --success-color: #22c55e;
    --error-color: #ef4444;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow: hidden;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

#game-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

.header {
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(8px);
    z-index: 10;
}

.stats {
    display: flex;
    gap: 1.5rem;
    font-weight: bold;
}

.grid-wrapper {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    overflow: auto;
}

.game-grid {
    display: grid;
    gap: clamp(2px, 1vw, 8px); /* Thu hẹp khoảng cách khi màn hình nhỏ */
    margin: auto;
    width: 100%;
    max-width: min(90vw, 70vh); /* Đảm bảo luôn lọt trong màn hình dọc và ngang */
}

.cell {
    width: 100%;
    aspect-ratio: 1 / 1;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: min(1.4rem, 4vw); /* Co giãn font chữ theo màn hình */
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s;
    position: relative;
    min-width: 0; /* Cho phép co lại dưới kích thước nội dung */
}

.cell:active {
    transform: scale(0.9);
}

/* Shapes */
.shape-square {
    background-color: var(--card-bg);
    border-radius: 4px;
}

.shape-circle {
    background-color: var(--card-bg);
    border-radius: 50%;
}

.shape-octagon {
    background-color: var(--card-bg);
    clip-path: polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%);
}

.cell-text {
    z-index: 2;
}

/* Animations */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.error-shake {
    animation: shake 0.2s ease-in-out 2;
    background-color: var(--error-color) !important;
}

.success-pop {
    transform: scale(1.2);
    background-color: var(--success-color) !important;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    text-align: center;
}

.modal {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    max-width: 400px;
    width: 90%;
}

.btn {
    background: var(--accent-color);
    color: #000;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: bold;
    cursor: pointer;
    margin-top: 1rem;
    transition: opacity 0.2s;
}

.btn:hover {
    opacity: 0.9;
}

/* Word elements need wider cells */
.wide-cell {
    aspect-ratio: 2 / 1;
}
