:root {
    --bg-primary: #f0f4f8;
    --bg-secondary: #ffffff;
    --panel-bg: #e3eaf2;
    --grid-bg: #dbe4f0;
    --grid-line: #c1cde0;
    --primary-blue: #4a90e2;
    --hover-blue: #3a7bc8;
    --green-success: #50e3c2;
    --hover-green: #38c8a8;
    --red-error: #e94e77;
    --font-primary: 'Fredoka One', cursive;
    --font-secondary: 'Nunito', sans-serif;
    --shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    --border-radius: 12px;
}

body {
    font-family: var(--font-secondary);
    background-color: var(--bg-primary);
    color: #333;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    box-sizing: border-box;
}

.page-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    align-items: center;
    padding: 1rem;
}

#game-container {
    width: 100%;
    max-width: 1200px;
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 1rem;
}

.game-header {
    background-color: var(--primary-blue);
    color: white;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-header {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 2px solid rgba(255,255,255,0.3);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.btn-header:hover {
    background: rgba(255,255,255,0.3);
    border-color: rgba(255,255,255,0.5);
    transform: translateY(-2px);
}

.game-header h1 {
    font-family: var(--font-primary);
    margin: 0;
    font-size: 1.5rem;
}

#level-indicator {
    font-family: var(--font-secondary);
    font-weight: 700;
    font-size: 1.2rem;
    background: rgba(255,255,255,0.2);
    padding: 0.5rem 1rem;
    border-radius: 20px;
}

.level-indicator-clickable {
    font-family: var(--font-secondary);
    font-weight: 700;
    font-size: 1.2rem;
    background: rgba(255,255,255,0.2);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid rgba(255,255,255,0.3);
}

.level-indicator-clickable:hover {
    background: rgba(255,255,255,0.3);
    border-color: rgba(255,255,255,0.5);
    transform: translateY(-2px);
}

.game-main {
    display: flex;
    flex-direction: row;
    padding: 1.5rem;
    gap: 1.5rem;
}

.game-world {
    flex: 2;
    display: grid;
    place-items: center;
    background-color: var(--grid-bg);
    border-radius: var(--border-radius);
    padding: 1rem;
}

#grid-container {
    display: grid;
    border: 2px solid var(--grid-line);
    position: relative;
}

.grid-tile {
    width: 50px;
    height: 50px;
    border: 1px solid var(--grid-line);
    box-sizing: border-box;
}

.grid-object {
    position: absolute;
    width: 50px;
    height: 50px;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    transition: transform 0.3s ease-in-out, top 0.4s ease-in-out, left 0.4s ease-in-out;
}

#robot { background-image: url('../assets/robot.svg'); z-index: 10;}
.goal { background-image: url('../assets/goal.svg'); z-index: 5;}
.obstacle { background-image: url('../assets/obstacle.svg'); z-index: 5;}

/* Robot Directions */
.direction-north { transform: rotate(0deg); }
.direction-east { transform: rotate(90deg); }
.direction-south { transform: rotate(180deg); }
.direction-west { transform: rotate(270deg); }

/* Animations */
.goal-collected { transform: scale(0); opacity: 0; transition: all 0.3s ease-in;}
.shake { animation: shake 0.5s; }
@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); }
}

.control-panel {
    flex: 1;
    background-color: var(--panel-bg);
    border-radius: var(--border-radius);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.control-panel h2 {
    font-family: var(--font-primary);
    margin: 0;
    text-align: center;
    color: var(--primary-blue);
}

#code-editor {
    width: 100%;
    border: 2px solid var(--grid-line);
    border-radius: 8px;
    padding: 0.5rem;
    font-family: 'Courier New', Courier, monospace;
    font-size: 1rem;
    resize: vertical;
    box-sizing: border-box;
}
#code-editor:focus {
    outline: none;
    border-color: var(--primary-blue);
}

.error-feedback {
    color: var(--red-error);
    font-size: 0.9rem;
    height: 20px;
    margin-top: 5px;
    font-weight: bold;
}

