* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #e0e0e0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 10px;
}

.container {
    width: 100%;
    max-width: 420px;
    text-align: center;
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

header h1 {
    font-size: 2.2rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
}

.header-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.header-info div {
    font-weight: 600;
    color: #b0b0b0;
}

.header-info span {
    color: #4ecdc4;
    font-weight: 700;
}

.grid-container {
    display: grid;
    gap: 8px;
    margin: 20px 0;
    padding: 15px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.grid-cell {
    background: linear-gradient(145deg, #2a2a3e, #1e1e2e);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    cursor: pointer;
    aspect-ratio: 1 / 1;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
}

/* Responsive font sizing for larger grids */
.grid-container[data-size="5x5"] .grid-cell {
    font-size: 1.6rem;
}

.grid-container[data-size="5x5"] .grid-cell.incorrect {
    font-size: 0.5rem;
}

.grid-container[data-size="6x6"] .grid-cell {
    font-size: 1.4rem;
}

.grid-container[data-size="6x6"] .grid-cell.incorrect {
    font-size: 0.45rem;
}

.grid-container[data-size="7x7"] .grid-cell {
    font-size: 1.2rem;
}

.grid-container[data-size="7x7"] .grid-cell.incorrect {
    font-size: 0.4rem;
}

.grid-cell::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0));
    border-radius: 12px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.grid-cell:hover::before {
    opacity: 1;
}

.grid-cell.hidden-cell {
    background: linear-gradient(145deg, #1a1a2e, #16213e);
    border: 2px dashed rgba(255, 255, 255, 0.2);
    cursor: pointer;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

.grid-cell.selected {
    background: linear-gradient(145deg, #4ecdc4, #3bb3b0);
    transform: scale(0.95);
    box-shadow: 0 0 20px rgba(78, 205, 196, 0.4);
    border-color: #4ecdc4;
}

.grid-cell.correct {
    background: linear-gradient(145deg, #4CAF50, #45a049);
    color: white;
    animation: correctPulse 0.6s ease;
    box-shadow: 0 0 25px rgba(76, 175, 80, 0.5);
}

@keyframes correctPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.grid-cell.incorrect {
    background: linear-gradient(145deg, #F44336, #d32f2f);
    color: white;
    animation: incorrectShake 0.6s ease;
    box-shadow: 0 0 25px rgba(244, 67, 54, 0.5);
    font-size: 0.6rem;  /* Even smaller font for arrow text */
    line-height: 1;
    text-align: center;
    padding: 1px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    word-break: break-all;
    hyphens: none;
}

@keyframes incorrectShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

#instructions {
    min-height: 48px;
    margin: 15px 0;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 1rem;
    line-height: 1.4;
    color: #f0f0f0;
}

#progress-info {
    display: flex;
    justify-content: space-between;
    margin: 15px 0;
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    font-size: 0.9rem;
    color: #b0b0b0;
}

#progress-info span {
    color: #4ecdc4;
    font-weight: 600;
}

#controls {
    margin: 20px 0;
}

button {
    background: linear-gradient(145deg, #4ecdc4, #3bb3b0);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin: 5px;
    box-shadow: 0 4px 15px rgba(78, 205, 196, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(78, 205, 196, 0.4);
    background: linear-gradient(145deg, #5ed5cc, #4ecdc4);
}

button:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(78, 205, 196, 0.3);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.hidden {
    display: none !important;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: linear-gradient(145deg, #2a2a3e, #1e1e2e);
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    width: 90%;
    max-width: 400px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { 
        opacity: 0;
        transform: translateY(30px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-content h3 {
    margin-top: 0;
    color: #4ecdc4;
    font-size: 1.5rem;
}

#share-summary {
    margin: 20px 0;
    padding: 15px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#share-summary div {
    margin: 8px 0;
    font-weight: 600;
}

#share-text {
    width: 100%;
    min-height: 120px;
    margin: 15px 0;
    padding: 15px;
    background: rgba(0, 0, 0, 0.4);
    color: #e0e0e0;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    font-family: monospace;
    font-size: 0.9rem;
    resize: vertical;
    outline: none;
}

#share-text:focus {
    border-color: #4ecdc4;
    box-shadow: 0 0 10px rgba(78, 205, 196, 0.3);
}

/* Mobile responsiveness */
@media (max-width: 480px) {
    .container {
        padding: 15px;
        margin: 5px;
    }
    
    header h1 {
        font-size: 1.8rem;
    }
    
    .grid-cell {
        font-size: 1.5rem;
    }
    
    .header-info {
        font-size: 0.9rem;
    }
    
    #progress-info {
        flex-direction: column;
        gap: 5px;
        text-align: center;
    }
    
    button {
        padding: 10px 20px;
        font-size: 0.9rem;
    }
    
    .modal-content {
        padding: 20px;
        margin: 10px;
    }
}
