: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;
    }
}

/* TRUE FINAL OVERRIDES: compact layout + visible code editor */
.page-container {
    padding: 0.35rem;
}

#game-container {
    margin-bottom: 0.35rem;
    max-width: 1120px;
}

.game-header {
    padding: 0.55rem 0.7rem;
}

.game-header h1 {
    font-size: 1.18rem;
}

.header-controls {
    gap: 0.42rem;
}

.btn-header,
.level-indicator-clickable {
    border-radius: 14px;
    font-size: 0.78rem;
    min-height: 36px;
    padding: 0.32rem 0.55rem;
}

.header-stats span {
    font-size: 0.7rem;
    padding: 0.28rem 0.46rem;
}

.home-screen {
    gap: 0.55rem;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 0.72fr);
    padding: 0.6rem;
}

.home-hero,
.home-progress-card,
.home-stat {
    padding: 0.65rem;
}

.home-hero {
    grid-row: span 2;
}

.home-logo {
    font-size: 2.8rem;
}

.home-hero h2 {
    font-size: 1.55rem;
}

.home-copy {
    font-size: 0.9rem;
}

.home-system-line {
    font-size: 0.68rem;
    margin-top: 0.45rem;
    padding: 0.38rem 0.5rem;
}

.home-progress-track {
    height: 11px;
    margin: 0.55rem 0 0.35rem;
}

.home-stat span {
    font-size: 1.28rem;
}

.home-actions {
    gap: 0.42rem;
    grid-column: 1 / -1;
}

.game-main {
    align-items: start;
    display: grid;
    gap: 0.55rem;
    grid-template-columns: minmax(280px, max-content) minmax(340px, 430px);
    justify-content: center;
    padding: 0.55rem;
}

.game-world {
    align-self: start;
    flex: initial;
    gap: 0.35rem;
    justify-items: center;
    padding: 0.45rem;
    width: fit-content;
    max-width: 100%;
}

.world-hud {
    gap: 0.3rem;
}

.world-hud span,
.world-terminal {
    font-size: 0.68rem;
    min-height: 28px;
    padding: 0.26rem 0.45rem;
}

.control-panel {
    align-self: start;
    gap: 0.45rem;
    max-width: 430px;
    padding: 0.55rem;
    width: 100%;
}

.control-panel h2 {
    display: none;
}

.mission-panel {
    padding: 0.48rem 0.55rem;
}

.mission-kicker {
    font-size: 0.64rem;
}

.mission-panel h3 {
    font-size: 0.88rem;
    margin: 0.12rem 0;
}

.mission-concept {
    font-size: 0.64rem;
    margin-bottom: 0.25rem;
    padding: 0.12rem 0.42rem;
}

.mission-panel p {
    font-size: 0.74rem;
    margin-bottom: 0.28rem;
}

.mission-objectives {
    display: grid;
    gap: 0.12rem 0.35rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mission-objectives li {
    font-size: 0.63rem;
}

.code-editor-wrapper {
    background: #263445;
    border: 2px solid #3e536c;
    border-radius: 10px;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04);
    padding: 0.35rem;
}

.code-titlebar {
    align-items: center;
    color: #d6f5ed;
    display: grid;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.74rem;
    gap: 0.45rem;
    grid-template-columns: auto 1fr auto;
    padding: 0.18rem 0.2rem 0.45rem;
}

.code-titlebar strong {
    color: #ffffff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.code-dots {
    display: flex;
    gap: 0.24rem;
}

.code-dots span {
    border-radius: 50%;
    display: block;
    height: 9px;
    width: 9px;
}