.snippet-buttons, .action-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.btn {
    padding: 0.75rem;
    border: none;
    border-radius: 8px;
    font-family: var(--font-secondary);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.btn-snippet { background-color: white; color: var(--primary-blue); border: 2px solid var(--primary-blue); }
.btn-action { color: white; }
.btn-run { background-color: var(--green-success); }
.btn-run:hover { background-color: var(--hover-green); }
.btn-reset { background-color: var(--primary-blue); }
.btn-reset:hover { background-color: var(--hover-blue); }
.btn-hint { background-color: #f5a623; }
.btn-hint:hover { background-color: #d88f17; }
.btn-next { background-color: var(--green-success); }
.btn-next:hover { background-color: var(--hover-green); }
.btn:disabled { background-color: #ccc; cursor: not-allowed; transform: none; box-shadow: none; }

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s ease;
}
.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}
.modal-content {
    background: white;
    padding: 2rem 3rem;
    border-radius: var(--border-radius);
    text-align: center;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}
.modal-overlay:not(.hidden) .modal-content {
    transform: scale(1);
}

.modal-content h2 { font-family: var(--font-primary); font-size: 2rem; color: var(--primary-blue); }
.star-rating { font-size: 2.5rem; margin: 1rem 0; }
.star-rating .star.filled { color: #f5a623; }

/* Hint Modal Styles */
.hint-modal {
    max-width: 500px;
    padding: 1.5rem;
    background: linear-gradient(135deg, #fff 0%, #f8f9ff 100%);
    border: 3px solid var(--primary-blue);
}

.hint-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px dashed var(--primary-blue);
}

.hint-icon {
    font-size: 2rem;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

.hint-header h2 {
    color: var(--primary-blue);
    font-size: 1.5rem;
    margin: 0;
    flex-grow: 1;
    text-align: center;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #999;
    padding: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    background: #f0f0f0;
    color: var(--red-error);
}

.hint-content {
    margin: 1rem 0;
}

#hint-text {
    font-size: 1.1rem;
    line-height: 1.5;
    color: #333;
    background: #f0f8ff;
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid var(--green-success);
}

.hint-visual {
    margin: 1rem 0;
    padding: 1rem;
    background: #fff;
    border-radius: 8px;
    border: 2px dashed var(--grid-line);
    text-align: center;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hint-tips {
    background: #fffbf0;
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid #f5a623;
}

.hint-tips h3 {
    margin: 0 0 0.5rem 0;
    color: #d88f17;
    font-size: 1rem;
}

.hint-tips ul {
    margin: 0;
    padding-left: 1.2rem;
}

.hint-tips li {
    margin-bottom: 0.3rem;
    color: #666;
}

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

.hint-actions .btn {
    flex: 1;
    max-width: 200px;
}

/* Fix hint modal button colors */
.hint-actions .btn-action {
    background-color: var(--primary-blue);
    color: black; /* Changed from white to black */
}

.hint-actions .btn-action:hover {
    background-color: var(--hover-blue);
    color: black; /* Ensure it stays black on hover */
}

/* Alternative: If you want to specifically target the "try again" button */
#try-again-btn {
    color: black !important;
}

#try-again-btn:hover {
    color: black !important;
}

/* Mobile responsive for hint modal */
@media (max-width: 480px) {
    .hint-modal {
        margin: 1rem;
        max-width: calc(100% - 2rem);
        padding: 1rem;
    }
    
    .hint-header h2 {
        font-size: 1.2rem;
    }
    
    .hint-actions {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .hint-actions .btn {
        width: 100%;
        max-width: 100%;
    }
}

/* Share Modal Styles */
.share-modal {
    max-width: 450px;
    padding: 2rem;
    background: linear-gradient(135deg, #fff 0%, #f8f9ff 100%);
    border: 3px solid var(--green-success);
    text-align: center;
}

.share-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px dashed var(--green-success);
}

.share-header h2 {
    color: var(--green-success);
    font-family: var(--font-primary);
    font-size: 1.6rem;
    margin: 0;
    flex-grow: 1;
}

.achievement-summary {
    background: #f0fff4;
    padding: 1.5rem;
    border-radius: 12px;
    border-left: 4px solid var(--green-success);
    margin-bottom: 1.5rem;
}

.achievement-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    animation: trophy-spin 3s ease-in-out infinite;
}

.achievement-summary h3 {
    color: var(--primary-blue);
    font-family: var(--font-primary);
    font-size: 1.4rem;
    margin: 0 0 0.5rem 0;
}

.achievement-summary p {
    color: #666;
    font-size: 1.1rem;
    margin: 0;
    font-weight: 600;
}

.share-options {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.share-btn {
    background: var(--primary-blue);
    color: white;
    padding: 0.8rem 1rem;
    font-size: 0.9rem;
    width: 100%;
    justify-content: center;
    transition: all 0.2s ease;
}

.share-btn:hover {
    background: var(--hover-blue);
    transform: translateY(-2px);
}

.share-btn:nth-child(2) {
    background: #1da1f2;
}

.share-btn:nth-child(2):hover {
    background: #1a91da;
}

.share-btn:nth-child(3) {
    background: #4267b2;
}

.share-btn:nth-child(3):hover {
    background: #365899;
}

/* Mobile responsive for share modal */
@media (max-width: 480px) {
    .share-modal {
        margin: 1rem;
        max-width: calc(100% - 2rem);
        padding: 1.5rem;
    }
    
    .share-header h2 {
        font-size: 1.3rem;
    }
    
    .achievement-summary {
        padding: 1rem;
    }
    
    .achievement-icon {
        font-size: 2.5rem;
    }
}

/* Welcome Modal Styles - Updated with better mobile responsiveness */
.welcome-modal {
    max-width: 400px;
    padding: 1.2rem;
    background: linear-gradient(135deg, #fff 0%, #f8faff 100%);
    border: 3px solid var(--primary-blue);
    text-align: center;
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
}

.welcome-modal::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--green-success), var(--primary-blue), var(--green-success));
    animation: rainbow 3s linear infinite;
}

@keyframes rainbow {
    0%, 100% { transform: translateX(-100%); }
    50% { transform: translateX(100%); }
}

@keyframes robotBounce {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-10px) rotate(-5deg); }
    75% { transform: translateY(-5px) rotate(5deg); }
}

