/* ===== CSS Reset & Base Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

* {
    box-sizing: border-box;
    /* Ensure padding doesn't add to width */
}

:root {
    /* Color Palette */
    --primary-bg: #0f172a;
    --secondary-bg: #1e293b;
    --accent-bg: #334155;
    --highlight: #3b82f6;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;

    /* Command Block Colors */
    --cmd-forward: linear-gradient(135deg, #3b82f6, #2563eb);
    --cmd-left: linear-gradient(135deg, #eab308, #ca8a04);
    --cmd-right: linear-gradient(135deg, #f97316, #ea580c);
    --cmd-jump: linear-gradient(135deg, #a855f7, #9333ea);
    --cmd-repeat: linear-gradient(135deg, #10b981, #059669);

    /* Spacing */
    --gap-sm: 0.5rem;
    --gap-md: 1rem;
    --gap-lg: 1.5rem;
    --gap-xl: 2rem;

    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 1rem;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.6);

    /* Animation */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;500;600;700;800&display=swap');

body {
    font-family: 'Nunito', 'Segoe UI', sans-serif;
    /* Friendly rounded font */
    background-color: var(--primary-bg);
    color: var(--text-primary);
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
    /* Prevent global scrolling */
    background-image:
        radial-gradient(circle at 10% 20%, rgba(59, 130, 246, 0.1) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, rgba(139, 92, 246, 0.1) 0%, transparent 20%);
    /* Subtle background blobs */
}

/* ===== Header Styles ===== */
.game-header {
    background: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(59, 130, 246, 0.3);
    padding: var(--gap-md) var(--gap-lg);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-md);
}

.header-content {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--gap-lg);
}

.game-title {
    font-size: 1.75rem;
    font-weight: 800;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: flex;
    align-items: center;
    gap: var(--gap-sm);
}

.title-icon {
    font-size: 2rem;
    filter: drop-shadow(0 2px 4px rgba(59, 130, 246, 0.5));
}

.header-info {
    display: flex;
    align-items: center;
    gap: var(--gap-lg);
}

.level-display,
.energy-display {
    display: flex;
    align-items: center;
    gap: var(--gap-sm);
    background: rgba(51, 65, 85, 0.6);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.level-display .label,
.energy-display .label {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
}

.level-display .value,
.energy-display .value {
    color: var(--highlight);
    font-size: 1.125rem;
    font-weight: 700;
}

.level-name {
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 600;
    margin-left: 0.5rem;
}

/* ===== Main Container ===== */
.game-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: var(--gap-md) var(--gap-lg);
    display: grid;
    grid-template-columns: 2fr 1.2fr 1.8fr;
    gap: var(--gap-lg);
    height: calc(100vh - 85px);
    /* Header approx 85px */
    overflow: hidden;
}

/* ===== Section Common Styles ===== */
/* Panels */
.action-area,
.command-storage,
.programming-board {
    background: rgba(30, 41, 59, 0.7);
    /* Transparent dark */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 24px;
    /* Extra rounded */
    padding: 24px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    overflow: hidden;
    /* Ensure content doesn't overflow panel */
}

.action-area:hover,
.command-storage:hover,
.programming-board:hover {
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.area-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 2px dashed rgba(255, 255, 255, 0.1);
}

.area-header h2 {
    font-size: 1.4rem;
    font-weight: 900;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ===== Action Area (Game Board) ===== */
.game-board-wrapper {
    flex: 1;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: var(--gap-xl);
    position: relative;
    background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
    border-radius: var(--radius-md);
    padding: var(--gap-lg);
    min-height: 400px;
    border: 1px solid rgba(59, 130, 246, 0.2);
    box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.5);
}

#gameCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    /* Let clicks pass through to grid */
    z-index: 10;
}

.game-grid {
    display: grid;
    gap: 4px;
    background: transparent;
    padding: 10px;
    border-radius: var(--radius-md);
    position: relative;
    padding: 10px;
    border-radius: var(--radius-md);
    position: relative;
    /* Anchor for absolute robot */
    /* Isometric-like perspective optional, but let's keep it flat for clarity first */
}

.grid-cell {
    aspect-ratio: 1;
    border-radius: 4px;
    transition: all var(--transition-fast);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-size: 2rem;
    box-shadow: var(--shadow-sm);
}

.grid-cell.empty {
    background: #334155 url('../assets/images/floor.png') center/cover no-repeat;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.grid-cell.wall {
    background: url('../assets/images/wall.png') center/cover no-repeat;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.5);
    border: none;
    /* Image has its own border look */
    z-index: 5;
}

.grid-cell.pit {
    background: #000 url('../assets/images/pit.png') center/cover no-repeat;
    box-shadow: inset 0 0 20px #000;
    border: 1px solid #1e293b;
}

.grid-cell.goal {
    background:
        radial-gradient(circle, transparent 20%, rgba(16, 185, 129, 0.4) 21%, transparent 22%),
        radial-gradient(circle, transparent 40%, rgba(16, 185, 129, 0.3) 41%, transparent 42%),
        linear-gradient(135deg, #064e3b, #065f46);
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.6);
    animation: goalPulse 2s ease-in-out infinite;
    overflow: hidden;
}

.grid-cell.goal::after {
    content: '🚩';
    font-size: 2rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
    animation: flagWave 2s ease-in-out infinite alternate;
}

@keyframes flagWave {
    from {
        transform: rotate(-5deg);
    }

    to {
        transform: rotate(5deg);
    }
}

@keyframes goalPulse {

    0%,
    100% {
        box-shadow: 0 0 15px rgba(16, 185, 129, 0.5);
    }

    50% {
        box-shadow: 0 0 25px rgba(16, 185, 129, 0.8);
    }
}

.grid-cell.start {
    background:
        repeating-linear-gradient(45deg,
            #1e3a8a,
            #1e3a8a 10px,
            #172554 10px,
            #172554 20px);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.5);
    border: 2px solid #3b82f6;
    border: 2px solid #3b82f6;
    /* overflow: hidden; Removed to allow arrow to be fully seen */
}

.grid-cell.start::after {
    content: '➜';
    font-size: 2.5rem;
    /* Slightly smaller to fit better */
    color: #fde047;
    /* Bright yellow */
    position: absolute;
    transform-origin: center;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.8));
    z-index: 1;
    opacity: 1;
}

