/* Robot Command Game Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #06B6D4;
    --primary-light: #67E8F9;
    --secondary: #8B5CF6;
    --background: #F8FAFC;
    --surface: #FFFFFF;
    --text: #1E293B;
    --text-muted: #64748B;
    --success: #10B981;
    --error: #EF4444;
    --grid-bg: #0F172A;
}

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: linear-gradient(135deg, #06B6D4 0%, #3B82F6 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

#game-container {
    width: 100%;
    max-width: 500px;
    background: var(--surface);
    border-radius: 24px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

/* Header */
#game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--background);
    border-bottom: 1px solid #E5E7EB;
}

.game-title {
    font-weight: 700;
    font-size: 18px;
    color: var(--text);
}

.stats {
    display: flex;
    gap: 24px;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
}

.icon-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--surface);
    border-radius: 12px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.icon-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* Game Area */
#game-area {
    padding: 20px;
}

/* Grid */
.grid {
    display: grid;
    gap: 4px;
    padding: 16px;
    background: var(--grid-bg);
    border-radius: 16px;
    margin-bottom: 20px;
}

.cell {
    aspect-ratio: 1;
    background: #1E293B;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    position: relative;
    transition: background 0.3s;
}

.cell.path {
    background: #334155;
}

.cell.goal {
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
    animation: goalPulse 2s infinite;
}

@keyframes goalPulse {

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

    50% {
        box-shadow: 0 0 20px 5px rgba(16, 185, 129, 0.3);
    }
}

.cell.obstacle {
    background: #475569;
}

.robot {
    font-size: 32px;
    transition: all 0.3s ease;
    z-index: 10;
}

.robot.moving {
    animation: robotBounce 0.3s ease;
}

@keyframes robotBounce {

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

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

/* Command Panel */
.command-panel {
    background: var(--background);
    border-radius: 16px;
    padding: 16px;
}

.commands-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.command-queue {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 50px;
    padding: 12px;
    background: var(--surface);
    border-radius: 12px;
    border: 2px dashed #E5E7EB;
    margin-bottom: 16px;
}

.command-queue .cmd {
    padding: 8px 12px;
    background: linear-gradient(135deg, var(--primary) 0%, #0891B2 100%);
    color: white;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    animation: cmdPop 0.2s ease;
}

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

    to {
        transform: scale(1);
    }
}

.command-queue .cmd.executing {
    animation: cmdExecute 0.3s ease;
    background: linear-gradient(135deg, var(--secondary) 0%, #7C3AED 100%);
}

@keyframes cmdExecute {

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

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

.command-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.cmd-btn {
    padding: 12px 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    background: var(--surface);
    border: 2px solid #E5E7EB;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.cmd-btn:hover {
    border-color: var(--primary);
    background: linear-gradient(135deg, #ECFEFF 0%, #CFFAFE 100%);
    transform: translateY(-2px);
}

.action-buttons {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 12px;
}

.btn-run {
    padding: 14px;
    font-size: 16px;
    font-weight: 700;
    color: white;
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-run:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(16, 185, 129, 0.4);
}

.btn-run:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-clear {
    padding: 14px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    background: var(--surface);
    border: 2px solid #E5E7EB;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

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

/* Feedback */
.feedback {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 24px 48px;
    background: var(--surface);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    z-index: 50;
    animation: popIn 0.3s ease;
}

.feedback.hidden {
    display: none;
}

#feedback-emoji {
    font-size: 48px;
}

#feedback-text {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}

@keyframes popIn {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0;
    }

    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(4px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--surface);
    padding: 40px;
    border-radius: 24px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    animation: popIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.stars {
    font-size: 48px;
    margin-bottom: 16px;
}

.modal-content h2 {
    font-size: 28px;
    color: var(--text);
    margin-bottom: 8px;
}

.modal-content p {
    color: var(--text-muted);
    margin-bottom: 24px;
}

.result-stats {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 32px;
}

.result-stat {
    display: flex;
    flex-direction: column;
}

.result-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary);
}

.result-label {
    font-size: 14px;
    color: var(--text-muted);
}

.modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.btn-primary,
.btn-secondary {
    padding: 14px 28px;
    border-radius: 50px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #3B82F6 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(6, 182, 212, 0.4);
}

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

.btn-secondary:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* Responsive */
@media (max-width: 480px) {
    .grid {
        padding: 12px;
    }

    .cell {
        font-size: 22px;
    }

    .robot {
        font-size: 26px;
    }

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

    .cmd-btn {
        padding: 10px;
        font-size: 12px;
    }

    .stats {
        gap: 16px;
    }

    .stat-value {
        font-size: 16px;
    }
}