.welcome-header {
    margin-bottom: 1.2rem;
    position: relative;
}

.welcome-header .close-btn {
    position: absolute;
    top: -0.6rem;
    right: -0.6rem;
    background: var(--red-error);
    color: white;
    border: none;
    width: 21px;
    height: 21px;
    border-radius: 50%;
    font-size: 0.9rem;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s ease;
}

.welcome-header .close-btn:hover {
    background: #d73e63;
    transform: scale(1.1);
}

.game-logo {
    font-size: 2.4rem;
    margin-bottom: 0.6rem;
    animation: robotBounce 2s ease-in-out infinite;
}

.welcome-header h1 {
    font-family: var(--font-primary);
    color: var(--primary-blue);
    font-size: 1.65rem;
    margin: 0 0 0.3rem 0;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
    word-wrap: break-word;
}

.welcome-subtitle {
    color: var(--hover-blue);
    font-size: 0.825rem;
    font-weight: 600;
    margin: 0;
    opacity: 0.9;
}

.welcome-content {
    margin: 0.9rem 0;
    text-align: left;
}

.game-description {
    background: linear-gradient(135deg, #f0f8ff 0%, #e8f4ff 100%);
    padding: 0.6rem;
    border-radius: 12px;
    border-left: 4px solid var(--green-success);
    margin-bottom: 0.9rem;
    text-align: center;
}

.game-description p {
    margin: 0;
    color: #333;
    font-size: 0.75rem;
    line-height: 1.25;
    word-wrap: break-word;
}

.quick-commands h3 {
    color: var(--primary-blue);
    font-size: 0.825rem;
    margin: 0 0 0.6rem 0;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    flex-wrap: wrap;
}

.command-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.3rem;
    margin-bottom: 0.9rem;
}

.cmd-item {
    background: white;
    padding: 0.48rem 0.3rem;
    border-radius: 8px;
    border: 2px solid var(--grid-line);
    text-align: center;
    transition: all 0.2s ease;
    box-sizing: border-box;
    min-height: 60px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.cmd-item:hover {
    border-color: var(--primary-blue);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.2);
}