.grid-cell.start[data-start-direction="right"]::after {
    transform: rotate(0deg) translateX(28px);
}

.grid-cell.start[data-start-direction="down"]::after {
    transform: rotate(90deg) translateX(28px);
}

.grid-cell.start[data-start-direction="left"]::after {
    transform: rotate(180deg) translateX(28px);
}

.grid-cell.start[data-start-direction="up"]::after {
    transform: rotate(270deg) translateX(28px);
}

.robot {
    width: 100px;
    height: 100px;
    background: transparent;
    /* Remove gradient background */
    border-radius: 0;
    /* Remove circle */
    border: none;
    /* Remove border */
    box-shadow: none;
    /* Remove shadow box */
    position: absolute;
    top: 0;
    left: 0;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    z-index: 10;
    margin: 0;
    /* Reset margins */
    /* Reset margins */
    transform-origin: center;
    pointer-events: none;
    /* Allow clicks to pass through */
    /* Scale down slightly to fit inside cell with gap is handled by JS but keeping base clean */
}

.robot-inner {
    width: 100%;
    height: 100%;
    background-image: url('../assets/images/robot.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    transform: scale(0.9);
    /* Slightly smaller to fit */
    transition: transform 0.2s;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4));
    /* Add shadow to image directly */
}

.robot.moving .robot-inner {
    animation: robotMove 0.3s ease;
}

@keyframes robotMove {

    0%,
    100% {
        transform: scale(0.8);
    }

    50% {
        transform: scale(0.7);
    }
}

.robot.jumping .robot-inner {
    animation: robotJump 0.5s ease;
}

