:root {
    --font-color: #1E293B;
    --secondary-font: #475569;
    --border-color: #E2E8F0;
    --primary-action-color: #6366F1;
    --disabled-color: #C7D2FE;
    --correct-color: #10B981;
    --delete-color: #EF4444;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Poppins', sans-serif;
    color: var(--font-color);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
    background: linear-gradient(135deg, #ff6b6b, #f94d6a, #f7d794, #7bed9f, #54a0ff, #be2edd, #ff6b6b);
    background-size: 500% 500%;
    animation: glitter-background 20s ease infinite;
}

@keyframes glitter-background {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.container {
    width: 100%;
    max-width: 480px; /* Compact width */
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.container.hidden { display: none; }

.content-box {
    background-color: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 1.5rem;
    border-radius: 24px;
    text-align: center;
    width: 100%;
    box-shadow: 0 15px 50px -10px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.6);
}

.page-header {
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--secondary-font);
}

.title {
    font-family: 'Fredoka', sans-serif;
    font-size: clamp(2rem, 5vw, 2.5rem);
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(45deg, #8B5CF6, #EC4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle { font-size: 1rem; color: var(--secondary-font); margin-bottom: 1.5rem; }

/* Rules Screen Specific Styles */
#rules-container .content-box { background: linear-gradient(135deg, #8B5CF6, #EC4899); }
#rules-container .page-header { color: rgba(255,255,255,0.8); border-bottom-color: rgba(255,255,255,0.3); }
.rules-title { background: white; -webkit-background-clip: text; }
.rules-text { color: white; font-size: 1.1rem; line-height: 1.6; }
#rules-container .btn { background-color: white; color: var(--primary-action-color); }

/* Form Styles */
#player-form { margin-bottom: 1rem; }
#player-form input {
    display: block; width: 100%; padding: 0.8rem; margin-bottom: 0.8rem;
    background-color: rgba(248, 250, 252, 0.8); border: 2px solid var(--border-color);
    border-radius: 10px; font-size: 0.9rem; text-align: center; font-weight: 600;
}
#player-form input:focus { outline: none; border-color: var(--primary-action-color); }

.btn {
    padding: 0.9rem; font-size: 1rem; font-weight: 600; border-radius: 10px;
    background-color: var(--primary-action-color); color: white; border: none;
    cursor: pointer; transition: all 0.3s; width: 100%;
}
.btn:hover:not(:disabled) { transform: translateY(-3px); box-shadow: 0 5px 20px rgba(99, 102, 241, 0.3); }
.btn:disabled { background-color: var(--disabled-color); cursor: not-allowed; }
.btn-secondary { background: none; border: 2px solid var(--border-color); color: var(--secondary-font); padding: 0.6rem; font-size: 0.8rem; margin-top: 1rem; }
.btn-secondary:hover { color: var(--primary-action-color); border-color: var(--primary-action-color); }

/* Game Styles */
.game-box { padding: 1.2rem; }
.game-header { display: flex; justify-content: space-between; align-items: center; width: 100%; margin-bottom: 1.2rem; }
.stat { text-align: center; flex: 1; }
.stat .label { font-size: 0.7rem; font-weight: 600; color: var(--secondary-font); }
.stat span:last-child { font-size: 1.3rem; font-weight: 700; font-family: 'Fredoka', sans-serif; }

#game-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin-bottom: 1.2rem;
}

.tile {
    aspect-ratio: 1; border-radius: 12px; display: flex; justify-content: center; align-items: center;
    font-size: clamp(1.2rem, 5vw, 1.8rem); font-family: 'Fredoka', sans-serif;
    font-weight: 700; cursor: pointer; color: white; text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.8s ease;
    border: 3px solid transparent;
}
.tile.selected { transform: scale(1.15) rotate(5deg); box-shadow: 0 0 25px 5px white; z-index: 10; }
.tile.correct { border-color: var(--correct-color); }

/* Records Table */
#records-table { width: 100%; border-collapse: collapse; margin-bottom: 1.5rem; font-size: 0.9rem;}
#records-table th, #records-table td { padding: 0.5rem; }
#records-table th { color: var(--primary-action-color); border-bottom: 2px solid var(--border-color); }
#records-table tbody tr:nth-child(even) { background-color: rgba(248, 250, 252, 0.8); }
#records-table td { font-weight: 600; color: var(--secondary-font); vertical-align: middle; }
.delete-btn { background: none; border: none; font-size: 1.2rem; color: #CBD5E1; cursor: pointer; transition: all 0.2s; }
.delete-btn:hover { color: var(--delete-color); transform: scale(1.2); }