:root {
    --bg-color: #0f172a;
    --grid-bg: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-color: #38bdf8;
    --accent-hover: #0ea5e9;
    --danger-color: #ef4444;
    --success-color: #22c55e;
    --font-main: 'Outfit', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-main);
    overflow: hidden;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.app-container {
    width: 100%;
    max-width: 600px;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 20px;
    position: relative;
}

/* Header */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 20px;
}

.logo {
    font-size: 1.5rem;
    font-weight: 900;
    letter-spacing: 1px;
    color: var(--accent-color);
}

.stats-bar {
    display: flex;
    gap: 20px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 700;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
}

/* Game Area */
.game-area {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.grid-container {
    background-color: var(--grid-bg);
    border-radius: 16px;
    padding: 10px;
    display: grid;
    gap: 6px;
    width: 100%;
    aspect-ratio: 1;
    max-height: 80vh;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.grid-item {
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.1s;
}

.grid-item:active {
    transform: scale(0.95);
}

/* Modal */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: #1e293b;
    padding: 40px;
    border-radius: 24px;
    text-align: center;
    border: 1px solid #334155;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    width: 90%;
    max-width: 400px;
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-content.wide-modal {
    max-width: 550px;
}

.active .modal-content {
    transform: translateY(0);
}

.modal-title {
    font-size: 2rem;
    margin-bottom: 20px;
    background: linear-gradient(135deg, #fff 0%, #94a3b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.rules-box {
    background: #0f172a;
    padding: 24px;
    border-radius: 16px;
    margin-bottom: 30px;
    text-align: left;
    border: 1px solid #1e293b;
}

.rule-title {
    font-size: 0.8rem;
    color: var(--accent-color);
    font-weight: 700;
    letter-spacing: 2px;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.rule-desc {
    font-size: 1.2rem;
    font-weight: 500;
    margin-bottom: 20px;
    line-height: 1.4;
}

.rule-details {
    display: flex;
    flex-direction: column;
    gap: 12px;
    border-top: 1px solid #1e293b;
    padding-top: 16px;
}

.rule-item {
    font-size: 0.95rem;
    color: var(--text-secondary);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    line-height: 1.5;
}

.rule-item .icon {
    font-size: 1.1rem;
    min-width: 24px;
}

.rule-item:last-child {
    margin-bottom: 0;
}

.rule-item strong {
    color: var(--text-primary);
    font-weight: 600;
}

.final-score-box {
    margin-bottom: 30px;
}

.final-score-label {
    display: block;
    color: var(--text-secondary);
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.final-score-value {
    font-size: 4.5rem;
    font-weight: 900;
    color: var(--accent-color);
}

.primary-btn {
    background: var(--accent-color);
    color: #0f172a;
    border: none;
    padding: 16px 32px;
    font-size: 1.1rem;
    font-weight: 700;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    font-family: var(--font-main);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.primary-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(56, 189, 248, 0.2);
}

.primary-btn:active {
    transform: translateY(0);
}

/* Floating Feedback */
.feedback-text {
    position: absolute;
    font-weight: 900;
    font-size: 2rem;
    pointer-events: none;
    animation: floatUp 0.8s ease-out forwards;
    z-index: 50;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

@keyframes floatUp {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0;
    }

    20% {
        transform: translate(-50%, -80%) scale(1.2);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -150%) scale(1);
        opacity: 0;
    }
}

.shake {
    animation: shake 0.4s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes shake {

    10%,
    90% {
        transform: translate3d(-1px, 0, 0);
    }

    20%,
    80% {
        transform: translate3d(2px, 0, 0);
    }

    30%,
    50%,
    70% {
        transform: translate3d(-4px, 0, 0);
    }

    40%,
    60% {
        transform: translate3d(4px, 0, 0);
    }
}