@keyframes robotJump {

    0%,
    100% {
        transform: translateY(0) scale(0.8);
    }

    50% {
        transform: translateY(-20px) scale(0.9);
    }
}

.energy-pin {
    position: absolute;
    width: 60%;
    height: 60%;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    border-radius: 50%;
    box-shadow: 0 0 15px rgba(251, 191, 36, 0.8);
    animation: energyFloat 2s ease-in-out infinite;
    display: flex;
    align-items: center;
    justify-content: center;
}

.energy-pin::before {
    content: '⚡';
    font-size: 1.5rem;
}

@keyframes energyFloat {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }
}

.tutorial-hint {
    margin-top: var(--gap-md);
    padding: var(--gap-md);
    background: rgba(59, 130, 246, 0.1);
    border-left: 4px solid var(--highlight);
    border-radius: var(--radius-sm);
}

.tutorial-hint p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.5;
}

/* ===== Command Storage ===== */
.command-blocks-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--gap-md);
    padding: var(--gap-md);
    background: rgba(15, 23, 42, 0.4);
    border-radius: var(--radius-md);
    overflow-y: auto;
}

/* Command Blocks */
.command-block {
    background-color: var(--surface-light);
    border: none;
    border-left: 5px solid var(--primary);
    /* Default border */
    border-radius: 8px;
    /* Rounded block */
    padding: 12px;
    margin-bottom: 10px;
    cursor: grab;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s;
    user-select: none;
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.2);
    font-weight: 700;
}

.command-block:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 0 rgba(0, 0, 0, 0.2);
    z-index: 10;
}

.command-block:active {
    cursor: grabbing;
}

.command-block.dragging {
    opacity: 0.5;
    transform: scale(0.95);
}

/* Color Coding */
.command-block[data-command="forward"],
.command-block[data-command="jump"] {
    background-color: #3b82f6;
    /* Blue */
    color: white;
    border-left: none;
    border-bottom: 4px solid #1d4ed8;
}

.command-block[data-command="turnLeft"],
.command-block[data-command="turnRight"] {
    background-color: #ec4899;
    /* Pink */
    color: white;
    border-left: none;
    border-bottom: 4px solid #be185d;
}

.command-block[data-command="repeat"] {
    background-color: #f97316;
    /* Orange */
    color: white;
    border-left: none;
    border-bottom: 4px solid #c2410c;
}

.command-block[data-command="repeat"] {
    background-color: #f97316;
    /* Orange */
    color: white;
    border-left: none;
    border-bottom: 4px solid #c2410c;
}

.block-icon {
    font-size: 1.5rem;
    background: rgba(0, 0, 0, 0.2);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.block-label {
    font-size: 1rem;
    font-weight: 600;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.command-info {
    margin-top: var(--gap-md);
    padding: var(--gap-md);
    background: rgba(16, 185, 129, 0.1);
    border-left: 4px solid var(--success);
    border-radius: var(--radius-sm);
}

.command-info p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.5;
}

/* ===== Programming Board ===== */
.program-slots {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--gap-md);
    padding: var(--gap-md);
    background: rgba(15, 23, 42, 0.4);
    border-radius: var(--radius-md);
    min-height: 300px;
    overflow-y: auto;
    align-content: start;
}

.program-slots.three-cols {
    grid-template-columns: 1fr 1fr 1fr;
    gap: var(--gap-sm);
}

/* Loop Configuration Styles */
.modal-content.loop-config {
    max-width: 600px;
    background: linear-gradient(135deg, #1e293b, #0f172a);
    border: 3px solid #6366f1;
    box-shadow: 0 0 30px rgba(99, 102, 241, 0.3);
}

.config-section {
    margin-bottom: 2rem;
    text-align: center;
}

.config-section label {
    display: block;
    margin-bottom: 1rem;
    color: #cbd5e1;
    font-size: 1.1rem;
    font-weight: 600;
}

/* Action Grid */
.action-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-top: 0.5rem;
}

