:root {
    --bg-color: #121212;
    --card-bg: #1e1e1e;
    --primary: #bb86fc;
    --primary-variant: #3700b3;
    --secondary: #03dac6;
    --error: #cf6679;
    --text-main: #ffffff;
    --text-muted: #b0b0b0;
    --success: #00e676;
    --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --radius: 12px;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: var(--font-family);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Navbar/Header */
.game-header {
    background-color: var(--card-bg);
    padding: 1rem;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.brand {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    letter-spacing: 0.5px;
}

.brand:hover {
    color: var(--primary);
}

.brand i {
    color: var(--primary);
    font-size: 1.4rem;
}

.nav-controls {
    display: flex;
    gap: 1rem;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 1.2rem;
    cursor: pointer;
    position: relative;
    transition: transform 0.2s;
}

.icon-btn:hover {
    color: var(--primary);
    transform: scale(1.1);
}

/* Main Container */
.game-container {
    flex: 1;
    width: 100%;
    max-width: 620px;
    margin: 0 auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.full-width {
    width: 100%;
}

/* Game Card */
.game-card {
    background-color: var(--card-bg);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
    animation: slideUp 0.5s ease-out;
    width: 100%;
}

.stats-bar {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
    padding: 0.5rem;
    border-radius: var(--radius);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stat-value {
    color: var(--secondary);
    font-weight: bold;
}

/* Puzzle Image */
.puzzle-frame {
    width: 100%;
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 150px;
    border: 2px solid var(--primary-variant);
}

.puzzle-frame img {
    max-width: 100%;
    max-height: 35vh;
    object-fit: contain;
}

/* Answer Area */
.letter-spaces {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem; /* Gap between words */
    margin-bottom: 1rem;
    min-height: 40px;
}

.word-container {
    display: flex;
    gap: 8px;
}

.letter-slot {
    width: 28px;
    height: 36px;
    border-bottom: 3px solid var(--secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    font-weight: bold;
    text-transform: uppercase;
    color: var(--text-main);
}

.letter-slot.revealed {
    color: var(--primary);
    border-color: var(--primary);
}

.letter-slot.empty {
    color: transparent;
}

/* Input Area */
.input-area {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

#answer-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid transparent;
    border-radius: var(--radius);
    padding: 0.75rem;
    color: var(--text-main);
    font-size: 1.1rem;
    outline: none;
    transition: border-color 0.3s;
}

#answer-input:focus {
    border-color: var(--primary);
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, filter 0.2s;
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn:active {
    transform: scale(0.95);
}

.btn-primary {
    background-color: var(--primary);
    color: #000;
}

.btn-primary:hover {
    filter: brightness(1.1);
}

.btn-secondary {
    background-color: transparent;
    border: 2px solid var(--secondary);
    color: var(--secondary);
}

.btn-secondary:hover {
    background-color: rgba(3, 218, 198, 0.1);
}

.btn-hint {
    background-color: transparent;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.btn-hint:hover {
    color: var(--text-main);
}

.controls-row {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 0.5rem;
}

/* Feedback */
#feedback {
    margin-top: 0.5rem;
    padding: 0; /* Initially 0 */
    border-radius: var(--radius);
    text-align: center;
    font-weight: bold;
    opacity: 0;
    height: 0; /* Initially 0 height */
    overflow: hidden; /* Hide content */
    transition: opacity 0.3s, height 0.3s, padding 0.3s, margin 0.3s; /* Smooth transition */
}

#feedback.show {
    opacity: 1;
    height: auto; /* Allow it to grow */
    padding: 0.5rem; /* Restore padding */
    margin-bottom: 0.5rem; /* Restore margin if needed */
}

#feedback.success {
    background-color: rgba(0, 230, 118, 0.1);
    color: var(--success);
    border: 1px solid var(--success);
}

#feedback.error {
    background-color: rgba(207, 102, 121, 0.1);
    color: var(--error);
    border: 1px solid var(--error);
    animation: shake 0.5s;
}

/* Modals */
.custom-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.custom-modal.active {
    display: flex;
    animation: fadeIn 0.3s;
}

.modal-content {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: var(--radius);
    max-width: 90%;
    width: 500px;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid var(--primary-variant);
    box-shadow: 0 0 20px rgba(187, 134, 252, 0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 1rem;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

.close-btn:hover {
    color: var(--error);
}

/* Badges */
.badge-notification {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--error);
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    animation: pulse 2s infinite;
}

.hidden {
    display: none !important;
}

/* Achievements */
.achievement-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1rem;
}

.achievement-item {
    background: rgba(255,255,255,0.05);
    padding: 1rem;
    border-radius: var(--radius);
    text-align: center;
    border: 1px solid transparent;
}

.achievement-item.gold { border-color: gold; }
.achievement-item.silver { border-color: silver; }
.achievement-item.bronze { border-color: #cd7f32; }

/* Animations */
@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

.shake-animation {
    animation: shake 0.5s ease-in-out;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* Helper for JS toggling */
.d-none {
    display: none !important;
}

/* Visually hidden for SEO - accessible to screen readers and search engines */
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .game-container {
        padding: 0.5rem;
    }

    .letter-slot {
        width: 24px;
        height: 32px;
        font-size: 1.2rem;
    }

    .btn {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }

    .stats-bar {
        font-size: 0.8rem;
    }
}

@media (max-width: 768px) {
    body {
        padding: 0;
    }

    .game-container {
        max-width: 100%;
        padding: 0.4rem;
    }

    .stats-bar {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .puzzle-frame {
        min-height: 120px;
    }

    .controls-row {
        flex-direction: column;
        gap: 0.6rem;
    }
}