.code-dots span:nth-child(1) { background: #e94e77; }
.code-dots span:nth-child(2) { background: #f5a623; }
.code-dots span:nth-child(3) { background: #50e3c2; }

#code-editor {
    background: #101a26;
    border: 1px solid #4a90e2;
    color: #e9f6ff;
    font-size: 0.88rem;
    height: 205px;
    line-height: 1.42;
    min-height: 205px;
    resize: vertical;
}

#code-editor::placeholder {
    color: #86a9cc;
    opacity: 1;
}

.error-feedback {
    background: transparent;
    color: #ff8dab;
    font-size: 0.75rem;
    margin-top: 0.3rem;
    min-height: 0;
}

.console-feedback {
    margin-top: 0.35rem;
    max-height: 58px;
    padding: 0.38rem;
}

.snippet-buttons {
    gap: 0.35rem;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.action-buttons {
    gap: 0.35rem;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.btn {
    font-size: 0.78rem;
    min-height: 36px;
    padding: 0.44rem 0.38rem;
}

.ad-container-bottom {
    margin-top: 0.25rem;
    padding: 0.3rem;
}

.ad-iframe-bottom {
    height: 64px;
}

.site-footer {
    font-size: 0.76rem;
    margin-top: 0.25rem;
}

@media (max-width: 980px) {
    .home-screen {
        grid-template-columns: 1fr;
    }

    .home-hero {
        grid-row: auto;
    }

    .game-main {
        grid-template-columns: 1fr;
    }

    .game-world {
        justify-self: center;
    }

    .control-panel {
        justify-self: center;
        max-width: 620px;
    }
}

@media (max-width: 720px) {
    .page-container {
        padding: 0.2rem;
    }

    #game-container {
        border-radius: 8px;
    }

    .game-header {
        gap: 0.35rem;
        padding: 0.45rem;
    }

    .game-header h1 {
        font-size: 0.98rem;
        text-align: center;
        width: 100%;
    }

    .header-controls {
        align-items: stretch;
        display: grid;
        gap: 0.28rem;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
    }

    .header-stats {
        display: grid;
        gap: 0.25rem;
        grid-column: 1 / -1;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        justify-content: stretch;
        width: 100%;
    }

    .header-stats span,
    .btn-header,
    .level-indicator-clickable {
        font-size: 0.62rem;
        min-height: 31px;
        overflow: hidden;
        padding: 0.22rem 0.24rem;
        text-align: center;
        text-overflow: ellipsis;
        white-space: nowrap;
        width: 100%;
    }

    .home-screen {
        gap: 0.4rem;
        padding: 0.38rem;
    }

    .home-hero {
        gap: 0.45rem;
        grid-template-columns: auto 1fr;
        padding: 0.5rem;
        text-align: left;
    }

    .home-logo {
        font-size: 2rem;
    }

    .home-kicker,
    .home-label {
        font-size: 0.6rem;
    }

    .home-hero h2 {
        font-size: 1.04rem;
    }

    .home-copy,
    .home-progress-copy {
        font-size: 0.74rem;
        line-height: 1.25;
    }

    .home-system-line {
        font-size: 0.58rem;
        padding: 0.32rem 0.38rem;
    }

    .home-progress-card {
        padding: 0.48rem;
    }

    .home-progress-top {
        gap: 0.3rem;
        grid-template-columns: 1fr 1fr;
    }

    .home-progress-top strong {
        font-size: 0.78rem;
    }

    .home-stat-grid {
        gap: 0.3rem;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .home-stat {
        padding: 0.38rem 0.2rem;
    }

    .home-stat span {
        font-size: 1rem;
    }

    .home-stat strong {
        font-size: 0.58rem;
    }

    .home-actions {
        gap: 0.3rem;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    #home-resume-btn {
        grid-column: 1 / -1;
    }

    .game-main {
        gap: 0.35rem;
        padding: 0.35rem;
    }

    .game-world {
        gap: 0.28rem;
        padding: 0.3rem;
        width: 100%;
    }

    .world-hud {
        gap: 0.24rem;
    }

    .world-hud span,
    .world-terminal {
        font-size: 0.58rem;
        min-height: 24px;
        padding: 0.22rem 0.3rem;
    }

    .control-panel {
        gap: 0.35rem;
        max-width: none;
        padding: 0.35rem;
    }

    .mission-panel {
        padding: 0.38rem;
    }

    .mission-panel h3 {
        font-size: 0.76rem;
    }

    .mission-panel p,
    .mission-objectives li {
        font-size: 0.58rem;
    }

    .mission-objectives {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .mission-objectives li:nth-child(n+3) {
        display: none;
    }

    .code-editor-wrapper {
        padding: 0.28rem;
    }

    .code-titlebar {
        font-size: 0.62rem;
        padding-bottom: 0.32rem;
    }

    #code-editor {
        font-size: 0.72rem;
        height: 138px;
        min-height: 138px;
        padding: 0.42rem;
    }

    .snippet-buttons {
        gap: 0.28rem;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .action-buttons {
        gap: 0.28rem;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .btn {
        font-size: 0.66rem;
        min-height: 32px;
        padding: 0.32rem 0.24rem;
    }

    .ad-container-bottom {
        display: none;
    }
}

@media (max-width: 390px) {
    .header-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .home-hero {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .home-actions,
    .snippet-buttons {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Final density overrides: keep mobile and desktop surfaces tight. */
.page-container {
    padding: 0.65rem;
}

#game-container {
    margin-bottom: 0.5rem;
    max-width: 1280px;
}

.game-header {
    padding: 0.7rem 1rem;
}

.game-header h1 {
    font-size: 1.28rem;
}

.header-controls {
    gap: 0.5rem;
}

.home-screen {
    gap: 0.75rem;
    grid-template-columns: minmax(0, 1.15fr) minmax(300px, 0.85fr);
    padding: 0.9rem;
}

.home-hero {
    grid-row: span 2;
    padding: 1rem;
}

.home-progress-card,
.home-stat,
.certificate-panel {
    padding: 0.75rem;
}

.home-actions {
    gap: 0.55rem;
    grid-column: 1 / -1;
}

.game-main {
    align-items: start;
    display: grid;
    gap: 0.9rem;
    grid-template-columns: minmax(330px, 1fr) minmax(330px, 420px);
    padding: 0.9rem;
}

.game-world {
    align-self: start;
    gap: 0.55rem;
    padding: 0.7rem;
}

.control-panel {
    align-self: start;
    gap: 0.65rem;
    padding: 0.75rem;
}

.mission-objectives {
    display: grid;
    gap: 0.15rem 0.4rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.snippet-buttons {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.action-buttons {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.ad-container-bottom {
    margin-top: 0.35rem;
    padding: 0.55rem;
}

.ad-iframe-bottom {
    height: 120px;
}

@media (max-width: 1080px) {
    .home-screen {
        grid-template-columns: 1fr;
    }

    .home-hero {
        grid-row: auto;
    }
}

@media (max-width: 820px) {
    .page-container {
        padding: 0.35rem;
    }

    .game-header {
        gap: 0.45rem;
        padding: 0.6rem;
    }

    .game-header h1 {
        font-size: 1.05rem;
        text-align: center;
        width: 100%;
    }

    .header-controls {
        align-items: stretch;
        display: grid;
        gap: 0.4rem;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
    }

    .header-stats {
        display: grid;
        gap: 0.35rem;
        grid-column: 1 / -1;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        justify-content: stretch;
        width: 100%;
    }

    .header-stats span,
    .btn-header,
    .level-indicator-clickable {
        border-radius: 14px;
        font-size: 0.7rem;
        min-height: 36px;
        overflow: hidden;
        padding: 0.3rem 0.35rem;
        text-align: center;
        text-overflow: ellipsis;
        width: 100%;
    }

    .home-screen {
        gap: 0.55rem;
        padding: 0.55rem;
    }

    .home-hero {
        gap: 0.6rem;
        grid-template-columns: auto 1fr;
        padding: 0.7rem;
        text-align: left;
    }

    .home-logo {
        font-size: 2.25rem;
    }

    .home-hero h2 {
        font-size: 1.22rem;
    }

    .home-copy {
        font-size: 0.86rem;
    }

    .home-system-line {
        font-size: 0.68rem;
        margin-top: 0.45rem;
        padding: 0.42rem 0.5rem;
    }

    .home-progress-card {
        padding: 0.65rem;
    }

    .home-progress-top {
        grid-template-columns: 1fr;
        gap: 0.45rem;
    }

    .home-stat-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .home-stat {
        padding: 0.58rem 0.3rem;
    }

    .home-stat span {
        font-size: 1.25rem;
    }

    .home-stat strong {
        font-size: 0.68rem;
    }

    .home-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    #home-resume-btn {
        grid-column: 1 / -1;
    }

    .game-main {
        gap: 0.55rem;
        grid-template-columns: 1fr;
        padding: 0.55rem;
    }

    .game-world {
        gap: 0.42rem;
        padding: 0.5rem;
    }

    .world-hud span,
    .world-terminal {
        font-size: 0.67rem;
        padding: 0.3rem 0.42rem;
    }

    .control-panel {
        gap: 0.5rem;
        padding: 0.58rem;
    }

    .control-panel h2 {
        display: none;
    }

    .mission-panel {
        padding: 0.55rem;
    }

    .mission-panel h3 {
        font-size: 0.88rem;
    }

    .mission-panel p,
    .mission-objectives li {
        font-size: 0.68rem;
    }

    .mission-objectives {
        grid-template-columns: 1fr;
    }

    #code-editor {
        font-size: 0.78rem;
        height: 150px;
        min-height: 150px;
    }

    .snippet-buttons {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .action-buttons {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .btn {
        font-size: 0.78rem;
        min-height: 38px;
        padding: 0.48rem 0.4rem;
    }

    .ad-container-bottom {
        padding: 0.35rem;
    }

    .ad-iframe-bottom {
        height: 70px;
    }
}

@media (max-width: 420px) {
    .header-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .home-hero {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .home-actions {
        grid-template-columns: 1fr;
    }

    .snippet-buttons {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Home screen, certificate, and mobile display refinements */
* {
    box-sizing: border-box;
}

html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

.home-screen {
    display: grid;
    gap: 1rem;
    padding: 1.5rem;
}

.home-screen.hidden {
    display: none;
}

.home-hero,
.home-progress-card,
.home-stat,
.certificate-panel {
    background: #f8fbff;
    border: 2px solid var(--grid-line);
    border-radius: 12px;
}

.home-hero {
    align-items: center;
    display: grid;
    gap: 1rem;
    grid-template-columns: auto 1fr;
    padding: 1.25rem;
}

.home-logo {
    animation: robotBounce 2s ease-in-out infinite;
    font-size: 4rem;
    line-height: 1;
}

.home-kicker,
.home-label {
    color: var(--hover-blue);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
}

.home-hero h2 {
    color: var(--primary-blue);
    font-family: var(--font-primary);
    font-size: 2.2rem;
    margin: 0.15rem 0;
}

.home-copy,
.home-progress-copy {
    color: #526173;
    line-height: 1.45;
    margin: 0;
}

.home-progress-card {
    padding: 1rem;
}

.home-progress-top,
.home-stat-grid,
.home-actions {
    display: grid;
    gap: 0.8rem;
}

.home-progress-top {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.home-progress-top strong {
    color: #263445;
    display: block;
    font-size: 1.05rem;
    margin-top: 0.25rem;
}

.home-progress-track {
    background: #dbe4f0;
    border-radius: 999px;
    height: 16px;
    margin: 1rem 0 0.5rem;
    overflow: hidden;
}

.home-progress-fill {
    background: linear-gradient(90deg, var(--green-success), var(--primary-blue));
    border-radius: inherit;
    height: 100%;
    transition: width 0.3s ease;
    width: 0;
}

.home-stat-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.home-stat {
    padding: 1rem;
    text-align: center;
}

.home-stat span {
    color: var(--primary-blue);
    display: block;
    font-size: 1.8rem;
    font-weight: 900;
}

.home-stat strong {
    color: #607086;
    display: block;
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

.home-actions {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.home-actions .btn,
.certificate-input-row .btn {
    flex: initial;
    max-width: none;
    min-width: 0;
    white-space: normal;
}

.home-actions .btn:disabled {
    background: #c7d2df;
    color: #6a7685;
    cursor: not-allowed;
}

.certificate-panel {
    flex: 1 0 100%;
    padding: 1rem;
    text-align: left;
}

.certificate-panel label {
    color: var(--primary-blue);
    display: block;
    font-weight: 900;
    margin-bottom: 0.5rem;
}

.certificate-input-row {
    display: grid;
    gap: 0.65rem;
    grid-template-columns: minmax(0, 1fr) auto;
}

.certificate-input-row input {
    border: 2px solid var(--grid-line);
    border-radius: 8px;
    font-family: var(--font-secondary);
    font-size: 1rem;
    min-width: 0;
    padding: 0.7rem;
    width: 100%;
}

.certificate-input-row input:focus {
    border-color: var(--primary-blue);
    outline: none;
}

.modal-overlay {
    padding: 1rem;
}

.modal-content {
    box-sizing: border-box;
    max-height: calc(100dvh - 2rem);
    max-width: min(92vw, 760px);
    overflow-y: auto;
}

.game-main.hidden {
    display: none;
}

.game-world,
.control-panel {
    min-width: 0;
}

.game-world {
    overflow: auto;
}

.btn {
    min-height: 44px;
}

@media (max-width: 980px) {
    .home-actions {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    .page-container {
        padding: 0.5rem;
    }

    #game-container {
        border-radius: 10px;
    }

    .game-header {
        padding: 0.85rem;
    }

    .game-header h1 {
        font-size: 1.2rem;
        line-height: 1.2;
    }

    .header-controls {
        align-items: stretch;
        display: grid;
        grid-template-columns: 1fr;
        width: 100%;
    }

    .header-stats {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
    }

    .header-stats span,
    .btn-header,
    .level-indicator-clickable {
        text-align: center;
        width: 100%;
    }

    .home-screen,
    .game-main {
        padding: 0.75rem;
    }

    .home-hero {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .home-logo {
        font-size: 3rem;
    }

    .home-hero h2 {
        font-size: 1.55rem;
    }

    .home-progress-top,
    .home-stat-grid,
    .home-actions {
        grid-template-columns: 1fr;
    }

    .game-main {
        gap: 0.9rem;
    }

    .game-world {
        padding: 0.65rem;
    }

    .control-panel {
        gap: 0.75rem;
        padding: 0.75rem;
    }

    .control-panel h2 {
        font-size: 1.1rem;
    }

    .mission-panel {
        padding: 0.7rem;
    }

    #code-editor {
        font-size: 0.86rem;
        height: clamp(170px, 32dvh, 280px);
        min-height: 170px;
    }

    .snippet-buttons {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .action-buttons {
        grid-template-columns: 1fr;
    }

    .ad-container-bottom {
        padding: 0.5rem;
    }

    .ad-iframe-bottom {
        height: 90px;
    }

    .modal-content {
        padding: 1rem;
        width: min(94vw, 620px);
    }

    .certificate-input-row {
        grid-template-columns: 1fr;
    }

    .game-complete-actions .btn {
        max-width: 100%;
    }
}

@media (max-width: 420px) {
    .header-stats {
        grid-template-columns: 1fr;
    }

    .snippet-buttons {
        grid-template-columns: 1fr;
    }

    .home-stat span,
    .stat-number {
        font-size: 1.35rem;
    }

    .reward-tabs {
        grid-template-columns: 1fr;
    }

    .reward-grid {
        grid-template-columns: 1fr;
    }

    .level-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Compact density and playful runtime polish */
.page-container {
    padding: 0.65rem;
}

#game-container {
    margin-bottom: 0.5rem;
    max-width: 1280px;
}

.game-header {
    padding: 0.7rem 1rem;
}

.game-header h1 {
    font-size: 1.28rem;
}

.header-controls {
    gap: 0.5rem;
}

.btn-header,
.level-indicator-clickable {
    padding: 0.42rem 0.72rem;
}

.home-screen {
    gap: 0.75rem;
    grid-template-columns: minmax(0, 1.15fr) minmax(300px, 0.85fr);
    padding: 0.9rem;
}

.home-hero {
    grid-row: span 2;
    padding: 1rem;
}

.home-progress-card,
.home-stat,
.certificate-panel {
    padding: 0.75rem;
}

.home-stat-grid {
    gap: 0.55rem;
}

.home-actions {
    gap: 0.55rem;
    grid-column: 1 / -1;
}

.home-system-line {
    background: #263445;
    border-radius: 8px;
    color: #d6f5ed;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1.35;
    margin: 0.7rem 0 0;
    padding: 0.55rem 0.65rem;
}

.game-main {
    align-items: start;
    display: grid;
    gap: 0.9rem;
    grid-template-columns: minmax(330px, 1fr) minmax(330px, 420px);
    padding: 0.9rem;
}

.game-world {
    align-self: start;
    gap: 0.55rem;
    justify-items: center;
    padding: 0.7rem;
}

.world-hud {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    justify-content: space-between;
    width: 100%;
}

.world-hud span,
.world-terminal {
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 800;
    padding: 0.35rem 0.6rem;
}

#robot-status {
    background: #eef8ff;
    color: var(--primary-blue);
}

#robot-status.status-working {
    background: #fffbf0;
    color: #b27310;
}

#robot-status.status-success {
    background: #effffb;
    color: #15977a;
}

#robot-status.status-alert {
    background: #fff0f4;
    color: var(--red-error);
}

#sensor-status {
    background: #f3f6fb;
    color: #5b6a7d;
}

.world-terminal {
    background: #263445;
    border-radius: 8px;
    color: #d6f5ed;
    font-family: 'Courier New', Courier, monospace;
    line-height: 1.3;
    min-height: 31px;
    text-align: center;
    width: 100%;
}

.control-panel {
    align-self: start;
    gap: 0.65rem;
    padding: 0.75rem;
}

.control-panel h2 {
    font-size: 1.05rem;
}

.mission-panel {
    padding: 0.65rem;
}

.mission-panel p {
    margin-bottom: 0.35rem;
}

.mission-objectives {
    display: grid;
    gap: 0.15rem 0.4rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

#code-editor {
    min-height: 190px;
}

.error-feedback {
    height: auto;
    min-height: 0;
}

.error-feedback:empty {
    display: none;
}

.snippet-buttons {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.action-buttons {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.btn {
    min-height: 40px;
    padding: 0.62rem 0.55rem;
}

.goal:not(.goal-collected) {
    animation: beaconPulse 1.8s ease-in-out infinite;
}

@keyframes beaconPulse {
    0%, 100% {
        filter: drop-shadow(0 0 0 rgba(245, 166, 35, 0));
    }
    50% {
        filter: drop-shadow(0 0 8px rgba(245, 166, 35, 0.75));
    }
}

.ad-container-bottom {
    margin-top: 0.35rem;
    padding: 0.55rem;
}

.ad-iframe-bottom {
    height: 120px;
}

.site-footer {
    margin-top: 0.35rem;
}

@media (max-width: 1080px) {
    .game-main {
        grid-template-columns: minmax(300px, 1fr) minmax(310px, 380px);
    }

    .home-screen {
        grid-template-columns: 1fr;
    }

    .home-hero {
        grid-row: auto;
    }
}

@media (max-width: 820px) {
    .page-container {
        padding: 0.35rem;
    }

    #game-container {
        border-radius: 8px;
    }

    .game-header {
        gap: 0.45rem;
        padding: 0.6rem;
    }

    .game-header h1 {
        font-size: 1.05rem;
        text-align: center;
        width: 100%;
    }

    .header-controls {
        display: grid;
        gap: 0.4rem;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .header-stats {
        display: grid;
        gap: 0.35rem;
        grid-column: 1 / -1;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .header-stats span {
        font-size: 0.68rem;
        overflow: hidden;
        padding: 0.28rem 0.35rem;
        text-overflow: ellipsis;
    }

    .btn-header,
    .level-indicator-clickable {
        border-radius: 14px;
        font-size: 0.78rem;
        min-height: 38px;
        padding: 0.35rem 0.4rem;
    }

    .home-screen {
        gap: 0.55rem;
        padding: 0.55rem;
    }

    .home-hero {
        gap: 0.6rem;
        grid-template-columns: auto 1fr;
        padding: 0.7rem;
        text-align: left;
    }

    .home-logo {
        font-size: 2.25rem;
    }

    .home-hero h2 {
        font-size: 1.22rem;
    }

    .home-copy {
        font-size: 0.86rem;
    }

    .home-system-line {
        font-size: 0.68rem;
        margin-top: 0.45rem;
        padding: 0.42rem 0.5rem;
    }

    .home-progress-card {
        padding: 0.65rem;
    }

    .home-progress-top {
        grid-template-columns: 1fr;
        gap: 0.45rem;
    }

    .home-progress-track {
        height: 12px;
        margin-top: 0.65rem;
    }

    .home-stat-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .home-stat {
        padding: 0.58rem 0.3rem;
    }

    .home-stat span {
        font-size: 1.25rem;
    }

    .home-stat strong {
        font-size: 0.68rem;
    }

    .home-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    #home-resume-btn {
        grid-column: 1 / -1;
    }

    .game-main {
        gap: 0.55rem;
        grid-template-columns: 1fr;
        padding: 0.55rem;
    }

    .game-world {
        gap: 0.42rem;
        padding: 0.5rem;
    }

    .world-hud span,
    .world-terminal {
        font-size: 0.67rem;
        padding: 0.3rem 0.42rem;
    }

    .control-panel {
        gap: 0.5rem;
        padding: 0.58rem;
    }

    .control-panel h2 {
        display: none;
    }

    .mission-panel h3 {
        font-size: 0.88rem;
    }

    .mission-panel p,
    .mission-objectives li {
        font-size: 0.68rem;
    }

    .mission-objectives {
        grid-template-columns: 1fr;
    }

    #code-editor {
        font-size: 0.78rem;
        height: 150px;
        min-height: 150px;
    }

    .snippet-buttons {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .action-buttons {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .btn {
        font-size: 0.78rem;
        min-height: 38px;
        padding: 0.48rem 0.4rem;
    }

    .ad-container-bottom {
        padding: 0.35rem;
    }

    .ad-iframe-bottom {
        height: 70px;
    }
}

@media (max-width: 420px) {
    .header-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .home-hero {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .home-actions {
        grid-template-columns: 1fr;
    }

    .snippet-buttons {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Production upgrade additions */
.header-controls {
    flex-wrap: wrap;
    justify-content: flex-end;
}

.header-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    justify-content: flex-end;
}

.header-stats span {
    background: rgba(255,255,255,0.22);
    border: 1px solid rgba(255,255,255,0.32);
    border-radius: 18px;
    color: white;
    font-size: 0.78rem;
    font-weight: 800;
    padding: 0.35rem 0.65rem;
    white-space: nowrap;
}

.mission-panel {
    background: #f8fbff;
    border: 2px solid var(--grid-line);
    border-left: 5px solid var(--green-success);
    border-radius: 10px;
    padding: 0.85rem;
    text-align: left;
}

.mission-kicker {
    color: var(--hover-blue);
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
}

.mission-panel h3 {
    color: var(--primary-blue);
    font-family: var(--font-primary);
    font-size: 1rem;
    margin: 0.2rem 0;
}

.mission-concept {
    background: #fffbf0;
    border-radius: 999px;
    color: #b27310;
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 800;
    margin-bottom: 0.45rem;
    padding: 0.18rem 0.55rem;
}

.mission-panel p {
    color: #444;
    font-size: 0.86rem;
    line-height: 1.35;
    margin: 0 0 0.55rem 0;
}

.mission-objectives {
    list-style: none;
    margin: 0;
    padding: 0;
}

.mission-objectives li {
    color: #607086;
    font-size: 0.74rem;
    font-weight: 700;
    margin-bottom: 0.2rem;
}

.mission-objectives li.complete {
    color: #1f9f82;
}

.console-feedback {
    background: #263445;
    border-radius: 8px;
    color: #d6f5ed;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.78rem;
    margin-top: 0.5rem;
    max-height: 90px;
    overflow-y: auto;
    padding: 0.55rem;
    text-align: left;
}

.hidden {
    display: none;
}

.level-reward-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    justify-content: center;
    margin: 1rem 0;
}

.reward-pill {
    background: #eef8ff;
    border: 2px solid var(--grid-line);
    border-radius: 999px;
    color: var(--primary-blue);
    font-size: 0.82rem;
    font-weight: 800;
    padding: 0.35rem 0.7rem;
}

.site-footer {
    color: #607086;
    font-size: 0.85rem;
    font-weight: 700;
    margin-top: 0.75rem;
    text-align: center;
}

.site-footer a {
    color: var(--primary-blue);
    text-decoration: none;
}

.site-footer a:hover {
    text-decoration: underline;
}

.reward-center-modal {
    max-height: 88vh;
    max-width: 860px;
    overflow-y: auto;
    padding: 1.4rem;
    width: min(92vw, 860px);
}

.reward-center-header {
    align-items: center;
    border-bottom: 2px dashed var(--grid-line);
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
}

.reward-center-header h2 {
    font-size: 1.6rem;
    margin: 0;
}

.reward-tabs {
    display: grid;
    gap: 0.5rem;
    grid-template-columns: repeat(4, 1fr);
    margin-bottom: 0.75rem;
}

.reward-tab {
    background: #edf4fd;
    border: 2px solid var(--grid-line);
    border-radius: 8px;
    color: var(--primary-blue);
    cursor: pointer;
    font-family: var(--font-secondary);
    font-weight: 800;
    padding: 0.65rem 0.4rem;
}

.reward-tab.active {
    background: var(--primary-blue);
    border-color: var(--primary-blue);
    color: white;
}

.reward-status {
    color: var(--hover-blue);
    font-weight: 800;
    min-height: 22px;
    text-align: center;
}

.reward-grid {
    display: grid;
    gap: 0.85rem;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    text-align: left;
}

.reward-card {
    background: #f8fbff;
    border: 2px solid var(--grid-line);
    border-radius: 10px;
    min-height: 170px;
    padding: 0.85rem;
}

.reward-card.owned,
.reward-card.selected {
    border-color: var(--green-success);
    background: #f1fffb;
}

.reward-card.locked {
    opacity: 0.62;
}

.reward-icon {
    font-size: 1.8rem;
}

.reward-card h3 {
    color: var(--primary-blue);
    font-family: var(--font-primary);
    font-size: 0.95rem;
    margin: 0.35rem 0;
}

.reward-card p {
    color: #5d6875;
    font-size: 0.78rem;
    line-height: 1.35;
    min-height: 42px;
}

.reward-card span,
.shop-balance {
    color: #1f9f82;
    font-weight: 800;
}

.shop-balance {
    margin-bottom: 0.8rem;
    text-align: center;
}

.reward-buy-btn,
.reward-select-btn {
    background: var(--primary-blue);
    width: 100%;
}

.reward-buy-btn:disabled,
.reward-select-btn:disabled {
    background: #b8c4d1;
}

.hint-reward-copy {
    background: #f8fbff;
    border: 2px solid var(--grid-line);
    border-left: 5px solid #f5a623;
    border-radius: 10px;
    padding: 1rem;
    text-align: left;
}

.hint-reward-copy h3 {
    color: var(--primary-blue);
    font-family: var(--font-primary);
    margin-top: 0;
}

.hint-balance {
    color: var(--hover-blue);
    font-size: 0.85rem;
    font-weight: 800;
    text-align: right;
}

.locked-hint {
    color: #8b6b2c;
    font-weight: 800;
}

.level-concept {
    color: #677386;
    font-size: 0.65rem;
    font-weight: 800;
    margin-top: 0.15rem;
}

.game-complete-stats {
    flex-wrap: wrap;
}

#final-rank {
    font-size: 1.3rem;
}

#robot.skin-classic {
    filter: none;
}

#robot.skin-ocean {
    filter: hue-rotate(175deg) saturate(1.45);
}

#robot.skin-solar {
    filter: hue-rotate(305deg) saturate(1.55) brightness(1.12);
}

#robot.skin-mint {
    filter: hue-rotate(95deg) saturate(1.2) brightness(1.08);
}

#robot.skin-galaxy {
    filter: hue-rotate(250deg) saturate(1.65) brightness(1.05);
}

.grid-trail {
    border-radius: 50%;
    opacity: 0.75;
    pointer-events: none;
    position: absolute;
    transform: scale(1);
    animation: trailFade 650ms ease forwards;
    z-index: 3;
}

.trail-spark {
    background: #f5a623;
    box-shadow: 0 0 12px #f5a623;
}

.trail-comet {
    background: var(--green-success);
    box-shadow: 0 0 14px var(--green-success);
}

@keyframes trailFade {
    to {
        opacity: 0;
        transform: scale(0.2);
    }
}

.game-world.theme-mint-grid {
    background: #dff5ec;
}

#grid-container.theme-mint-grid,
.theme-mint-grid .grid-tile {
    border-color: #9edec7;
}

.game-world.theme-night-grid {
    background: #233146;
}

#grid-container.theme-night-grid,
.theme-night-grid .grid-tile {
    border-color: #61708a;
}

.game-world.theme-sunrise-grid {
    background: #fff2df;
}

#grid-container.theme-sunrise-grid,
.theme-sunrise-grid .grid-tile {
    border-color: #f1c27d;
}

@media (max-width: 900px) {
    .game-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.75rem;
    }

    .header-controls,
    .header-stats {
        justify-content: flex-start;
        width: 100%;
    }
}

@media (max-width: 620px) {
    .reward-tabs {
        grid-template-columns: repeat(2, 1fr);
    }

    .header-stats span {
        font-size: 0.7rem;
        padding: 0.28rem 0.48rem;
    }

    .mission-panel h3 {
        font-size: 0.9rem;
    }
}

/* 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;
    }
}