.action-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #334155;
    border: 2px solid #475569;
    border-radius: 12px;
    padding: 1rem 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    color: white;
}

.action-option:hover {
    background: #475569;
    transform: translateY(-2px);
}

.action-option.selected {
    background: rgba(99, 102, 241, 0.2);
    border-color: #6366f1;
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.3);
}

.act-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.act-label {
    font-size: 0.9rem;
    font-weight: 500;
}

/* Counter Control */
.counter-control {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    background: #334155;
    padding: 0.5rem;
    border-radius: 20px;
    width: fit-content;
    margin: 0 auto;
    border: 2px solid #475569;
}

.btn-counter {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: #6366f1;
    color: white;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-counter:hover {
    background: #818cf8;
    transform: scale(1.1);
}

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

.counter-value {
    font-size: 2rem;
    font-weight: 800;
    color: white;
    min-width: 40px;
    text-align: center;
}

/* Loop Modal Footer */
.modal-content.loop-config .modal-footer {
    justify-content: center;
    gap: 1rem;
}

/* Save Button */
#saveLoopBtn {
    width: auto;
    min-width: 200px;
    padding: 0.8rem 2rem;
    font-size: 1.1rem;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    box-shadow: 0 4px 0 #15803d;
    transition: all 0.1s;
    border: none;
}

#saveLoopBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #15803d;
}

#saveLoopBtn:active {
    transform: translateY(2px);
    box-shadow: 0 0 0 #15803d;
}

/* Cancel Button specific adjustment if needed */
#cancelLoopBtn {
    font-size: 1.1rem;
    padding: 0.8rem 1.5rem;
}

.program-slot {
    display: flex;
    align-items: center;
    gap: var(--gap-md);
    padding: var(--gap-xs);
    background: rgba(51, 65, 85, 0.4);
    border: 2px dashed rgba(59, 130, 246, 0.3);
    border-radius: var(--radius-md);
    min-height: 50px;
    transition: all var(--transition-fast);
}

.program-slot.drag-over {
    background: rgba(59, 130, 246, 0.2);
    border-color: var(--highlight);
    border-style: solid;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.4);
}

.program-slot.filled {
    background: transparent;
    border-style: solid;
    border-color: transparent;
}

.program-slot .slot-number {
    width: 30px;
    height: 30px;
    background: rgba(59, 130, 246, 0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--highlight);
    flex-shrink: 0;
}

.program-slot .command-block {
    flex: 1;
    position: relative;
}

.program-slot .remove-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    background: var(--danger);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-md);
}

.program-slot.executing {
    border-color: #fca5a5;
    background-color: rgba(252, 165, 165, 0.1);
    box-shadow: 0 0 10px rgba(251, 191, 36, 0.5);
    transform: scale(1.02);
}

.program-slot .command-block:hover .remove-btn {
    display: flex;
}

.remove-btn:hover {
    background: #dc2626;
    transform: scale(1.1);
}

.program-slot.executing {
    animation: slotExecute 0.5s ease;
}

@keyframes slotExecute {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
        box-shadow: 0 0 20px var(--highlight);
    }
}

/* ===== Execution Controls ===== */
.execution-controls {
    margin-top: var(--gap-lg);
    display: flex;
    flex-direction: column;
    gap: var(--gap-md);
}

.control-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--gap-md);
}

.run-button,
.stop-button,
.debug-button,
.next-step-button {
    flex: 1;
    padding: var(--gap-lg);
    font-size: 1.25rem;
    font-weight: 700;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--gap-sm);
    box-shadow: var(--shadow-lg);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.run-button {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}

.run-button:hover:not(:disabled) {
    background: linear-gradient(135deg, #059669, #047857);
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl), 0 0 30px rgba(16, 185, 129, 0.5);
}

.run-button:active:not(:disabled) {
    transform: translateY(0);
}

.run-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.stop-button {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
}

.stop-button:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    transform: translateY(-2px);
}