.cmd-item code {
    display: block;
    font-family: 'Courier New', monospace;
    background: var(--primary-blue);
    color: white;
    padding: 0.18rem 0.3rem;
    border-radius: 4px;
    font-size: 0.6rem;
    font-weight: bold;
    margin-bottom: 0.18rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.cmd-item span {
    color: #666;
    font-size: 0.6375rem;
    word-wrap: break-word;
}

.game-features {
    background: #fffbf0;
    padding: 0.6rem;
    border-radius: 12px;
    border-left: 4px solid #f5a623;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 0.48rem;
    margin-bottom: 0.3rem;
    font-size: 0.7125rem;
    color: #333;
    flex-wrap: wrap;
}

.feature-item:last-child {
    margin-bottom: 0;
}

.feature-icon {
    font-size: 0.9rem;
    width: 14px;
    text-align: center;
    flex-shrink: 0;
}

.welcome-actions {
    margin-top: 1.2rem;
    padding-top: 0.9rem;
    border-top: 2px dashed var(--grid-line);
    display: flex;
    gap: 0.6rem;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

.btn-start {
    background: linear-gradient(135deg, var(--green-success) 0%, var(--hover-green) 100%);
    color: white;
    font-size: 0.825rem;
    padding: 0.6rem 1.2rem;
    border-radius: 25px;
    box-shadow: 0 4px 15px rgba(80, 227, 194, 0.3);
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-width: 140px;
    max-width: 180px;
    animation: pulse 2s infinite;
    white-space: nowrap;
    border: none;
    cursor: pointer;
    font-family: var(--font-secondary);
    font-weight: 700;
    text-align: center;
    line-height: 1;
}

.btn-start:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(80, 227, 194, 0.4);
    animation: none;
}

.btn-start span:first-child {
    font-size: 1rem;
    line-height: 1;
}

.btn-secondary {
    background: var(--grid-line);
    color: #666;
    font-size: 0.75rem;
    padding: 0.6rem 0.9rem;
    border-radius: 25px;
    transition: all 0.3s ease;
    min-width: 80px;
    max-width: 120px;
    white-space: nowrap;
    border: none;
    cursor: pointer;
    font-family: var(--font-secondary);
    font-weight: 700;
    text-align: center;
    line-height: 1;
}

.btn-secondary:hover {
    background: #b0bcc9;
    color: #333;
    transform: translateY(-2px);
}

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

/* Enhanced Mobile responsive adjustments for buttons */
@media (max-width: 600px) {
    .welcome-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 0.8rem;
    }
    
    .btn-start {
        width: 100%;
        max-width: 100%;
        min-width: auto;
        font-size: 0.9rem;
        padding: 0.8rem 1rem;
        justify-content: center;
    }
    
    .btn-start span:first-child {
        font-size: 1.1rem;
    }
    
    .btn-secondary {
        width: 100%;
        max-width: 100%;
        min-width: auto;
        font-size: 0.8rem;
        padding: 0.7rem 1rem;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .welcome-actions {
        margin-top: 1rem;
        padding-top: 0.8rem;
        gap: 0.6rem;
    }
    
    .btn-start {
        font-size: 0.85rem;
        padding: 0.7rem 0.8rem;
    }
    
    .btn-start span:first-child {
        font-size: 1rem;
    }
    
    .btn-secondary {
        font-size: 0.75rem;
        padding: 0.6rem 0.8rem;
    }
}

@media (max-width: 320px) {
    .btn-start {
        font-size: 0.8rem;
        padding: 0.6rem 0.7rem;
    }
    
    .btn-start span:first-child {
        font-size: 0.9rem;
    }
    
    .btn-secondary {
        font-size: 0.7rem;
        padding: 0.5rem 0.6rem;
    }
}

/* Fix any conflicting button styles */
.welcome-modal .btn {
    box-sizing: border-box;
}

.welcome-modal .btn:focus {
    outline: 2px solid var(--primary-blue);
    outline-offset: 2px;
}

.welcome-modal .btn:active {
    transform: translateY(0);
}

.welcome-actions {
    margin-top: 1.2rem;
    padding-top: 0.9rem;
    border-top: 2px dashed var(--grid-line);
    display: flex;
    gap: 0.6rem;
    justify-content: center;
    flex-wrap: wrap;
}

.welcome-actions .btn {
    flex: 1;
    max-width: 200px;
}

.welcome-actions {
    margin-top: 1.2rem;
    padding-top: 0.9rem;
    border-top: 2px dashed var(--grid-line);
    display: flex;
    gap: 0.6rem;
    justify-content: center;
    flex-wrap: wrap;
}

.welcome-actions .btn {
    flex: 1;
    max-width: 200px;
}

/* Enhanced Mobile responsive adjustments */
@media (max-width: 600px) {
    .welcome-modal {
        margin: 0.5rem;
        max-width: calc(100vw - 1rem);
        max-height: calc(100vh - 1rem);
        padding: 0.8rem;
        overflow-y: auto;
    }
    
    .game-logo {
        font-size: 2rem;
    }
    
    .welcome-header h1 {
        font-size: 1.2rem;
        line-height: 1.2;
    }
    
    .welcome-subtitle {
        font-size: 0.7rem;
    }
    
    .command-grid {
        grid-template-columns: 1fr;
        gap: 0.4rem;
    }
    
    .cmd-item {
        padding: 0.5rem;
        min-height: 50px;
    }
    
    .cmd-item code {
        font-size: 0.65rem;
        padding: 0.2rem 0.4rem;
    }
    
    .cmd-item span {
        font-size: 0.65rem;
    }
    
    .game-description p {
        font-size: 0.7rem;
        line-height: 1.3;
    }
    
    .feature-item {
        font-size: 0.65rem;
        gap: 0.4rem;
    }
    
    .feature-icon {
        font-size: 0.8rem;
        width: 16px;
    }
    
    .welcome-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    
    .btn-start, .btn-secondary {
        max-width: 100%;
        width: 100%;
        flex: none;
        font-size: 0.8rem;
        padding: 0.7rem 1rem;
    }
}

@media (max-width: 480px) {
    .welcome-modal {
        margin: 0.3rem;
        max-width: calc(100vw - 0.6rem);
        padding: 0.6rem;
    }
    
    .welcome-header {
        margin-bottom: 0.8rem;
    }
    
    .welcome-header h1 {
        font-size: 1rem;
        margin: 0 0 0.2rem 0;
    }
    
    .welcome-subtitle {
        font-size: 0.65rem;
    }
    
    .game-logo {
        font-size: 1.8rem;
        margin-bottom: 0.4rem;
    }
    
    .welcome-content {
        margin: 0.6rem 0;
    }
    
    .game-description {
        padding: 0.5rem;
        margin-bottom: 0.6rem;
    }
    
    .game-description p {
        font-size: 0.65rem;
    }
    
    .quick-commands h3 {
        font-size: 0.7rem;
        margin: 0 0 0.4rem 0;
    }
    
    .command-grid {
        margin-bottom: 0.6rem;
    }
    
    .game-features {
        padding: 0.5rem;
    }
    
    .feature-item {
        font-size: 0.6rem;
        margin-bottom: 0.25rem;
    }
    
    .welcome-actions {
        margin-top: 0.8rem;
        padding-top: 0.6rem;
    }
    
    .btn-start, .btn-secondary {
        font-size: 0.75rem;
        padding: 0.6rem 0.8rem;
    }
    
    .welcome-header .close-btn {
        width: 18px;
        height: 18px;
        font-size: 0.7rem;
        top: -0.4rem;
        right: -0.4rem;
    }
}

/* Extra small screens */
@media (max-width: 320px) {
    .welcome-modal {
        margin: 0.2rem;
        max-width: calc(100vw - 0.4rem);
        padding: 0.5rem;
    }
    
    .welcome-header h1 {
        font-size: 0.9rem;
    }
    
    .game-logo {
        font-size: 1.5rem;
    }
    
    .btn-start, .btn-secondary {
        font-size: 0.7rem;
        padding: 0.5rem 0.6rem;
    }
}

/* Bottom Advertisement Styles */
.ad-container-bottom {
    width: 100%;
    max-width: 1200px;
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    border: 2px solid var(--grid-line);
    padding: 1rem;
    margin-top: auto;
}

.ad-iframe-bottom {
    width: 100%;
    height: 200px;
    border: none;
    border-radius: 8px;
    background-color: transparent;
    display: block;
}

/* Responsive Design */
@media (max-width: 900px) {
    .game-main {
        flex-direction: column;
    }
    .control-panel {
        max-width: 500px;
        width: 100%;
        margin: 0 auto;
    }
    .ad-iframe-bottom {
        height: 150px;
    }
}

@media (max-width: 768px) {
    .page-container {
        padding: 0.5rem;
    }
    .ad-iframe-bottom {
        height: 120px;
    }
    .level-select-modal {
        max-width: 95vw;
        max-height: 90vh;
        padding: 1rem;
        margin: 1rem;
    }
    
    .level-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 0.8rem;
    }
    
    .level-item {
        min-height: 90px;
        padding: 0.8rem 0.3rem;
    }
    
    .level-number {
        font-size: 1.2rem;
    }
    
    .level-name {
        font-size: 0.7rem;
        line-height: 1.1;
    }
    
    .level-stars {
        font-size: 0.8rem;
    }
    
    .header-controls {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .level-progress-summary {
        flex-direction: column;
        gap: 1rem;
    }
    
    .game-complete-stats {
        flex-direction: column;
        gap: 1rem;
    }
    
    .level-complete-actions,
    .game-complete-actions,
    .level-select-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .level-complete-actions .btn,
    .game-complete-actions .btn,
    .level-select-actions .btn {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .game-header h1 { font-size: 1.2rem; }
    .game-main { padding: 1rem; gap: 1rem; }
    .grid-tile, .grid-object { 
        width: 40px; 
        height: 40px; 
    }
    .ad-container-bottom {
        padding: 0.5rem;
    }
    .ad-iframe-bottom {
        height: 100px;
    }
    .level-select-modal {
        max-width: 98vw;
        padding: 0.8rem;
        margin: 0.5rem;
    }
    
    .level-grid {
        grid-template-columns: repeat(auto-fill, minmax(85px, 1fr));
        gap: 0.6rem;
    }
    
    .level-item {
        min-height: 80px;
        padding: 0.6rem 0.2rem;
    }
    
    .level-number {
        font-size: 1.1rem;
    }
    
    .level-name {
        font-size: 0.65rem;
        line-height: 1;
    }
    
    .level-stars {
        font-size: 0.7rem;
        gap: 1px;
    }
    
    .level-select-actions {
        flex-direction: column;
        gap: 0.8rem;
    }
    
    .level-select-actions .btn {
        max-width: none;
        min-width: auto;
    }
    
    .game-complete-modal {
        margin: 0.5rem;
        max-width: calc(100vw - 1rem);
        padding: 1.5rem;
    }
    
    .level-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }
    
    .level-item {
        min-height: 75px;
        padding: 0.5rem 0.2rem;
    }
    
    .level-number {
        font-size: 1.2rem;
    }
    
    .level-name {
        font-size: 0.7rem;
    }
}

/* Remove old ad styles */
.ad-container {
    display: none;
}

/* Level Complete Modal Updates */
.level-complete-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.level-complete-actions .btn {
    flex: 1;
    min-width: 120px;
    max-width: 150px;
}

/* Game Complete Modal Styles */
.game-complete-modal {
    max-width: 500px;
    padding: 2rem;
    background: linear-gradient(135deg, #fff 0%, #f0f8ff 100%);
    border: 3px solid var(--green-success);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.game-complete-modal::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--green-success), #f5a623, var(--green-success));
    animation: rainbow 3s linear infinite;
}

.game-complete-header h2 {
    color: var(--green-success);
    font-family: var(--font-primary);
    font-size: 2rem;
    margin: 0 0 1rem 0;
    animation: bounce 2s infinite;
}

.trophy-animation {
    font-size: 4rem;
    margin: 1rem 0;
    animation: trophy-spin 3s ease-in-out infinite;
}

@keyframes trophy-spin {
    0%, 100% { transform: rotate(0deg) scale(1); }
    25% { transform: rotate(-10deg) scale(1.1); }
    75% { transform: rotate(10deg) scale(1.1); }
}

.completion-message {
    font-size: 1.2rem;
    color: #333;
    margin: 1rem 0 2rem 0;
    line-height: 1.4;
}

.game-complete-stats {
    display: flex;
    justify-content: space-around;
    margin: 2rem 0;
    background: #f0f8ff;
    padding: 1rem;
    border-radius: 12px;
    border-left: 4px solid var(--green-success);
}

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

.stat-number {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-blue);
}