.execution-status {
    margin-top: var(--gap-md);
    padding: var(--gap-md);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    text-align: center;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.execution-status.running {
    background: rgba(59, 130, 246, 0.1);
    border-left: 4px solid var(--highlight);
    color: var(--highlight);
}

.execution-status.success {
    background: rgba(16, 185, 129, 0.1);
    border-left: 4px solid var(--success);
    color: var(--success);
}

.execution-status.error {
    background: rgba(239, 68, 68, 0.1);
    border-left: 4px solid var(--danger);
    color: var(--danger);
}

/* ===== Buttons ===== */
.icon-btn,
.small-btn {
    padding: 0.5rem 1rem;
    background: rgba(51, 65, 85, 0.6);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 0.875rem;
    font-weight: 500;
}

.icon-btn:hover,
.small-btn:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: var(--highlight);
    transform: translateY(-1px);
}

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

.modal.show {
    display: flex;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-content {
    background: linear-gradient(135deg, #1e293b, #334155);
    border-radius: var(--radius-lg);
    padding: var(--gap-xl);
    max-width: 500px;
    width: 90%;
    box-shadow: var(--shadow-xl);
    border: 2px solid rgba(59, 130, 246, 0.3);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    text-align: center;
    margin-bottom: var(--gap-lg);
}

.modal-header h2 {
    font-size: 2rem;
    font-weight: 800;
}

.modal-content.victory .modal-header h2 {
    background: linear-gradient(135deg, #10b981, #3b82f6);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.modal-content.gameover .modal-header h2 {
    background: linear-gradient(135deg, #ef4444, #f59e0b);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.modal-body {
    text-align: center;
    margin-bottom: var(--gap-lg);
}

.stars-display {
    display: flex;
    justify-content: center;
    gap: var(--gap-md);
    font-size: 3rem;
    margin-bottom: var(--gap-lg);
    animation: starsAppear 0.5s ease 0.3s both;
}

@keyframes starsAppear {
    from {
        transform: scale(0);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.victory-message,
.error-message {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: var(--gap-md);
}

.hint-message {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.stats {
    margin-top: var(--gap-lg);
    padding: var(--gap-md);
    background: rgba(15, 23, 42, 0.4);
    border-radius: var(--radius-md);
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: var(--gap-sm) 0;
}

.stat-label {
    color: var(--text-secondary);
}

.stat-value {
    color: var(--highlight);
    font-weight: 700;
}

.modal-footer {
    display: flex;
    gap: var(--gap-md);
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.1s;
    display: flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
    top: 0;
}

.btn:active {
    top: 4px;
    box-shadow: none !important;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
    box-shadow: 0 4px 0 #1d4ed8;
    /* Darker blue shadow */
}

.btn-primary:hover {
    background-color: #2563eb;
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #1d4ed8;
}

.btn-primary:active {
    transform: translateY(2px);
}

.btn-secondary {
    background-color: var(--surface-light);
    color: var(--text-primary);
    box-shadow: 0 4px 0 #334155;
    /* Darker slate shadow */
}

.btn-secondary:hover {
    background-color: #334155;
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #334155;
}

.btn-accent {
    background-color: var(--accent);
    color: white;
    box-shadow: 0 4px 0 #ea580c;
    /* Darker orange shadow */
}

.btn-accent:hover {
    background-color: #ea580c;
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #c2410c;
}

@media (max-width: 1200px) {
    .game-container {
        grid-template-columns: 1fr;
        gap: var(--gap-md);
    }

    .action-area {
        order: 1;
    }

    .programming-board {
        order: 2;
    }

    .command-storage {
        order: 3;
    }

    .command-blocks-container {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .command-block {
        flex: 0 0 calc(50% - var(--gap-sm));
    }
}

@media (max-width: 768px) {
    .game-title {
        font-size: 1.25rem;
    }

    .header-info {
        flex-wrap: wrap;
        gap: var(--gap-sm);
    }

    .command-block {
        flex: 0 0 100%;
    }
}

/* ===== Utility Classes ===== */
.hidden {
    display: none !important;
}

.fade-in {
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}