.stat-label {
    font-size: 0.9rem;
    color: #666;
    text-align: center;
}

.game-complete-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 2rem;
}

.game-complete-actions .btn {
    flex: 1;
    min-width: 140px;
    max-width: 160px;
}

.btn-restart {
    background: var(--red-error);
    color: white;
}

.btn-restart:hover {
    background: #d73e63;
}

.btn-browse {
    background: var(--primary-blue);
    color: white;
}

.btn-browse:hover {
    background: var(--hover-blue);
}

/* Level Selection Modal Styles */
.level-select-modal {
    max-width: 700px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 2rem;
    background: linear-gradient(135deg, #fff 0%, #f8f9ff 100%);
    border: 3px solid var(--primary-blue);
}

.level-select-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px dashed var(--primary-blue);
}

.level-select-header h2 {
    color: var(--primary-blue);
    font-family: var(--font-primary);
    font-size: 1.8rem;
    margin: 0;
}

.level-select-description {
    text-align: center;
    color: #666;
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    background: #f0f8ff;
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid var(--green-success);
}

.level-progress-summary {
    display: flex;
    justify-content: space-around;
    margin: 1.5rem 0;
    background: #fffbf0;
    padding: 1rem;
    border-radius: 12px;
    border-left: 4px solid #f5a623;
}

.progress-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
}

.progress-item span:first-child {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-blue);
}

.progress-item span:last-child {
    font-size: 0.8rem;
    color: #666;
    text-align: center;
}

.level-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 1rem;
    margin: 2rem 0;
}

.level-item {
    background: white;
    border: 3px solid var(--grid-line);
    border-radius: 12px;
    padding: 1rem 0.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    min-height: 110px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.level-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(74, 144, 226, 0.3);
}

.level-item.completed {
    border-color: var(--green-success);
    background: linear-gradient(135deg, #f0fff4 0%, #e8f5e8 100%);
}

.level-item.completed:hover {
    box-shadow: 0 8px 25px rgba(80, 227, 194, 0.4);
}

.level-item.current {
    border-color: var(--primary-blue);
    background: linear-gradient(135deg, #f0f8ff 0%, #e8f4ff 100%);
    animation: pulse-level 2s infinite;
}

@keyframes pulse-level {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

.level-item.locked {
    background: #f5f5f5;
    border-color: #ddd;
    cursor: not-allowed;
    opacity: 0.6;
}

.level-item.locked:hover {
    transform: none;
    box-shadow: none;
}

.level-number {
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--primary-blue);
    margin-bottom: 0.3rem;
}

.level-item.completed .level-number {
    color: var(--green-success);
}

.level-item.locked .level-number {
    color: #999;
}

.level-name {
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 0.5rem;
    line-height: 1.2;
    text-align: center;
}

.level-stars {
    display: flex;
    justify-content: center;
    gap: 2px;
    font-size: 0.9rem;
    margin-top: 0.3rem;
}

.level-stars .star {
    color: #ddd;
}

.level-stars .star.filled {
    color: #f5a623;
}

.level-item.locked .level-stars {
    display: none;
}

.level-lock-icon {
    font-size: 1.5rem;
    color: #999;
    margin-bottom: 0.3rem;
}

.level-select-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    padding-top: 1rem;
    border-top: 2px dashed var(--grid-line);
    flex-wrap: wrap;
}

.level-select-actions .btn {
    flex: 1;
    min-width: 160px;
    max-width: 200px;
}

.btn-continue {
    background: var(--green-success);
    color: white;
}

.btn-continue:hover {
    background: var(--hover-green);
}

.btn-danger {
    background: var(--red-error);
    color: white;
}

.btn-danger:hover {
    background: #d73e63;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .header-controls {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .level-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 0.8rem;
    }
    
    .level-item {
        min-height: 90px;
        padding: 0.8rem 0.3rem;
    }
    
    .level-progress-summary {
        flex-direction: column;
        gap: 1rem;
    }
    
    .game-complete-stats {
        flex-direction: column;
        gap: 1rem;
    }
    
    .level-complete-actions,
    .game-complete-actions,
    .level-select-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .level-complete-actions .btn,
    .game-complete-actions .btn,
    .level-select-actions .btn {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .level-select-modal {
        margin: 0.5rem;
        max-width: calc(100vw - 1rem);
        padding: 1rem;
    }
    
    .game-complete-modal {
        margin: 0.5rem;
        max-width: calc(100vw - 1rem);
        padding: 1.5rem;
    }
    
    .level-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }
    
    .level-item {
        min-height: 75px;
        padding: 0.5rem 0.2rem;
    }
    
    .level-number {
        font-size: 1.2rem;
    }
    
    .level-name {
        font-size: 0.7rem;
    }
}